Skip to contentSkip to conversation

Patch "KVM: PPC: Book3S PR: Fix WIMG handling under pHyp" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Jan 13, 2018

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

KVM: PPC: Book3S PR: Fix WIMG handling under pHyp

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
kvm-ppc-book3s-pr-fix-wimg-handling-under-phyp.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 6c7d47c33ed323f14f2a3b8de925e831dbaa4e69 Mon Sep 17 00:00:00 2001

From: Alexey Kardashevskiy <[email protected]>
Date: Wed, 22 Nov 2017 14:42:21 +1100
Subject: KVM: PPC: Book3S PR: Fix WIMG handling under pHyp

From: Alexey Kardashevskiy <[email protected]>

commit 6c7d47c33ed323f14f2a3b8de925e831dbaa4e69 upstream.

Commit 96df226 ("KVM: PPC: Book3S PR: Preserve storage control bits") added code to preserve WIMG bits but it missed 2 special cases:
- a magic page in kvmppc_mmu_book3s_64_xlate() and
- guest real mode in kvmppc_handle_pagefault().

For these ptes, WIMG was 0 and pHyp failed on these causing a guest to stop in the very beginning at NIP=0x100 (due to bd9166ffe "KVM: PPC:
Book3S PR: Exit KVM on failed mapping").

According to LoPAPR v1.1 14.5.4.1.2 H_ENTER:

The hypervisor checks that the WIMG bits within the PTE are appropriate for the physical page number else H_Parameter return. (For System Memory pages WIMG=0010, or, 1110 if the SAO option is enabled, and for IO pages WIMG=01**.)

This hence initializes WIMG to non-zero value HPTE_R_M (0x10), as expected by pHyp.

[[email protected] - fix compile for 32-bit]

---
 arch/powerpc/kvm/book3s_64_mmu.c |    1 +
 arch/powerpc/kvm/book3s_pr.c     |    2 ++
 2 files changed, 3 insertions(+)
arch/powerpc/kvm/book3s_64_mmu.c +1 -0
@@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(st
 		gpte->may_read = true;
 		gpte->may_write = true;
 		gpte->page_size = MMU_PAGE_4K;
+		gpte->wimg = HPTE_R_M;
 
 		return 0;
 	}
arch/powerpc/kvm/book3s_pr.c +2 -0
@@ -60,6 +60,7 @@ static void kvmppc_giveup_fac(struct kvm
 #define MSR_USER32 MSR_USER
 #define MSR_USER64 MSR_USER
 #define HW_PAGE_SIZE PAGE_SIZE
+#define HPTE_R_M   _PAGE_COHERENT
 #endif
 
 static bool kvmppc_is_split_real(struct kvm_vcpu *vcpu)
@@ -557,6 +558,7 @@ int kvmppc_handle_pagefault(struct kvm_r
 		pte.eaddr = eaddr;
 		pte.vpage = eaddr >> 12;
 		pte.page_size = MMU_PAGE_64K;
+		pte.wimg = HPTE_R_M;
 	}
 
 	switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/kvm-ppc-book3s-pr-fix-wimg-handling-under-phyp.patch