ia64/xen-unstable

changeset 15571:1315b0901dea

Simplify vmx host state setup code.
Signed-off-by: Xin Li <xin.b.li@intel.com>
author kfraser@localhost.localdomain
date Tue Jul 10 15:45:44 2007 +0100 (2007-07-10)
parents 26eef8426110
children 25a42f826a63
files xen/arch/x86/hvm/vmx/vmcs.c xen/include/asm-x86/desc.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Tue Jul 10 15:41:26 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Tue Jul 10 15:45:44 2007 +0100
     1.3 @@ -247,55 +247,27 @@ void vmx_free_host_vmcs(struct vmcs_stru
     1.4      vmx_free_vmcs(vmcs);
     1.5  }
     1.6  
     1.7 -#define GUEST_SEGMENT_LIMIT     0xffffffff
     1.8 -
     1.9 -struct host_execution_env {
    1.10 -    /* selectors */
    1.11 -    unsigned short ldtr_selector;
    1.12 -    unsigned short tr_selector;
    1.13 -    unsigned short ds_selector;
    1.14 -    unsigned short cs_selector;
    1.15 -    /* limits */
    1.16 -    unsigned short gdtr_limit;
    1.17 -    unsigned short ldtr_limit;
    1.18 -    unsigned short idtr_limit;
    1.19 -    unsigned short tr_limit;
    1.20 -    /* base */
    1.21 -    unsigned long gdtr_base;
    1.22 -    unsigned long ldtr_base;
    1.23 -    unsigned long idtr_base;
    1.24 -    unsigned long tr_base;
    1.25 -    unsigned long ds_base;
    1.26 -    unsigned long cs_base;
    1.27 -#ifdef __x86_64__
    1.28 -    unsigned long fs_base;
    1.29 -    unsigned long gs_base;
    1.30 -#endif
    1.31 +struct xgt_desc {
    1.32 +    unsigned short size;
    1.33 +    unsigned long address __attribute__((packed));
    1.34  };
    1.35  
    1.36  static void vmx_set_host_env(struct vcpu *v)
    1.37  {
    1.38      unsigned int tr, cpu;
    1.39 -    struct host_execution_env host_env;
    1.40 -    struct Xgt_desc_struct desc;
    1.41 +    struct xgt_desc desc;
    1.42  
    1.43      cpu = smp_processor_id();
    1.44 -    __asm__ __volatile__ ("sidt  (%0) \n" :: "a"(&desc) : "memory");
    1.45 -    host_env.idtr_limit = desc.size;
    1.46 -    host_env.idtr_base = desc.address;
    1.47 -    __vmwrite(HOST_IDTR_BASE, host_env.idtr_base);
    1.48 +
    1.49 +    __asm__ __volatile__ ( "sidt (%0) \n" : : "a" (&desc) : "memory" );
    1.50 +    __vmwrite(HOST_IDTR_BASE, desc.address);
    1.51  
    1.52 -    __asm__ __volatile__ ("sgdt  (%0) \n" :: "a"(&desc) : "memory");
    1.53 -    host_env.gdtr_limit = desc.size;
    1.54 -    host_env.gdtr_base = desc.address;
    1.55 -    __vmwrite(HOST_GDTR_BASE, host_env.gdtr_base);
    1.56 +    __asm__ __volatile__ ( "sgdt (%0) \n" : : "a" (&desc) : "memory" );
    1.57 +    __vmwrite(HOST_GDTR_BASE, desc.address);
    1.58  
    1.59 -    __asm__ __volatile__ ("str  (%0) \n" :: "a"(&tr) : "memory");
    1.60 -    host_env.tr_selector = tr;
    1.61 -    host_env.tr_limit = sizeof(struct tss_struct);
    1.62 -    host_env.tr_base = (unsigned long) &init_tss[cpu];
    1.63 -    __vmwrite(HOST_TR_SELECTOR, host_env.tr_selector);
    1.64 -    __vmwrite(HOST_TR_BASE, host_env.tr_base);
    1.65 +    __asm__ __volatile__ ( "str (%0) \n" : : "a" (&tr) : "memory" );
    1.66 +    __vmwrite(HOST_TR_SELECTOR, tr);
    1.67 +    __vmwrite(HOST_TR_BASE, (unsigned long)&init_tss[cpu]);
    1.68  
    1.69      /*
    1.70       * Skip end of cpu_user_regs when entering the hypervisor because the
    1.71 @@ -306,6 +278,8 @@ static void vmx_set_host_env(struct vcpu
    1.72                (unsigned long)&get_cpu_info()->guest_cpu_user_regs.error_code);
    1.73  }
    1.74  
    1.75 +#define GUEST_SEGMENT_LIMIT     0xffffffff
    1.76 +
    1.77  static void construct_vmcs(struct vcpu *v)
    1.78  {
    1.79      unsigned long cr0, cr4;
     2.1 --- a/xen/include/asm-x86/desc.h	Tue Jul 10 15:41:26 2007 +0100
     2.2 +++ b/xen/include/asm-x86/desc.h	Tue Jul 10 15:45:44 2007 +0100
     2.3 @@ -203,11 +203,6 @@ extern struct desc_struct compat_gdt_tab
     2.4  # define compat_gdt_table gdt_table
     2.5  #endif
     2.6  
     2.7 -struct Xgt_desc_struct {
     2.8 -    unsigned short size;
     2.9 -    unsigned long address __attribute__((packed));
    2.10 -};
    2.11 -
    2.12  extern void set_intr_gate(unsigned int irq, void * addr);
    2.13  extern void set_system_gate(unsigned int n, void *addr);
    2.14  extern void set_task_gate(unsigned int n, unsigned int sel);