public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Yinghai Lu <Yinghai.Lu@Sun.COM>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86: trim ram need to check if mtrr is there v3
Date: Fri, 25 Jan 2008 15:21:50 +0100	[thread overview]
Message-ID: <20080125142150.GA27767@elte.hu> (raw)
In-Reply-To: <200801250042.53074.yinghai.lu@sun.com>


* Yinghai Lu <Yinghai.Lu@Sun.COM> wrote:

> -static __init int amd_special_default_mtrr(unsigned long end_pfn)
> +static __init int amd_special_default_mtrr(void)
>  {
>  	u32 l, h;
>  
> -	/* Doesn't apply to memory < 4GB */
> -	if (end_pfn <= (0xffffffff >> PAGE_SHIFT))
> -		return 0;
>  	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
>  		return 0;

The logic we ideally would like to have is something like this:

find _any_ RAM that is not mapped via any MTRRs (be that special MTRR 
extensions like Tom2) and clear that from the e820 maps.

not just 'end of RAM'.

And in that sense the amd_special_default_mtrr() check is wrong, because 
it just checks that Tom2 is set and then does no other checking. And the 
original MTRR check is wrong too because it just finds the highest 
cacheable MTRR-covered address and compares that to the kernel-known end 
of RAM.

what we should probably do instead is to have a filter function:

   new_end = trim_range_to_mtrr_cached(start, end);

and then we could iterate through every e820 map entry that is marked as 
usable RAM, and send it through this filter. If the filter returns the 
same value that got passed in, we keep the e820 entry unchanged. If the 
filter returns a new "end" value, we use that in the e820 map.

that way, the current Tom2 hack is just a natural extension to the 
filter function: it would (on AMD CPUs) recognize (within 
trim_range_to_mtrr_cached filter) that all memory addresses above 4GB 
are marked as cacheable via Tom2.

Or something like this. Hm?

	Ingo

  parent reply	other threads:[~2008-01-25 14:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-25  1:44 x86.git: mtrr trimming removes all memory under kvm Jeremy Fitzhardinge
2008-01-25  1:49 ` H. Peter Anvin
2008-01-25  2:21   ` Yinghai Lu
2008-01-25  2:32   ` Yinghai Lu
2008-01-25 10:52     ` Andi Kleen
2008-01-25  3:47   ` [PATCH] x86: trim ram need to check if mtrr is there v2 Yinghai Lu
2008-01-25  5:44     ` H. Peter Anvin
2008-01-25  7:50       ` Yinghai Lu
2008-01-25  7:43     ` Jeremy Fitzhardinge
2008-01-25  8:13       ` Yinghai Lu
2008-01-25  8:39         ` Yinghai Lu
2008-01-25 11:12         ` Ingo Molnar
2008-01-25 15:47           ` H. Peter Anvin
2008-01-25  8:42       ` [PATCH] x86: trim ram need to check if mtrr is there v3 Yinghai Lu
2008-01-25 11:09         ` Ingo Molnar
2008-01-25 18:55           ` Jeremy Fitzhardinge
2008-01-25 18:59             ` Ingo Molnar
2008-01-25 19:01               ` Jeremy Fitzhardinge
2008-01-25 19:04                 ` Ingo Molnar
2008-01-25 19:27                   ` Jeremy Fitzhardinge
2008-01-25 19:30                     ` Ingo Molnar
2008-01-25 19:32                     ` Yinghai Lu
2008-01-25 19:39                       ` Jeremy Fitzhardinge
2008-01-25 19:19             ` Yinghai Lu
2008-01-25 19:04               ` Jeremy Fitzhardinge
2008-01-25 18:59           ` Jeremy Fitzhardinge
2008-01-25 19:02             ` Ingo Molnar
2008-01-25 14:21         ` Ingo Molnar [this message]
2008-01-25 14:57           ` Andi Kleen
2008-01-25 15:10             ` Ingo Molnar
2008-01-25 15:57               ` H. Peter Anvin

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=20080125142150.GA27767@elte.hu \
    --to=mingo@elte.hu \
    --cc=Yinghai.Lu@Sun.COM \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    /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