[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Add XENVER_get_features sub-operation to HYPERVISOR_xen_version.



# HG changeset patch
# User Ian.Campbell@xxxxxxxxxxxxx
# Node ID 31083f13ae47f55bc86407450c37eb1e6d8656e7
# Parent  4be553bcfb0fa5c47b5e8831463dec3d1e1e7db1
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@xxxxxxxxxxxxx>
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;
+     }
+}
+

diff -r 4be553bcfb0f -r 31083f13ae47 
linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Fri Jan 27 11:29:42 2006
+++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c Fri Jan 27 11:31:12 2006
@@ -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();
diff -r 4be553bcfb0f -r 31083f13ae47 
linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c
--- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c       Fri Jan 27 
11:29:42 2006
+++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup.c       Fri Jan 27 
11:31:12 2006
@@ -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);
 
diff -r 4be553bcfb0f -r 31083f13ae47 xen/common/kernel.c
--- a/xen/common/kernel.c       Fri Jan 27 11:29:42 2006
+++ b/xen/common/kernel.c       Fri Jan 27 11:31:12 2006
@@ -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;
diff -r 4be553bcfb0f -r 31083f13ae47 xen/include/public/version.h
--- a/xen/include/public/version.h      Fri Jan 27 11:29:42 2006
+++ b/xen/include/public/version.h      Fri Jan 27 11:31:12 2006
@@ -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__ */
 
 /*
diff -r 4be553bcfb0f -r 31083f13ae47 
linux-2.6-xen-sparse/arch/xen/kernel/features.c
--- /dev/null   Fri Jan 27 11:29:42 2006
+++ b/linux-2.6-xen-sparse/arch/xen/kernel/features.c   Fri Jan 27 11:31:12 2006
@@ -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;
+     }
+}
+
diff -r 4be553bcfb0f -r 31083f13ae47 
linux-2.6-xen-sparse/include/asm-xen/features.h
--- /dev/null   Fri Jan 27 11:29:42 2006
+++ b/linux-2.6-xen-sparse/include/asm-xen/features.h   Fri Jan 27 11:31:12 2006
@@ -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

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.