public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yan Li <elliot.li.tech@gmail.com>
To: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	"H. Peter Anvin" <hpa@zytor.com>
Cc: Yan Li <elliot.li.tech@gmail.com>,
	joerg.roedel@amd.com, rjmaomao@gmail.com,
	Yinghai Lu <yhlu.kernel@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	nancydreaming@gmail.com
Subject: [PATCH 2/2] Suppress false "mtrr all empty" warning message when running as VMware guest
Date: Wed, 24 Sep 2008 20:24:37 +0800	[thread overview]
Message-ID: <48da36b3.0e0d6e0a.1c8e.fffff980@mx.google.com> (raw)
In-Reply-To: <a120cfa37281607d8dc361deda1a35419accd193.1222258080.git.elliot.li.tech@gmail.com>

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.

Signed-off-by: Yan Li <elliot.li.tech@gmail.com>
---
 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(-)

diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index b117d7f..95d1cc0 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -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 */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 9838f25..4cbec10 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -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();
 
 	/*
diff --git a/include/asm-x86/mtrr.h b/include/asm-x86/mtrr.h
index a69a01a..b6d8fcb 100644
--- a/include/asm-x86/mtrr.h
+++ b/include/asm-x86/mtrr.h
@@ -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 {
-- 
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)

       reply	other threads:[~2008-09-24 12:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a120cfa37281607d8dc361deda1a35419accd193.1222258080.git.elliot.li.tech@gmail.com>
2008-09-24 12:24 ` Yan Li [this message]
2008-09-24 12:54   ` [PATCH 2/2] Suppress false "mtrr all empty" warning message when running as VMware guest Laurent Vivier
2008-09-24 13:10     ` Yan Li
2008-09-24 14:16   ` Joerg Roedel
2008-09-25  2:51     ` Yan Li
2008-09-24 16:39   ` Yinghai Lu
2008-09-25  2:52     ` Yan Li
2008-09-25 14:18     ` Yan Li
2008-09-25 17:13       ` Yinghai Lu
2008-09-26  9:50         ` Yan Li
2008-10-01 20:03   ` Pavel Machek
2008-10-05 12:05     ` Yan Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48da36b3.0e0d6e0a.1c8e.fffff980@mx.google.com \
    --to=elliot.li.tech@gmail.com \
    --cc=hpa@zytor.com \
    --cc=joerg.roedel@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nancydreaming@gmail.com \
    --cc=rjmaomao@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=yhlu.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox