x86/HVM: type adjustments - constify struct hvm_trap * function parameters - width reduce and shuffle some struct hvm_trap members - use bool_t for boolean fields struct hvm_function_table - use unsigned for struct hvm_function_table's hap_capabilities field Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2826,7 +2826,7 @@ void hvm_triple_fault(void) domain_shutdown(d, reason); } -void hvm_inject_trap(struct hvm_trap *trap) +void hvm_inject_trap(const struct hvm_trap *trap) { struct vcpu *curr = current; --- a/xen/arch/x86/hvm/svm/nestedsvm.c +++ b/xen/arch/x86/hvm/svm/nestedsvm.c @@ -821,7 +821,7 @@ nsvm_vcpu_vmexit_inject(struct vcpu *v, } int -nsvm_vcpu_vmexit_trap(struct vcpu *v, struct hvm_trap *trap) +nsvm_vcpu_vmexit_trap(struct vcpu *v, const struct hvm_trap *trap) { ASSERT(vcpu_nestedhvm(v).nv_vvmcx != NULL); --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1181,7 +1181,7 @@ static void svm_vcpu_destroy(struct vcpu passive_domain_destroy(v); } -static void svm_inject_trap(struct hvm_trap *trap) +static void svm_inject_trap(const struct hvm_trap *trap) { struct vcpu *curr = current; struct vmcb_struct *vmcb = curr->arch.hvm_svm.vmcb; @@ -1442,7 +1442,7 @@ const struct hvm_function_table * __init if ( !printed ) printk(" - none\n"); - svm_function_table.hap_supported = cpu_has_svm_npt; + svm_function_table.hap_supported = !!cpu_has_svm_npt; svm_function_table.hap_capabilities = HVM_HAP_SUPERPAGE_2MB | ((cpuid_edx(0x80000001) & 0x04000000) ? HVM_HAP_SUPERPAGE_1GB : 0); --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1416,7 +1416,7 @@ void nvmx_enqueue_n2_exceptions(struct v nvmx->intr.intr_info, nvmx->intr.error_code); } -static int nvmx_vmexit_trap(struct vcpu *v, struct hvm_trap *trap) +static int nvmx_vmexit_trap(struct vcpu *v, const struct hvm_trap *trap) { nvmx_enqueue_n2_exceptions(v, trap->vector, trap->error_code, hvm_intsrc_none); @@ -1502,7 +1502,7 @@ void vmx_inject_nmi(void) * - #DB is X86_EVENTTYPE_HW_EXCEPTION, except when generated by * opcode 0xf1 (which is X86_EVENTTYPE_PRI_SW_EXCEPTION) */ -static void vmx_inject_trap(struct hvm_trap *trap) +static void vmx_inject_trap(const struct hvm_trap *trap) { unsigned long intr_info; struct vcpu *curr = current; --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -72,10 +72,10 @@ enum hvm_intblk { #define HVM_HAP_SUPERPAGE_1GB 0x00000002 struct hvm_trap { - int vector; - unsigned int type; /* X86_EVENTTYPE_* */ - int error_code; /* HVM_DELIVER_NO_ERROR_CODE if n/a */ - int insn_len; /* Instruction length */ + int16_t vector; + uint8_t type; /* X86_EVENTTYPE_* */ + uint8_t insn_len; /* Instruction length */ + uint32_t error_code; /* HVM_DELIVER_NO_ERROR_CODE if n/a */ unsigned long cr2; /* Only for TRAP_page_fault h/w exception */ }; @@ -88,17 +88,16 @@ struct hvm_function_table { char *name; /* Support Hardware-Assisted Paging? */ - int hap_supported; + bool_t hap_supported; /* Necessary hardware support for PVH mode? */ - int pvh_supported; + bool_t pvh_supported; /* Necessary hardware support for alternate p2m's? */ bool_t altp2m_supported; /* Indicate HAP capabilities. */ - int hap_capabilities; - + unsigned int hap_capabilities; /* * Initialise/destroy HVM domain/vcpu resources @@ -142,7 +141,7 @@ struct hvm_function_table { void (*set_tsc_offset)(struct vcpu *v, u64 offset, u64 at_tsc); - void (*inject_trap)(struct hvm_trap *trap); + void (*inject_trap)(const struct hvm_trap *trap); void (*init_hypercall_page)(struct domain *d, void *hypercall_page); @@ -175,7 +174,7 @@ struct hvm_function_table { int (*nhvm_vcpu_initialise)(struct vcpu *v); void (*nhvm_vcpu_destroy)(struct vcpu *v); int (*nhvm_vcpu_reset)(struct vcpu *v); - int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v, struct hvm_trap *trap); + int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v, const struct hvm_trap *trap); uint64_t (*nhvm_vcpu_p2m_base)(struct vcpu *v); bool_t (*nhvm_vmcx_guest_intercepts_trap)(struct vcpu *v, unsigned int trapnr, @@ -371,7 +370,7 @@ bool_t hvm_io_pending(struct vcpu *v); void hvm_do_resume(struct vcpu *v); void hvm_migrate_pirqs(struct vcpu *v); -void hvm_inject_trap(struct hvm_trap *trap); +void hvm_inject_trap(const struct hvm_trap *trap); void hvm_inject_hw_exception(unsigned int trapnr, int errcode); void hvm_inject_page_fault(int errcode, unsigned long cr2); @@ -495,7 +494,8 @@ int hvm_x2apic_msr_write(struct vcpu *v, /* inject vmexit into l1 guest. l1 guest will see a VMEXIT due to * 'trapnr' exception. */ -static inline int nhvm_vcpu_vmexit_trap(struct vcpu *v, struct hvm_trap *trap) +static inline int nhvm_vcpu_vmexit_trap(struct vcpu *v, + const struct hvm_trap *trap) { return hvm_funcs.nhvm_vcpu_vmexit_trap(v, trap); } --- a/xen/include/asm-x86/hvm/support.h +++ b/xen/include/asm-x86/hvm/support.h @@ -25,7 +25,7 @@ #include #include -#define HVM_DELIVER_NO_ERROR_CODE -1 +#define HVM_DELIVER_NO_ERROR_CODE (~0U) #ifndef NDEBUG #define DBG_LEVEL_0 (1 << 0) --- a/xen/include/asm-x86/hvm/svm/nestedsvm.h +++ b/xen/include/asm-x86/hvm/svm/nestedsvm.h @@ -110,7 +110,7 @@ void nsvm_vcpu_destroy(struct vcpu *v); int nsvm_vcpu_initialise(struct vcpu *v); int nsvm_vcpu_reset(struct vcpu *v); int nsvm_vcpu_vmrun(struct vcpu *v, struct cpu_user_regs *regs); -int nsvm_vcpu_vmexit_trap(struct vcpu *v, struct hvm_trap *trap); +int nsvm_vcpu_vmexit_trap(struct vcpu *v, const struct hvm_trap *trap); uint64_t nsvm_vcpu_hostcr3(struct vcpu *v); bool_t nsvm_vmcb_guest_intercepts_trap(struct vcpu *v, unsigned int trapnr, int errcode);