aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-x86
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-08-07 17:30:09 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-08-07 17:30:09 +0100
commitb4923c7d99ef7093b8c2ff1e90bea61a92c23288 (patch)
tree2db183627c04aec91853a6f67d165ab1d564f564 /xen/include/asm-x86
parentc0efd4c9393885bfa80d1511d152aaed4202c3be (diff)
downloadxen-b4923c7d99ef7093b8c2ff1e90bea61a92c23288.tar.gz
xen-b4923c7d99ef7093b8c2ff1e90bea61a92c23288.tar.bz2
xen-b4923c7d99ef7093b8c2ff1e90bea61a92c23288.zip
hvm: Clean up control-register and EFER handling.
No semantic changes. :-) Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/include/asm-x86')
-rw-r--r--xen/include/asm-x86/hvm/hvm.h54
-rw-r--r--xen/include/asm-x86/hvm/support.h2
-rw-r--r--xen/include/asm-x86/hvm/svm/asid.h9
-rw-r--r--xen/include/asm-x86/hvm/svm/vmcb.h5
-rw-r--r--xen/include/asm-x86/hvm/vcpu.h12
-rw-r--r--xen/include/asm-x86/hvm/vmx/vmcs.h6
-rw-r--r--xen/include/asm-x86/hvm/vmx/vmx.h4
7 files changed, 27 insertions, 65 deletions
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
index 7913110795..223299ff2d 100644
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -95,23 +95,13 @@ struct hvm_function_table {
/*
* Examine specifics of the guest state:
- * 1) determine whether paging is enabled,
- * 2) determine whether long mode is enabled,
- * 3) determine whether PAE paging is enabled,
- * 4) determine whether NX is enabled,
- * 5) determine whether interrupts are enabled or not,
- * 6) determine the mode the guest is running in,
- * 7) return the current guest control-register value
- * 8) return the current guest segment descriptor base
- * 9) return the current guest segment descriptor
+ * 1) determine whether interrupts are enabled or not
+ * 2) determine the mode the guest is running in
+ * 3) return the current guest segment descriptor base
+ * 4) return the current guest segment descriptor
*/
- int (*paging_enabled)(struct vcpu *v);
- int (*long_mode_enabled)(struct vcpu *v);
- int (*pae_enabled)(struct vcpu *v);
- int (*nx_enabled)(struct vcpu *v);
int (*interrupts_enabled)(struct vcpu *v, enum hvm_intack);
int (*guest_x86_mode)(struct vcpu *v);
- unsigned long (*get_guest_ctrl_reg)(struct vcpu *v, unsigned int num);
unsigned long (*get_segment_base)(struct vcpu *v, enum x86_segment seg);
void (*get_segment_register)(struct vcpu *v, enum x86_segment seg,
struct segment_register *reg);
@@ -189,41 +179,27 @@ hvm_load_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *r)
void hvm_set_guest_time(struct vcpu *v, u64 gtime);
u64 hvm_get_guest_time(struct vcpu *v);
-static inline int
-hvm_paging_enabled(struct vcpu *v)
-{
- return hvm_funcs.paging_enabled(v);
-}
+#define hvm_paging_enabled(v) \
+ (!!((v)->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PG))
+#define hvm_pae_enabled(v) \
+ (hvm_paging_enabled(v) && ((v)->arch.hvm_vcpu.guest_cr[4] & X86_CR4_PAE))
+#define hvm_nx_enabled(v) \
+ (!!((v)->arch.hvm_vcpu.guest_efer & EFER_NX))
#ifdef __x86_64__
-static inline int
-hvm_long_mode_enabled(struct vcpu *v)
-{
- return hvm_funcs.long_mode_enabled(v);
-}
+#define hvm_long_mode_enabled(v) \
+ ((v)->arch.hvm_vcpu.guest_efer & EFER_LMA)
#else
#define hvm_long_mode_enabled(v) (v,0)
#endif
static inline int
-hvm_pae_enabled(struct vcpu *v)
-{
- return hvm_funcs.pae_enabled(v);
-}
-
-static inline int
hvm_interrupts_enabled(struct vcpu *v, enum hvm_intack type)
{
return hvm_funcs.interrupts_enabled(v, type);
}
static inline int
-hvm_nx_enabled(struct vcpu *v)
-{
- return hvm_funcs.nx_enabled(v);
-}
-
-static inline int
hvm_guest_x86_mode(struct vcpu *v)
{
return hvm_funcs.guest_x86_mode(v);
@@ -257,12 +233,6 @@ void hvm_hypercall_page_initialise(struct domain *d,
void *hypercall_page);
static inline unsigned long
-hvm_get_guest_ctrl_reg(struct vcpu *v, unsigned int num)
-{
- return hvm_funcs.get_guest_ctrl_reg(v, num);
-}
-
-static inline unsigned long
hvm_get_segment_base(struct vcpu *v, enum x86_segment seg)
{
return hvm_funcs.get_segment_base(v, seg);
diff --git a/xen/include/asm-x86/hvm/support.h b/xen/include/asm-x86/hvm/support.h
index b4d4c17e53..d98ffa4a17 100644
--- a/xen/include/asm-x86/hvm/support.h
+++ b/xen/include/asm-x86/hvm/support.h
@@ -234,4 +234,6 @@ int hvm_do_hypercall(struct cpu_user_regs *pregs);
void hvm_hlt(unsigned long rflags);
void hvm_triple_fault(void);
+int hvm_set_cr3(unsigned long value);
+
#endif /* __ASM_X86_HVM_SUPPORT_H__ */
diff --git a/xen/include/asm-x86/hvm/svm/asid.h b/xen/include/asm-x86/hvm/svm/asid.h
index be5180e65a..c4f23279cb 100644
--- a/xen/include/asm-x86/hvm/svm/asid.h
+++ b/xen/include/asm-x86/hvm/svm/asid.h
@@ -32,20 +32,11 @@ void svm_asid_init_vcpu(struct vcpu *v);
void svm_asid_inv_asid(struct vcpu *v);
void svm_asid_inc_generation(void);
-/*
- * ASID related, guest triggered events.
- */
-
static inline void svm_asid_g_update_paging(struct vcpu *v)
{
svm_asid_inv_asid(v);
}
-static inline void svm_asid_g_mov_to_cr3(struct vcpu *v)
-{
- svm_asid_inv_asid(v);
-}
-
static inline void svm_asid_g_invlpg(struct vcpu *v, unsigned long g_vaddr)
{
#if 0
diff --git a/xen/include/asm-x86/hvm/svm/vmcb.h b/xen/include/asm-x86/hvm/svm/vmcb.h
index 1400e81035..19fa838d79 100644
--- a/xen/include/asm-x86/hvm/svm/vmcb.h
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h
@@ -440,11 +440,6 @@ struct arch_svm_struct {
u32 *msrpm;
int launch_core;
bool_t vmcb_in_sync; /* VMCB sync'ed with VMSAVE? */
- unsigned long cpu_shadow_cr0; /* Guest value for CR0 */
- unsigned long cpu_shadow_cr4; /* Guest value for CR4 */
- unsigned long cpu_shadow_efer; /* Guest value for EFER */
- unsigned long cpu_cr2;
- unsigned long cpu_cr3;
};
struct vmcb_struct *alloc_vmcb(void);
diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h
index a6a762ef36..ff62684a58 100644
--- a/xen/include/asm-x86/hvm/vcpu.h
+++ b/xen/include/asm-x86/hvm/vcpu.h
@@ -29,7 +29,17 @@
#define HVM_VCPU_INIT_SIPI_SIPI_STATE_WAIT_SIPI 1
struct hvm_vcpu {
- unsigned long hw_cr3; /* value we give to HW to use */
+ /* Guest control-register and EFER values, just as the guest sees them. */
+ unsigned long guest_cr[5];
+ unsigned long guest_efer;
+
+ /*
+ * Processor-visible CR0-4 while guest executes.
+ * Only CR3 is guaranteed to be valid: all other array entries are private
+ * to the specific HVM implementation (e.g., VMX, SVM).
+ */
+ unsigned long hw_cr[5];
+
struct hvm_io_op io_op;
struct vlapic vlapic;
s64 cache_tsc_offset;
diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm/vmx/vmcs.h
index d1b5ee54d7..c2fde90522 100644
--- a/xen/include/asm-x86/hvm/vmx/vmcs.h
+++ b/xen/include/asm-x86/hvm/vmx/vmcs.h
@@ -67,17 +67,11 @@ struct arch_vmx_struct {
/* Cache of cpu execution control. */
u32 exec_control;
- unsigned long cpu_cr0; /* copy of guest CR0 */
- unsigned long cpu_shadow_cr0; /* copy of guest read shadow CR0 */
- unsigned long cpu_shadow_cr4; /* copy of guest read shadow CR4 */
- unsigned long cpu_cr2; /* save CR2 */
- unsigned long cpu_cr3;
#ifdef __x86_64__
struct vmx_msr_state msr_state;
unsigned long shadow_gs;
unsigned long cstar;
#endif
- unsigned long efer;
/* Following fields are all specific to vmxassist. */
unsigned long vmxassist_enabled:1;
diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h
index 963079359a..28edcfe088 100644
--- a/xen/include/asm-x86/hvm/vmx/vmx.h
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h
@@ -279,8 +279,8 @@ static inline void __vmx_inject_exception(
__vmwrite(VM_ENTRY_INTR_INFO, intr_fields);
- if (trap == TRAP_page_fault)
- HVMTRACE_2D(PF_INJECT, v, v->arch.hvm_vmx.cpu_cr2, error_code);
+ if ( trap == TRAP_page_fault )
+ HVMTRACE_2D(PF_INJECT, v, v->arch.hvm_vcpu.guest_cr[2], error_code);
else
HVMTRACE_2D(INJ_EXC, v, trap, error_code);
}