File tree Expand file tree Collapse file tree 4 files changed +55
-2
lines changed Expand file tree Collapse file tree 4 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,18 @@ static inline bool kvm_arm_harden_branch_predictor(void)
315315 return false;
316316}
317317
318+ #define KVM_SSBD_UNKNOWN -1
319+ #define KVM_SSBD_FORCE_DISABLE 0
320+ #define KVM_SSBD_KERNEL 1
321+ #define KVM_SSBD_FORCE_ENABLE 2
322+ #define KVM_SSBD_MITIGATED 3
323+
324+ static inline int kvm_arm_have_ssbd (void )
325+ {
326+ /* No way to detect it yet, pretend it is not there. */
327+ return KVM_SSBD_UNKNOWN ;
328+ }
329+
318330static inline void kvm_vcpu_load_sysregs (struct kvm_vcpu * vcpu ) {}
319331static inline void kvm_vcpu_put_sysregs (struct kvm_vcpu * vcpu ) {}
320332
Original file line number Diff line number Diff line change @@ -455,6 +455,29 @@ static inline bool kvm_arm_harden_branch_predictor(void)
455455 return cpus_have_const_cap (ARM64_HARDEN_BRANCH_PREDICTOR );
456456}
457457
458+ #define KVM_SSBD_UNKNOWN -1
459+ #define KVM_SSBD_FORCE_DISABLE 0
460+ #define KVM_SSBD_KERNEL 1
461+ #define KVM_SSBD_FORCE_ENABLE 2
462+ #define KVM_SSBD_MITIGATED 3
463+
464+ static inline int kvm_arm_have_ssbd (void )
465+ {
466+ switch (arm64_get_ssbd_state ()) {
467+ case ARM64_SSBD_FORCE_DISABLE :
468+ return KVM_SSBD_FORCE_DISABLE ;
469+ case ARM64_SSBD_KERNEL :
470+ return KVM_SSBD_KERNEL ;
471+ case ARM64_SSBD_FORCE_ENABLE :
472+ return KVM_SSBD_FORCE_ENABLE ;
473+ case ARM64_SSBD_MITIGATED :
474+ return KVM_SSBD_MITIGATED ;
475+ case ARM64_SSBD_UNKNOWN :
476+ default :
477+ return KVM_SSBD_UNKNOWN ;
478+ }
479+ }
480+
458481void kvm_vcpu_load_sysregs (struct kvm_vcpu * vcpu );
459482void kvm_vcpu_put_sysregs (struct kvm_vcpu * vcpu );
460483
Original file line number Diff line number Diff line change @@ -122,6 +122,10 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
122122 /* Reset PMU */
123123 kvm_pmu_vcpu_reset (vcpu );
124124
125+ /* Default workaround setup is enabled (if supported) */
126+ if (kvm_arm_have_ssbd () == KVM_SSBD_KERNEL )
127+ vcpu -> arch .workaround_flags |= VCPU_WORKAROUND_2_FLAG ;
128+
125129 /* Reset timer */
126130 return kvm_timer_vcpu_reset (vcpu );
127131}
Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ static int kvm_psci_call(struct kvm_vcpu *vcpu)
405405int kvm_hvc_call_handler (struct kvm_vcpu * vcpu )
406406{
407407 u32 func_id = smccc_get_function (vcpu );
408- u32 val = PSCI_RET_NOT_SUPPORTED ;
408+ u32 val = SMCCC_RET_NOT_SUPPORTED ;
409409 u32 feature ;
410410
411411 switch (func_id ) {
@@ -417,7 +417,21 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
417417 switch (feature ) {
418418 case ARM_SMCCC_ARCH_WORKAROUND_1 :
419419 if (kvm_arm_harden_branch_predictor ())
420- val = 0 ;
420+ val = SMCCC_RET_SUCCESS ;
421+ break ;
422+ case ARM_SMCCC_ARCH_WORKAROUND_2 :
423+ switch (kvm_arm_have_ssbd ()) {
424+ case KVM_SSBD_FORCE_DISABLE :
425+ case KVM_SSBD_UNKNOWN :
426+ break ;
427+ case KVM_SSBD_KERNEL :
428+ val = SMCCC_RET_SUCCESS ;
429+ break ;
430+ case KVM_SSBD_FORCE_ENABLE :
431+ case KVM_SSBD_MITIGATED :
432+ val = SMCCC_RET_NOT_REQUIRED ;
433+ break ;
434+ }
421435 break ;
422436 }
423437 break ;
You can’t perform that action at this time.
0 commit comments