Skip to contentSkip to conversation

Remove PSE flag from guest CR4

PATCH In review Dave McCracken 3 participants 5 messages Sep 14, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove PSE flag from guest CR4

When I originally did the Xen hypervisor hugepage patch I also allowed guests to see the PSE flag in CR4. This has proven to be a mistake. Here is a patch to remove that functionality.

All Linux kernels will still allow userspace hugepages without the flag.

Dave McCracken

./xen/arch/x86/traps.c +3 -7
@@ -752,8 +752,7 @@ static void pv_cpuid(struct cpu_user_reg
         __clear_bit(X86_FEATURE_VME, &d);
         if ( !cpu_has_apic )
             __clear_bit(X86_FEATURE_APIC, &d);
-        if ( !opt_allow_hugepage )
-            __clear_bit(X86_FEATURE_PSE, &d);
+        __clear_bit(X86_FEATURE_PSE, &d);
         __clear_bit(X86_FEATURE_PGE, &d);
         __clear_bit(X86_FEATURE_PSE36, &d);
     }
@@ -2064,12 +2063,9 @@ static int emulate_privileged_op(struct 
         case 4: /* Read CR4 */
             /*
              * Guests can read CR4 to see what features Xen has enabled. We
-             * therefore lie about PGE as it is unavailable to guests.
-             * Also disallow PSE if hugepages are not enabled.
+             * therefore lie about PGE and PSE as they are unavailable to guests.
              */
-            *reg = read_cr4() & ~X86_CR4_PGE;
-            if ( !opt_allow_hugepage )
-                *reg &= ~X86_CR4_PSE;
+            *reg = read_cr4() & ~(X86_CR4_PGE|X86_CR4_PSE);
             break;
 
         default:

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

If you hide PSE in CR4 and CPUID, how does the guest know it can use superpages?

-- Keir

Quoted 8 lines · Dave McCracken

When I originally did the Xen hypervisor hugepage patch I also allowed guests to see the PSE flag in CR4. This has proven to be a mistake. Here is a patch to remove that functionality.

All Linux kernels will still allow userspace hugepages without the flag.

Dave McCracken

#2 lore raw
Quoted 2 lines · Keir Fraser

If you hide PSE in CR4 and CPUID, how does the guest know it can use superpages?

Linux assumes it will just work.

Since hugepages in Linux are an optional feature the kernel will boot even on a machine that doesn't support PSE. Applications that use hugepages will get a nasty error.

With the PSE bit set in CPUID Linux tries to do things like map the entire kernel in hugepages.

Dave McCracken

#3 lore raw
Quoted 6 lines · Dave McCracken

Linux assumes it will just work.

Since hugepages in Linux are an optional feature the kernel will boot even on a machine that doesn't support PSE. Applications that use hugepages will get a nasty error.

That sounds like a Linux bug; at the very least, it sounds very fragile to rely on this behaviour.

J

#4 lore raw
Quoted 9 lines · Jeremy Fitzhardinge
Quoted 5 lines · Dave McCracken

Linux assumes it will just work.

Since hugepages in Linux are an optional feature the kernel will boot even on a machine that doesn't support PSE. Applications that use hugepages will get a nasty error.

That sounds like a Linux bug; at the very least, it sounds very fragile to rely on this behaviour.

Perhaps, but hugepages has always worked like that. I think the reality is that any machine small enough/old enough to not support PSE is way too small for hugepages to be useful on it, so no one tries to run it on those machines.

Dave McCracken