[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 7/8] x86emul: support RDPID
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -158,6 +158,11 @@ static int read_msr( case 0xc0000080: /* EFER */ *val = ctxt->addr_size > 32 ? 0x500 /* LME|LMA */ : 0; return X86EMUL_OKAY; + + case 0xc0000103: /* TSC_AUX */ +#define TSC_AUX_VALUE 0xCACACACA + *val = TSC_AUX_VALUE; + return X86EMUL_OKAY; } return X86EMUL_UNHANDLEABLE; @@ -1472,6 +1477,16 @@ int main(int argc, char **argv) else printf("skipped\n"); + printf("%-40s", "Testing rdpid %ecx..."); + instr[0] = 0xF3; instr[1] = 0x0f; instr[2] = 0xC7; instr[3] = 0xf9; + regs.eip = (unsigned long)&instr[0]; + rc = x86_emulate(&ctxt, &emulops); + if ( (rc != X86EMUL_OKAY) || + (regs.ecx != TSC_AUX_VALUE) || + (regs.eip != (unsigned long)&instr[4]) ) + goto fail; + printf("okay\n"); + printf("%-40s", "Testing movq %mm3,(%ecx)..."); if ( stack_exec && cpu_has_mmx ) { --- a/tools/tests/x86_emulator/x86_emulate.c +++ b/tools/tests/x86_emulator/x86_emulate.c @@ -60,9 +60,15 @@ int emul_test_cpuid( if ( leaf == 1 ) res->c |= 1U << 22; - /* The emulator doesn't itself use ADCX/ADOX, so we can always run the test. */ + /* + * The emulator doesn't itself use ADCX/ADOX/RDPID, so we can always run + * the respective tests. + */ if ( leaf == 7 && subleaf == 0 ) + { res->b |= 1U << 19; + res->c |= 1U << 22; + } return X86EMUL_OKAY; } --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1367,6 +1367,7 @@ static bool vcpu_has( #define vcpu_has_smap() vcpu_has( 7, EBX, 20, ctxt, ops) #define vcpu_has_clflushopt() vcpu_has( 7, EBX, 23, ctxt, ops) #define vcpu_has_clwb() vcpu_has( 7, EBX, 24, ctxt, ops) +#define vcpu_has_rdpid() vcpu_has( 7, ECX, 22, ctxt, ops) #define vcpu_must_have(feat) \ generate_exception_if(!vcpu_has_##feat(), EXC_UD) @@ -5782,8 +5783,23 @@ x86_emulate( break; #endif + case 7: /* rdseed / rdpid */ + if ( repe_prefix() ) /* rdpid */ + { + uint64_t tsc_aux; + + generate_exception_if(ea.type != OP_REG, EXC_UD); + vcpu_must_have(rdpid); + fail_if(!ops->read_msr); + if ( (rc = ops->read_msr(MSR_TSC_AUX, &tsc_aux, + ctxt)) != X86EMUL_OKAY ) + goto done; + dst = ea; + dst.val = tsc_aux; + dst.bytes = 4; + break; + } #ifdef HAVE_GAS_RDSEED - case 7: /* rdseed */ generate_exception_if(rep_prefix(), EXC_UD); host_and_vcpu_must_have(rdseed); dst = ea; --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -226,6 +226,7 @@ XEN_CPUFEATURE(PREFETCHWT1, 6*32+ 0) / XEN_CPUFEATURE(AVX512VBMI, 6*32+ 1) /*A AVX-512 Vector Byte Manipulation Instrs */ XEN_CPUFEATURE(PKU, 6*32+ 3) /*H Protection Keys for Userspace */ XEN_CPUFEATURE(OSPKE, 6*32+ 4) /*! OS Protection Keys Enable */ +XEN_CPUFEATURE(RDPID, 6*32+22) /*A RDPID instruction */ /* AMD-defined CPU features, CPUID level 0x80000007.edx, word 7 */ XEN_CPUFEATURE(ITSC, 7*32+ 8) /* Invariant TSC */ Attachment:
x86emul-RDPID.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |