Function report | 
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 activity | Download SCCT | Chinese | 
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 | 
| 779 | mode = SPECTRE_V2_IBRS_ENHANCED | 
| 781 | The base value of the SPEC_CTRL MSR that always has to be preserved. |= Indirect Branch Restricted Speculation | 
| 782 | wrmsrl(Speculation Control , The base value of the SPEC_CTRL MSR that always has to be preserved. ) | 
| 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 : | 
| 808 | If Not boot_cpu_has("" LFENCE synchronizes RDTSC ) Then | 
| 809 | pr_err("Spectre mitigation: LFENCE not serializing, switching to generic retpoline\n") | 
| 810 | Go to retpoline_generic | 
| 812 | mode = SPECTRE_V2_RETPOLINE_AMD | 
| 815 | Else | 
| 816 | retpoline_generic : | 
| 821 | specv2_set_mode : | 
| 822 | spectre_v2_enabled = mode | 
| 823 | pr_info("%s\n", spectre_v2_strings[mode]) | 
| 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 | 
| 849 | pr_info("Enabling Restricted Speculation for firmware calls\n") | 
| Name | Describe | 
|---|---|
| check_bugs | 
| Source code conversion tool public plug-in interface  | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion  |