Skip to contentSkip to conversation

Suppress false "mtrr all empty" warning message when running as VMware guest

PATCH In review Yan Li 5 participants 12 messages Sep 24, 2008 – Oct 5, 2008 1 message not in the archive x86

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): a120cfa37281607d8dc361deda1a35419accd193.1222258080.git.elliot.li.tech@gmail.com

Yan Li

author
#1 lore raw

PATCH 2/2 Suppress false "mtrr all empty" warning message when running as VMware guest

Since the mtrr empty was detected very early before we can use DMI or PCI to check whether we are running as a VMware guest or not, we now only print an info there. Warning will only be issued later when we are sure that we are not running as a VMware guest.

mtrr_trim_uncached_memory() is modified to return meaningful codes for later warning decision.

---
 arch/x86/kernel/cpu/mtrr/main.c |   16 +++++++++++++++-
 arch/x86/kernel/setup.c         |   27 ++++++++++++++++++++++++++-
 include/asm-x86/mtrr.h          |    2 ++
 3 files changed, 43 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mtrr/main.c +15 -1
index b117d7f..95d1cc0 100644
@@ -1453,6 +1453,11 @@ static u64 __init real_trim_memory(unsigned long start_pfn,
  * all of the memory the kernel is intending to use. If not, it'll trim any
  * memory off the end by adjusting end_pfn, removing it from the kernel's
  * allocation pools, warning the user with an obnoxious message.
+ *
+ * Return code:
+ * EMTRR_ALL_BLANK (-1):  not trimmed due to CPU MTRRs all blank
+ *                    0:  not trimmed due to other reasons
+ *                    1:  trimmed successfully
  */
 int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 {
@@ -1494,11 +1499,20 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 			highest_pfn = base + size;
 	}
 
-	/* kvm/qemu doesn't have mtrr set right, don't trim them all */
+	/* kvm/qemu/VMware doesn't have mtrr set right, don't trim them all */
 	if (!highest_pfn) {
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+		/* the "mtrr all blank" warning will be deferred until
+		 * after DMI scanning and we know the machine is not a
+		 * VMware guest
+		 */
+		printk(KERN_INFO "CPU MTRRs all blank\n");
+		return EMTRR_ALL_BLANK;
+#else
 		WARN(!kvm_para_available(), KERN_WARNING
 				"WARNING: strange, CPU MTRRs all blank?\n");
 		return 0;
+#endif
 	}
 
 	/* check entries number */
arch/x86/kernel/setup.c +26 -1
index 9838f25..4cbec10 100644
@@ -102,6 +102,7 @@
 #include <asm/percpu.h>
 #include <asm/topology.h>
 #include <asm/apicdef.h>
+#include <asm/vmware.h>
 #ifdef CONFIG_X86_64
 #include <asm/numa_64.h>
 #endif
@@ -593,6 +594,13 @@ struct x86_quirks *x86_quirks __initdata = &default_x86_quirks;
 
 void __init setup_arch(char **cmdline_p)
 {
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+	/* the "mtrr all blank" warning will be deferred until after
+	 * DMI scanning and we know the machine is not a VMware guest
+	 */
+	int cpu_mtrr_all_blank_later_warning = 0;
+#endif
+
 #ifdef CONFIG_X86_32
 	memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
 	visws_early_detect();
@@ -733,8 +741,16 @@ void __init setup_arch(char **cmdline_p)
 	early_reserve_e820_mpc_new();
 	/* update e820 for memory not covered by WB MTRRs */
 	mtrr_bp_init();
-	if (mtrr_trim_uncached_memory(max_pfn))
+	switch (mtrr_trim_uncached_memory(max_pfn)) {
+	case 1:
 		max_pfn = e820_end_of_ram_pfn();
+		break;
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+	case EMTRR_ALL_BLANK:
+		cpu_mtrr_all_blank_later_warning = 1;
+		break;
+#endif
+	}
 
 #ifdef CONFIG_X86_32
 	/* max_low_pfn get updated here */
@@ -783,6 +799,15 @@ void __init setup_arch(char **cmdline_p)
 
 	dmi_scan_machine();
 
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+	if (cpu_mtrr_all_blank_later_warning) {
+		WARN(!(kvm_para_available() || (is_vmware_guest())),
+		     KERN_WARNING
+		     "WARNING: strange, CPU MTRRs all blank? "
+		     "Deferred from mtrr_trim_uncached_memory()\n");
+	}
+#endif
+
 	io_delay_init();
 
 	/*
include/asm-x86/mtrr.h +2 -0
index a69a01a..b6d8fcb 100644
@@ -26,6 +26,8 @@
 #include <linux/ioctl.h>
 #include <linux/errno.h>
 
+#define	EMTRR_ALL_BLANK (-1)
+
 #define	MTRR_IOCTL_BASE	'M'
 
 struct mtrr_sentry {
Signature · 9 lines
1.5.4.3


-- 
Li, Yan

"Everything that is really great and inspiring is created by the
individual who can labor in freedom."
              - Albert Einstein, in Out of My Later Years (1950)
#2 lore raw
Quoted 41 lines · Yan Li

Since the mtrr empty was detected very early before we can use DMI or PCI to check whether we are running as a VMware guest or not, we now only print an info there. Warning will only be issued later when we are sure that we are not running as a VMware guest.

mtrr_trim_uncached_memory() is modified to return meaningful codes for later warning decision.

---
 arch/x86/kernel/cpu/mtrr/main.c |   16 +++++++++++++++-
 arch/x86/kernel/setup.c         |   27 ++++++++++++++++++++++++++-
 include/asm-x86/mtrr.h          |    2 ++
 3 files changed, 43 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mtrr/main.c +9 -1
index b117d7f..95d1cc0 100644
@@ -1453,6 +1453,11 @@ static u64 __init real_trim_memory(unsigned long start_pfn,
  * all of the memory the kernel is intending to use. If not, it'll trim any
  * memory off the end by adjusting end_pfn, removing it from the kernel's
  * allocation pools, warning the user with an obnoxious message.
+ *
+ * Return code:
+ * EMTRR_ALL_BLANK (-1):  not trimmed due to CPU MTRRs all blank
+ *                    0:  not trimmed due to other reasons
+ *                    1:  trimmed successfully
  */
 int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 {
@@ -1494,11 +1499,20 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 			highest_pfn = base + size;
 	}
 
-	/* kvm/qemu doesn't have mtrr set right, don't trim them all */
+	/* kvm/qemu/VMware doesn't have mtrr set right, don't trim them all */
 	if (!highest_pfn) {
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+		/* the "mtrr all blank" warning will be deferred until
+		 * after DMI scanning and we know the machine is not a

arch/x86/kernel/cpu/mtrr/main.c int __init mtrr_trim_uncached_memory(unsigned long end_pfn) · line 1516

Quoted 10 lines
arch/x86/kernel/cpu/mtrr/main.c +6 -0
+		 * VMware guest
+		 */
+		printk(KERN_INFO "CPU MTRRs all blank\n");
+		return EMTRR_ALL_BLANK;
+#else
 		WARN(!kvm_para_available(), KERN_WARNING
 				"WARNING: strange, CPU MTRRs all blank?\n");
 		return 0;
+#endif
 	}

perhaps something like:

#ifdef CONFIG_VMWARE_GUEST_DETECT
WARN(!kvm_para_available() && !is_vmware_guest(), KERN_WARNING

				"WARNING: strange, CPU MTRRs all blank?\n");

#else
WARN(!kvm_para_available(), KERN_WARNING
"WARNING: strange, CPU MTRRs all blank?\n");
...

???

Laurent

Signature · 3 lines
----------------- [email protected]  ------------------
  "La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
author
#3 lore raw
Quoted 19 lines · Laurent Vivier

arch/x86/kernel/cpu/mtrr/main.c int __init mtrr_trim_uncached_memory(unsigned long end_pfn) · line 1516

Quoted 13 lines · Yan Li
arch/x86/kernel/cpu/mtrr/main.c +9 -0
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+		/* the "mtrr all blank" warning will be deferred until
+		 * after DMI scanning and we know the machine is not a
+		 * VMware guest
+		 */
+		printk(KERN_INFO "CPU MTRRs all blank\n");
+		return EMTRR_ALL_BLANK;
+#else
 		WARN(!kvm_para_available(), KERN_WARNING
 				"WARNING: strange, CPU MTRRs all blank?\n");
 		return 0;
+#endif
 	}

perhaps something like:

#ifdef CONFIG_VMWARE_GUEST_DETECT
WARN(!kvm_para_available() && !is_vmware_guest(), KERN_WARNING

Quoted 7 lines
				"WARNING: strange, CPU MTRRs all blank?\n");

#else
WARN(!kvm_para_available(), KERN_WARNING
"WARNING: strange, CPU MTRRs all blank?\n");
...

???

As stated in the comments: the warning has to be deferred. The reason is that "is_vmware_guest()" replies on DMI and can only be used after dmi_scan(). These mtrr codes here are run very early during setup_arch() when the DMI is not available. So when I've detected all MTRRs are blank, I returned a status code to setup_arch(), who will call "is_vmware_guest()" later, after dmi_scan(), to decide whether to issue a warning or not.

Signature · 5 lines
Li, Yan

"Everything that is really great and inspiring is created by the
individual who can labor in freedom."
              - Albert Einstein, in Out of My Later Years (1950)
#4 lore raw
In reply to Yan Li
Quoted 7 lines · Yan Li

Since the mtrr empty was detected very early before we can use DMI or PCI to check whether we are running as a VMware guest or not, we now only print an info there. Warning will only be issued later when we are sure that we are not running as a VMware guest.

mtrr_trim_uncached_memory() is modified to return meaningful codes for later warning decision.

A lot of code if #ifdef'ed to vmware. Can you hide this into a header file? This way its not very clean code I think.

Quoted 32 lines
---
 arch/x86/kernel/cpu/mtrr/main.c |   16 +++++++++++++++-
 arch/x86/kernel/setup.c         |   27 ++++++++++++++++++++++++++-
 include/asm-x86/mtrr.h          |    2 ++
 3 files changed, 43 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mtrr/main.c +8 -1
index b117d7f..95d1cc0 100644
@@ -1453,6 +1453,11 @@ static u64 __init real_trim_memory(unsigned long start_pfn,
  * all of the memory the kernel is intending to use. If not, it'll trim any
  * memory off the end by adjusting end_pfn, removing it from the kernel's
  * allocation pools, warning the user with an obnoxious message.
+ *
+ * Return code:
+ * EMTRR_ALL_BLANK (-1):  not trimmed due to CPU MTRRs all blank
+ *                    0:  not trimmed due to other reasons
+ *                    1:  trimmed successfully
  */
 int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 {
@@ -1494,11 +1499,20 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 			highest_pfn = base + size;
 	}
 
-	/* kvm/qemu doesn't have mtrr set right, don't trim them all */
+	/* kvm/qemu/VMware doesn't have mtrr set right, don't trim them all */
 	if (!highest_pfn) {
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+		/* the "mtrr all blank" warning will be deferred until

arch/x86/kernel/cpu/mtrr/main.c int __init mtrr_trim_uncached_memory(unsigned long end_pfn) · line 1515

Quoted 10 lines
arch/x86/kernel/cpu/mtrr/main.c +7 -0
+		 * after DMI scanning and we know the machine is not a
+		 * VMware guest
+		 */
+		printk(KERN_INFO "CPU MTRRs all blank\n");
+		return EMTRR_ALL_BLANK;
+#else
 		WARN(!kvm_para_available(), KERN_WARNING
 				"WARNING: strange, CPU MTRRs all blank?\n");
 		return 0;
+#endif

Can we move the WARN after the DMI scanning for all cases? This will save this #ifdef and is a cleaner approach imho.

Quoted 87 lines
arch/x86/kernel/cpu/mtrr/main.c +0 -0
 	}
 
 	/* check entries number */
arch/x86/kernel/setup.c +26 -1
index 9838f25..4cbec10 100644
@@ -102,6 +102,7 @@
 #include <asm/percpu.h>
 #include <asm/topology.h>
 #include <asm/apicdef.h>
+#include <asm/vmware.h>
 #ifdef CONFIG_X86_64
 #include <asm/numa_64.h>
 #endif
@@ -593,6 +594,13 @@ struct x86_quirks *x86_quirks __initdata = &default_x86_quirks;
 
 void __init setup_arch(char **cmdline_p)
 {
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+	/* the "mtrr all blank" warning will be deferred until after
+	 * DMI scanning and we know the machine is not a VMware guest
+	 */
+	int cpu_mtrr_all_blank_later_warning = 0;
+#endif
+
 #ifdef CONFIG_X86_32
 	memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
 	visws_early_detect();
@@ -733,8 +741,16 @@ void __init setup_arch(char **cmdline_p)
 	early_reserve_e820_mpc_new();
 	/* update e820 for memory not covered by WB MTRRs */
 	mtrr_bp_init();
-	if (mtrr_trim_uncached_memory(max_pfn))
+	switch (mtrr_trim_uncached_memory(max_pfn)) {
+	case 1:
 		max_pfn = e820_end_of_ram_pfn();
+		break;
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+	case EMTRR_ALL_BLANK:
+		cpu_mtrr_all_blank_later_warning = 1;
+		break;
+#endif
+	}
 
 #ifdef CONFIG_X86_32
 	/* max_low_pfn get updated here */
@@ -783,6 +799,15 @@ void __init setup_arch(char **cmdline_p)
 
 	dmi_scan_machine();
 
+#ifdef CONFIG_VMWARE_GUEST_DETECT
+	if (cpu_mtrr_all_blank_later_warning) {
+		WARN(!(kvm_para_available() || (is_vmware_guest())),
+		     KERN_WARNING
+		     "WARNING: strange, CPU MTRRs all blank? "
+		     "Deferred from mtrr_trim_uncached_memory()\n");
+	}
+#endif
+
 	io_delay_init();
 
 	/*
include/asm-x86/mtrr.h +2 -0
index a69a01a..b6d8fcb 100644
@@ -26,6 +26,8 @@
 #include <linux/ioctl.h>
 #include <linux/errno.h>
 
+#define	EMTRR_ALL_BLANK (-1)
+
 #define	MTRR_IOCTL_BASE	'M'
 
 struct mtrr_sentry {
Signature · 9 lines
1.5.4.3


-- 
Li, Yan

"Everything that is really great and inspiring is created by the
individual who can labor in freedom."
              - Albert Einstein, in Out of My Later Years (1950)
Signature · 6 lines
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
author
#5 lore raw
Quoted 2 lines · Joerg Roedel

A lot of code if #ifdef'ed to vmware. Can you hide this into a header file? This way its not very clean code I think.

Hum.. OK, I'm thinking about this.

Quoted 2 lines

Can we move the WARN after the DMI scanning for all cases? This will save this #ifdef and is a cleaner approach imho.

Sounds good. Thanks!

Signature · 1 line
Li, Yan
#6 lore raw
In reply to Yan Li
Quoted 7 lines · Yan Li

Since the mtrr empty was detected very early before we can use DMI or PCI to check whether we are running as a VMware guest or not, we now only print an info there. Warning will only be issued later when we are sure that we are not running as a VMware guest.

mtrr_trim_uncached_memory() is modified to return meaningful codes for later warning decision.

we have moved dmi_scan_machine() much early...

so please check with latest tip/master to use
dmi_check_system with that.

BTW:
those warning should be good, because VMware is the root cause.

YH

author
#7 lore raw
Quoted 6 lines · Yinghai Lu
Quoted 5 lines · Yan Li

Since the mtrr empty was detected very early before we can use DMI or PCI to check whether we are running as a VMware guest or not, we now only print an info there. Warning will only be issued later when we are sure that we are not running as a VMware guest.

Quoted 7 lines
Quoted 2 lines

mtrr_trim_uncached_memory() is modified to return meaningful codes for later warning decision.

we have moved dmi_scan_machine() much early...

so please check with latest tip/master to use
dmi_check_system with that.

OK! Thanks, I'll try.

Quoted 2 lines

BTW:
those warning should be good, because VMware is the root cause.

Sorry, do you mean we also need a warning for this in VMware?

Signature · 1 line
Li, Yan
author
#8 lore raw
In reply to Yinghai Lu
Quoted 6 lines · Yinghai Lu
Quoted 5 lines · Yan Li

Since the mtrr empty was detected very early before we can use DMI or PCI to check whether we are running as a VMware guest or not, we now only print an info there. Warning will only be issued later when we are sure that we are not running as a VMware guest.

Quoted 7 lines
Quoted 2 lines

mtrr_trim_uncached_memory() is modified to return meaningful codes for later warning decision.

we have moved dmi_scan_machine() much early...

so please check with latest tip/master to use
dmi_check_system with that.

I checked your patch 1c6e5503 that moved dmi_scan_machine() earlier, but it's still behind mtrr_trim_uncached_memory(), so we still can't use DMI to check for VMware there.

Signature · 1 line
Li, Yan
#9 lore raw
Quoted 10 lines · Yan Li
Quoted 9 lines · Yinghai Lu
Quoted 7 lines · Yan Li

Since the mtrr empty was detected very early before we can use DMI or PCI to check whether we are running as a VMware guest or not, we now only print an info there. Warning will only be issued later when we are sure that we are not running as a VMware guest.

mtrr_trim_uncached_memory() is modified to return meaningful codes for later warning decision.

Quoted 9 lines
Quoted 4 lines

we have moved dmi_scan_machine() much early...

so please check with latest tip/master to use
dmi_check_system with that.

I checked your patch 1c6e5503 that moved dmi_scan_machine() earlier, but it's still behind mtrr_trim_uncached_memory(), so we still can't use DMI to check for VMware there.

you must be kidding!

...

        dmi_scan_machine();

        dmi_check_system(bad_bios_dmi_table);
#ifdef CONFIG_X86_32
        probe_roms();

#endif

        /* after parse_early_param, so could debug it */
        insert_resource(&iomem_resource, &code_resource);
        insert_resource(&iomem_resource, &data_resource);
        insert_resource(&iomem_resource, &bss_resource);

        if (efi_enabled)
                efi_init();
#ifdef CONFIG_X86_32
        if (ppro_with_ram_bug()) {
                e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
                                  E820_RESERVED);
                sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
                printk(KERN_INFO "fixed physical RAM map:\n");
                e820_print_map("bad_ppro");
        }
#else
        early_gart_iommu_check();

#endif

        /*
         * partially used pages are not usable - thus
         * we are rounding upwards:
         */
        max_pfn = e820_end_of_ram_pfn();

        /* preallocate 4k for mptable mpc */
        early_reserve_e820_mpc_new();
        /* update e820 for memory not covered by WB MTRRs */
        mtrr_bp_init();
        if (mtrr_trim_uncached_memory(max_pfn))
                max_pfn = e820_end_of_ram_pfn();
author
#10 lore raw
Quoted 11 lines · Yinghai Lu
Quoted 9 lines
Quoted 4 lines

we have moved dmi_scan_machine() much early...

so please check with latest tip/master to use
dmi_check_system with that.

I checked your patch 1c6e5503 that moved dmi_scan_machine() earlier, but it's still behind mtrr_trim_uncached_memory(), so we still can't use DMI to check for VMware there.

you must be kidding!

Ooops. Sorry, my fault. I checked the wrong tree. I'm looking into this.

Thanks!

Signature · 1 line
Li, Yan
#11 lore raw
In reply to Yan Li

Hi!

Subject says: Suppress false "mtrr all empty" .... would you explain why is the message false? I believe it is very true, and points out fact that VMWare virtualization fails to simulate MTRR-s.

IMO VMWare should just fix their emulator.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
author
#12 lore raw
Quoted 7 lines · Pavel Machek

Hi!

Subject says: Suppress false "mtrr all empty" .... would you explain why is the message false? I believe it is very true, and points out fact that VMWare virtualization fails to simulate MTRR-s.

IMO VMWare should just fix their emulator.

You are right, to some degree. Actually I have no strong evidence to support this either. Since KVM doesn't set MTRR, by hunch I thought VMware might having similar shortages. Also nothing bad can be observed after the system booted, so I guessed that warning was useless. Moreover, none other OSes (include old Linux kernels) is complaining about this in VMware so users of VMware might think 2.6.27 is buggy on this.

Hope someone from VMware could clear this up. I think they are working on this problem followed this thread. I'd be happy to help.

Signature · 1 line
Li, Yan