]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
x86: Add sub-leaf selection parameter to cpuid_*
authorJan Kiszka <jan.kiszka@siemens.com>
Tue, 11 Aug 2015 04:32:15 +0000 (06:32 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Sun, 10 Jan 2016 08:44:42 +0000 (09:44 +0100)
This allows to call cpuid also on specific sub-leaves. Will be used
first for CAT.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/x86/include/asm/processor.h
hypervisor/arch/x86/paging.c
hypervisor/arch/x86/setup.c
hypervisor/arch/x86/svm.c
hypervisor/arch/x86/vcpu.c
hypervisor/arch/x86/vmx.c

index 5ece2a6ba1c0dba72eb0158e9b7077400eca7d99..716b76002b5607a4fc27ecff3d5c9e9a06f84988 100644 (file)
@@ -207,15 +207,15 @@ static inline void cpuid(unsigned int *eax, unsigned int *ebx,
            : "memory");
 }
 
-#define CPUID_REG(reg)                                         \
-static inline unsigned int cpuid_##reg(unsigned int op)                \
-{                                                              \
-       unsigned int eax, ebx, ecx, edx;                        \
-                                                               \
-       eax = op;                                               \
-       ecx = 0;                                                \
-       cpuid(&eax, &ebx, &ecx, &edx);                          \
-       return reg;                                             \
+#define CPUID_REG(reg)                                                 \
+static inline unsigned int cpuid_##reg(unsigned int op, unsigned int sub) \
+{                                                                      \
+       unsigned int eax, ebx, ecx, edx;                                \
+                                                                       \
+       eax = op;                                                       \
+       ecx = sub;                                                      \
+       cpuid(&eax, &ebx, &ecx, &edx);                                  \
+       return reg;                                                     \
 }
 
 CPUID_REG(eax)
index 46638a975e89744bf583803f1fac125d3f94a033..e92b880aa2d6e6aef3bc67c8a93ca157103855d4 100644 (file)
@@ -166,7 +166,7 @@ const struct paging x86_64_paging[] = {
 void arch_paging_init(void)
 {
        memcpy(hv_paging, x86_64_paging, sizeof(x86_64_paging));
-       if (!(cpuid_edx(0x80000001) & X86_FEATURE_GBPAGES))
+       if (!(cpuid_edx(0x80000001, 0) & X86_FEATURE_GBPAGES))
                hv_paging[1].page_size = 0;
 }
 
index efb5379874f80505b1814efa6a8464e73de5c7da..6edef303a196d75953e22ea23145abc4330834f1 100644 (file)
@@ -55,7 +55,7 @@ int arch_init_early(void)
        unsigned int vector;
        int err;
 
-       cache_line_size = (cpuid_ebx(1) & 0xff00) >> 5;
+       cache_line_size = (cpuid_ebx(1, 0) & 0xff00) >> 5;
 
        err = apic_init();
        if (err)
index 29292615c0c1da6eccf2ce7f5983df32b1a946a1..72df24b22c4ddee7e23e728aeb967129c70acd05 100644 (file)
@@ -107,24 +107,24 @@ static void *avic_page;
 static int svm_check_features(void)
 {
        /* SVM is available */
-       if (!(cpuid_ecx(0x80000001) & X86_FEATURE_SVM))
+       if (!(cpuid_ecx(0x80000001, 0) & X86_FEATURE_SVM))
                return trace_error(-ENODEV);
 
        /* Nested paging */
-       if (!(cpuid_edx(0x8000000A) & X86_FEATURE_NP))
+       if (!(cpuid_edx(0x8000000A, 0) & X86_FEATURE_NP))
                return trace_error(-EIO);
 
        /* Decode assists */
-       if ((cpuid_edx(0x8000000A) & X86_FEATURE_DECODE_ASSISTS))
+       if ((cpuid_edx(0x8000000A, 0) & X86_FEATURE_DECODE_ASSISTS))
                has_assists = true;
 
        /* AVIC support */
        /* FIXME: Jailhouse support is incomplete so far
-       if (cpuid_edx(0x8000000A) & X86_FEATURE_AVIC)
+       if (cpuid_edx(0x8000000A, 0) & X86_FEATURE_AVIC)
                has_avic = true; */
 
        /* TLB Flush by ASID support */
-       if (cpuid_edx(0x8000000A) & X86_FEATURE_FLUSH_BY_ASID)
+       if (cpuid_edx(0x8000000A, 0) & X86_FEATURE_FLUSH_BY_ASID)
                has_flush_by_asid = true;
 
        return 0;
index a0cbfdb25d0b8533ba43fa7274baec9bd7836c2c..4ef0b965db6c23e29654ff0c86cf5ee0464dfee9 100644 (file)
@@ -347,9 +347,9 @@ bool vcpu_handle_xsetbv(void)
 
        this_cpu_data()->stats[JAILHOUSE_CPU_STAT_VMEXITS_XSETBV]++;
 
-       if (cpuid_ecx(1) & X86_FEATURE_XSAVE &&
+       if (cpuid_ecx(1, 0) & X86_FEATURE_XSAVE &&
            guest_regs->rax & X86_XCR0_FP &&
-           (guest_regs->rax & ~cpuid_eax(0x0d)) == 0 &&
+           (guest_regs->rax & ~cpuid_eax(0x0d, 0)) == 0 &&
             guest_regs->rcx == 0 && guest_regs->rdx == 0) {
                vcpu_skip_emulated_instruction(X86_INST_LEN_XSETBV);
                asm volatile(
index db3b914f143819fc70c7e7d473fb92607217fb85..fdde2611d6b6833fbd7a16be77217b0271edff68 100644 (file)
@@ -190,7 +190,7 @@ static int vmx_check_features(void)
        unsigned long vmx_pin_ctrl, vmx_basic, maybe1, required1;
        unsigned long vmx_entry_ctrl, vmx_exit_ctrl;
 
-       if (!(cpuid_ecx(1) & X86_FEATURE_VMX))
+       if (!(cpuid_ecx(1, 0) & X86_FEATURE_VMX))
                return trace_error(-ENODEV);
 
        vmx_basic = read_msr(MSR_IA32_VMX_BASIC);
@@ -233,7 +233,7 @@ static int vmx_check_features(void)
                return trace_error(-EIO);
 
        /* require RDTSCP if present in CPUID */
-       if (cpuid_edx(0x80000001) & X86_FEATURE_RDTSCP) {
+       if (cpuid_edx(0x80000001, 0) & X86_FEATURE_RDTSCP) {
                enable_rdtscp = SECONDARY_EXEC_RDTSCP;
                if (!(vmx_proc_ctrl2 & SECONDARY_EXEC_RDTSCP))
                        return trace_error(-EIO);
@@ -605,7 +605,7 @@ int vcpu_init(struct per_cpu *cpu_data)
        int err;
 
        /* make sure all perf counters are off */
-       if ((cpuid_eax(0x0a) & 0xff) > 0)
+       if ((cpuid_eax(0x0a, 0) & 0xff) > 0)
                write_msr(MSR_IA32_PERF_GLOBAL_CTRL, 0);
 
        if (cpu_data->linux_cr4 & X86_CR4_VMXE)
@@ -652,7 +652,8 @@ int vcpu_init(struct per_cpu *cpu_data)
         */
        write_cr0(X86_CR0_HOST_STATE);
        write_cr4(X86_CR4_HOST_STATE | X86_CR4_VMXE |
-                 ((cpuid_ecx(1) & X86_FEATURE_XSAVE) ? X86_CR4_OSXSAVE : 0));
+                 ((cpuid_ecx(1, 0) & X86_FEATURE_XSAVE) ?
+                  X86_CR4_OSXSAVE : 0));
 
        if (!vmxon(cpu_data))  {
                write_cr4(cpu_data->linux_cr4);