ia64/xen-unstable

changeset 6721:ec4a3f2d060e

Add more version and capability reporting to Xen. Print the results with 'xm info'.
Signed-off-by: ian@xensource.com
author iap10@freefall.cl.cam.ac.uk
date Fri Sep 09 15:33:32 2005 +0000 (2005-09-09)
parents 3f4d14357976
children b2f4823b6ff0 16cd990994d5
files linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendNode.py xen/arch/x86/dom0_ops.c xen/arch/x86/setup.c xen/arch/x86/vmx.c xen/common/kernel.c xen/include/public/dom0_ops.h xen/include/public/version.h
line diff
     1.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Sep 09 13:28:23 2005 +0000
     1.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Sep 09 15:33:32 2005 +0000
     1.3 @@ -690,6 +690,8 @@ static PyObject *pyxc_physinfo(PyObject 
     1.4  {
     1.5      XcObject *xc = (XcObject *)self;
     1.6      xc_physinfo_t info;
     1.7 +    char cpu_cap[128], *p=cpu_cap, *q=cpu_cap;
     1.8 +    int i;
     1.9      
    1.10      if ( !PyArg_ParseTuple(args, "") )
    1.11          return NULL;
    1.12 @@ -697,14 +699,25 @@ static PyObject *pyxc_physinfo(PyObject 
    1.13      if ( xc_physinfo(xc->xc_handle, &info) != 0 )
    1.14          return PyErr_SetFromErrno(xc_error);
    1.15  
    1.16 -    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i}",
    1.17 +    *q=0;
    1.18 +    for(i=0;i<sizeof(info.hw_cap)/4;i++)
    1.19 +    {
    1.20 +        p+=sprintf(p,"%08x:",info.hw_cap[i]);
    1.21 +        if(info.hw_cap[i])
    1.22 +	    q=p;
    1.23 +    }
    1.24 +    if(q>cpu_cap)
    1.25 +        *(q-1)=0;
    1.26 +
    1.27 +    return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i,s:s}",
    1.28                           "threads_per_core", info.threads_per_core,
    1.29                           "cores_per_socket", info.cores_per_socket,
    1.30                           "sockets_per_node", info.sockets_per_node,
    1.31                           "nr_nodes",         info.nr_nodes,
    1.32                           "total_pages",      info.total_pages,
    1.33                           "free_pages",       info.free_pages,
    1.34 -                         "cpu_khz",          info.cpu_khz);
    1.35 +                         "cpu_khz",          info.cpu_khz,
    1.36 +                         "hw_caps",          cpu_cap);
    1.37  }
    1.38  
    1.39  static PyObject *pyxc_xeninfo(PyObject *self,
    1.40 @@ -715,7 +728,10 @@ static PyObject *pyxc_xeninfo(PyObject *
    1.41      xen_extraversion_t xen_extra;
    1.42      xen_compile_info_t xen_cc;
    1.43      xen_changeset_info_t xen_chgset;
    1.44 +    xen_capabilities_info_t xen_caps;
    1.45 +    xen_parameters_info_t xen_parms;
    1.46      long xen_version;
    1.47 +    char str[128];
    1.48  
    1.49      xen_version = xc_version(xc->xc_handle, XENVER_version, NULL);
    1.50  
    1.51 @@ -728,10 +744,20 @@ static PyObject *pyxc_xeninfo(PyObject *
    1.52      if ( xc_version(xc->xc_handle, XENVER_changeset, &xen_chgset) != 0 )
    1.53          return PyErr_SetFromErrno(xc_error);
    1.54  
    1.55 -    return Py_BuildValue("{s:i,s:i,s:s,s:s,s:s,s:s,s:s,s:s}",
    1.56 +    if ( xc_version(xc->xc_handle, XENVER_capabilities, &xen_caps) != 0 )
    1.57 +        return PyErr_SetFromErrno(xc_error);
    1.58 +
    1.59 +    if ( xc_version(xc->xc_handle, XENVER_parameters, &xen_parms) != 0 )
    1.60 +        return PyErr_SetFromErrno(xc_error);
    1.61 +
    1.62 +    sprintf(str,"virt_start=0x%lx",xen_parms.virt_start);
    1.63 +
    1.64 +    return Py_BuildValue("{s:i,s:i,s:s,s:s,s:s,s:s,s:s,s:s,s:s,s:s}",
    1.65                           "xen_major", xen_version >> 16,
    1.66                           "xen_minor", (xen_version & 0xffff),
    1.67                           "xen_extra", xen_extra,
    1.68 +                         "xen_caps",  xen_caps.caps,
    1.69 +                         "xen_params", str,
    1.70                           "xen_changeset", xen_chgset,
    1.71                           "cc_compiler", xen_cc.compiler,
    1.72                           "cc_compile_by", xen_cc.compile_by,
     2.1 --- a/tools/python/xen/xend/XendNode.py	Fri Sep 09 13:28:23 2005 +0000
     2.2 +++ b/tools/python/xen/xend/XendNode.py	Fri Sep 09 15:33:32 2005 +0000
     2.3 @@ -58,20 +58,26 @@ class XendNode:
     2.4  
     2.5      def physinfo(self):
     2.6          pinfo = self.xc.physinfo()
     2.7 -        info = [['cores_per_socket', pinfo['cores_per_socket']],
     2.8 +        info = [['nr_cpus',          pinfo['nr_nodes']*pinfo['sockets_per_node']*pinfo['cores_per_socket']*pinfo['threads_per_core']],
     2.9 +                ['nr_nodes',         pinfo['nr_nodes']],
    2.10 +                ['sockets_per_node', pinfo['sockets_per_node']],
    2.11 +                ['cores_per_socket', pinfo['cores_per_socket']],
    2.12                  ['threads_per_core', pinfo['threads_per_core']],
    2.13 -                ['cpu_mhz', pinfo['cpu_khz']/1000],
    2.14 -                ['memory', pinfo['total_pages']/256],
    2.15 -                ['free_memory', pinfo['free_pages']/256]]
    2.16 +                ['cpu_mhz',          pinfo['cpu_khz']/1000],
    2.17 +                ['hw_caps',          pinfo['hw_caps']],
    2.18 +                ['memory',           pinfo['total_pages']/256],
    2.19 +                ['free_memory',      pinfo['free_pages']/256]]
    2.20          return info
    2.21          
    2.22      def xeninfo(self):
    2.23          xinfo = self.xc.xeninfo()
    2.24 -	return [['xen_major', xinfo['xen_major']],
    2.25 -	        ['xen_minor', xinfo['xen_minor']],
    2.26 -	        ['xen_extra', xinfo['xen_extra']],
    2.27 -		['xen_changeset', xinfo['xen_changeset']],
    2.28 -		['cc_compiler', xinfo['cc_compiler']],
    2.29 +        return [['xen_major', xinfo['xen_major']],
    2.30 +                ['xen_minor', xinfo['xen_minor']],
    2.31 +                ['xen_extra', xinfo['xen_extra']],
    2.32 +                ['xen_caps',  xinfo['xen_caps']],
    2.33 +                ['xen_params',xinfo['xen_params']],
    2.34 +                ['xen_changeset', xinfo['xen_changeset']],
    2.35 +                ['cc_compiler', xinfo['cc_compiler']],
    2.36                  ['cc_compile_by', xinfo['cc_compile_by']],
    2.37                  ['cc_compile_domain', xinfo['cc_compile_domain']],
    2.38                  ['cc_compile_date', xinfo['cc_compile_date']]]
     3.1 --- a/xen/arch/x86/dom0_ops.c	Fri Sep 09 13:28:23 2005 +0000
     3.2 +++ b/xen/arch/x86/dom0_ops.c	Fri Sep 09 15:33:32 2005 +0000
     3.3 @@ -19,6 +19,7 @@
     3.4  #include <xen/console.h>
     3.5  #include <asm/shadow.h>
     3.6  #include <asm/irq.h>
     3.7 +#include <asm/processor.h>
     3.8  #include <public/sched_ctl.h>
     3.9  
    3.10  #include <asm/mtrr.h>
    3.11 @@ -188,9 +189,11 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
    3.12          pi->total_pages      = max_page;
    3.13          pi->free_pages       = avail_domheap_pages();
    3.14          pi->cpu_khz          = cpu_khz;
    3.15 -
    3.16 -        copy_to_user(u_dom0_op, op, sizeof(*op));
    3.17 +        memset( pi->hw_cap, 0, sizeof(pi->hw_cap) );
    3.18 +        memcpy( pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4 );
    3.19          ret = 0;
    3.20 +        if( copy_to_user(u_dom0_op, op, sizeof(*op)) )
    3.21 +	    ret = -EINVAL;
    3.22      }
    3.23      break;
    3.24      
     4.1 --- a/xen/arch/x86/setup.c	Fri Sep 09 13:28:23 2005 +0000
     4.2 +++ b/xen/arch/x86/setup.c	Fri Sep 09 15:33:32 2005 +0000
     4.3 @@ -12,6 +12,8 @@
     4.4  #include <xen/trace.h>
     4.5  #include <xen/multiboot.h>
     4.6  #include <xen/domain_page.h>
     4.7 +#include <xen/compile.h>
     4.8 +#include <public/version.h>
     4.9  #include <asm/bitops.h>
    4.10  #include <asm/smp.h>
    4.11  #include <asm/processor.h>
    4.12 @@ -91,6 +93,8 @@ unsigned long mmu_cr4_features = X86_CR4
    4.13  #endif
    4.14  EXPORT_SYMBOL(mmu_cr4_features);
    4.15  
    4.16 +int hvm_enabled = 0; /* can we run unmodified guests */
    4.17 +
    4.18  struct vcpu *idle_task[NR_CPUS] = { &idle0_vcpu };
    4.19  
    4.20  int acpi_disabled;
    4.21 @@ -529,6 +533,45 @@ void __init __start_xen(multiboot_info_t
    4.22      startup_cpu_idle_loop();
    4.23  }
    4.24  
    4.25 +void arch_get_xen_caps(xen_capabilities_info_t *info)
    4.26 +{
    4.27 +    char *p=info->caps;
    4.28 +
    4.29 +    *p=0;
    4.30 +
    4.31 +#ifdef CONFIG_X86_32
    4.32 +
    4.33 +#ifndef CONFIG_X86_PAE       
    4.34 +    p+=sprintf(p,"xen_%d.%d_x86_32 ",XEN_VERSION,XEN_SUBVERSION);    
    4.35 +    if(hvm_enabled)
    4.36 +    {
    4.37 +        p+=sprintf(p,"hvm_%d.%d_x86_32 ",XEN_VERSION,XEN_SUBVERSION);    
    4.38 +    }
    4.39 +#else
    4.40 +    p+=sprintf(p,"xen_%d.%d_x86_32p ",XEN_VERSION,XEN_SUBVERSION);
    4.41 +    if(hvm_enabled)
    4.42 +    {
    4.43 +        //p+=sprintf(p,"hvm_%d.%d_x86_32 ",XEN_VERSION,XEN_SUBVERSION);    
    4.44 +        //p+=sprintf(p,"hvm_%d.%d_x86_32p ",XEN_VERSION,XEN_SUBVERSION);    
    4.45 +    }
    4.46 +
    4.47 +#endif        
    4.48 +
    4.49 +#else /* !CONFIG_X86_32 */
    4.50 +    p+=sprintf(p,"xen_%d.%d_x86_64 ",XEN_VERSION,XEN_SUBVERSION);
    4.51 +    if(hvm_enabled)
    4.52 +    {
    4.53 +        //p+=sprintf(p,"hvm_%d.%d_x86_32 ",XEN_VERSION,XEN_SUBVERSION);    
    4.54 +        //p+=sprintf(p,"hvm_%d.%d_x86_32p ",XEN_VERSION,XEN_SUBVERSION);    
    4.55 +        p+=sprintf(p,"hvm_%d.%d_x86_64 ",XEN_VERSION,XEN_SUBVERSION);    
    4.56 +    }
    4.57 +#endif
    4.58 +    
    4.59 +    BUG_ON((p-info->caps)>sizeof(*info));
    4.60 +
    4.61 +    if(p>info->caps) *(p-1) = 0;
    4.62 +}
    4.63 +
    4.64  /*
    4.65   * Local variables:
    4.66   * mode: C
     5.1 --- a/xen/arch/x86/vmx.c	Fri Sep 09 13:28:23 2005 +0000
     5.2 +++ b/xen/arch/x86/vmx.c	Fri Sep 09 15:33:32 2005 +0000
     5.3 @@ -50,6 +50,8 @@ int vmcs_size;
     5.4  unsigned int opt_vmx_debug_level = 0;
     5.5  integer_param("vmx_debug", opt_vmx_debug_level);
     5.6  
     5.7 +extern int hvm_enabled;
     5.8 +
     5.9  #ifdef TRACE_BUFFER
    5.10  static unsigned long trace_values[NR_CPUS][4];
    5.11  #define TRACE_VMEXIT(index,value) trace_values[current->processor][index]=value
    5.12 @@ -345,6 +347,8 @@ int start_vmx(void)
    5.13  
    5.14      vmx_save_init_msrs();
    5.15  
    5.16 +    hvm_enabled = 1;
    5.17 +
    5.18      return 1;
    5.19  }
    5.20  
     6.1 --- a/xen/common/kernel.c	Fri Sep 09 13:28:23 2005 +0000
     6.2 +++ b/xen/common/kernel.c	Fri Sep 09 15:33:32 2005 +0000
     6.3 @@ -113,16 +113,27 @@ long do_xen_version(int cmd, void *arg)
     6.4  
     6.5      case XENVER_capabilities:
     6.6      {
     6.7 -        struct xen_capabilities_info info;
     6.8 +        xen_capabilities_info_t info;
     6.9 +        extern void arch_get_xen_caps(xen_capabilities_info_t * info);
    6.10          
    6.11 -        /* FIXME */
    6.12 -        info.arch = 0;
    6.13 -        info.pae = 0;
    6.14 +        memset(&info, 0, sizeof(info));
    6.15 +        arch_get_xen_caps(&info);
    6.16 +
    6.17          if ( copy_to_user(arg, &info, sizeof(info)) )
    6.18              return -EFAULT;
    6.19          return 0;
    6.20      }
    6.21      
    6.22 +    case XENVER_parameters:
    6.23 +    {
    6.24 +        xen_parameters_info_t info = { .virt_start = HYPERVISOR_VIRT_START };
    6.25 +
    6.26 +        if ( copy_to_user(arg, &info, sizeof(info)) )
    6.27 +            return -EFAULT;
    6.28 +        return 0;
    6.29 +        
    6.30 +    }
    6.31 +    
    6.32      case XENVER_changeset:
    6.33      {
    6.34          xen_changeset_info_t chgset;
     7.1 --- a/xen/include/public/dom0_ops.h	Fri Sep 09 13:28:23 2005 +0000
     7.2 +++ b/xen/include/public/dom0_ops.h	Fri Sep 09 15:33:32 2005 +0000
     7.3 @@ -213,6 +213,7 @@ typedef struct {
     7.4      u32      cpu_khz;
     7.5      unsigned long total_pages;
     7.6      unsigned long free_pages;
     7.7 +    u32      hw_cap[8];
     7.8  } dom0_physinfo_t;
     7.9  
    7.10  /*
     8.1 --- a/xen/include/public/version.h	Fri Sep 09 13:28:23 2005 +0000
     8.2 +++ b/xen/include/public/version.h	Fri Sep 09 15:33:32 2005 +0000
     8.3 @@ -30,11 +30,15 @@ typedef struct xen_compile_info {
     8.4  
     8.5  #define XENVER_capabilities 3
     8.6  typedef struct xen_capabilities_info {
     8.7 -    int pae;
     8.8 -    int arch;
     8.9 +    char caps[1024];
    8.10  } xen_capabilities_info_t;
    8.11  
    8.12  #define XENVER_changeset 4
    8.13  typedef char xen_changeset_info_t[64];
    8.14  
    8.15 +#define XENVER_parameters 5
    8.16 +typedef struct xen_paramaters_info {
    8.17 +unsigned long virt_start;
    8.18 +} xen_parameters_info_t;
    8.19 +
    8.20  #endif /* __XEN_PUBLIC_VERSION_H__ */