Skip to content

Commit 96df226

Browse files
aikpaulusmack
authored andcommitted
KVM: PPC: Book3S PR: Preserve storage control bits
PR KVM page fault handler performs eaddr to pte translation for a guest, however kvmppc_mmu_book3s_64_xlate() does not preserve WIMG bits (storage control) in the kvmppc_pte struct. If PR KVM is running as a second level guest under HV KVM, and PR KVM tries inserting HPT entry, this fails in HV KVM if it already has this mapping. This preserves WIMG bits between kvmppc_mmu_book3s_64_xlate() and kvmppc_mmu_map_page(). Signed-off-by: Alexey Kardashevskiy <[email protected]> Reviewed-by: David Gibson <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent bd9166f commit 96df226

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

arch/powerpc/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ struct kvmppc_pte {
342342
bool may_read : 1;
343343
bool may_write : 1;
344344
bool may_execute : 1;
345+
unsigned long wimg;
345346
u8 page_size; /* MMU_PAGE_xxx */
346347
};
347348

arch/powerpc/kvm/book3s_64_mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
319319
gpte->may_execute = true;
320320
gpte->may_read = false;
321321
gpte->may_write = false;
322+
gpte->wimg = r & HPTE_R_WIMG;
322323

323324
switch (pp) {
324325
case 0:

arch/powerpc/kvm/book3s_64_mmu_host.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte,
145145
else
146146
kvmppc_mmu_flush_icache(pfn);
147147

148+
rflags = (rflags & ~HPTE_R_WIMG) | orig_pte->wimg;
149+
148150
/*
149151
* Use 64K pages if possible; otherwise, on 64K page kernels,
150152
* we need to transfer 4 more bits from guest real to host real addr.

arch/powerpc/kvm/book3s_pr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
537537
int r = RESUME_GUEST;
538538
int relocated;
539539
int page_found = 0;
540-
struct kvmppc_pte pte;
540+
struct kvmppc_pte pte = { 0 };
541541
bool dr = (kvmppc_get_msr(vcpu) & MSR_DR) ? true : false;
542542
bool ir = (kvmppc_get_msr(vcpu) & MSR_IR) ? true : false;
543543
u64 vsid;

0 commit comments

Comments
 (0)