]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated
authorJames Morse <james.morse@arm.com>
Wed, 6 Apr 2022 16:45:44 +0000 (17:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Apr 2022 05:52:17 +0000 (07:52 +0200)
commit a5905d6af492ee6a4a2205f0d550b3f931b03d03 upstream.

KVM allows the guest to discover whether the ARCH_WORKAROUND SMCCC are
implemented, and to preserve that state during migration through its
firmware register interface.

Add the necessary boiler plate for SMCCC_ARCH_WORKAROUND_3.

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
[ kvm code moved to arch/arm/kvm, removed fw regs ABI. Added 32bit stub ]
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/include/asm/kvm_host.h
arch/arm/kvm/psci.c
arch/arm64/include/asm/kvm_host.h

index 2fda7e905754b4430c535ede0e8bd0d4c759ef51..82c71a147f21da4e69ce15885fa5635c469109dc 100644 (file)
@@ -349,4 +349,9 @@ static inline int kvm_arm_have_ssbd(void)
        return KVM_SSBD_UNKNOWN;
 }
 
+static inline bool kvm_arm_spectre_bhb_mitigated(void)
+{
+       /* 32bit guests don't need firmware for this */
+       return false;
+}
 #endif /* __ARM_KVM_HOST_H__ */
index 83365bec04b690af29fc50830fd44ac3d95b4f81..a262c175456d3118d07984cec44946871f0a0156 100644 (file)
@@ -431,6 +431,10 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
                                break;
                        }
                        break;
+               case ARM_SMCCC_ARCH_WORKAROUND_3:
+                       if (kvm_arm_spectre_bhb_mitigated())
+                               val = SMCCC_RET_SUCCESS;
+                       break;
                }
                break;
        default:
index a152a7bbc85ab2a9c8a8701f678ffa6f7d385f74..a75f02e5f0fdc6e630db251d59a139a6c9dd141e 100644 (file)
@@ -452,4 +452,8 @@ static inline int kvm_arm_have_ssbd(void)
        }
 }
 
+static inline bool kvm_arm_spectre_bhb_mitigated(void)
+{
+       return arm64_get_spectre_bhb_state() == SPECTRE_MITIGATED;
+}
 #endif /* __ARM64_KVM_HOST_H__ */