From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qyh02-0000Xf-Rm for qemu-devel@nongnu.org; Wed, 31 Aug 2011 05:22:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qyh01-0001Ex-Fw for qemu-devel@nongnu.org; Wed, 31 Aug 2011 05:22:22 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56822 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qyh01-0001Cs-72 for qemu-devel@nongnu.org; Wed, 31 Aug 2011 05:22:21 -0400 Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <1313030188-19347-3-git-send-email-david@gibson.dropbear.id.au> Date: Wed, 31 Aug 2011 11:22:18 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <1C49B879-F90D-4D8D-8783-EC4A34875EE7@suse.de> References: <1313030188-19347-1-git-send-email-david@gibson.dropbear.id.au> <1313030188-19347-3-git-send-email-david@gibson.dropbear.id.au> Subject: Re: [Qemu-devel] [PATCH 2/2] pseries: Implement hcall-bulk hypervisor interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: qemu-devel@nongnu.org On 11.08.2011, at 04:36, David Gibson wrote: > This patch adds support for the H_REMOVE_BULK hypercall on the pseries > machine. Strictly speaking this isn't necessarym since the kernel = will > only attempt to use this if hcall-bulk is advertised in the device = tree, > which previously it was not. >=20 > Adding this support may give a marginal performance increase, but more > importantly it reduces the differences between the emulated machine = and > an existing PowerVM or kvm system, both of which already implement > hcall-bulk. >=20 > Signed-off-by: David Gibson > --- > hw/spapr.c | 2 +- > hw/spapr_hcall.c | 122 = ++++++++++++++++++++++++++++++++++++++++++++++++----- > 2 files changed, 111 insertions(+), 13 deletions(-) >=20 > diff --git a/hw/spapr.c b/hw/spapr.c > index 3f4433c..0db1051 100644 > --- a/hw/spapr.c > +++ b/hw/spapr.c > @@ -72,7 +72,7 @@ static void *spapr_create_fdt_skel(const char = *cpu_model, > uint32_t end_prop =3D cpu_to_be32(initrd_base + initrd_size); > uint32_t pft_size_prop[] =3D {0, cpu_to_be32(hash_shift)}; > char hypertas_prop[] =3D = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt" > - "\0hcall-tce\0hcall-vio\0hcall-splpar"; > + "\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk"; > uint32_t interrupt_server_ranges_prop[] =3D {0, = cpu_to_be32(smp_cpus)}; > int i; > char *modelname; > diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c > index 0c61c10..9ac42ee 100644 > --- a/hw/spapr_hcall.c > +++ b/hw/spapr_hcall.c > @@ -174,20 +174,25 @@ static target_ulong h_enter(CPUState *env, = sPAPREnvironment *spapr, > return H_SUCCESS; > } >=20 > -static target_ulong h_remove(CPUState *env, sPAPREnvironment *spapr, > - target_ulong opcode, target_ulong *args) > +enum { > + REMOVE_SUCCESS =3D 0, > + REMOVE_NOT_FOUND =3D 1, > + REMOVE_PARM =3D 2, > + REMOVE_HW =3D 3, > +}; > + > +static target_ulong remove_hpte(CPUState *env, target_ulong ptex, = target_ulong avpn, > + target_ulong flags, > + target_ulong *vp, target_ulong *rp) > { > - target_ulong flags =3D args[0]; > - target_ulong pte_index =3D args[1]; > - target_ulong avpn =3D args[2]; > uint8_t *hpte; > target_ulong v, r, rb; >=20 > - if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) { > - return H_PARAMETER; > + if ((ptex * HASH_PTE_SIZE_64) & ~env->htab_mask) { > + return REMOVE_PARM; > } >=20 > - hpte =3D env->external_htab + (pte_index * HASH_PTE_SIZE_64); > + hpte =3D env->external_htab + (ptex * HASH_PTE_SIZE_64); > while (!lock_hpte(hpte, HPTE_V_HVLOCK)) { > /* We have no real concurrency in qemu soft-emulation, so we > * will never actually have a contested lock */ > @@ -202,14 +207,104 @@ static target_ulong h_remove(CPUState *env, = sPAPREnvironment *spapr, > ((flags & H_ANDCOND) && (v & avpn) !=3D 0)) { > stq_p(hpte, v & ~HPTE_V_HVLOCK); > assert(!(ldq_p(hpte) & HPTE_V_HVLOCK)); > - return H_NOT_FOUND; > + return REMOVE_NOT_FOUND; > } > - args[0] =3D v & ~HPTE_V_HVLOCK; > - args[1] =3D r; > + *vp =3D v & ~HPTE_V_HVLOCK; > + *rp =3D r; > stq_p(hpte, 0); > - rb =3D compute_tlbie_rb(v, r, pte_index); > + rb =3D compute_tlbie_rb(v, r, ptex); > ppc_tlb_invalidate_one(env, rb); > assert(!(ldq_p(hpte) & HPTE_V_HVLOCK)); > + return REMOVE_SUCCESS; > +} > + > +static target_ulong h_remove(CPUState *env, sPAPREnvironment *spapr, > + target_ulong opcode, target_ulong *args) > +{ > + target_ulong flags =3D args[0]; > + target_ulong pte_index =3D args[1]; > + target_ulong avpn =3D args[2]; > + int ret; > + > + ret =3D remove_hpte(env, pte_index, avpn, flags, > + &args[0], &args[1]); > + > + switch (ret) { > + case REMOVE_SUCCESS: > + return H_SUCCESS; > + =20 > + case REMOVE_NOT_FOUND: > + return H_NOT_FOUND; > + > + case REMOVE_PARM: > + return H_PARAMETER; > + > + case REMOVE_HW: > + return H_HARDWARE; > + } > + > + assert(0); > +} > + > +#define H_BULK_REMOVE_TYPE 0xc000000000000000ULL > +#define H_BULK_REMOVE_REQUEST 0x4000000000000000ULL > +#define H_BULK_REMOVE_RESPONSE 0x8000000000000000ULL > +#define H_BULK_REMOVE_END 0xc000000000000000ULL > +#define H_BULK_REMOVE_CODE 0x3000000000000000ULL > +#define H_BULK_REMOVE_SUCCESS 0x0000000000000000ULL > +#define H_BULK_REMOVE_NOT_FOUND 0x1000000000000000ULL > +#define H_BULK_REMOVE_PARM 0x2000000000000000ULL > +#define H_BULK_REMOVE_HW 0x3000000000000000ULL > +#define H_BULK_REMOVE_RC 0x0c00000000000000ULL > +#define H_BULK_REMOVE_FLAGS 0x0300000000000000ULL > +#define H_BULK_REMOVE_ABSOLUTE 0x0000000000000000ULL > +#define H_BULK_REMOVE_ANDCOND 0x0100000000000000ULL > +#define H_BULK_REMOVE_AVPN 0x0200000000000000ULL > +#define H_BULK_REMOVE_PTEX 0x00ffffffffffffffULL indenting looks broken. > + > +static target_ulong h_bulk_remove(CPUState *env, sPAPREnvironment = *spapr, > + target_ulong opcode, target_ulong = *args) > +{ > + int i; > + > + for (i =3D 0; i < 4; i++) { > + target_ulong *tsh =3D &args[i*2]; > + target_ulong tsl =3D args[i*2 + 1]; Mind to replace all those magic numbers by something more verbose? Alex