Skip to contentSkip to conversation

KVM: PPC: Fix Mac OS X guests on non-Apple hosts

PATCH New Alexander Graf 1 participant 3 messages Jul 10, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover KVM: PPC: Fix Mac OS X guests on non-Apple hosts

While trying to get Mac-on-Linux to work on a POWER7 box I stumbled over two issues in our book3s_32 MMU emulation. With these issues fixed and a hack to disable magic page mapping (very hard to get right with 64k pages in this case) I can successfully run Mac OS X guests on a POWER7 host.

Alex

Alexander Graf (2):
KVM: PPC: Deflect page write faults properly in kvmppc_st
KVM: PPC: Book3S: Stop PTE lookup on write errors

 arch/powerpc/kvm/book3s.c        | 6 ++++--
 arch/powerpc/kvm/book3s_32_mmu.c | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/2 KVM: PPC: Deflect page write faults properly in kvmppc_st

When we have a page that we're not allowed to write to, xlate() will already tell us -EPERM on lookup of that page. With the code as is we change it into a "page missing" error which a guest may get confused about. Instead, just tell the caller about the -EPERM directly.

This fixes Mac OS X guests when run with DCBZ32 emulation.

---
 arch/powerpc/kvm/book3s.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s.c +4 -2
index bd75902..9624c56 100644
@@ -418,11 +418,13 @@ int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
 	      bool data)
 {
 	struct kvmppc_pte pte;
+	int r;
 
 	vcpu->stat.st++;
 
-	if (kvmppc_xlate(vcpu, *eaddr, data, true, &pte))
-		return -ENOENT;
+	r = kvmppc_xlate(vcpu, *eaddr, data, true, &pte);
+	if (r < 0)
+		return r;
 
 	*eaddr = pte.raddr;
 
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/2 KVM: PPC: Book3S: Stop PTE lookup on write errors

In reply to Alexander Graf

When a page lookup failed because we're not allowed to write to the page, we should not overwrite that value with another lookup on the second PTEG which will return "page not found". Instead, we should just tell the caller that we had a permission problem.

This fixes Mac OS X guests looping endlessly in page lookup code for me.

---
 arch/powerpc/kvm/book3s_32_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kvm/book3s_32_mmu.c +1 -1
index 93503bb..cd0b073 100644
@@ -335,7 +335,7 @@ static int kvmppc_mmu_book3s_32_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
 	if (r < 0)
 		r = kvmppc_mmu_book3s_32_xlate_pte(vcpu, eaddr, pte,
 						   data, iswrite, true);
-	if (r < 0)
+	if (r = -ENOENT)
 		r = kvmppc_mmu_book3s_32_xlate_pte(vcpu, eaddr, pte,
 						   data, iswrite, false);
 
Signature · 1 line
1.8.1.4