KVM: arm64: ARM_SMCCC_ARCH_WORKAROUND_1 doesn't return SMCCC_RET_NOT_REQUIRED
PATCH 1/1 KVM: arm64: ARM_SMCCC_ARCH_WORKAROUND_1 doesn't return SMCCC_RET_NOT_REQUIRED
commit 1de111b51b829bcf01d2e57971f8fd07a665fa3f upstream.
According to the SMCCC spec[1](7.5.2 Discovery) the ARM_SMCCC_ARCH_WORKAROUND_1 function id only returns 0, 1, and SMCCC_RET_NOT_SUPPORTED.
0 is "workaround required and safe to call this function"
1 is "workaround not required but safe to call this function" SMCCC_RET_NOT_SUPPORTED is "might be vulnerable or might not be, who knows, I give up!"
SMCCC_RET_NOT_SUPPORTED might as well mean "workaround required, except calling this function may not work because it isn't implemented in some cases". Wonderful. We map this SMC call to
0 is SPECTRE_MITIGATED
1 is SPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE
For KVM hypercalls (hvc), we've implemented this function id to return SMCCC_RET_NOT_SUPPORTED, 0, and SMCCC_RET_NOT_REQUIRED. One of those isn't supposed to be there. Per the code we call arm64_get_spectre_v2_state() to figure out what to return for this feature discovery call.
0 is SPECTRE_MITIGATED
SMCCC_RET_NOT_REQUIRED is SPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE
Let's clean this up so that KVM tells the guest this mapping:
0 is SPECTRE_MITIGATED
1 is SPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTED is SPECTRE_VULNERABLE
Note: SMCCC_RET_NOT_AFFECTED is 1 but isn't part of the SMCCC spec
--- arch/arm64/kvm/hypercalls.c | 2 +- include/linux/arm-smccc.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm64/kvm/hypercalls.c +1 -1
@@ -31,7 +31,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) val =SMCCC_RET_SUCCESS ;break ;case KVM_BP_HARDEN_NOT_REQUIRED : - val =SMCCC_RET_NOT_REQUIRED ; + val =SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED ;break ; }break ;
include/linux/arm-smccc.h +2 -0
@@ -86,6 +86,8 @@ ARM_SMCCC_SMC_32, \ 0, 0x7fff) +#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED 1 +/* Paravirtualised time calls (defined by ARM DEN0057A) */ #define ARM_SMCCC_HV_PV_TIME_FEATURES \ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
Signature · 1 line
Sent by a computer, using git, on the internet
Quoted 48 lines · Stephen Boyd
commit
1de111b51b829bcf01d2e57971f8fd07a665fa3fupstream.According to the SMCCC spec[1](7.5.2 Discovery) the
ARM_SMCCC_ARCH_WORKAROUND_1function id only returns 0, 1, andSMCCC_RET_NOT_SUPPORTED.0 is "workaround required and safe to call this function"
1 is "workaround not required but safe to call this function"SMCCC_RET_NOT_SUPPORTEDis "might be vulnerable or might not be, who knows, I give up!"
SMCCC_RET_NOT_SUPPORTEDmight as well mean "workaround required, except calling this function may not work because it isn't implemented in some cases". Wonderful. We map this SMC call to0 is
SPECTRE_MITIGATED
1 isSPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTEDisSPECTRE_VULNERABLEFor KVM hypercalls (hvc), we've implemented this function id to return
SMCCC_RET_NOT_SUPPORTED, 0, andSMCCC_RET_NOT_REQUIRED. One of those isn't supposed to be there. Per the code we callarm64_get_spectre_v2_state()to figure out what to return for this feature discovery call.0 is
SPECTRE_MITIGATED
SMCCC_RET_NOT_REQUIREDisSPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTEDisSPECTRE_VULNERABLELet's clean this up so that KVM tells the guest this mapping:
0 is
SPECTRE_MITIGATED
1 isSPECTRE_UNAFFECTED
SMCCC_RET_NOT_SUPPORTEDisSPECTRE_VULNERABLENote:
SMCCC_RET_NOT_AFFECTEDis 1 but isn't part of the SMCCC specFixes c118bbb52743 ("arm64: KVM: Propagate full Spectre v2 workaround state to KVM guests")Signed-off-by Stephen Boyd <[email protected]>Acked-by Marc Zyngier <[email protected]>Acked-by Will Deacon <[email protected]>Cc Andre Przywara <[email protected]>Cc Steven Price <[email protected]>Cc Marc Zyngier <[email protected]>Signed-off-by Will Deacon <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Quoted 4 lines
--- arch/arm64/kvm/hypercalls.c | 2 +- include/linux/arm-smccc.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
Thanks for both of these, now queued up.
greg k-h