Received: from eggs.gnu.org ([2001:4830:134:3::10]:38032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSfRC-0000sJ-E4 for qemu-devel@nongnu.org; Mon, 08 Feb 2016 01:36:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSfQd-0003Hs-6X for qemu-devel@nongnu.org; Mon, 08 Feb 2016 01:36:42 -0500 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:36047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSfQc-0003Gz-Ro for qemu-devel@nongnu.org; Mon, 08 Feb 2016 01:36:07 -0500 Received: by mail-pf0-x242.google.com with SMTP id e127so760561pfe.3 for ; Sun, 07 Feb 2016 22:36:05 -0800 (PST) References: <1454638439-11938-1-git-send-email-david@gibson.dropbear.id.au> <1454638439-11938-6-git-send-email-david@gibson.dropbear.id.au> From: Alexey Kardashevskiy Message-ID: <56B8374F.7080707@ozlabs.ru> Date: Mon, 8 Feb 2016 17:35:59 +1100 MIME-Version: 1.0 In-Reply-To: <1454638439-11938-6-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/6] target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , benh@kernel.crashing.org, agraf@suse.de Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org On 02/05/2016 01:13 PM, David Gibson wrote: > With HV KVM, the guest's hash page table (HPT) is managed by the kernel and > not directly accessible to QEMU. This means that spapr->htab is NULL > and normally env->external_htab would also be NULL for each cpu. > > However, that would cause ppc_hash64_load_hpte*() to do the wrong thing in > the few cases where QEMU does need to load entries from the in-kernel HPT. > Specifically, seeing external_htab is NULL, they would look for an HPT > within the guest's address space instead. > > To stop that we have an ugly hack in the pseries machine type code to > set external htab to (void *)1 instead. > > This patch removes that hack by having ppc_hash64_load_hpte*() explicitly > check kvmppc_kern_htab instead, which makes more sense. > > Signed-off-by: David Gibson To my limited knowledge of kvmppc_kern_htab&co, this looks good. Reviewed-by: Alexey Kardashevskiy > --- > hw/ppc/spapr.c | 7 ------- > target-ppc/mmu-hash64.h | 4 ++-- > 2 files changed, 2 insertions(+), 9 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index d228375..77dd1b6 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1196,13 +1196,6 @@ static void spapr_cpu_reset(void *opaque) > env->spr[SPR_HIOR] = 0; > > env->external_htab = (uint8_t *)spapr->htab; > - if (kvm_enabled() && !env->external_htab) { > - /* > - * HV KVM, set external_htab to 1 so our ppc_hash64_load_hpte* > - * functions do the right thing. > - */ > - env->external_htab = (void *)1; > - } > env->htab_base = -1; > /* > * htab_mask is the mask used to normalize hash value to PTEG index. > diff --git a/target-ppc/mmu-hash64.h b/target-ppc/mmu-hash64.h > index ab0f86b..e7d9925 100644 > --- a/target-ppc/mmu-hash64.h > +++ b/target-ppc/mmu-hash64.h > @@ -102,7 +102,7 @@ static inline target_ulong ppc_hash64_load_hpte0(PowerPCCPU *cpu, > uint64_t addr; > > addr = token + (index * HASH_PTE_SIZE_64); > - if (env->external_htab) { > + if (kvmppc_kern_htab || env->external_htab) { > return ldq_p((const void *)(uintptr_t)addr); > } else { > return ldq_phys(CPU(cpu)->as, addr); Out of curiosity - how does this work? ldq_p() reads from the userspace address > @@ -116,7 +116,7 @@ static inline target_ulong ppc_hash64_load_hpte1(PowerPCCPU *cpu, > uint64_t addr; > > addr = token + (index * HASH_PTE_SIZE_64) + HASH_PTE_SIZE_64/2; > - if (env->external_htab) { > + if (kvmppc_kern_htab || env->external_htab) { > return ldq_p((const void *)(uintptr_t)addr); > } else { > return ldq_phys(CPU(cpu)->as, addr); > -- Alexey