All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH xen-unstable] Remove PSE flag from guest CR4
@ 2009-09-14 17:27 Dave McCracken
  2009-09-14 17:42 ` Keir Fraser
  0 siblings, 1 reply; 5+ messages in thread
From: Dave McCracken @ 2009-09-14 17:27 UTC (permalink / raw)
  To: Xen Developers List, Keir Fraser; +Cc: Jeremy Fitzhardinge

[-- Attachment #1: Type: Text/Plain, Size: 280 bytes --]


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

[-- Attachment #2: xen-hpage-090914-1.patch --]
[-- Type: text/x-patch, Size: 1204 bytes --]

--- xen-unstable/./xen/arch/x86/traps.c	2009-09-14 12:15:46.000000000 -0500
+++ xen-hpage/./xen/arch/x86/traps.c	2009-09-14 12:18:42.000000000 -0500
@@ -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:

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH xen-unstable] Remove PSE flag from guest CR4
  2009-09-14 17:27 [PATCH xen-unstable] Remove PSE flag from guest CR4 Dave McCracken
@ 2009-09-14 17:42 ` Keir Fraser
  2009-09-14 17:53   ` Dave McCracken
  0 siblings, 1 reply; 5+ messages in thread
From: Keir Fraser @ 2009-09-14 17:42 UTC (permalink / raw)
  To: Dave McCracken, Xen Developers List; +Cc: Jeremy Fitzhardinge

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

 -- Keir

On 14/09/2009 18:27, "Dave McCracken" <dcm@mccr.org> wrote:

> 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH xen-unstable] Remove PSE flag from guest CR4
  2009-09-14 17:42 ` Keir Fraser
@ 2009-09-14 17:53   ` Dave McCracken
  2009-09-14 19:07     ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 5+ messages in thread
From: Dave McCracken @ 2009-09-14 17:53 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Jeremy Fitzhardinge, Xen Developers List

On Monday 14 September 2009, Keir Fraser wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH xen-unstable] Remove PSE flag from guest CR4
  2009-09-14 17:53   ` Dave McCracken
@ 2009-09-14 19:07     ` Jeremy Fitzhardinge
  2009-09-14 19:47       ` Dave McCracken
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2009-09-14 19:07 UTC (permalink / raw)
  To: Dave McCracken; +Cc: Xen Developers List, Keir Fraser

On 09/14/09 10:53, Dave McCracken wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH xen-unstable] Remove PSE flag from guest CR4
  2009-09-14 19:07     ` Jeremy Fitzhardinge
@ 2009-09-14 19:47       ` Dave McCracken
  0 siblings, 0 replies; 5+ messages in thread
From: Dave McCracken @ 2009-09-14 19:47 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Xen Developers List, Keir Fraser

On Monday 14 September 2009, Jeremy Fitzhardinge wrote:
> On 09/14/09 10:53, Dave McCracken wrote:
> > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-09-14 19:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-14 17:27 [PATCH xen-unstable] Remove PSE flag from guest CR4 Dave McCracken
2009-09-14 17:42 ` Keir Fraser
2009-09-14 17:53   ` Dave McCracken
2009-09-14 19:07     ` Jeremy Fitzhardinge
2009-09-14 19:47       ` Dave McCracken

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.