Skip to content

Commit c2d2e9b

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Start handling SMCs from EL1
Whelp, the architecture gods have spoken and confirmed that the function ID space is common between SMCs and HVCs. Not only that, the expectation is that hypervisors handle calls to both SMC and HVC conduits. KVM recently picked up support for SMCCCs in commit bd36b1a ("KVM: arm64: nv: Handle SMCs taken from virtual EL2") but scoped it only to a nested hypervisor. Let's just open the floodgates and let EL1 access our SMCCC implementation with the SMC instruction as well. Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230404154050.2270077-6-oliver.upton@linux.dev
1 parent aac9496 commit c2d2e9b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

arch/arm64/kvm/handle_exit.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ static int handle_smc(struct kvm_vcpu *vcpu)
7272
*
7373
* We need to advance the PC after the trap, as it would
7474
* otherwise return to the same address...
75-
*
76-
* Only handle SMCs from the virtual EL2 with an immediate of zero and
77-
* skip it otherwise.
7875
*/
79-
if (!vcpu_is_el2(vcpu) || kvm_vcpu_hvc_get_imm(vcpu)) {
76+
kvm_incr_pc(vcpu);
77+
78+
/*
79+
* SMCs with a nonzero immediate are reserved according to DEN0028E 2.9
80+
* "SMC and HVC immediate value".
81+
*/
82+
if (kvm_vcpu_hvc_get_imm(vcpu)) {
8083
vcpu_set_reg(vcpu, 0, ~0UL);
81-
kvm_incr_pc(vcpu);
8284
return 1;
8385
}
8486

@@ -93,8 +95,6 @@ static int handle_smc(struct kvm_vcpu *vcpu)
9395
if (ret < 0)
9496
vcpu_set_reg(vcpu, 0, ~0UL);
9597

96-
kvm_incr_pc(vcpu);
97-
9898
return ret;
9999
}
100100

0 commit comments

Comments
 (0)