x86/HVM: type adjustments
PATCH 1/1 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
xen/arch/x86/hvm/hvm.c +1 -1
@@ -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;
xen/arch/x86/hvm/svm/nestedsvm.c +1 -1
@@ -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 );
xen/arch/x86/hvm/svm/svm.c +2 -2
@@ -1181,7 +1181,7 @@ static void svm_vcpu_destroy(struct vcpupassive_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 * __initif ( !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 );
xen/arch/x86/hvm/vmx/vmx.c +2 -2
@@ -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;
xen/include/asm-x86/hvm/hvm.h +12 -12
@@ -72,10 +72,10 @@ enum hvm_intblk {#define HVM_HAP_SUPERPAGE_1GB 0x00000002struct 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); }
xen/include/asm-x86/hvm/support.h +1 -1
@@ -25,7 +25,7 @@#include <xen/hvm/save.h> #include <asm/processor.h> -#define HVM_DELIVER_NO_ERROR_CODE -1 +#define HVM_DELIVER_NO_ERROR_CODE (~0U)#ifndef NDEBUG #define DBG_LEVEL_0 (1 << 0)
xen/include/asm-x86/hvm/svm/nestedsvm.h +1 -1
@@ -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);
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
xen/arch/x86/hvm/hvm.c +1 -1
@@ -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;
xen/arch/x86/hvm/svm/nestedsvm.c +1 -1
@@ -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 );
xen/arch/x86/hvm/svm/svm.c +2 -2
@@ -1181,7 +1181,7 @@ static void svm_vcpu_destroy(struct vcpupassive_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 * __initif ( !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 );
xen/arch/x86/hvm/vmx/vmx.c +2 -2
@@ -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;
xen/include/asm-x86/hvm/hvm.h +12 -12
@@ -72,10 +72,10 @@ enum hvm_intblk {#define HVM_HAP_SUPERPAGE_1GB 0x00000002struct 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); }
xen/include/asm-x86/hvm/support.h +1 -1
@@ -25,7 +25,7 @@#include <xen/hvm/save.h> #include <asm/processor.h> -#define HVM_DELIVER_NO_ERROR_CODE -1 +#define HVM_DELIVER_NO_ERROR_CODE (~0U)#ifndef NDEBUG #define DBG_LEVEL_0 (1 << 0)
xen/include/asm-x86/hvm/svm/nestedsvm.h +1 -1
@@ -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);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
- constify struct
hvm_trap* function parameters
- width reduce and shuffle some structhvm_trapmembers
- usebool_tfor boolean fields structhvm_function_table
- use unsigned for struct hvm_function_table'shap_capabilitiesfieldSigned-off-by Jan Beulich <[email protected]>
Quoted 21 lines · Jan Beulich
- constify struct
hvm_trap* function parameters
- width reduce and shuffle some structhvm_trapmembers
- usebool_tfor boolean fields structhvm_function_table
- use unsigned for struct hvm_function_table'shap_capabilitiesfieldSigned-off-by Jan Beulich <[email protected]>xen/arch/x86/hvm/svm/svm.c +1
-1@@ -1181,7 +1181,7 @@ static void svm_vcpu_destroy(struct vcpupassive_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;
xen/arch/x86/hvm/svm/svm.c const struct hvm_function_table * __init · line 1445
Quoted 5 lines
xen/arch/x86/hvm/svm/svm.c +1
-1@@ -1442,7 +1442,7 @@ const struct hvm_function_table * __initif ( !printed )printk (" - none\n" ); - svm_function_table.hap_supported = cpu_has_svm_npt; + svm_function_table.hap_supported = !!cpu_has_svm_npt;
(Should we redefine constant_test_bit/variable_test_bit (which is what cpu_has_* is) to return bool_t?)
-boris
Quoted 9 lines
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, November 23, 2015 9:51 PM- constify struct
hvm_trap* function parameters
- width reduce and shuffle some structhvm_trapmembers
- usebool_tfor boolean fields structhvm_function_table
- use unsigned for struct hvm_function_table'shap_capabilitiesfieldSigned-off-by Jan Beulich <[email protected]>