From: Xenia Ragiadakou Date: Fri, 17 Feb 2023 18:48:11 +0000 (+0200) Subject: x86/svm: cleanup svm.c X-Git-Tag: 4.18.0-rc1~1054 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a90a0018f605e3bb0588816e5a1f957d6e4562eb;p=xen.git x86/svm: cleanup svm.c Do not include the headers: xen/irq.h asm/hvm/svm/intr.h asm/io.h asm/mem_sharing.h asm/regs.h because none of the declarations and macro definitions in them is used. Sort the rest of the headers alphabetically. Remove the forward declaration of svm_function_table and place start_svm() after the svm_function_table's definition. Replace double new lines with one. No functional change intended. Signed-off-by: Xenia Ragiadakou Acked-by: Andrew Cooper --- diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index fa73257203..f412b537aa 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -16,60 +16,49 @@ * this program; If not, see . */ +#include #include +#include #include #include -#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include + #include +#include +#include +#include #include -#include -#include -#include +#include #include #include -#include #include -#include +#include +#include +#include #include -#include -#include #include -#include -#include #include -#include -#include -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include +#include +#include #include -#include +#include +#include +#include +#include +#include + +#include void noreturn svm_asm_do_resume(void); u32 svm_feature_flags; -static struct hvm_function_table svm_function_table; - /* * Physical addresses of the Host State Area (for hardware) and vmcb (for Xen) * which contains Xen's fs/gs/tr/ldtr and GSBASE/STAR/SYSENTER state when in @@ -505,7 +494,6 @@ static int svm_vmcb_restore(struct vcpu *v, struct hvm_hw_cpu *c) return 0; } - static void svm_save_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) { struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb; @@ -517,7 +505,6 @@ static void svm_save_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) data->msr_syscall_mask = vmcb->sfmask; } - static void svm_load_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) { struct vmcb_struct *vmcb = v->arch.hvm.svm.vmcb; @@ -1649,57 +1636,6 @@ static int cf_check svm_cpu_up(void) return _svm_cpu_up(false); } -const struct hvm_function_table * __init start_svm(void) -{ - bool_t printed = 0; - - svm_host_osvw_reset(); - - if ( _svm_cpu_up(true) ) - { - printk("SVM: failed to initialise.\n"); - return NULL; - } - - setup_vmcb_dump(); - - if ( boot_cpu_data.extended_cpuid_level >= 0x8000000a ) - svm_feature_flags = cpuid_edx(0x8000000a); - - printk("SVM: Supported advanced features:\n"); - - /* DecodeAssists fast paths assume nextrip is valid for fast rIP update. */ - if ( !cpu_has_svm_nrips ) - __clear_bit(SVM_FEATURE_DECODEASSISTS, &svm_feature_flags); - - if ( cpu_has_tsc_ratio ) - svm_function_table.tsc_scaling.ratio_frac_bits = 32; - -#define P(p,s) if ( p ) { printk(" - %s\n", s); printed = 1; } - P(cpu_has_svm_npt, "Nested Page Tables (NPT)"); - P(cpu_has_svm_lbrv, "Last Branch Record (LBR) Virtualisation"); - P(cpu_has_svm_nrips, "Next-RIP Saved on #VMEXIT"); - P(cpu_has_svm_cleanbits, "VMCB Clean Bits"); - P(cpu_has_svm_decode, "DecodeAssists"); - P(cpu_has_svm_vloadsave, "Virtual VMLOAD/VMSAVE"); - P(cpu_has_svm_vgif, "Virtual GIF"); - P(cpu_has_pause_filter, "Pause-Intercept Filter"); - P(cpu_has_pause_thresh, "Pause-Intercept Filter Threshold"); - P(cpu_has_tsc_ratio, "TSC Rate MSR"); - P(cpu_has_svm_sss, "NPT Supervisor Shadow Stack"); - P(cpu_has_svm_spec_ctrl, "MSR_SPEC_CTRL virtualisation"); -#undef P - - if ( !printed ) - printk(" - none\n"); - - svm_function_table.hap_supported = !!cpu_has_svm_npt; - svm_function_table.hap_capabilities = HVM_HAP_SUPERPAGE_2MB | - (cpu_has_page1gb ? HVM_HAP_SUPERPAGE_1GB : 0); - - return &svm_function_table; -} - static void svm_do_nested_pgfault(struct vcpu *v, struct cpu_user_regs *regs, uint64_t pfec, paddr_t gpa) { @@ -2598,6 +2534,57 @@ static struct hvm_function_table __initdata_cf_clobber svm_function_table = { }, }; +const struct hvm_function_table * __init start_svm(void) +{ + bool_t printed = 0; + + svm_host_osvw_reset(); + + if ( _svm_cpu_up(true) ) + { + printk("SVM: failed to initialise.\n"); + return NULL; + } + + setup_vmcb_dump(); + + if ( boot_cpu_data.extended_cpuid_level >= 0x8000000a ) + svm_feature_flags = cpuid_edx(0x8000000a); + + printk("SVM: Supported advanced features:\n"); + + /* DecodeAssists fast paths assume nextrip is valid for fast rIP update. */ + if ( !cpu_has_svm_nrips ) + __clear_bit(SVM_FEATURE_DECODEASSISTS, &svm_feature_flags); + + if ( cpu_has_tsc_ratio ) + svm_function_table.tsc_scaling.ratio_frac_bits = 32; + +#define P(p,s) if ( p ) { printk(" - %s\n", s); printed = 1; } + P(cpu_has_svm_npt, "Nested Page Tables (NPT)"); + P(cpu_has_svm_lbrv, "Last Branch Record (LBR) Virtualisation"); + P(cpu_has_svm_nrips, "Next-RIP Saved on #VMEXIT"); + P(cpu_has_svm_cleanbits, "VMCB Clean Bits"); + P(cpu_has_svm_decode, "DecodeAssists"); + P(cpu_has_svm_vloadsave, "Virtual VMLOAD/VMSAVE"); + P(cpu_has_svm_vgif, "Virtual GIF"); + P(cpu_has_pause_filter, "Pause-Intercept Filter"); + P(cpu_has_pause_thresh, "Pause-Intercept Filter Threshold"); + P(cpu_has_tsc_ratio, "TSC Rate MSR"); + P(cpu_has_svm_sss, "NPT Supervisor Shadow Stack"); + P(cpu_has_svm_spec_ctrl, "MSR_SPEC_CTRL virtualisation"); +#undef P + + if ( !printed ) + printk(" - none\n"); + + svm_function_table.hap_supported = !!cpu_has_svm_npt; + svm_function_table.hap_capabilities = HVM_HAP_SUPERPAGE_2MB | + (cpu_has_page1gb ? HVM_HAP_SUPERPAGE_1GB : 0); + + return &svm_function_table; +} + void svm_vmexit_handler(struct cpu_user_regs *regs) { uint64_t exit_reason;