mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86emul: support RDPID
Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
a8fe4ec532
commit
58f1bba440
4 files changed
+40
-2
No files matched your search
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -5800,8 +5801,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;
|
||||
|
||||
@@ -227,6 +227,7 @@ XEN_CPUFEATURE(AVX512VBMI, 6*32+ 1) /*A AVX-512 Vector Byte Manipulation Ins
|
||||
XEN_CPUFEATURE(PKU, 6*32+ 3) /*H Protection Keys for Userspace */
|
||||
XEN_CPUFEATURE(OSPKE, 6*32+ 4) /*! OS Protection Keys Enable */
|
||||
XEN_CPUFEATURE(AVX512_VPOPCNTDQ, 6*32+14) /*A POPCNT for vectors of DW/QW */
|
||||
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 */
|
||||
|
||||