direct-io.hg

changeset 8675:31083f13ae47

Add XENVER_get_features sub-operation to HYPERVISOR_xen_version.

This operation allows a guest OS to determine which features are
supported by the running version of Xen. This changeset contains the
base infrastructure but does not implement any features yet.

Signed-off-by: Ian Campbell <Ian.Campbell@XenSource.com>
Index: xen-features/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
===================================================================
--- xen-features.orig/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c 2006-01-27 11:13:22.000000000 +0000
+++ xen-features/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c 2006-01-27 11:27:14.000000000 +0000
@@ -56,6 +56,7 @@
#include <asm/hypervisor.h>
#include <asm-xen/xen-public/physdev.h>
#include <asm-xen/xen-public/memory.h>
+#include <asm-xen/features.h>
#include "setup_arch_pre.h"
#include <bios_ebda.h>

@@ -1591,6 +1592,9 @@
rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
#endif
+
+ setup_xen_features();
+
ARCH_SETUP
if (efi_enabled)
efi_init();
Index: xen-features/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c
===================================================================
--- xen-features.orig/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c 2006-01-27 11:13:22.000000000 +0000
+++ xen-features/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c 2006-01-27 11:27:14.000000000 +0000
@@ -63,6 +63,7 @@
#include "setup_arch_pre.h"
#include <asm/hypervisor.h>
#include <asm-xen/xen-public/nmi.h>
+#include <asm-xen/features.h>
#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
#define PFN_PHYS(x) ((x) << PAGE_SHIFT)
#define end_pfn_map end_pfn
@@ -587,6 +588,8 @@

#endif

+ setup_xen_features();
+
HYPERVISOR_vm_assist(VMASST_CMD_enable,
VMASST_TYPE_writable_pagetables);

Index: xen-features/linux-2.6-xen-sparse/include/asm-xen/features.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ xen-features/linux-2.6-xen-sparse/include/asm-xen/features.h 2006-01-27 11:27:14.000000000 +0000
@@ -0,0 +1,20 @@
+/******************************************************************************
+ * features.h
+ *
+ * Query the features reported by Xen.
+ *
+ * Copyright (c) 2006, Ian Campbell
+ */
+
+#ifndef __ASM_XEN_FEATURES_H__
+#define __ASM_XEN_FEATURES_H__
+
+#include <asm-xen/xen-public/version.h>
+
+extern void setup_xen_features(void);
+
+extern unsigned long xen_features[XENFEAT_NR_SUBMAPS];
+
+#define xen_feature(flag) (test_bit(_XENFEAT_ ## flag, xen_features))
+
+#endif
Index: xen-features/xen/common/kernel.c
===================================================================
--- xen-features.orig/xen/common/kernel.c 2006-01-27 11:13:22.000000000 +0000
+++ xen-features/xen/common/kernel.c 2006-01-27 11:27:34.000000000 +0000
@@ -144,6 +144,28 @@
return -EFAULT;
return 0;
}
+
+ case XENVER_get_features:
+ {
+ xen_feature_info_t fi;
+
+ if ( copy_from_user(&fi, arg, sizeof(fi)) )
+ return -EFAULT;
+
+ switch ( fi.submap_idx )
+ {
+ case 0:
+ fi.submap = 0;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if ( copy_to_user(arg, &fi, sizeof(fi)) )
+ return -EFAULT;
+ return 0;
+ }
+
}

return -ENOSYS;
Index: xen-features/xen/include/public/version.h
===================================================================
--- xen-features.orig/xen/include/public/version.h 2006-01-27 11:13:22.000000000 +0000
+++ xen-features/xen/include/public/version.h 2006-01-27 11:27:22.000000000 +0000
@@ -39,6 +39,14 @@
unsigned long virt_start;
} xen_platform_parameters_t;

+#define XENVER_get_features 6
+typedef struct xen_feature_info {
+ unsigned int submap_idx; /* IN: which 32-bit submap to return */
+ uint32_t submap; /* OUT: 32-bit submap */
+} xen_feature_info_t;
+
+#define XENFEAT_NR_SUBMAPS 1
+
#endif /* __XEN_PUBLIC_VERSION_H__ */

