From: "Jan Beulich" Subject: [PATCH] x86/HVM: type adjustments Date: Mon, 23 Nov 2015 06:51:27 -0700 Message-ID: <565327EF02000078000B7DA6@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartBB8CB3CF.3__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a0rWp-0004L8-Un for xen-devel@lists.xenproject.org; Mon, 23 Nov 2015 13:51:36 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Kevin Tian , Keir Fraser , suravee.suthikulpanit@amd.com, Andrew Cooper , Aravind Gopalakrishnan , Jun Nakajima , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartBB8CB3CF.3__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline - 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); } =20 -void hvm_inject_trap(struct hvm_trap *trap) +void hvm_inject_trap(const struct hvm_trap *trap) { struct vcpu *curr =3D current; =20 --- 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, } =20 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 !=3D NULL); =20 --- 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); } =20 -static void svm_inject_trap(struct hvm_trap *trap) +static void svm_inject_trap(const struct hvm_trap *trap) { struct vcpu *curr =3D current; struct vmcb_struct *vmcb =3D curr->arch.hvm_svm.vmcb; @@ -1442,7 +1442,7 @@ const struct hvm_function_table * __init if ( !printed ) printk(" - none\n"); =20 - svm_function_table.hap_supported =3D cpu_has_svm_npt; + svm_function_table.hap_supported =3D !!cpu_has_svm_npt; svm_function_table.hap_capabilities =3D HVM_HAP_SUPERPAGE_2MB | ((cpuid_edx(0x80000001) & 0x04000000) ? HVM_HAP_SUPERPAGE_1GB : = 0); =20 --- 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); } =20 -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 =3D 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 =20 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 */=20 + 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 = */ }; =20 @@ -88,17 +88,16 @@ struct hvm_function_table { char *name; =20 /* Support Hardware-Assisted Paging? */ - int hap_supported; + bool_t hap_supported; =20 /* Necessary hardware support for PVH mode? */ - int pvh_supported; + bool_t pvh_supported; =20 /* Necessary hardware support for alternate p2m's? */ bool_t altp2m_supported; =20 /* Indicate HAP capabilities. */ - int hap_capabilities; - + unsigned int hap_capabilities; =20 /* * Initialise/destroy HVM domain/vcpu resources @@ -142,7 +141,7 @@ struct hvm_function_table { =20 void (*set_tsc_offset)(struct vcpu *v, u64 offset, u64 at_tsc); =20 - void (*inject_trap)(struct hvm_trap *trap); + void (*inject_trap)(const struct hvm_trap *trap); =20 void (*init_hypercall_page)(struct domain *d, void *hypercall_page); =20 @@ -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); =20 -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); =20 @@ -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. */=20 -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 =20 -#define HVM_DELIVER_NO_ERROR_CODE -1 +#define HVM_DELIVER_NO_ERROR_CODE (~0U) =20 #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); --=__PartBB8CB3CF.3__= Content-Type: text/plain; name="x86-HVM-types.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HVM-types.patch" x86/HVM: type adjustments=0A=0A- constify struct hvm_trap * function = parameters=0A- width reduce and shuffle some struct hvm_trap members=0A- = use bool_t for boolean fields struct hvm_function_table=0A- use unsigned = for struct hvm_function_table's hap_capabilities field=0A=0ASigned-off-by: = Jan Beulich =0A=0A--- a/xen/arch/x86/hvm/hvm.c=0A+++ = b/xen/arch/x86/hvm/hvm.c=0A@@ -2826,7 +2826,7 @@ void hvm_triple_fault(void= )=0A domain_shutdown(d, reason);=0A }=0A =0A-void hvm_inject_trap(struc= t hvm_trap *trap)=0A+void hvm_inject_trap(const struct hvm_trap *trap)=0A = {=0A struct vcpu *curr =3D current;=0A =0A--- a/xen/arch/x86/hvm/svm/ne= stedsvm.c=0A+++ b/xen/arch/x86/hvm/svm/nestedsvm.c=0A@@ -821,7 +821,7 @@ = nsvm_vcpu_vmexit_inject(struct vcpu *v,=0A }=0A =0A int=0A-nsvm_vcpu_vmexit= _trap(struct vcpu *v, struct hvm_trap *trap)=0A+nsvm_vcpu_vmexit_trap(struc= t vcpu *v, const struct hvm_trap *trap)=0A {=0A ASSERT(vcpu_nestedhvm(v= ).nv_vvmcx !=3D NULL);=0A =0A--- a/xen/arch/x86/hvm/svm/svm.c=0A+++ = b/xen/arch/x86/hvm/svm/svm.c=0A@@ -1181,7 +1181,7 @@ static void svm_vcpu_d= estroy(struct vcpu=0A passive_domain_destroy(v);=0A }=0A =0A-static = void svm_inject_trap(struct hvm_trap *trap)=0A+static void svm_inject_trap(= const struct hvm_trap *trap)=0A {=0A struct vcpu *curr =3D current;=0A = struct vmcb_struct *vmcb =3D curr->arch.hvm_svm.vmcb;=0A@@ -1442,7 = +1442,7 @@ const struct hvm_function_table * __init=0A if ( !printed = )=0A printk(" - none\n");=0A =0A- svm_function_table.hap_support= ed =3D cpu_has_svm_npt;=0A+ svm_function_table.hap_supported =3D = !!cpu_has_svm_npt;=0A svm_function_table.hap_capabilities =3D = HVM_HAP_SUPERPAGE_2MB |=0A ((cpuid_edx(0x80000001) & 0x04000000) ? = HVM_HAP_SUPERPAGE_1GB : 0);=0A =0A--- a/xen/arch/x86/hvm/vmx/vmx.c=0A+++ = b/xen/arch/x86/hvm/vmx/vmx.c=0A@@ -1416,7 +1416,7 @@ void nvmx_enqueue_n2_e= xceptions(struct v=0A nvmx->intr.intr_info, nvmx->intr.err= or_code);=0A }=0A =0A-static int nvmx_vmexit_trap(struct vcpu *v, struct = hvm_trap *trap)=0A+static int nvmx_vmexit_trap(struct vcpu *v, const = struct hvm_trap *trap)=0A {=0A nvmx_enqueue_n2_exceptions(v, trap->vect= or, trap->error_code,=0A hvm_intsrc_none);= =0A@@ -1502,7 +1502,7 @@ void vmx_inject_nmi(void)=0A * - #DB is = X86_EVENTTYPE_HW_EXCEPTION, except when generated by=0A * opcode 0xf1 = (which is X86_EVENTTYPE_PRI_SW_EXCEPTION)=0A */=0A-static void vmx_inject_= trap(struct hvm_trap *trap)=0A+static void vmx_inject_trap(const struct = hvm_trap *trap)=0A {=0A unsigned long intr_info;=0A struct vcpu = *curr =3D current;=0A--- a/xen/include/asm-x86/hvm/hvm.h=0A+++ b/xen/includ= e/asm-x86/hvm/hvm.h=0A@@ -72,10 +72,10 @@ enum hvm_intblk {=0A #define = HVM_HAP_SUPERPAGE_1GB 0x00000002=0A =0A struct hvm_trap {=0A- int = vector;=0A- unsigned int type; /* X86_EVENTTYPE_* */=0A- = int error_code; /* HVM_DELIVER_NO_ERROR_CODE if n/a */=0A- = int insn_len; /* Instruction length */ =0A+ int16_t = vector;=0A+ uint8_t type; /* X86_EVENTTYPE_* */=0A+ = uint8_t insn_len; /* Instruction length */=0A+ uint32_t = error_code; /* HVM_DELIVER_NO_ERROR_CODE if n/a */=0A unsigned long = cr2; /* Only for TRAP_page_fault h/w exception */=0A };=0A =0A@@ = -88,17 +88,16 @@ struct hvm_function_table {=0A char *name;=0A =0A = /* Support Hardware-Assisted Paging? */=0A- int hap_supported;=0A+ = bool_t hap_supported;=0A =0A /* Necessary hardware support for PVH = mode? */=0A- int pvh_supported;=0A+ bool_t pvh_supported;=0A =0A = /* Necessary hardware support for alternate p2m's? */=0A bool_t = altp2m_supported;=0A =0A /* Indicate HAP capabilities. */=0A- int = hap_capabilities;=0A-=0A+ unsigned int hap_capabilities;=0A =0A = /*=0A * Initialise/destroy HVM domain/vcpu resources=0A@@ -142,7 = +141,7 @@ struct hvm_function_table {=0A =0A void (*set_tsc_offset)(str= uct vcpu *v, u64 offset, u64 at_tsc);=0A =0A- void (*inject_trap)(struct= hvm_trap *trap);=0A+ void (*inject_trap)(const struct hvm_trap = *trap);=0A =0A void (*init_hypercall_page)(struct domain *d, void = *hypercall_page);=0A =0A@@ -175,7 +174,7 @@ struct hvm_function_table {=0A = int (*nhvm_vcpu_initialise)(struct vcpu *v);=0A void (*nhvm_vcpu_de= stroy)(struct vcpu *v);=0A int (*nhvm_vcpu_reset)(struct vcpu *v);=0A- = int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v, struct hvm_trap *trap);=0A+= int (*nhvm_vcpu_vmexit_trap)(struct vcpu *v, const struct hvm_trap = *trap);=0A uint64_t (*nhvm_vcpu_p2m_base)(struct vcpu *v);=0A = bool_t (*nhvm_vmcx_guest_intercepts_trap)(struct vcpu *v,=0A = unsigned int trapnr,=0A@@ -371,7 +370,7 @@ = bool_t hvm_io_pending(struct vcpu *v);=0A void hvm_do_resume(struct vcpu = *v);=0A void hvm_migrate_pirqs(struct vcpu *v);=0A =0A-void hvm_inject_trap= (struct hvm_trap *trap);=0A+void hvm_inject_trap(const struct hvm_trap = *trap);=0A void hvm_inject_hw_exception(unsigned int trapnr, int = errcode);=0A void hvm_inject_page_fault(int errcode, unsigned long = cr2);=0A =0A@@ -495,7 +494,8 @@ int hvm_x2apic_msr_write(struct vcpu = *v,=0A /* inject vmexit into l1 guest. l1 guest will see a VMEXIT due = to=0A * 'trapnr' exception.=0A */ =0A-static inline int nhvm_vcpu_vmexit_= trap(struct vcpu *v, struct hvm_trap *trap)=0A+static inline int nhvm_vcpu_= vmexit_trap(struct vcpu *v,=0A+ = const struct hvm_trap *trap)=0A {=0A return hvm_funcs.nhvm_vcpu_vmexit_= trap(v, trap);=0A }=0A--- a/xen/include/asm-x86/hvm/support.h=0A+++ = b/xen/include/asm-x86/hvm/support.h=0A@@ -25,7 +25,7 @@=0A #include = =0A #include =0A =0A-#define HVM_DELIVER_N= O_ERROR_CODE -1=0A+#define HVM_DELIVER_NO_ERROR_CODE (~0U)=0A =0A = #ifndef NDEBUG=0A #define DBG_LEVEL_0 (1 << 0)=0A--- = a/xen/include/asm-x86/hvm/svm/nestedsvm.h=0A+++ b/xen/include/asm-x86/hvm/s= vm/nestedsvm.h=0A@@ -110,7 +110,7 @@ void nsvm_vcpu_destroy(struct vcpu = *v);=0A int nsvm_vcpu_initialise(struct vcpu *v);=0A int nsvm_vcpu_reset(st= ruct vcpu *v);=0A int nsvm_vcpu_vmrun(struct vcpu *v, struct cpu_user_regs = *regs);=0A-int nsvm_vcpu_vmexit_trap(struct vcpu *v, struct hvm_trap = *trap);=0A+int nsvm_vcpu_vmexit_trap(struct vcpu *v, const struct hvm_trap = *trap);=0A uint64_t nsvm_vcpu_hostcr3(struct vcpu *v);=0A bool_t nsvm_vmcb_= guest_intercepts_trap(struct vcpu *v, unsigned int trapnr,=0A = int errcode);=0A --=__PartBB8CB3CF.3__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartBB8CB3CF.3__=--