mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
x86/emul: Pass a full cpuid_policy into x86_emulate()
This will be used to simplify feature checking. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
76d8dd2705
commit
4e069d6093
8 files changed
+12
-10
No files matched your search
@@ -830,6 +830,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)
|
||||
struct x86_emulate_ctxt ctxt = {
|
||||
.data = &state,
|
||||
.regs = &input.regs,
|
||||
.cpuid = &cp,
|
||||
.addr_size = 8 * sizeof(void *),
|
||||
.sp_size = 8 * sizeof(void *),
|
||||
};
|
||||
|
||||
@@ -472,7 +472,7 @@ int main(int argc, char **argv)
|
||||
|
||||
ctxt.regs = ®s;
|
||||
ctxt.force_writeback = 0;
|
||||
ctxt.vendor = X86_VENDOR_UNKNOWN;
|
||||
ctxt.cpuid = &cp;
|
||||
ctxt.lma = sizeof(void *) == 8;
|
||||
ctxt.addr_size = 8 * sizeof(void *);
|
||||
ctxt.sp_size = 8 * sizeof(void *);
|
||||
|
||||
@@ -2594,7 +2594,7 @@ void hvm_emulate_init_once(
|
||||
|
||||
hvmemul_ctxt->validate = validate;
|
||||
hvmemul_ctxt->ctxt.regs = regs;
|
||||
hvmemul_ctxt->ctxt.vendor = curr->domain->arch.cpuid->x86_vendor;
|
||||
hvmemul_ctxt->ctxt.cpuid = curr->domain->arch.cpuid;
|
||||
hvmemul_ctxt->ctxt.force_writeback = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ const struct x86_emulate_ops *shadow_init_emulation(
|
||||
memset(sh_ctxt, 0, sizeof(*sh_ctxt));
|
||||
|
||||
sh_ctxt->ctxt.regs = regs;
|
||||
sh_ctxt->ctxt.vendor = v->domain->arch.cpuid->x86_vendor;
|
||||
sh_ctxt->ctxt.cpuid = v->domain->arch.cpuid;
|
||||
sh_ctxt->ctxt.lma = hvm_long_mode_active(v);
|
||||
|
||||
/* Segment cache initialisation. Primed with CS. */
|
||||
|
||||
@@ -1243,7 +1243,7 @@ int pv_emulate_privileged_op(struct cpu_user_regs *regs)
|
||||
struct domain *currd = curr->domain;
|
||||
struct priv_op_ctxt ctxt = {
|
||||
.ctxt.regs = regs,
|
||||
.ctxt.vendor = currd->arch.cpuid->x86_vendor,
|
||||
.ctxt.cpuid = currd->arch.cpuid,
|
||||
.ctxt.lma = !is_pv_32bit_domain(currd),
|
||||
};
|
||||
int rc;
|
||||
|
||||
@@ -351,7 +351,7 @@ int pv_ro_page_fault(unsigned long addr, struct cpu_user_regs *regs)
|
||||
unsigned int addr_size = is_pv_32bit_domain(currd) ? 32 : BITS_PER_LONG;
|
||||
struct x86_emulate_ctxt ctxt = {
|
||||
.regs = regs,
|
||||
.vendor = currd->arch.cpuid->x86_vendor,
|
||||
.cpuid = currd->arch.cpuid,
|
||||
.addr_size = addr_size,
|
||||
.sp_size = addr_size,
|
||||
.lma = addr_size > 32,
|
||||
|
||||
@@ -1930,6 +1930,7 @@ protmode_load_seg(
|
||||
struct x86_emulate_ctxt *ctxt,
|
||||
const struct x86_emulate_ops *ops)
|
||||
{
|
||||
const struct cpuid_policy *cp = ctxt->cpuid;
|
||||
enum x86_segment sel_seg = (sel & 4) ? x86_seg_ldtr : x86_seg_gdtr;
|
||||
struct { uint32_t a, b; } desc, desc_hi = {};
|
||||
uint8_t dpl, rpl;
|
||||
@@ -1954,7 +1955,7 @@ protmode_load_seg(
|
||||
case x86_seg_tr:
|
||||
goto raise_exn;
|
||||
}
|
||||
if ( ctxt->vendor != X86_VENDOR_AMD || !ops->read_segment ||
|
||||
if ( cp->x86_vendor != X86_VENDOR_AMD || !ops->read_segment ||
|
||||
ops->read_segment(seg, sreg, ctxt) != X86EMUL_OKAY )
|
||||
memset(sreg, 0, sizeof(*sreg));
|
||||
else
|
||||
@@ -2081,7 +2082,7 @@ protmode_load_seg(
|
||||
*/
|
||||
bool wide = desc.b & 0x1000
|
||||
? false : (desc.b & 0xf00) != 0xc00 &&
|
||||
ctxt->vendor != X86_VENDOR_AMD
|
||||
cp->x86_vendor != X86_VENDOR_AMD
|
||||
? mode_64bit() : ctxt->lma;
|
||||
|
||||
if ( wide )
|
||||
@@ -2099,7 +2100,7 @@ protmode_load_seg(
|
||||
default:
|
||||
return rc;
|
||||
}
|
||||
if ( !mode_64bit() && ctxt->vendor == X86_VENDOR_AMD &&
|
||||
if ( !mode_64bit() && cp->x86_vendor == X86_VENDOR_AMD &&
|
||||
(desc.b & 0xf00) != 0xc00 )
|
||||
desc_hi.b = desc_hi.a = 0;
|
||||
if ( (desc_hi.b & 0x00001f00) ||
|
||||
|
||||
@@ -502,8 +502,8 @@ struct x86_emulate_ctxt
|
||||
* Input-only state:
|
||||
*/
|
||||
|
||||
/* CPU vendor (X86_VENDOR_UNKNOWN for "don't care") */
|
||||
unsigned char vendor;
|
||||
/* CPUID Policy for the domain. */
|
||||
const struct cpuid_policy *cpuid;
|
||||
|
||||
/* Set this if writes may have side effects. */
|
||||
bool force_writeback;
|
||||
|
||||