Skip to content

Commit 1f50cc1

Browse files
mdrothpaulusmack
authored andcommitted
KVM: PPC: Book3S HV: Fix H_CEDE return code for nested guests
The h_cede_tm kvm-unit-test currently fails when run inside an L1 guest via the guest/nested hypervisor. ./run-tests.sh -v ... TESTNAME=h_cede_tm TIMEOUT=90s ACCEL= ./powerpc/run powerpc/tm.elf -smp 2,threads=2 -machine cap-htm=on -append "h_cede_tm" FAIL h_cede_tm (2 tests, 1 unexpected failures) While the test relates to transactional memory instructions, the actual failure is due to the return code of the H_CEDE hypercall, which is reported as 224 instead of 0. This happens even when no TM instructions are issued. 224 is the value placed in r3 to execute a hypercall for H_CEDE, and r3 is where the caller expects the return code to be placed upon return. In the case of guest running under a nested hypervisor, issuing H_CEDE causes a return from H_ENTER_NESTED. In this case H_CEDE is specially-handled immediately rather than later in kvmppc_pseries_do_hcall() as with most other hcalls, but we forget to set the return code for the caller, hence why kvm-unit-test sees the 224 return code and reports an error. Guest kernels generally don't check the return value of H_CEDE, so that likely explains why this hasn't caused issues outside of kvm-unit-tests so far. Fix this by setting r3 to 0 after we finish processing the H_CEDE. RHBZ: 1778556 Fixes: 4bad777 ("KVM: PPC: Book3S HV: Handle hypercalls correctly when nested") Cc: [email protected] Cc: David Gibson <[email protected]> Cc: Paul Mackerras <[email protected]> Signed-off-by: Michael Roth <[email protected]> Reviewed-by: David Gibson <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 1dff306 commit 1f50cc1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

arch/powerpc/kvm/book3s_hv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3615,6 +3615,7 @@ int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
36153615
if (trap == BOOK3S_INTERRUPT_SYSCALL && !vcpu->arch.nested &&
36163616
kvmppc_get_gpr(vcpu, 3) == H_CEDE) {
36173617
kvmppc_nested_cede(vcpu);
3618+
kvmppc_set_gpr(vcpu, 3, 0);
36183619
trap = 0;
36193620
}
36203621
} else {

0 commit comments

Comments
 (0)