Re: [PATCH] reserve end-of-conventional-memory to 1MB, 32-bit, use paravirt_enabled

Alexander van Heukelum
2008-03-04T18:59:42Z

Jeremy Fitzhardinge pointed out that looking at the boot_params
struct to determine if the system is running in a paravirtual
environment is not reliable for the Xen case, currently. He also
points out that there already exists a function to determine if
the system is running in a paravirtual environment. So let's use
that instead. This gets rid of the preprocessor test too.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>

---

On Tue, Mar 04, 2008 at 09:11:33AM -0800, Jeremy Fitzhardinge wrote:
> Alexander van Heukelum wrote:
> >On Tue, 04 Mar 2008 07:18:48 -0800, "Jeremy Fitzhardinge"
> ><jeremy@goop.org> said:
> >>Yes, is_paravirt() already exists for this purpose.
> >
> >Hi,
> >
> >If it exists, it is well-hidden. A grep for is_paravirt on the testing
> >tree turns up nothing. Did you get the name right?
> >
>
> Nope. paravirt_enabled().

Duh, I should have been able to find that :-/. Thanks for the pointer.

> Just because something is paravirtualized and uses a non-PC
> hardware_subarch doesn't mean this stuff isn't present. Even the
> paravirt_enabled() test isn't accurate, because the environment may
> still choose to emulate these things (or in the Xen dom0 case, it may
> directly expose the real hardware).

paravirt_enabled() returns 0 if CONFIG_PARAVIRT is not set, or if a
paravirt-enabled kernel is run on bare hardware: dom0. If that is right,
then it is exactly what is needed.

Greetings,
Alexander

diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c
index 20e537b..f595d7b 100644
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -64,6 +64,7 @@
#include <setup_arch.h>
#include <bios_ebda.h>
#include <asm/cacheflush.h>
+#include <asm/processor.h>

/* This value is set up by the early boot code to point to the value
immediately after the boot time page tables. It contains a *physical*
@@ -408,12 +409,8 @@ static void __init reserve_ebda_region(void)
/* that area is absent. We'll just have to assume */
/* that the paravirt case can handle memory setup */
/* correctly, without our help. */
-#ifdef CONFIG_PARAVIRT
- if ((boot_params.hdr.version >= 0x207) &&
- (boot_params.hdr.hardware_subarch != 0)) {
+ if (paravirt_enabled())
return;
- }
-#endif

/* end of low (conventional) memory */
lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);