[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/6] 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@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 1 + tools/tests/x86_emulator/test_x86_emulator.c | 2 +- xen/arch/x86/hvm/emulate.c | 2 +- xen/arch/x86/mm/shadow/common.c | 2 +- xen/arch/x86/pv/emul-priv-op.c | 2 +- xen/arch/x86/pv/ro-page-fault.c | 2 +- xen/arch/x86/x86_emulate/x86_emulate.c | 7 ++++--- xen/arch/x86/x86_emulate/x86_emulate.h | 4 ++-- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c index 0ffd0fb..8d0ea02 100644 --- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c +++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c @@ -827,6 +827,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 *), }; diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c index ed5a3d8..286abb7 100644 --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -434,7 +434,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 *); diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 9e7deaa..91fa9db 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -2543,7 +2543,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; } diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index d54a848..4526055 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -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. */ diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index f73ea4a..5968f99 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -1299,7 +1299,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; diff --git a/xen/arch/x86/pv/ro-page-fault.c b/xen/arch/x86/pv/ro-page-fault.c index e7a7179..9d4913d 100644 --- a/xen/arch/x86/pv/ro-page-fault.c +++ b/xen/arch/x86/pv/ro-page-fault.c @@ -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, diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index e69dfdd..8bff02a 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -1838,6 +1838,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; @@ -1862,7 +1863,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 @@ -1989,7 +1990,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 ) @@ -2007,7 +2008,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) || diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h b/xen/arch/x86/x86_emulate/x86_emulate.h index 3750f0c..0397c1d 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.h +++ b/xen/arch/x86/x86_emulate/x86_emulate.h @@ -501,8 +501,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; -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |