Skip to contentSkip to conversation

HAP: Add global enable/disable command line option

PATCH Superseded Andrew Cooper 2 participants 2 messages Jan 25, 2013 – Jan 28, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HAP: Add global enable/disable command line option

Also, correct a copy&paste error in the documentation.

---

This patch has been in the XenServer patch queue for a long time. It is more for debugging purposes than anything else, but is still proving to be valuable for tracking down bugs with HVM paging operations.

docs/misc/xen-command-line.markdown +9 -1
diff -r 5af4f2ab06f3 -r e6ec5b2b717f docs/misc/xen-command-line.markdown
@@ -521,6 +521,14 @@ more importance will be printed.
 The optional `<rate-limited level>` option instructs which severities
 should be rate limited.
 
+### hap
+> `= <boolean>`
+
+> Default: `true`
+
+Flag to globally enable or disable support for Hardware Assisted
+Paging (HAP)
+
 ### hap\_1gb
 > `= <boolean>`
 
@@ -534,7 +542,7 @@ Paging (HAP).
 
 > Default: `true`
 
-Flag to enable 1 GB host page table support for Hardware Assisted
+Flag to enable 2 MB host page table support for Hardware Assisted
 Paging (HAP).
 
 ### hpetbroadcast
xen/arch/x86/hvm/hvm.c +20 -7
diff -r 5af4f2ab06f3 -r e6ec5b2b717f xen/arch/x86/hvm/hvm.c
@@ -78,6 +78,10 @@ struct hvm_function_table hvm_funcs __re
 unsigned long __attribute__ ((__section__ (".bss.page_aligned")))
     hvm_io_bitmap[3*PAGE_SIZE/BYTES_PER_LONG];
 
+/* Xen command-line option to enable HAP */
+static int opt_hap_enabled = 1;
+boolean_param("hap", opt_hap_enabled);
+
 static int cpu_callback(
     struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
@@ -125,14 +129,23 @@ static int __init hvm_enable(void)
     printk("HVM: %s enabled\n", hvm_funcs.name);
     if ( hvm_funcs.hap_supported )
     {
-        printk("HVM: Hardware Assisted Paging (HAP) detected\n");
-        printk("HVM: HAP page sizes: 4kB");
-        if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB )
-            printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]");
-        if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB )
-            printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]");
-        printk("\n");
+        hvm_funcs.hap_supported = hvm_funcs.hap_supported && opt_hap_enabled;
+
+        if ( hvm_funcs.hap_supported )
+        {
+            printk("HVM: Hardware Assisted Paging (HAP) detected\n");
+            printk("HVM: HAP page sizes: 4kB");
+            if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB )
+                printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]");
+            if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB )
+                printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]");
+            printk("\n");
+        }
+        else
+            printk("HVM: Hardware Assisted Paging (HAP) detected but disabled\n");
     }
+    else
+        printk("HVM: Hardware Assisted Paging (HAP) not detected\n");
 
     /*
      * Allow direct access to the PC debug ports 0x80 and 0xed (they are
#1 lore raw
Quoted 44 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper

Also, correct a copy&paste error in the documentation.

---

This patch has been in the XenServer patch queue for a long time. It is more
for debugging purposes than anything else, but is still proving to be valuable
for tracking down bugs with HVM paging operations.

diff -r 5af4f2ab06f3 -r e6ec5b2b717f docs/misc/xen-command-line.markdown

docs/misc/xen-command-line.markdown +9 -1
@@ -521,6 +521,14 @@ more importance will be printed.
 The optional `<rate-limited level>` option instructs which severities
 should be rate limited.
 
+### hap
+> `= <boolean>`
+
+> Default: `true`
+
+Flag to globally enable or disable support for Hardware Assisted
+Paging (HAP)
+
 ### hap\_1gb
 > `= <boolean>`
 
@@ -534,7 +542,7 @@ Paging (HAP).
 
 > Default: `true`
 
-Flag to enable 1 GB host page table support for Hardware Assisted
+Flag to enable 2 MB host page table support for Hardware Assisted
 Paging (HAP).
 
 ### hpetbroadcast

diff -r 5af4f2ab06f3 -r e6ec5b2b717f xen/arch/x86/hvm/hvm.c

xen/arch/x86/hvm/hvm.c struct hvm_function_table hvm_funcs __re · line 82

Quoted 5 lines
xen/arch/x86/hvm/hvm.c +2 -0
@@ -78,6 +78,10 @@ struct hvm_function_table hvm_funcs __re
 unsigned long __attribute__ ((__section__ (".bss.page_aligned")))
     hvm_io_bitmap[3*PAGE_SIZE/BYTES_PER_LONG];
 
+/* Xen command-line option to enable HAP */
+static int opt_hap_enabled = 1;

bool_t __initdata

Quoted 23 lines
xen/arch/x86/hvm/hvm.c +9 -7
+boolean_param("hap", opt_hap_enabled);
+
 static int cpu_callback(
     struct notifier_block *nfb, unsigned long action, void *hcpu)
 {
@@ -125,14 +129,23 @@ static int __init hvm_enable(void)
     printk("HVM: %s enabled\n", hvm_funcs.name);
     if ( hvm_funcs.hap_supported )
     {
-        printk("HVM: Hardware Assisted Paging (HAP) detected\n");
-        printk("HVM: HAP page sizes: 4kB");
-        if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB )
-            printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]");
-        if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB )
-            printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]");
-        printk("\n");
+        hvm_funcs.hap_supported = hvm_funcs.hap_supported && opt_hap_enabled;
+
+        if ( hvm_funcs.hap_supported )
+        {
+            printk("HVM: Hardware Assisted Paging (HAP) detected\n");
+            printk("HVM: HAP page sizes: 4kB");
+            if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB )

xen/arch/x86/hvm/hvm.c static int __init hvm_enable(void) · line 148

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +9 -0
+                printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]");
+            if ( hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB )
+                printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]");
+            printk("\n");
+        }
+        else
+            printk("HVM: Hardware Assisted Paging (HAP) detected but disabled\n");
     }
+    else
+        printk("HVM: Hardware Assisted Paging (HAP) not detected\n");

Also, with a suitable if/else-if sequence you could reduce the churn (and the level of indentation):

if ( !hvm_funcs.hap_supported )
...
else if ( !opt_hap_enabled )
...
else

Jan

Quoted 3 lines
xen/arch/x86/hvm/hvm.c +0 -0
     /*
      * Allow direct access to the PC debug ports 0x80 and 0xed (they are