Skip to content

Commit

Permalink
KVM: PPC: Book3S HV: Fix software walk of guest process page tables
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul Mackerras committed Mar 1, 2017
1 parent fd7e9a8 commit 70cd4c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion arch/powerpc/include/asm/book3s/64/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extern struct patb_entry *partition_tb;

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

/*
* Limit process table to PAGE_SIZE table. This
Expand Down
5 changes: 3 additions & 2 deletions arch/powerpc/kvm/book3s_64_mmu_radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
u32 pid;
int ret, level, ps;
__be64 prte, rpte;
unsigned long ptbl;
unsigned long root, pte, index;
unsigned long rts, bits, offset;
unsigned long gpa;
Expand All @@ -53,8 +54,8 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
return -EINVAL;

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

Expand Down

0 comments on commit 70cd4c1

Please sign in to comment.