Skip to content

Commit 839d893

Browse files
npigginmpe
authored andcommitted
KVM: PPC: Book3S PR: Disallow AIL != 0
KVM PR does not implement address translation modes on interrupt, so it must not allow H_SET_MODE to succeed. The behaviour change caused by this mode is architected and not advisory (interrupts *must* behave differently). QEMU does not deal with differences in AIL support in the host. The solution to that is a spapr capability and corresponding KVM CAP, but this patch does not break things more than before (the host behaviour already differs, this change just disallows some modes that are not implemented properly). By happy coincidence, this allows PR Linux guests that are using the SCV facility to boot and run, because Linux disables the use of SCV if AIL can not be set to 3. This does not fix the underlying problem of missing SCV support (an OS could implement real-mode SCV vectors and try to enable the facility). The true fix for that is for KVM PR to emulate scv interrupts from the facility unavailable interrupt. Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Reviewed-by: Fabiano Rosas <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b5149e2 commit 839d893

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

arch/powerpc/kvm/book3s_pr_papr.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,22 @@ static int kvmppc_h_pr_logical_ci_store(struct kvm_vcpu *vcpu)
281281
return EMULATE_DONE;
282282
}
283283

284+
static int kvmppc_h_pr_set_mode(struct kvm_vcpu *vcpu)
285+
{
286+
unsigned long mflags = kvmppc_get_gpr(vcpu, 4);
287+
unsigned long resource = kvmppc_get_gpr(vcpu, 5);
288+
289+
if (resource == H_SET_MODE_RESOURCE_ADDR_TRANS_MODE) {
290+
/* KVM PR does not provide AIL!=0 to guests */
291+
if (mflags == 0)
292+
kvmppc_set_gpr(vcpu, 3, H_SUCCESS);
293+
else
294+
kvmppc_set_gpr(vcpu, 3, H_UNSUPPORTED_FLAG_START - 63);
295+
return EMULATE_DONE;
296+
}
297+
return EMULATE_FAIL;
298+
}
299+
284300
#ifdef CONFIG_SPAPR_TCE_IOMMU
285301
static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu)
286302
{
@@ -384,6 +400,8 @@ int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd)
384400
return kvmppc_h_pr_logical_ci_load(vcpu);
385401
case H_LOGICAL_CI_STORE:
386402
return kvmppc_h_pr_logical_ci_store(vcpu);
403+
case H_SET_MODE:
404+
return kvmppc_h_pr_set_mode(vcpu);
387405
case H_XIRR:
388406
case H_CPPR:
389407
case H_EOI:
@@ -421,6 +439,7 @@ int kvmppc_hcall_impl_pr(unsigned long cmd)
421439
case H_CEDE:
422440
case H_LOGICAL_CI_LOAD:
423441
case H_LOGICAL_CI_STORE:
442+
case H_SET_MODE:
424443
#ifdef CONFIG_KVM_XICS
425444
case H_XIRR:
426445
case H_CPPR:
@@ -447,6 +466,7 @@ static unsigned int default_hcall_list[] = {
447466
H_BULK_REMOVE,
448467
H_PUT_TCE,
449468
H_CEDE,
469+
H_SET_MODE,
450470
#ifdef CONFIG_KVM_XICS
451471
H_XIRR,
452472
H_CPPR,

0 commit comments

Comments
 (0)