public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] x86: mtrr_cleanup: print out correct type
@ 2008-10-04 21:50 Yinghai Lu
  2008-10-04 21:50 ` [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs Yinghai Lu
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Yinghai Lu @ 2008-10-04 21:50 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton
  Cc: linux-kernel, Yinghai Lu

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
---
 arch/x86/kernel/cpu/mtrr/main.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/main.c
+++ linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
@@ -1273,12 +1273,14 @@ static int __init mtrr_cleanup(unsigned
 		size_base = to_size_factor(size_base, &size_factor),
 		start_base = range_state[i].base_pfn << (PAGE_SHIFT - 10);
 		start_base = to_size_factor(start_base, &start_factor),
+		type = range_state[i].type;
 
 		printk(KERN_DEBUG "reg %d, base: %ld%cB, range: %ld%cB, type %s\n",
 			i, start_base, start_factor,
 			size_base, size_factor,
 			(type == MTRR_TYPE_UNCACHABLE) ? "UC" :
-			    ((type == MTRR_TYPE_WRBACK) ? "WB" : "Other")
+			    ((type == MTRR_TYPE_WRPROT) ? "WPROT" :
+			     ((type == MTRR_TYPE_WRBACK) ? "WB" : "Other"))
 			);
 	}
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs
  2008-10-04 21:50 [PATCH 1/3] x86: mtrr_cleanup: print out correct type Yinghai Lu
@ 2008-10-04 21:50 ` Yinghai Lu
  2008-10-05  0:46   ` H. Peter Anvin
  2008-10-04 21:50 ` [PATCH 3/3] x86: mtrr_cleanup: treat WRPROT as UNCACHEABLE Yinghai Lu
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Yinghai Lu @ 2008-10-04 21:50 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton
  Cc: linux-kernel, Yinghai Lu

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
---
 arch/x86/kernel/cpu/mtrr/main.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/main.c
+++ linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
@@ -1292,6 +1292,15 @@ static int __init mtrr_cleanup(unsigned
 			(mtrr_tom2 >> PAGE_SHIFT) - extra_remove_base;
 	nr_range = x86_get_mtrr_mem_range(range, 0, extra_remove_base,
 					  extra_remove_size);
+	/*
+	 * [0, 1M) should always be coverred by var mtrr with WB
+	 * and fixed mtrrs should take effective before var mtrr for it
+	 */
+	nr_range = add_range_with_merge(range, nr_range, 0,
+					(1ULL<<(20 - PAGE_SHIFT)) - 1);
+	/* sort the ranges */
+	sort(range, nr_range, sizeof(struct res_range), cmp_range, NULL);
+
 	range_sums = sum_ranges(range, nr_range);
 	printk(KERN_INFO "total RAM coverred: %ldM\n",
 	       range_sums >> (20 - PAGE_SHIFT));

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] x86: mtrr_cleanup: treat WRPROT as UNCACHEABLE
  2008-10-04 21:50 [PATCH 1/3] x86: mtrr_cleanup: print out correct type Yinghai Lu
  2008-10-04 21:50 ` [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs Yinghai Lu
@ 2008-10-04 21:50 ` Yinghai Lu
  2008-10-05  0:42 ` [PATCH 1/3] x86: mtrr_cleanup: print out correct type H. Peter Anvin
  2008-10-05  3:10 ` H. Peter Anvin
  3 siblings, 0 replies; 11+ messages in thread
From: Yinghai Lu @ 2008-10-04 21:50 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Andrew Morton
  Cc: linux-kernel, Yinghai Lu

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
---
 arch/x86/kernel/cpu/mtrr/main.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Index: linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/main.c
