Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:arch\x86\kernel\cpu\bugs.c Create Date:2022-07-28 07:56:16
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:spectre_v2_select_mitigation

Proto:static void __init spectre_v2_select_mitigation(void)

Type:void

Parameter:Nothing

761  cmd = spectre_v2_parse_cmdline()
762  mode = SPECTRE_V2_NONE
768  If Not boot_cpu_has_bug(CPU is affected by Spectre variant 2 attack with indirect branches ) && ( cmd == SPECTRE_V2_CMD_NONE || cmd == SPECTRE_V2_CMD_AUTO ) Then Return
773  Case cmd == SPECTRE_V2_CMD_NONE
774  Return
776  Case cmd == SPECTRE_V2_CMD_FORCE
777  Case cmd == SPECTRE_V2_CMD_AUTO
778  If boot_cpu_has(Enhanced IBRS ) Then
783  Go to specv2_set_mode
785  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_RETPOLINE) Then Go to retpoline_auto
787  Break
788  Case cmd == SPECTRE_V2_CMD_RETPOLINE_AMD
789  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_RETPOLINE) Then Go to retpoline_amd
791  Break
792  Case cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC
793  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_RETPOLINE) Then Go to retpoline_generic
795  Break
796  Case cmd == SPECTRE_V2_CMD_RETPOLINE
797  If IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_RETPOLINE) Then Go to retpoline_auto
799  Break
801  pr_err("Spectre mitigation: kernel not compiled with retpoline; no mitigation available!")
802  Return
804  retpoline_auto :
805  If CPU vendor == X86_VENDOR_AMD || CPU vendor == X86_VENDOR_HYGON Then
807  retpoline_amd :
809  pr_err("Spectre mitigation: LFENCE not serializing, switching to generic retpoline\n")
810  Go to retpoline_generic
812  mode = SPECTRE_V2_RETPOLINE_AMD
813  setup_force_cpu_cap("" AMD Retpoline mitigation for Spectre variant 2 )
814  setup_force_cpu_cap("" Generic Retpoline mitigation for Spectre variant 2 )
815  Else
816  retpoline_generic :
817  mode = SPECTRE_V2_RETPOLINE_GENERIC
818  setup_force_cpu_cap("" Generic Retpoline mitigation for Spectre variant 2 )
821  specv2_set_mode :
822  spectre_v2_enabled = mode
823  pr_info("%s\n", spectre_v2_strings[mode])
833  setup_force_cpu_cap("" Fill RSB on context switches )
834  pr_info("Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch\n")
847  If boot_cpu_has(Indirect Branch Restricted Speculation ) && mode != SPECTRE_V2_IBRS_ENHANCED Then
848  setup_force_cpu_cap("" Use IBRS during runtime firmware calls )
849  pr_info("Enabling Restricted Speculation for firmware calls\n")
853  spectre_v2_user_select_mitigation(cmd)
Caller
NameDescribe
check_bugs