direct-io.hg

changeset 14080:cdc765772f69

hvm: Clean up initialisation of hvm_funcs.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Fri Feb 23 11:32:25 2007 +0000 (2007-02-23)
parents 38fb6c392dec
children 8bcaedc68f5a
files xen/arch/x86/hvm/hvm.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
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Fri Feb 23 10:47:55 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Fri Feb 23 11:32:25 2007 +0000
     1.3 @@ -49,18 +49,18 @@
     1.4  #include <public/version.h>
     1.5  #include <public/memory.h>
     1.6  
     1.7 -int hvm_enabled;
     1.8 +int hvm_enabled __read_mostly;
     1.9  
    1.10 -unsigned int opt_hvm_debug_level;
    1.11 +unsigned int opt_hvm_debug_level __read_mostly;
    1.12  integer_param("hvm_debug", opt_hvm_debug_level);
    1.13  
    1.14 -struct hvm_function_table hvm_funcs;
    1.15 +struct hvm_function_table hvm_funcs __read_mostly;
    1.16  
    1.17  /* I/O permission bitmap is globally shared by all HVM guests. */
    1.18  char __attribute__ ((__section__ (".bss.page_aligned")))
    1.19      hvm_io_bitmap[3*PAGE_SIZE];
    1.20  
    1.21 -void hvm_enable(void)
    1.22 +void hvm_enable(struct hvm_function_table *fns)
    1.23  {
    1.24      if ( hvm_enabled )
    1.25          return;
    1.26 @@ -72,6 +72,7 @@ void hvm_enable(void)
    1.27      memset(hvm_io_bitmap, ~0, sizeof(hvm_io_bitmap));
    1.28      clear_bit(0x80, hvm_io_bitmap);
    1.29  
    1.30 +    hvm_funcs   = *fns;
    1.31      hvm_enabled = 1;
    1.32  }
    1.33  
     2.1 --- a/xen/arch/x86/hvm/svm/svm.c	Fri Feb 23 10:47:55 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Fri Feb 23 11:32:25 2007 +0000
     2.3 @@ -988,6 +988,32 @@ static int svm_event_injection_faulted(s
     2.4      return vmcb->exitintinfo.fields.v;
     2.5  }
     2.6  
     2.7 +static struct hvm_function_table svm_function_table = {
     2.8 +    .disable              = stop_svm,
     2.9 +    .vcpu_initialise      = svm_vcpu_initialise,
    2.10 +    .vcpu_destroy         = svm_vcpu_destroy,
    2.11 +    .store_cpu_guest_regs = svm_store_cpu_guest_regs,
    2.12 +    .load_cpu_guest_regs  = svm_load_cpu_guest_regs,
    2.13 +    .save_cpu_ctxt        = svm_save_vmcb_ctxt,
    2.14 +    .load_cpu_ctxt        = svm_load_vmcb_ctxt,
    2.15 +    .paging_enabled       = svm_paging_enabled,
    2.16 +    .long_mode_enabled    = svm_long_mode_enabled,
    2.17 +    .pae_enabled          = svm_pae_enabled,
    2.18 +    .guest_x86_mode       = svm_guest_x86_mode,
    2.19 +    .get_guest_ctrl_reg   = svm_get_ctrl_reg,
    2.20 +    .get_segment_base     = svm_get_segment_base,
    2.21 +    .get_segment_register = svm_get_segment_register,
    2.22 +    .update_host_cr3      = svm_update_host_cr3,
    2.23 +    .update_guest_cr3     = svm_update_guest_cr3,
    2.24 +    .update_vtpr          = svm_update_vtpr,
    2.25 +    .stts                 = svm_stts,
    2.26 +    .set_tsc_offset       = svm_set_tsc_offset,
    2.27 +    .inject_exception     = svm_hvm_inject_exception,
    2.28 +    .init_ap_context      = svm_init_ap_context,
    2.29 +    .init_hypercall_page  = svm_init_hypercall_page,
    2.30 +    .event_injection_faulted = svm_event_injection_faulted
    2.31 +};
    2.32 +
    2.33  int start_svm(void)
    2.34  {
    2.35      u32 eax, ecx, edx;
    2.36 @@ -1031,42 +1057,7 @@ int start_svm(void)
    2.37      if (cpu == 0)
    2.38          setup_vmcb_dump();
    2.39  
    2.40 -    /* Setup HVM interfaces */
    2.41 -    hvm_funcs.disable = stop_svm;
    2.42 -
    2.43 -    hvm_funcs.vcpu_initialise = svm_vcpu_initialise;
    2.44 -    hvm_funcs.vcpu_destroy    = svm_vcpu_destroy;
    2.45 -
    2.46 -    hvm_funcs.store_cpu_guest_regs = svm_store_cpu_guest_regs;
    2.47 -    hvm_funcs.load_cpu_guest_regs = svm_load_cpu_guest_regs;
    2.48 -
    2.49 -    hvm_funcs.save_cpu_ctxt = svm_save_vmcb_ctxt;
    2.50 -    hvm_funcs.load_cpu_ctxt = svm_load_vmcb_ctxt;
    2.51 -
    2.52 -    hvm_funcs.paging_enabled = svm_paging_enabled;
    2.53 -    hvm_funcs.long_mode_enabled = svm_long_mode_enabled;
    2.54 -    hvm_funcs.pae_enabled = svm_pae_enabled;
    2.55 -    hvm_funcs.guest_x86_mode = svm_guest_x86_mode;
    2.56 -    hvm_funcs.get_guest_ctrl_reg = svm_get_ctrl_reg;
    2.57 -    hvm_funcs.get_segment_base = svm_get_segment_base;
    2.58 -    hvm_funcs.get_segment_register = svm_get_segment_register;
    2.59 -
    2.60 -    hvm_funcs.update_host_cr3 = svm_update_host_cr3;
    2.61 -    hvm_funcs.update_guest_cr3 = svm_update_guest_cr3;
    2.62 -    
    2.63 -    hvm_funcs.update_vtpr = svm_update_vtpr;
    2.64 -
    2.65 -    hvm_funcs.stts = svm_stts;
    2.66 -    hvm_funcs.set_tsc_offset = svm_set_tsc_offset;
    2.67 -
    2.68 -    hvm_funcs.inject_exception = svm_hvm_inject_exception;
    2.69 -
    2.70 -    hvm_funcs.init_ap_context = svm_init_ap_context;
    2.71 -    hvm_funcs.init_hypercall_page = svm_init_hypercall_page;
    2.72 -
    2.73 -    hvm_funcs.event_injection_faulted = svm_event_injection_faulted;
    2.74 -
    2.75 -    hvm_enable();
    2.76 +    hvm_enable(&svm_function_table);
    2.77  
    2.78      return 1;
    2.79  }
     3.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Feb 23 10:47:55 2007 +0000
     3.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Feb 23 11:32:25 2007 +0000
     3.3 @@ -1000,44 +1000,31 @@ static int vmx_event_injection_faulted(s
     3.4      return (idtv_info_field & INTR_INFO_VALID_MASK);
     3.5  }
     3.6  
     3.7 -/* Setup HVM interfaces */
     3.8 -static void vmx_setup_hvm_funcs(void)
     3.9 -{
    3.10 -    hvm_funcs.disable = stop_vmx;
    3.11 -
    3.12 -    hvm_funcs.vcpu_initialise = vmx_vcpu_initialise;
    3.13 -    hvm_funcs.vcpu_destroy    = vmx_vcpu_destroy;
    3.14 -
    3.15 -    hvm_funcs.store_cpu_guest_regs = vmx_store_cpu_guest_regs;
    3.16 -    hvm_funcs.load_cpu_guest_regs = vmx_load_cpu_guest_regs;
    3.17 -
    3.18 -    hvm_funcs.save_cpu_ctxt = vmx_save_vmcs_ctxt;
    3.19 -    hvm_funcs.load_cpu_ctxt = vmx_load_vmcs_ctxt;
    3.20 -
    3.21 -    hvm_funcs.paging_enabled = vmx_paging_enabled;
    3.22 -    hvm_funcs.long_mode_enabled = vmx_long_mode_enabled;
    3.23 -    hvm_funcs.pae_enabled = vmx_pae_enabled;
    3.24 -    hvm_funcs.guest_x86_mode = vmx_guest_x86_mode;
    3.25 -    hvm_funcs.get_guest_ctrl_reg = vmx_get_ctrl_reg;
    3.26 -    hvm_funcs.get_segment_base = vmx_get_segment_base;
    3.27 -    hvm_funcs.get_segment_register = vmx_get_segment_register;
    3.28 -
    3.29 -    hvm_funcs.update_host_cr3 = vmx_update_host_cr3;
    3.30 -    hvm_funcs.update_guest_cr3 = vmx_update_guest_cr3;
    3.31 -
    3.32 -    hvm_funcs.update_vtpr = vmx_update_vtpr;
    3.33 -
    3.34 -    hvm_funcs.stts = vmx_stts;
    3.35 -    hvm_funcs.set_tsc_offset = vmx_set_tsc_offset;
    3.36 -
    3.37 -    hvm_funcs.inject_exception = vmx_inject_exception;
    3.38 -
    3.39 -    hvm_funcs.init_ap_context = vmx_init_ap_context;
    3.40 -
    3.41 -    hvm_funcs.init_hypercall_page = vmx_init_hypercall_page;
    3.42 -
    3.43 -    hvm_funcs.event_injection_faulted = vmx_event_injection_faulted;
    3.44 -}
    3.45 +static struct hvm_function_table vmx_function_table = {
    3.46 +    .disable              = stop_vmx,
    3.47 +    .vcpu_initialise      = vmx_vcpu_initialise,
    3.48 +    .vcpu_destroy         = vmx_vcpu_destroy,
    3.49 +    .store_cpu_guest_regs = vmx_store_cpu_guest_regs,
    3.50 +    .load_cpu_guest_regs  = vmx_load_cpu_guest_regs,
    3.51 +    .save_cpu_ctxt        = vmx_save_vmcs_ctxt,
    3.52 +    .load_cpu_ctxt        = vmx_load_vmcs_ctxt,
    3.53 +    .paging_enabled       = vmx_paging_enabled,
    3.54 +    .long_mode_enabled    = vmx_long_mode_enabled,
    3.55 +    .pae_enabled          = vmx_pae_enabled,
    3.56 +    .guest_x86_mode       = vmx_guest_x86_mode,
    3.57 +    .get_guest_ctrl_reg   = vmx_get_ctrl_reg,
    3.58 +    .get_segment_base     = vmx_get_segment_base,
    3.59 +    .get_segment_register = vmx_get_segment_register,
    3.60 +    .update_host_cr3      = vmx_update_host_cr3,
    3.61 +    .update_guest_cr3     = vmx_update_guest_cr3,
    3.62 +    .update_vtpr          = vmx_update_vtpr,
    3.63 +    .stts                 = vmx_stts,
    3.64 +    .set_tsc_offset       = vmx_set_tsc_offset,
    3.65 +    .inject_exception     = vmx_inject_exception,
    3.66 +    .init_ap_context      = vmx_init_ap_context,
    3.67 +    .init_hypercall_page  = vmx_init_hypercall_page,
    3.68 +    .event_injection_faulted = vmx_event_injection_faulted
    3.69 +};
    3.70  
    3.71  int start_vmx(void)
    3.72  {
    3.73 @@ -1095,9 +1082,7 @@ int start_vmx(void)
    3.74  
    3.75      vmx_save_host_msrs();
    3.76  
    3.77 -    vmx_setup_hvm_funcs();
    3.78 -
    3.79 -    hvm_enable();
    3.80 +    hvm_enable(&vmx_function_table);
    3.81  
    3.82      return 1;
    3.83  }
     4.1 --- a/xen/include/asm-x86/hvm/hvm.h	Fri Feb 23 10:47:55 2007 +0000
     4.2 +++ b/xen/include/asm-x86/hvm/hvm.h	Fri Feb 23 11:32:25 2007 +0000
     4.3 @@ -146,8 +146,7 @@ extern struct hvm_function_table hvm_fun
     4.4  static inline void
     4.5  hvm_disable(void)
     4.6  {
     4.7 -    if ( hvm_funcs.disable )
     4.8 -        hvm_funcs.disable();
     4.9 +    hvm_funcs.disable();
    4.10  }
    4.11  
    4.12  int hvm_domain_initialise(struct domain *d);
    4.13 @@ -225,9 +224,7 @@ void hvm_hypercall_page_initialise(struc
    4.14  static inline unsigned long
    4.15  hvm_get_guest_ctrl_reg(struct vcpu *v, unsigned int num)
    4.16  {
    4.17 -    if ( hvm_funcs.get_guest_ctrl_reg )
    4.18 -        return hvm_funcs.get_guest_ctrl_reg(v, num);
    4.19 -    return 0;                   /* force to fail */
    4.20 +    return hvm_funcs.get_guest_ctrl_reg(v, num);
    4.21  }
    4.22  
    4.23  static inline unsigned long
     5.1 --- a/xen/include/asm-x86/hvm/support.h	Fri Feb 23 10:47:55 2007 +0000
     5.2 +++ b/xen/include/asm-x86/hvm/support.h	Fri Feb 23 11:32:25 2007 +0000
     5.3 @@ -260,7 +260,7 @@ int hvm_load(struct domain *d, hvm_domai
     5.4  extern char hvm_io_bitmap[];
     5.5  extern int hvm_enabled;
     5.6  
     5.7 -void hvm_enable(void);
     5.8 +void hvm_enable(struct hvm_function_table *);
     5.9  
    5.10  int hvm_copy_to_guest_phys(paddr_t paddr, void *buf, int size);
    5.11  int hvm_copy_from_guest_phys(void *buf, paddr_t paddr, int size);