[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/emul: Switch x86_emulate_ctxt to cpu_policy
commit 441b1b2a50ea3656954d75e06d42c96d619ea0fc Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> AuthorDate: Mon Apr 3 20:03:57 2023 +0100 Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> CommitDate: Wed Apr 5 11:47:08 2023 +0100 x86/emul: Switch x86_emulate_ctxt to cpu_policy As with struct domain, retain cpuid as a valid alias for local code clarity. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 2 +- tools/tests/x86_emulator/test_x86_emulator.c | 2 +- tools/tests/x86_emulator/x86-emulate.c | 2 +- xen/arch/x86/hvm/emulate.c | 4 ++-- xen/arch/x86/mm/shadow/hvm.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/private.h | 4 ++-- xen/arch/x86/x86_emulate/x86_emulate.h | 7 +++++-- 9 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c index 966e46bee1..4885a68210 100644 --- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c +++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c @@ -893,7 +893,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size) struct x86_emulate_ctxt ctxt = { .data = &state, .regs = &input.regs, - .cpuid = &cp, + .cpu_policy = &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 3e30ec51fe..55a1394e14 100644 --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -909,7 +909,7 @@ int main(int argc, char **argv) ctxt.regs = ®s; ctxt.force_writeback = 0; - ctxt.cpuid = &cp; + ctxt.cpu_policy = &cp; ctxt.lma = sizeof(void *) == 8; ctxt.addr_size = 8 * sizeof(void *); ctxt.sp_size = 8 * sizeof(void *); diff --git a/tools/tests/x86_emulator/x86-emulate.c b/tools/tests/x86_emulator/x86-emulate.c index f6ee094397..2692404df9 100644 --- a/tools/tests/x86_emulator/x86-emulate.c +++ b/tools/tests/x86_emulator/x86-emulate.c @@ -25,7 +25,7 @@ #endif uint32_t mxcsr_mask = 0x0000ffbf; -struct cpuid_policy cp; +struct cpu_policy cp; static char fpu_save_area[0x4000] __attribute__((__aligned__((64)))); static bool use_xsave; diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 95364deb19..5691725d6c 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -2771,7 +2771,7 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long gla) void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr, unsigned int errcode) { - struct hvm_emulate_ctxt ctx = {{ 0 }}; + struct hvm_emulate_ctxt ctx = {}; int rc; hvm_emulate_init_once(&ctx, NULL, guest_cpu_user_regs()); @@ -2846,7 +2846,7 @@ void hvm_emulate_init_once( hvmemul_ctxt->validate = validate; hvmemul_ctxt->ctxt.regs = regs; - hvmemul_ctxt->ctxt.cpuid = curr->domain->arch.cpuid; + hvmemul_ctxt->ctxt.cpu_policy = curr->domain->arch.cpu_policy; hvmemul_ctxt->ctxt.force_writeback = true; } diff --git a/xen/arch/x86/mm/shadow/hvm.c b/xen/arch/x86/mm/shadow/hvm.c index e2ee1c7705..cc84af0192 100644 --- a/xen/arch/x86/mm/shadow/hvm.c +++ b/xen/arch/x86/mm/shadow/hvm.c @@ -319,7 +319,7 @@ const struct x86_emulate_ops *shadow_init_emulation( memset(sh_ctxt, 0, sizeof(*sh_ctxt)); sh_ctxt->ctxt.regs = regs; - sh_ctxt->ctxt.cpuid = curr->domain->arch.cpuid; + sh_ctxt->ctxt.cpu_policy = curr->domain->arch.cpu_policy; sh_ctxt->ctxt.lma = hvm_long_mode_active(curr); /* 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 5da00e24e4..ab52768271 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -1327,7 +1327,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.cpuid = currd->arch.cpuid, + .ctxt.cpu_policy = currd->arch.cpu_policy, .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 5963f5ee2d..0d02c7d2ab 100644 --- a/xen/arch/x86/pv/ro-page-fault.c +++ b/xen/arch/x86/pv/ro-page-fault.c @@ -356,7 +356,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, - .cpuid = currd->arch.cpuid, + .cpu_policy = currd->arch.cpu_policy, .addr_size = addr_size, .sp_size = addr_size, .lma = addr_size > 32, diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h index 653a298c70..8dee019731 100644 --- a/xen/arch/x86/x86_emulate/private.h +++ b/xen/arch/x86/x86_emulate/private.h @@ -505,7 +505,7 @@ in_protmode( }) static inline bool -_amd_like(const struct cpuid_policy *cp) +_amd_like(const struct cpu_policy *cp) { return cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON); } @@ -513,7 +513,7 @@ _amd_like(const struct cpuid_policy *cp) static inline bool amd_like(const struct x86_emulate_ctxt *ctxt) { - return _amd_like(ctxt->cpuid); + return _amd_like(ctxt->cpu_policy); } #define vcpu_has_fpu() (ctxt->cpuid->basic.fpu) diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h b/xen/arch/x86/x86_emulate/x86_emulate.h index 75015104fb..0139d16da7 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.h +++ b/xen/arch/x86/x86_emulate/x86_emulate.h @@ -565,8 +565,11 @@ struct x86_emulate_ctxt * Input-only state: */ - /* CPUID Policy for the domain. */ - const struct cpuid_policy *cpuid; + /* CPU policy for the domain. Allow aliases for local code clarity. */ + union { + struct cpu_policy *cpu_policy; + struct cpu_policy *cpuid; + }; /* Set this if writes may have side effects. */ bool force_writeback; -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |