From patchwork Tue Feb 9 02:12:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 580608 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6A654140325 for ; Tue, 9 Feb 2016 13:12:09 +1100 (AEDT) Received: from localhost ([::1]:50862 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSxmh-0007v0-AG for incoming@patchwork.ozlabs.org; Mon, 08 Feb 2016 21:12:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSxmA-0006vO-W6 for qemu-devel@nongnu.org; Mon, 08 Feb 2016 21:11:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSxm9-0000i2-7a for qemu-devel@nongnu.org; Mon, 08 Feb 2016 21:11:34 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:57120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSxm8-0000hk-SY; Mon, 08 Feb 2016 21:11:33 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 2C7F6140B97; Tue, 9 Feb 2016 13:11:27 +1100 (AEDT) From: David Gibson To: benh@kernel.crashing.org, aik@ozlabs.ru, agraf@suse.de Date: Tue, 9 Feb 2016 12:12:25 +1000 Message-Id: <1454983946-32073-7-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454983946-32073-1-git-send-email-david@gibson.dropbear.id.au> References: <1454983946-32073-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2401:3900:2:1::2 Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCHv2 6/7] target-ppc: Remove hack for ppc_hash64_load_hpte*() with HV KVM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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 907439a..c85a125 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1197,13 +1197,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); @@ -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);