/*
Index: xen-features/linux-2.6-xen-sparse/arch/xen/kernel/features.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ xen-features/linux-2.6-xen-sparse/arch/xen/kernel/features.c 2006-01-27 11:27:14.000000000 +0000
@@ -0,0 +1,29 @@
+/******************************************************************************
+ * features.c
+ *
+ * Xen feature flags.
+ *
+ * Copyright (c) 2006, Ian Campbell
+ */
+#include <linux/types.h>
+#include <linux/cache.h>
+#include <asm/hypervisor.h>
+#include <asm-xen/features.h>
+
+/* When we rebase to a more recent version of Linux we can use __read_mostly here. */
+unsigned long xen_features[XENFEAT_NR_SUBMAPS] __cacheline_aligned;
+
+void setup_xen_features(void)
+{
+ uint32_t *flags = (uint32_t *)&xen_features[0];
+ xen_feature_info_t fi;
+ int i;
+
+ for (i=0; i<XENFEAT_NR_SUBMAPS; i++) {
+ fi.submap_idx = i;
+ if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0)
+ break;
+ flags[i] = fi.submap;
+ }
+}
+
author Ian.Campbell@xensource.com
date Fri Jan 27 11:31:12 2006 +0000 (2006-01-27)
parents 4be553bcfb0f
children 0eb38397e608
files linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c linux-2.6-xen-sparse/arch/xen/kernel/features.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c linux-2.6-xen-sparse/include/asm-xen/features.h xen/common/kernel.c xen/include/public/version.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Jan 27 11:29:42 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c	Fri Jan 27 11:31:12 2006 +0000
     1.3 @@ -56,6 +56,7 @@
     1.4  #include <asm/hypervisor.h>
     1.5  #include <asm-xen/xen-public/physdev.h>
     1.6  #include <asm-xen/xen-public/memory.h>
     1.7 +#include <asm-xen/features.h>
     1.8  #include "setup_arch_pre.h"
     1.9  #include <bios_ebda.h>
    1.10  
    1.11 @@ -1591,6 +1592,9 @@ void __init setup_arch(char **cmdline_p)
    1.12  	rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
    1.13  	rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
    1.14  #endif
    1.15 +
    1.16 +	setup_xen_features();
    1.17 +
    1.18  	ARCH_SETUP
    1.19  	if (efi_enabled)
    1.20  		efi_init();
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/features.c	Fri Jan 27 11:31:12 2006 +0000
     2.3 @@ -0,0 +1,29 @@
     2.4 +/******************************************************************************
     2.5 + * features.c
     2.6 + *
     2.7 + * Xen feature flags.
     2.8 + *
     2.9 + * Copyright (c) 2006, Ian Campbell
    2.10 + */
    2.11 +#include <linux/types.h>
    2.12 +#include <linux/cache.h>
    2.13 +#include <asm/hypervisor.h>
    2.14 +#include <asm-xen/features.h>
    2.15 +
    2.16 +/* When we rebase to a more recent version of Linux we can use __read_mostly here. */
    2.17 +unsigned long xen_features[XENFEAT_NR_SUBMAPS] __cacheline_aligned;
    2.18 +
    2.19 +void setup_xen_features(void)
    2.20 +{
    2.21 +     uint32_t *flags = (uint32_t *)&xen_features[0];
    2.22 +     xen_feature_info_t fi;
    2.23 +     int i;
    2.24 +
    2.25 +     for (i=0; i<XENFEAT_NR_SUBMAPS; i++) {
    2.26 +	  fi.submap_idx = i;
    2.27 +	  if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0)
    2.28 +	       break;
    2.29 +	  flags[i] = fi.submap;
    2.30 +     }
    2.31 +}
    2.32 +
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Jan 27 11:29:42 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c	Fri Jan 27 11:31:12 2006 +0000
     3.3 @@ -63,6 +63,7 @@
     3.4  #include "setup_arch_pre.h"
     3.5  #include <asm/hypervisor.h>
     3.6  #include <asm-xen/xen-public/nmi.h>
     3.7 +#include <asm-xen/features.h>
     3.8  #define PFN_UP(x)       (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
     3.9  #define PFN_PHYS(x)     ((x) << PAGE_SHIFT)
    3.10  #define end_pfn_map end_pfn
    3.11 @@ -587,6 +588,8 @@ void __init setup_arch(char **cmdline_p)
    3.12  
    3.13  #endif
    3.14  
    3.15 +	setup_xen_features();
    3.16 +
    3.17  	HYPERVISOR_vm_assist(VMASST_CMD_enable,
    3.18  			     VMASST_TYPE_writable_pagetables);
    3.19  
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/features.h	Fri Jan 27 11:31:12 2006 +0000
     4.3 @@ -0,0 +1,20 @@
     4.4 +/******************************************************************************
     4.5 + * features.h
     4.6 + *
     4.7 + * Query the features reported by Xen.
     4.8 + *
     4.9 + * Copyright (c) 2006, Ian Campbell
    4.10 + */
    4.11 +
    4.12 +#ifndef __ASM_XEN_FEATURES_H__
    4.13 +#define __ASM_XEN_FEATURES_H__
    4.14 +
    4.15 +#include <asm-xen/xen-public/version.h>
    4.16 +
    4.17 +extern void setup_xen_features(void);
    4.18 +
    4.19 +extern unsigned long xen_features[XENFEAT_NR_SUBMAPS];
    4.20 +
    4.21 +#define xen_feature(flag)	(test_bit(_XENFEAT_ ## flag, xen_features))
    4.22 +
    4.23 +#endif
     5.1 --- a/xen/common/kernel.c	Fri Jan 27 11:29:42 2006 +0000
     5.2 +++ b/xen/common/kernel.c	Fri Jan 27 11:31:12 2006 +0000
     5.3 @@ -144,6 +144,28 @@ long do_xen_version(int cmd, void *arg)
     5.4              return -EFAULT;
     5.5          return 0;
     5.6      }
     5.7 +
     5.8 +    case XENVER_get_features:
     5.9 +    {
    5.10 +        xen_feature_info_t fi;
    5.11 +
    5.12 +        if ( copy_from_user(&fi, arg, sizeof(fi)) )
    5.13 +            return -EFAULT;
    5.14 +
    5.15 +        switch ( fi.submap_idx )
    5.16 +        {
    5.17 +        case 0:
    5.18 +            fi.submap = 0;
    5.19 +            break;
    5.20 +        default:
    5.21 +            return -EINVAL;
    5.22 +        }
    5.23 +
    5.24 +        if ( copy_to_user(arg, &fi, sizeof(fi)) )
    5.25 +            return -EFAULT;
    5.26 +        return 0;
    5.27 +    }
    5.28 +
    5.29      }
    5.30  
    5.31      return -ENOSYS;
     6.1 --- a/xen/include/public/version.h	Fri Jan 27 11:29:42 2006 +0000
     6.2 +++ b/xen/include/public/version.h	Fri Jan 27 11:31:12 2006 +0000
     6.3 @@ -39,6 +39,14 @@ typedef struct xen_platform_parameters {
     6.4      unsigned long virt_start;
     6.5  } xen_platform_parameters_t;
     6.6  
     6.7 +#define XENVER_get_features 6
     6.8 +typedef struct xen_feature_info {
     6.9 +    unsigned int submap_idx;    /* IN: which 32-bit submap to return */
    6.10 +    uint32_t     submap;        /* OUT: 32-bit submap */
    6.11 +} xen_feature_info_t;
    6.12 +
    6.13 +#define XENFEAT_NR_SUBMAPS 1
    6.14 +
    6.15  #endif /* __XEN_PUBLIC_VERSION_H__ */
    6.16  
    6.17  /*