From patchwork Sun Jan 18 16:12:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Pircher X-Patchwork-Id: 430226 X-Patchwork-Delegate: michael@ellerman.id.au Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5A8881401DA for ; Mon, 19 Jan 2015 03:18:19 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 422571A0E17 for ; Mon, 19 Jan 2015 03:18:19 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org X-Greylist: delayed 313 seconds by postgrey-1.35 at bilbo; Mon, 19 Jan 2015 03:17:35 AEDT Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 025311A0CC0 for ; Mon, 19 Jan 2015 03:17:35 +1100 (AEDT) Received: from [192.168.20.23] ([79.51.106.165]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MEccf-1XxD8g11oX-00Fk5N; Sun, 18 Jan 2015 17:12:15 +0100 Message-ID: <54BBDB6E.6050808@gmx.net> Date: Sun, 18 Jan 2015 17:12:30 +0100 From: Gerhard Pircher User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: Alexander Graf Subject: [PATCH] powerpc: kvm: Set M flag for KVM PTE depending on CPU_FTR_NEED_COHERENT X-Provags-ID: V03:K0:OVKCcHG4iieKr+bfQY0OgtPz9dxH8KiWGyEPviFN9ItnUGf1+9H 5nhba/VoFDphSmKu8wAm1K0Bv+gJlSrr0FD34iSq9Im9yVQmI7T6bTG1SN1QBmObn59Isu9 DE0ttMMaobBBkuqyUYuwYU8eC0fF5vgiDYOB94la532WaoHigdZfI+trwq7qigx5VY2h7EK FwK4BWdgSn77V7cHI/Qlg== X-UI-Out-Filterresults: notjunk:1; Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Usually page table entries only have the M (coherence) flag set, if the kernel is in SMP mode or to avoid data corruption due to CPU bugs (e.g. some 74xx CPUs). KVM on book3s_32 however always sets the M flag for a PTE, which locks up machines based on the amigaone platform when running QEMU or MoL. Setting the M flag depending on CPU_FTR_NEED_COHERENT also makes KVM work on this platform and aligns the PTE setup to the rest of the kernel. Signed-off-by: Gerhard Pircher --- With this patch I could successfully run a Debian Wheezy installation inside QEMU started with --enable-kvm on my AmigaOneG3SE. arch/powerpc/kvm/book3s_32_mmu_host.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c index 2035d16..935c7d0 100644 --- a/arch/powerpc/kvm/book3s_32_mmu_host.c +++ b/arch/powerpc/kvm/book3s_32_mmu_host.c @@ -204,7 +204,10 @@ next_pteg: pteg0 = ((eaddr & 0x0fffffff) >> 22) | (vsid << 7) | PTE_V | (primary ? 0 : PTE_SEC); - pteg1 = hpaddr | PTE_M | PTE_R | PTE_C; + pteg1 = hpaddr | PTE_R | PTE_C; + + if (cpu_has_feature(CPU_FTR_NEED_COHERENT)) + pteg1 |= PTE_M; if (orig_pte->may_write && writable) { pteg1 |= PP_RWRW;