diff mbox series

[v5,42/48] KVM: PPC: Book3S HV: Radix guests should not have userspace hcalls reflected to them

Message ID 20210401150325.442125-43-npiggin@gmail.com
State New
Headers show
Series KVM: PPC: Book3S: C-ify the P9 entry/exit code | expand

Commit Message

Nicholas Piggin April 1, 2021, 3:03 p.m. UTC
The reflection of sc 1 hcalls from PR=1 userspace is required to support
PR KVM. Radix guests don't support PR KVM nor do they support nested
hash guests, so this sc 1 reflection can be removed from radix guests.
Cause a privileged program check instead, which is less surprising.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kvm/book3s_hv.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

Comments

Nicholas Piggin April 2, 2021, 12:07 a.m. UTC | #1
Excerpts from Nicholas Piggin's message of April 2, 2021 1:03 am:
> The reflection of sc 1 hcalls from PR=1 userspace is required to support
> PR KVM. Radix guests don't support PR KVM nor do they support nested
> hash guests, so this sc 1 reflection can be removed from radix guests.
> Cause a privileged program check instead, which is less surprising.

I'm thinking twice about where to put this patch. This is kind of
backwards (but also kind of not), so I decided instead to make
the change to not reflect on radix in the patch that removes real
mode hcall handlers from the P9 path.

And the patch around this part of the series will introduce reflection
for hash guest support in the P9 path.

End result is the same but I think that works better.

Thanks,
Nick
diff mbox series

Patch

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index ae5ad93a623f..f4d6ec6c4710 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1403,11 +1403,20 @@  static int kvmppc_handle_exit_hv(struct kvm_vcpu *vcpu,
 		int i;
 
 		if (unlikely(vcpu->arch.shregs.msr & MSR_PR)) {
-			/*
-			 * Guest userspace executed sc 1, reflect it back as a
-			 * syscall as it may be a PR KVM hcall.
-			 */
-			kvmppc_core_queue_syscall(vcpu);
+			if (!kvmhv_vcpu_is_radix(vcpu)) {
+				/*
+				 * Guest userspace executed sc 1, reflect it
+				 * back as a syscall as it may be a PR KVM
+				 * hcall.
+				 */
+				kvmppc_core_queue_syscall(vcpu);
+			} else {
+				/*
+				 * radix guests can not run PR KVM so send a
+				 * program check.
+				 */
+				kvmppc_core_queue_program(vcpu, SRR1_PROGPRIV);
+			}
 			r = RESUME_GUEST;
 			break;
 		}