* [PATCH] x86/HVM: type adjustments
@ 2015-11-23 13:51 Jan Beulich
2015-11-23 15:06 ` Andrew Cooper
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jan Beulich @ 2015-11-23 13:51 UTC (permalink / raw)
To: xen-devel
Cc: Kevin Tian, Keir Fraser, suravee.suthikulpanit, Andrew Cooper,
Aravind Gopalakrishnan, Jun Nakajima, Boris Ostrovsky
[-- Attachment #1: Type: text/plain, Size: 6379 bytes --]
- 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>
--- 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 <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)
--- 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);
[-- Attachment #2: x86-HVM-types.patch --]
[-- Type: text/plain, Size: 6404 bytes --]
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 <jbeulich@suse.com>
--- 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 <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)
--- 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);
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/HVM: type adjustments
2015-11-23 13:51 [PATCH] x86/HVM: type adjustments Jan Beulich
@ 2015-11-23 15:06 ` Andrew Cooper
2015-11-23 15:47 ` Boris Ostrovsky
2015-11-24 4:56 ` Tian, Kevin
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2015-11-23 15:06 UTC (permalink / raw)
To: Jan Beulich, xen-devel
Cc: Kevin Tian, Keir Fraser, suravee.suthikulpanit,
Aravind Gopalakrishnan, Jun Nakajima, Boris Ostrovsky
On 23/11/15 13:51, Jan Beulich wrote:
> - 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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/HVM: type adjustments
2015-11-23 13:51 [PATCH] x86/HVM: type adjustments Jan Beulich
2015-11-23 15:06 ` Andrew Cooper
@ 2015-11-23 15:47 ` Boris Ostrovsky
2015-11-24 4:56 ` Tian, Kevin
2 siblings, 0 replies; 4+ messages in thread
From: Boris Ostrovsky @ 2015-11-23 15:47 UTC (permalink / raw)
To: Jan Beulich, xen-devel
Cc: Kevin Tian, Keir Fraser, suravee.suthikulpanit, Andrew Cooper,
Aravind Gopalakrishnan, Jun Nakajima
On 11/23/2015 08:51 AM, Jan Beulich wrote:
> - 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>
>
> --- 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;
Reviewed-by: Boris Ostrovsky<boris.ostrovsky@oracle.com>
(Should we redefine constant_test_bit/variable_test_bit (which is what
cpu_has_* is) to return bool_t?)
-boris
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/HVM: type adjustments
2015-11-23 13:51 [PATCH] x86/HVM: type adjustments Jan Beulich
2015-11-23 15:06 ` Andrew Cooper
2015-11-23 15:47 ` Boris Ostrovsky
@ 2015-11-24 4:56 ` Tian, Kevin
2 siblings, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2015-11-24 4:56 UTC (permalink / raw)
To: Jan Beulich, xen-devel
Cc: Keir Fraser, suravee.suthikulpanit@amd.com, Andrew Cooper,
Aravind Gopalakrishnan, Nakajima, Jun, Boris Ostrovsky
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: Monday, November 23, 2015 9:51 PM
>
> - 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>
Acked-by: Kevin Tian <kevin.tian@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-24 4:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-23 13:51 [PATCH] x86/HVM: type adjustments Jan Beulich
2015-11-23 15:06 ` Andrew Cooper
2015-11-23 15:47 ` Boris Ostrovsky
2015-11-24 4:56 ` Tian, Kevin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.