x86/HVM: type adjustments
authorJan Beulich <jbeulich@suse.com>
Tue, 24 Nov 2015 11:31:13 +0000 (12:31 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 24 Nov 2015 11:31:13 +0000 (12:31 +0100)
- 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 <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky<boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/svm/nestedsvm.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/hvm.h
xen/include/asm-x86/hvm/support.h
xen/include/asm-x86/hvm/svm/nestedsvm.h

index ea982e263eb4329446ed12584d5a01c58fd94335..141a13032828b2702d90936b1fc5bc8e54403ef5 100644 (file)
@@ -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;
 
index 46f253200db0b68e72114d36c659ed8ea865f2dc..9d2ac09f8fb47e7b0380f0da465524c32f90a9a6 100644 (file)
@@ -821,7 +821,7 @@ nsvm_vcpu_vmexit_inject(struct vcpu *v, struct cpu_user_regs *regs,
 }
 
 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);
 
index d9bd97eb2a0808c8fc3bcd8658d75e8da7f2f2bd..e2db4db52779e04cddd919eb303bdba5340725a1 100644 (file)
@@ -1181,7 +1181,7 @@ static void svm_vcpu_destroy(struct vcpu *v)
     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 start_svm(void)
     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);
 
index 326d80313c208bff67ae64106e85f005c05f03b7..374eebf7dea4a03c7cf1b2818a55867169addf92 100644 (file)
@@ -1416,7 +1416,7 @@ void nvmx_enqueue_n2_exceptions(struct vcpu *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);
@@ -1500,7 +1500,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;
index da799a0a2173c62229c67ade3920c507391b7117..f80e143017d3fcdc9be298f7ae9b74f8d5127b07 100644 (file)
@@ -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, unsigned int msr, uint64_t msr_content)
 /* 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);
 }
index 2d51186a6ea7d7bd1be8c9f36cd62e37a93864dd..2984abcc65b6c2aa6327df977990ad9da2edd79a 100644 (file)
@@ -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)
index 974a7d46ca23e341d730da965107171b353d817c..0dbc5ec8842bd866d76eca287171e0295a45ee7f 100644 (file)
@@ -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);