+++ linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
@@ -759,7 +759,8 @@ x86_get_mtrr_mem_range(struct res_range
 	/* take out UC ranges */
 	for (i = 0; i < num_var_ranges; i++) {
 		type = range_state[i].type;
-		if (type != MTRR_TYPE_UNCACHABLE)
+		if (type != MTRR_TYPE_UNCACHABLE &&
+		    type != MTRR_TYPE_WRPROT)
 			continue;
 		size = range_state[i].size_pfn;
 		if (!size)
@@ -1248,6 +1249,8 @@ static int __init mtrr_cleanup(unsigned
 			continue;
 		if (!size)
 			type = MTRR_NUM_TYPES;
+		if (type == MTRR_TYPE_WRPROT)
+			type = MTRR_TYPE_UNCACHABLE;
 		num[type]++;
 	}
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] x86: mtrr_cleanup: print out correct type
  2008-10-04 21:50 [PATCH 1/3] x86: mtrr_cleanup: print out correct type Yinghai Lu
  2008-10-04 21:50 ` [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs Yinghai Lu
  2008-10-04 21:50 ` [PATCH 3/3] x86: mtrr_cleanup: treat WRPROT as UNCACHEABLE Yinghai Lu
@ 2008-10-05  0:42 ` H. Peter Anvin
  2008-10-05  1:42   ` Yinghai Lu
  2008-10-05  3:10 ` H. Peter Anvin
  3 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2008-10-05  0:42 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

Yinghai Lu wrote:
> 
> Index: linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/main.c
> +++ linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
> @@ -1273,12 +1273,14 @@ static int __init mtrr_cleanup(unsigned
>  		size_base = to_size_factor(size_base, &size_factor),
>  		start_base = range_state[i].base_pfn << (PAGE_SHIFT - 10);
>  		start_base = to_size_factor(start_base, &start_factor),
> +		type = range_state[i].type;
>  
>  		printk(KERN_DEBUG "reg %d, base: %ld%cB, range: %ld%cB, type %s\n",
>  			i, start_base, start_factor,
>  			size_base, size_factor,
>  			(type == MTRR_TYPE_UNCACHABLE) ? "UC" :
> -			    ((type == MTRR_TYPE_WRBACK) ? "WB" : "Other")
> +			    ((type == MTRR_TYPE_WRPROT) ? "WPROT" :
> +			     ((type == MTRR_TYPE_WRBACK) ? "WB" : "Other"))
>  			);

If you're going to abbreviate, please use the standard abbreviations as 
documented in the manuals.  The abbreviation for write protect is WP.

	-hpa

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs
  2008-10-04 21:50 ` [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs Yinghai Lu
@ 2008-10-05  0:46   ` H. Peter Anvin
  2008-10-05  1:49     ` Yinghai Lu
  0 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2008-10-05  0:46 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

Yinghai Lu wrote:
> +	/*
> +	 * [0, 1M) should always be coverred by var mtrr with WB
> +	 * and fixed mtrrs should take effective before var mtrr for it
> +	 */
> +	nr_range = add_range_with_merge(range, nr_range, 0,
> +					(1ULL<<(20 - PAGE_SHIFT)) - 1);
> +	/* sort the ranges */
> +	sort(range, nr_range, sizeof(struct res_range), cmp_range, NULL);
> +

The first 1 MB is a total don't care for the variable MTRRs -- they 
don't have to be covered *or* uncovered, since the entire first 1 MB is 
addressed by fixed MTRRs.

In practice, it is *likely* that you're going to want to merge it with a 
WB MTRR, but with various vendors doing all kinds of strange things on 
EFI-damaged platforms, it may not always be that way.

	-hpa

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] x86: mtrr_cleanup: print out correct type
  2008-10-05  0:42 ` [PATCH 1/3] x86: mtrr_cleanup: print out correct type H. Peter Anvin
@ 2008-10-05  1:42   ` Yinghai Lu
  0 siblings, 0 replies; 11+ messages in thread
From: Yinghai Lu @ 2008-10-05  1:42 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

On Sat, Oct 4, 2008 at 5:42 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> Yinghai Lu wrote:
>>
>> Index: linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
>> ===================================================================
>> --- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/main.c
>> +++ linux-2.6/arch/x86/kernel/cpu/mtrr/main.c
>> @@ -1273,12 +1273,14 @@ static int __init mtrr_cleanup(unsigned
>>                size_base = to_size_factor(size_base, &size_factor),
>>                start_base = range_state[i].base_pfn << (PAGE_SHIFT - 10);
>>                start_base = to_size_factor(start_base, &start_factor),
>> +               type = range_state[i].type;
>>                  printk(KERN_DEBUG "reg %d, base: %ld%cB, range: %ld%cB,
>> type %s\n",
>>                        i, start_base, start_factor,
>>                        size_base, size_factor,
>>                        (type == MTRR_TYPE_UNCACHABLE) ? "UC" :
>> -                           ((type == MTRR_TYPE_WRBACK) ? "WB" : "Other")
>> +                           ((type == MTRR_TYPE_WRPROT) ? "WPROT" :
>> +                            ((type == MTRR_TYPE_WRBACK) ? "WB" :
>> "Other"))
>>                        );
>
> If you're going to abbreviate, please use the standard abbreviations as
> documented in the manuals.  The abbreviation for write protect is WP.
>
ok, will use WP.

YH

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs
  2008-10-05  0:46   ` H. Peter Anvin
@ 2008-10-05  1:49     ` Yinghai Lu
  2008-10-05  1:52       ` H. Peter Anvin
  0 siblings, 1 reply; 11+ messages in thread
From: Yinghai Lu @ 2008-10-05  1:49 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

On Sat, Oct 4, 2008 at 5:46 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> Yinghai Lu wrote:
>>
>> +       /*
>> +        * [0, 1M) should always be coverred by var mtrr with WB
>> +        * and fixed mtrrs should take effective before var mtrr for it
>> +        */
>> +       nr_range = add_range_with_merge(range, nr_range, 0,
>> +                                       (1ULL<<(20 - PAGE_SHIFT)) - 1);
>> +       /* sort the ranges */
>> +       sort(range, nr_range, sizeof(struct res_range), cmp_range, NULL);
>> +
>
> The first 1 MB is a total don't care for the variable MTRRs -- they don't
> have to be covered *or* uncovered, since the entire first 1 MB is addressed
> by fixed MTRRs.

so it is safe to put it in WB, and can be spare some regs because it
start from base 0.

>
> In practice, it is *likely* that you're going to want to merge it with a WB
> MTRR, but with various vendors doing all kinds of strange things on
> EFI-damaged platforms, it may not always be that way.

EFI will not use fixed-mtrr for first 1M? and not cover first 1M in
var mtrr with WB? that will run out mtrr regs..

YH

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs
  2008-10-05  1:49     ` Yinghai Lu
@ 2008-10-05  1:52       ` H. Peter Anvin
  2008-10-05  1:59         ` Yinghai Lu
  0 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2008-10-05  1:52 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

Yinghai Lu wrote:
>> The first 1 MB is a total don't care for the variable MTRRs -- they don't
>> have to be covered *or* uncovered, since the entire first 1 MB is addressed
>> by fixed MTRRs.
> 
> so it is safe to put it in WB, and can be spare some regs because it
> start from base 0.

Yes, my point was that you can make those whatever you want.  It doesn't 
have to be WB; it can be any value.

>> In practice, it is *likely* that you're going to want to merge it with a WB
>> MTRR, but with various vendors doing all kinds of strange things on
>> EFI-damaged platforms, it may not always be that way.
> 
> EFI will not use fixed-mtrr for first 1M? and not cover first 1M in
> var mtrr with WB? that will run out mtrr regs..

There are some systems which, apparently, don't have RAM there.  Don't 
ask me how or why.

	-hpa

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs
  2008-10-05  1:52       ` H. Peter Anvin
@ 2008-10-05  1:59         ` Yinghai Lu
  2008-10-05  2:04           ` H. Peter Anvin
  0 siblings, 1 reply; 11+ messages in thread
From: Yinghai Lu @ 2008-10-05  1:59 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

On Sat, Oct 4, 2008 at 6:52 PM, H. Peter Anvin <hpa@zytor.com> wrote:

> There are some systems which, apparently, don't have RAM there.  Don't ask
> me how or why.

very old system or
very new system only have super big cache?

YH

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs
  2008-10-05  1:59         ` Yinghai Lu
@ 2008-10-05  2:04           ` H. Peter Anvin
  0 siblings, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2008-10-05  2:04 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

Yinghai Lu wrote:
> On Sat, Oct 4, 2008 at 6:52 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> 
>> There are some systems which, apparently, don't have RAM there.  Don't ask
>> me how or why.
> 
> very old system or
> very new system only have super big cache?
> 

Very new system.  That's all I know.  Don't know if they actually 
shipped, but it caused a lot of problems and I recommended to the OEM 
that they fix that.

	-hpa

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] x86: mtrr_cleanup: print out correct type
  2008-10-04 21:50 [PATCH 1/3] x86: mtrr_cleanup: print out correct type Yinghai Lu
                   ` (2 preceding siblings ...)
  2008-10-05  0:42 ` [PATCH 1/3] x86: mtrr_cleanup: print out correct type H. Peter Anvin
@ 2008-10-05  3:10 ` H. Peter Anvin
  3 siblings, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2008-10-05  3:10 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, linux-kernel

Patch series applied to tip:x86/mtrr, thanks!

	-hpa


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-10-05  3:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-04 21:50 [PATCH 1/3] x86: mtrr_cleanup: print out correct type Yinghai Lu
2008-10-04 21:50 ` [PATCH 2/3] x86: mtrr_cleanup: first 1M should be coverred in var mtrrs Yinghai Lu
2008-10-05  0:46   ` H. Peter Anvin
2008-10-05  1:49     ` Yinghai Lu
2008-10-05  1:52       ` H. Peter Anvin
2008-10-05  1:59         ` Yinghai Lu
2008-10-05  2:04           ` H. Peter Anvin
2008-10-04 21:50 ` [PATCH 3/3] x86: mtrr_cleanup: treat WRPROT as UNCACHEABLE Yinghai Lu
2008-10-05  0:42 ` [PATCH 1/3] x86: mtrr_cleanup: print out correct type H. Peter Anvin
2008-10-05  1:42   ` Yinghai Lu
2008-10-05  3:10 ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox