{"id":732674,"url":"http://patchwork.ozlabs.org/api/1.2/patches/732674/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170227033342.GB3591@fergus.ozlabs.ibm.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.2/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<20170227033342.GB3591@fergus.ozlabs.ibm.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20170227033342.GB3591@fergus.ozlabs.ibm.com/","date":"2017-02-27T03:33:42","name":"KVM: PPC: Book3S HV: Fix software walk of guest process page tables","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8d1583fdef1812f13b74663715481ffbf997540a","submitter":{"id":67079,"url":"http://patchwork.ozlabs.org/api/1.2/people/67079/?format=json","name":"Paul Mackerras","email":"paulus@ozlabs.org"},"delegate":{"id":13,"url":"http://patchwork.ozlabs.org/api/1.2/users/13/?format=json","username":"paulus","first_name":"Paul","last_name":"Mackerras","email":"paulus@samba.org"},"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170227033342.GB3591@fergus.ozlabs.ibm.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/732674/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/732674/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org","linuxppc-dev@ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3vWnSH2vPNz9sN5\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 27 Feb 2017 14:36:31 +1100 (AEDT)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3vWnSH28cjzDqL0\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 27 Feb 2017 14:36:31 +1100 (AEDT)","from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3vWnP85jmxzDqGh\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon, 27 Feb 2017 14:33:48 +1100 (AEDT)","by ozlabs.org (Postfix)\n\tid 3vWnP84scNz9sDg; Mon, 27 Feb 2017 14:33:48 +1100 (AEDT)","by ozlabs.org (Postfix, from userid 1003)\n\tid 3vWnP84VlBz9s9r; Mon, 27 Feb 2017 14:33:48 +1100 (AEDT)"],"Date":"Mon, 27 Feb 2017 14:33:42 +1100","From":"Paul Mackerras <paulus@ozlabs.org>","To":"linuxppc-dev@ozlabs.org, kvm@vger.kernel.org","Subject":"[PATCH] KVM: PPC: Book3S HV: Fix software walk of guest process page\n\ttables","Message-ID":"<20170227033342.GB3591@fergus.ozlabs.ibm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","User-Agent":"Mutt/1.5.24 (2015-08-30)","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"kvm-ppc@vger.kernel.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"This fixes some bugs in the code that walks the guest's page tables.\nThese bugs cause MMIO emulation to fail whenever the guest is in\nvirtial mode (MMU on), leading to the guest hanging if it tried to\naccess a virtio device.\n\nThe first bug was that when reading the guest's process table, we were\nusing the whole of arch->process_table, not just the field that contains\nthe process table base address.  The second bug was that the mask used\nwhen reading the process table entry to get the radix tree base address,\nRPDB_MASK, had the wrong value.\n\nFixes: 9e04ba69beec (\"KVM: PPC: Book3S HV: Add basic infrastructure for radix guests\")\nFixes: e99833448c5f (\"powerpc/mm/radix: Add partition table format & callback\")\nSigned-off-by: Paul Mackerras <paulus@ozlabs.org>\n---\n arch/powerpc/include/asm/book3s/64/mmu.h | 3 ++-\n arch/powerpc/kvm/book3s_64_mmu_radix.c   | 5 +++--\n 2 files changed, 5 insertions(+), 3 deletions(-)","diff":"diff --git a/arch/powerpc/include/asm/book3s/64/mmu.h b/arch/powerpc/include/asm/book3s/64/mmu.h\nindex d73e9df..440f342 100644\n--- a/arch/powerpc/include/asm/book3s/64/mmu.h\n+++ b/arch/powerpc/include/asm/book3s/64/mmu.h\n@@ -46,7 +46,7 @@ extern struct patb_entry *partition_tb;\n \n /* Bits in patb0 field */\n #define PATB_HR\t\t(1UL << 63)\n-#define RPDB_MASK\t0x0ffffffffffff00fUL\n+#define RPDB_MASK\t0x0fffffffffffff00UL\n #define RPDB_SHIFT\t(1UL << 8)\n #define RTS1_SHIFT\t61\t\t/* top 2 bits of radix tree size */\n #define RTS1_MASK\t(3UL << RTS1_SHIFT)\n@@ -57,6 +57,7 @@ extern struct patb_entry *partition_tb;\n /* Bits in patb1 field */\n #define PATB_GR\t\t(1UL << 63)\t/* guest uses radix; must match HR */\n #define PRTS_MASK\t0x1f\t\t/* process table size field */\n+#define PRTB_MASK\t0x0ffffffffffff000UL\n \n /*\n  * Limit process table to PAGE_SIZE table. This\ndiff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c\nindex 4344651..f6b3e67 100644\n--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c\n+++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c\n@@ -32,6 +32,7 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,\n \tu32 pid;\n \tint ret, level, ps;\n \t__be64 prte, rpte;\n+\tunsigned long ptbl;\n \tunsigned long root, pte, index;\n \tunsigned long rts, bits, offset;\n \tunsigned long gpa;\n@@ -53,8 +54,8 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,\n \t\treturn -EINVAL;\n \n \t/* Read partition table to find root of tree for effective PID */\n-\tret = kvm_read_guest(kvm, kvm->arch.process_table + pid * 16,\n-\t\t\t     &prte, sizeof(prte));\n+\tptbl = (kvm->arch.process_table & PRTB_MASK) + (pid * 16);\n+\tret = kvm_read_guest(kvm, ptbl, &prte, sizeof(prte));\n \tif (ret)\n \t\treturn ret;\n \n","prefixes":[]}