Skip to content

Commit 70cd4c1

Browse files
committed
KVM: PPC: Book3S HV: Fix software walk of guest process page tables
This fixes some bugs in the code that walks the guest's page tables. These bugs cause MMIO emulation to fail whenever the guest is in virtial mode (MMU on), leading to the guest hanging if it tried to access a virtio device. The first bug was that when reading the guest's process table, we were using the whole of arch->process_table, not just the field that contains the process table base address. The second bug was that the mask used when reading the process table entry to get the radix tree base address, RPDB_MASK, had the wrong value. Fixes: 9e04ba6 ("KVM: PPC: Book3S HV: Add basic infrastructure for radix guests") Fixes: e998334 ("powerpc/mm/radix: Add partition table format & callback") Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
1 parent fd7e9a8 commit 70cd4c1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

arch/powerpc/include/asm/book3s/64/mmu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extern struct patb_entry *partition_tb;
4646

4747
/* Bits in patb0 field */
4848
#define PATB_HR (1UL << 63)
49-
#define RPDB_MASK 0x0ffffffffffff00fUL
49+
#define RPDB_MASK 0x0fffffffffffff00UL
5050
#define RPDB_SHIFT (1UL << 8)
5151
#define RTS1_SHIFT 61 /* top 2 bits of radix tree size */
5252
#define RTS1_MASK (3UL << RTS1_SHIFT)
@@ -57,6 +57,7 @@ extern struct patb_entry *partition_tb;
5757
/* Bits in patb1 field */
5858
#define PATB_GR (1UL << 63) /* guest uses radix; must match HR */
5959
#define PRTS_MASK 0x1f /* process table size field */
60+
#define PRTB_MASK 0x0ffffffffffff000UL
6061

6162
/*
6263
* Limit process table to PAGE_SIZE table. This

arch/powerpc/kvm/book3s_64_mmu_radix.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
3232
u32 pid;
3333
int ret, level, ps;
3434
__be64 prte, rpte;
35+
unsigned long ptbl;
3536
unsigned long root, pte, index;
3637
unsigned long rts, bits, offset;
3738
unsigned long gpa;
@@ -53,8 +54,8 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
5354
return -EINVAL;
5455

5556
/* Read partition table to find root of tree for effective PID */
56-
ret = kvm_read_guest(kvm, kvm->arch.process_table + pid * 16,
57-
&prte, sizeof(prte));
57+
ptbl = (kvm->arch.process_table & PRTB_MASK) + (pid * 16);
58+
ret = kvm_read_guest(kvm, ptbl, &prte, sizeof(prte));
5859
if (ret)
5960
return ret;
6061

0 commit comments

Comments
 (0)