LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yinghai Lu <Yinghai.Lu@Sun.COM>
To: Ingo Molnar <mingo@elte.hu>
Cc: Pavel Emelyanov <xemul@openvz.org>,
"Kok, Auke" <auke-jan.h.kok@intel.com>,
jesse.brandeburg@intel.com, jeffrey.t.kirsher@intel.com,
john.ronciak@intel.com, David Miller <davem@davemloft.net>,
Linux Netdev List <netdev@vger.kernel.org>,
e1000-devel@lists.sourceforge.net, Denis Lunev <den@openvz.org>,
Justin Piszcz <jpiszcz@lucidpixels.com>,
Thomas Gleixner <tglx@linutronix.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86_32: fix regression caused by trim ram according to mtrr on system with 4G more RAM
Date: Wed, 06 Feb 2008 01:49:25 -0800 [thread overview]
Message-ID: <200802060149.26083.yinghai.lu@sun.com> (raw)
In-Reply-To: <47A97E28.1010400@openvz.org>
[PATCH] x86_32: fix regression caused by trim ram according to mtrr on system with 4G more RAM
Pravel report:
"
The commit
093af8d7f0ba3c6be1485973508584ef081e9f93
x86_32: trim memory by updating e820
broke my e1000 card: on loading driver says that
e1000: probe of 0000:04:03.0 failed with error -5
and the interface doesn't appear.
"
on 32 bit kernel, base will overflow when try to do PAGE_SHIFT.
and highest_addr will always less 4G.
so use pfn instead of address to avoid overflow when more than 4g
ram installed on 32bit kernel
Many thanks for Pavel Emelyanov to report and test it.
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Tested-by: Pavel Emelyanov <xemul@openvz.org>
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 1e27b69..4e7490f 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -659,7 +659,7 @@ static __init int amd_special_default_mtrr(void)
*/
int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
{
- unsigned long i, base, size, highest_addr = 0, def, dummy;
+ unsigned long i, base, size, highest_pfn = 0, def, dummy;
mtrr_type type;
u64 trim_start, trim_size;
@@ -682,28 +682,27 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
mtrr_if->get(i, &base, &size, &type);
if (type != MTRR_TYPE_WRBACK)
continue;
- base <<= PAGE_SHIFT;
- size <<= PAGE_SHIFT;
- if (highest_addr < base + size)
- highest_addr = base + size;
+ if (highest_pfn < base + size)
+ highest_pfn = base + size;
}
/* kvm/qemu doesn't have mtrr set right, don't trim them all */
- if (!highest_addr) {
+ if (!highest_pfn) {
printk(KERN_WARNING "WARNING: strange, CPU MTRRs all blank?\n");
WARN_ON(1);
return 0;
}
- if ((highest_addr >> PAGE_SHIFT) < end_pfn) {
+ if (highest_pfn < end_pfn) {
printk(KERN_WARNING "WARNING: BIOS bug: CPU MTRRs don't cover"
" all of memory, losing %LdMB of RAM.\n",
- (((u64)end_pfn << PAGE_SHIFT) - highest_addr) >> 20);
+ (end_pfn - highest_pfn) >> (20 - PAGE_SHIFT));
WARN_ON(1);
printk(KERN_INFO "update e820 for mtrr\n");
- trim_start = highest_addr;
+ trim_start = highest_pfn;
+ trim_start <<= PAGE_SHIFT;
trim_size = end_pfn;
trim_size <<= PAGE_SHIFT;
trim_size -= trim_start;
next parent reply other threads:[~2008-02-06 9:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <47A89A77.1050608@openvz.org>
[not found] ` <200802060119.25278.yinghai.lu@sun.com>
[not found] ` <47A97E28.1010400@openvz.org>
2008-02-06 9:49 ` Yinghai Lu [this message]
2008-02-06 9:51 ` Ingo Molnar
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=200802060149.26083.yinghai.lu@sun.com \
--to=yinghai.lu@sun.com \
--cc=auke-jan.h.kok@intel.com \
--cc=davem@davemloft.net \
--cc=den@openvz.org \
--cc=e1000-devel@lists.sourceforge.net \
--cc=jeffrey.t.kirsher@intel.com \
--cc=jesse.brandeburg@intel.com \
--cc=john.ronciak@intel.com \
--cc=jpiszcz@lucidpixels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=netdev@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=xemul@openvz.org \
--subject='Re: [PATCH] x86_32: fix regression caused by trim ram according to mtrr on system with 4G more RAM' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).