From: Avi Kivity <[email protected]> The vendor exit reason strings macro is the only thing that differs beween vmx ftrace and svm ftrace, and since it is a macro, multiple definitions cannot coexist, breaking KVM_INTEL=Y KVM_AMD=Y builds.
Replace the macro by a pointer in kvm_x86_ops. Signed-off-by: Avi Kivity <[email protected]> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 930bac2..30b625d 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -14,6 +14,7 @@ #include <linux/types.h> #include <linux/mm.h> #include <linux/mmu_notifier.h> +#include <linux/tracepoint.h> #include <linux/kvm.h> #include <linux/kvm_para.h> @@ -527,6 +528,7 @@ struct kvm_x86_ops { int (*set_tss_addr)(struct kvm *kvm, unsigned int addr); int (*get_tdp_level)(void); u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); + const struct trace_print_flags *exit_reasons_str; }; extern struct kvm_x86_ops *kvm_x86_ops; diff --git a/arch/x86/kvm/svm-trace.h b/arch/x86/kvm/svm-trace.h deleted file mode 100644 index 9685856..0000000 --- a/arch/x86/kvm/svm-trace.h +++ /dev/null @@ -1,51 +0,0 @@ -#define exit_reasons svm_exit_reasons -#define svm_exit_reasons \ - {SVM_EXIT_READ_CR0, "read_cr0"}, \ - {SVM_EXIT_READ_CR3, "read_cr3"}, \ - {SVM_EXIT_READ_CR4, "read_cr4"}, \ - {SVM_EXIT_READ_CR8, "read_cr8"}, \ - {SVM_EXIT_WRITE_CR0, "write_cr0"}, \ - {SVM_EXIT_WRITE_CR3, "write_cr3"}, \ - {SVM_EXIT_WRITE_CR4, "write_cr4"}, \ - {SVM_EXIT_WRITE_CR8, "write_cr8"}, \ - {SVM_EXIT_READ_DR0, "read_dr0"}, \ - {SVM_EXIT_READ_DR1, "read_dr1"}, \ - {SVM_EXIT_READ_DR2, "read_dr2"}, \ - {SVM_EXIT_READ_DR3, "read_dr3"}, \ - {SVM_EXIT_WRITE_DR0, "write_dr0"}, \ - {SVM_EXIT_WRITE_DR1, "write_dr1"}, \ - {SVM_EXIT_WRITE_DR2, "write_dr2"}, \ - {SVM_EXIT_WRITE_DR3, "write_dr3"}, \ - {SVM_EXIT_WRITE_DR5, "write_dr5"}, \ - {SVM_EXIT_WRITE_DR7, "write_dr7"}, \ - {SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp"}, \ - {SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp"}, \ - {SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp"}, \ - {SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp"}, \ - {SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp"}, \ - {SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp"}, \ - {SVM_EXIT_INTR, "interrupt"}, \ - {SVM_EXIT_NMI, "nmi"}, \ - {SVM_EXIT_SMI, "smi"}, \ - {SVM_EXIT_INIT, "init"}, \ - {SVM_EXIT_VINTR, "vintr"}, \ - {SVM_EXIT_CPUID, "cpuid"}, \ - {SVM_EXIT_INVD, "invd"}, \ - {SVM_EXIT_HLT, "hlt"}, \ - {SVM_EXIT_INVLPG, "invlpg"}, \ - {SVM_EXIT_INVLPGA, "invlpga"}, \ - {SVM_EXIT_IOIO, "io"}, \ - {SVM_EXIT_MSR, "msr"}, \ - {SVM_EXIT_TASK_SWITCH, "task_switch"}, \ - {SVM_EXIT_SHUTDOWN, "shutdown"}, \ - {SVM_EXIT_VMRUN, "vmrun"}, \ - {SVM_EXIT_VMMCALL, "hypercall"}, \ - {SVM_EXIT_VMLOAD, "vmload"}, \ - {SVM_EXIT_VMSAVE, "vmsave"}, \ - {SVM_EXIT_STGI, "stgi"}, \ - {SVM_EXIT_CLGI, "clgi"}, \ - {SVM_EXIT_SKINIT, "skinit"}, \ - {SVM_EXIT_WBINVD, "wbinvd"}, \ - {SVM_EXIT_MONITOR, "monitor"}, \ - {SVM_EXIT_MWAIT, "mwait"}, \ - {SVM_EXIT_NPF, "npf"} diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 610bcae..ef1577d 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -29,7 +29,6 @@ #include <asm/desc.h> #include <asm/virtext.h> -#include "svm-trace.h" #define CREATE_TRACE_POINTS #include "trace-arch.h" @@ -2703,6 +2702,59 @@ static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) return 0; } +static const struct trace_print_flags svm_exit_reasons_str[] = { + { SVM_EXIT_READ_CR0, "read_cr0" }, + { SVM_EXIT_READ_CR3, "read_cr3" }, + { SVM_EXIT_READ_CR4, "read_cr4" }, + { SVM_EXIT_READ_CR8, "read_cr8" }, + { SVM_EXIT_WRITE_CR0, "write_cr0" }, + { SVM_EXIT_WRITE_CR3, "write_cr3" }, + { SVM_EXIT_WRITE_CR4, "write_cr4" }, + { SVM_EXIT_WRITE_CR8, "write_cr8" }, + { SVM_EXIT_READ_DR0, "read_dr0" }, + { SVM_EXIT_READ_DR1, "read_dr1" }, + { SVM_EXIT_READ_DR2, "read_dr2" }, + { SVM_EXIT_READ_DR3, "read_dr3" }, + { SVM_EXIT_WRITE_DR0, "write_dr0" }, + { SVM_EXIT_WRITE_DR1, "write_dr1" }, + { SVM_EXIT_WRITE_DR2, "write_dr2" }, + { SVM_EXIT_WRITE_DR3, "write_dr3" }, + { SVM_EXIT_WRITE_DR5, "write_dr5" }, + { SVM_EXIT_WRITE_DR7, "write_dr7" }, + { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, + { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, + { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, + { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, + { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, + { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, + { SVM_EXIT_INTR, "interrupt" }, + { SVM_EXIT_NMI, "nmi" }, + { SVM_EXIT_SMI, "smi" }, + { SVM_EXIT_INIT, "init" }, + { SVM_EXIT_VINTR, "vintr" }, + { SVM_EXIT_CPUID, "cpuid" }, + { SVM_EXIT_INVD, "invd" }, + { SVM_EXIT_HLT, "hlt" }, + { SVM_EXIT_INVLPG, "invlpg" }, + { SVM_EXIT_INVLPGA, "invlpga" }, + { SVM_EXIT_IOIO, "io" }, + { SVM_EXIT_MSR, "msr" }, + { SVM_EXIT_TASK_SWITCH, "task_switch" }, + { SVM_EXIT_SHUTDOWN, "shutdown" }, + { SVM_EXIT_VMRUN, "vmrun" }, + { SVM_EXIT_VMMCALL, "hypercall" }, + { SVM_EXIT_VMLOAD, "vmload" }, + { SVM_EXIT_VMSAVE, "vmsave" }, + { SVM_EXIT_STGI, "stgi" }, + { SVM_EXIT_CLGI, "clgi" }, + { SVM_EXIT_SKINIT, "skinit" }, + { SVM_EXIT_WBINVD, "wbinvd" }, + { SVM_EXIT_MONITOR, "monitor" }, + { SVM_EXIT_MWAIT, "mwait" }, + { SVM_EXIT_NPF, "npf" }, + { -1, NULL } +}; + static struct kvm_x86_ops svm_x86_ops = { .cpu_has_kvm_support = has_svm, .disabled_by_bios = is_disabled, @@ -2764,6 +2816,8 @@ static struct kvm_x86_ops svm_x86_ops = { .set_tss_addr = svm_set_tss_addr, .get_tdp_level = get_npt_level, .get_mt_mask = svm_get_mt_mask, + + .exit_reasons_str = svm_exit_reasons_str, }; static int __init svm_init(void) diff --git a/arch/x86/kvm/trace-arch.h b/arch/x86/kvm/trace-arch.h index cf6165f..4e3197a 100644 --- a/arch/x86/kvm/trace-arch.h +++ b/arch/x86/kvm/trace-arch.h @@ -26,7 +26,8 @@ TRACE_EVENT(kvm_exit, ), TP_printk("reason %s rip 0x%lx", - __print_symbolic(__entry->exit_reason, exit_reasons), + ftrace_print_symbols_seq(p, __entry->exit_reason, + kvm_x86_ops->exit_reasons_str), __entry->guest_rip) ); diff --git a/arch/x86/kvm/vmx-trace.h b/arch/x86/kvm/vmx-trace.h deleted file mode 100644 index 49c6bc3..0000000 --- a/arch/x86/kvm/vmx-trace.h +++ /dev/null @@ -1,22 +0,0 @@ -#define exit_reasons vmx_exit_reasons -#define vmx_exit_reasons \ - {EXIT_REASON_EXCEPTION_NMI, "exception"}, \ - {EXIT_REASON_EXTERNAL_INTERRUPT, "ext_irq"}, \ - {EXIT_REASON_TRIPLE_FAULT, "triple_fault"}, \ - {EXIT_REASON_NMI_WINDOW, "nmi_window"}, \ - {EXIT_REASON_IO_INSTRUCTION, "io_instruction"}, \ - {EXIT_REASON_CR_ACCESS, "cr_access"}, \ - {EXIT_REASON_DR_ACCESS, "dr_access"}, \ - {EXIT_REASON_CPUID, "cpuid"}, \ - {EXIT_REASON_MSR_READ, "rdmsr"}, \ - {EXIT_REASON_MSR_WRITE, "wrmsr"}, \ - {EXIT_REASON_PENDING_INTERRUPT, "interrupt_window"}, \ - {EXIT_REASON_HLT, "halt"}, \ - {EXIT_REASON_INVLPG, "invlpg"}, \ - {EXIT_REASON_VMCALL, "hypercall"}, \ - {EXIT_REASON_TPR_BELOW_THRESHOLD, "tpr_below_thres"}, \ - {EXIT_REASON_APIC_ACCESS, "apic_access"}, \ - {EXIT_REASON_WBINVD, "wbinvd"}, \ - {EXIT_REASON_TASK_SWITCH, "task_switch"}, \ - {EXIT_REASON_EPT_VIOLATION, "ept_violation"} - diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 32ed8b6..e56b817 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -34,7 +34,6 @@ #include <asm/virtext.h> #include <asm/mce.h> -#include "vmx-trace.h" #define CREATE_TRACE_POINTS #include "trace-arch.h" @@ -3881,6 +3880,29 @@ static u64 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) return ret; } +static const struct trace_print_flags vmx_exit_reasons_str[] = { + { EXIT_REASON_EXCEPTION_NMI, "exception" }, + { EXIT_REASON_EXTERNAL_INTERRUPT, "ext_irq" }, + { EXIT_REASON_TRIPLE_FAULT, "triple_fault" }, + { EXIT_REASON_NMI_WINDOW, "nmi_window" }, + { EXIT_REASON_IO_INSTRUCTION, "io_instruction" }, + { EXIT_REASON_CR_ACCESS, "cr_access" }, + { EXIT_REASON_DR_ACCESS, "dr_access" }, + { EXIT_REASON_CPUID, "cpuid" }, + { EXIT_REASON_MSR_READ, "rdmsr" }, + { EXIT_REASON_MSR_WRITE, "wrmsr" }, + { EXIT_REASON_PENDING_INTERRUPT, "interrupt_window" }, + { EXIT_REASON_HLT, "halt" }, + { EXIT_REASON_INVLPG, "invlpg" }, + { EXIT_REASON_VMCALL, "hypercall" }, + { EXIT_REASON_TPR_BELOW_THRESHOLD, "tpr_below_thres" }, + { EXIT_REASON_APIC_ACCESS, "apic_access" }, + { EXIT_REASON_WBINVD, "wbinvd" }, + { EXIT_REASON_TASK_SWITCH, "task_switch" }, + { EXIT_REASON_EPT_VIOLATION, "ept_violation" }, + { -1, NULL } +}; + static struct kvm_x86_ops vmx_x86_ops = { .cpu_has_kvm_support = cpu_has_kvm_support, .disabled_by_bios = vmx_disabled_by_bios, @@ -3940,6 +3962,8 @@ static struct kvm_x86_ops vmx_x86_ops = { .set_tss_addr = vmx_set_tss_addr, .get_tdp_level = get_ept_level, .get_mt_mask = vmx_get_mt_mask, + + .exit_reasons_str = vmx_exit_reasons_str, }; static int __init vmx_init(void) -- To unsubscribe from this list: send the line "unsubscribe kvm-commits" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
