public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yhlu.kernel.send@gmail.com>
To: Ingo Molnar <mingo@elte.hu>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86: fixed mtrr change WP to WB
Date: Tue, 6 May 2008 10:41:39 -0700	[thread overview]
Message-ID: <200805061041.40047.yhlu.kernel@gmail.com> (raw)
In-Reply-To: <200805061038.58023.yhlu.kernel@gmail.com>

[PATCH] x86: fixed mtrr change WP to WB

so we modify mptable near below 1M

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

Index: linux-2.6/arch/x86/kernel/cpu/mtrr/generic.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/generic.c
+++ linux-2.6/arch/x86/kernel/cpu/mtrr/generic.c
@@ -192,6 +192,26 @@ void mtrr_save_fixed_ranges(void *info)
 		get_fixed_ranges(mtrr_state.fixed_ranges);
 }
 
+int update_mtrr_fixed_ranges(unsigned char old_type, unsigned char new_type)
+{
+	unsigned char *type;
+	int i;
+	int changed = 0;
+
+	if (!mtrr_state.have_fixed)
+		return 0;
+
+	type = mtrr_state.fixed_ranges;
+	for (i = 0; i < NUM_FIXED_RANGES; i++) {
+		if (type[i] == old_type) {
+			type[i] = new_type;
+			changed = 1;
+		}
+	}
+
+	return changed;
+}
+
 static void print_fixed(unsigned base, unsigned step, const mtrr_type*types)
 {
 	unsigned i;
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
@@ -794,6 +794,24 @@ x86_get_mtrr_mem_range(struct res_range 
 	return nr_range;
 }
 
+extern int __initdata enable_update_mptable;
+
+static int __init fixed_mtrr_cleanup(void)
+{
+	unsigned char new_type;
+
+	if (!enable_update_mptable)
+		return 0;
+
+	/* AMD 0x1e, intel 0x06 */
+	new_type = 0x06;
+	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
+	    (boot_cpu_data.x86 >= 0x0f && boot_cpu_data.x86 <= 0x11))
+		new_type = 0x1e;
+
+	return update_mtrr_fixed_ranges(0x05, new_type);
+}
+
 static struct res_range __initdata range[RANGE_NUM];
 
 #ifdef CONFIG_MTRR_SANITIZER
@@ -1162,6 +1180,7 @@ static int __init mtrr_cleanup(unsigned 
 	unsigned long range_sums, range_sums_new;
 	int index_good;
 	int num_reg_good;
+	int changed;
 
 	/* extra one for all 0 */
 	int num[MTRR_NUM_TYPES + 1];
@@ -1173,6 +1192,8 @@ static int __init mtrr_cleanup(unsigned 
 	if (def != MTRR_TYPE_UNCACHABLE)
 		return 0;
 
+	changed = fixed_mtrr_cleanup();
+
 	/* get it and store it aside */
 	memset(range_state, 0, sizeof(range_state));
 	for (i = 0; i < num_var_ranges; i++) {
@@ -1196,12 +1217,12 @@ static int __init mtrr_cleanup(unsigned 
 
 	/* check if we got UC entries */
 	if (!num[MTRR_TYPE_UNCACHABLE])
-		return 0;
+		return changed;
 
 	/* check if we only had WB and UC */
 	if (num[MTRR_TYPE_WRBACK] + num[MTRR_TYPE_UNCACHABLE] !=
 		num_var_ranges - num[MTRR_NUM_TYPES])
-		return 0;
+		return changed;
 
 	memset(range, 0, sizeof(range));
 	extra_remove_size = 0;
@@ -1363,12 +1384,12 @@ static int __init mtrr_cleanup(unsigned 
 	printk(KERN_INFO "mtrr_cleanup: can not find optimal value\n");
 	printk(KERN_INFO "please specify mtrr_gran_size/mtrr_chunk_size\n");
 
-	return 0;
+	return changed;
 }
 #else
 static int __init mtrr_cleanup(unsigned address_bits)
 {
-	return 0;
+	return fixed_mtrr_cleanup();
 }
 #endif
 
Index: linux-2.6/arch/x86/kernel/cpu/mtrr/mtrr.h
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/mtrr/mtrr.h
+++ linux-2.6/arch/x86/kernel/cpu/mtrr/mtrr.h
@@ -83,6 +83,7 @@ void set_mtrr_prepare_save(struct set_mt
 
 void fill_mtrr_var_range(unsigned int index,
 		u32 base_lo, u32 base_hi, u32 mask_lo, u32 mask_hi);
+int update_mtrr_fixed_ranges(unsigned char old_type, unsigned char new_type);
 void get_mtrr_state(void);
 
 extern void set_mtrr_ops(struct mtrr_ops * ops);

  reply	other threads:[~2008-05-06 17:44 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200805041823.57198.yhlu.kernel@gmail.com>
2008-05-06 17:38 ` [PATCH] x86: update mptable Yinghai Lu
2008-05-06 17:41   ` Yinghai Lu [this message]
2008-05-06 17:48     ` [PATCH] x86: fixed mtrr change WP to WB H. Peter Anvin
2008-05-06 18:24       ` Yinghai Lu
2008-05-06 18:31         ` H. Peter Anvin
2008-05-06 18:34           ` Yinghai Lu
2008-05-06 18:43             ` H. Peter Anvin
2008-05-06 19:05               ` Yinghai Lu
2008-05-06 19:08                 ` H. Peter Anvin
2008-05-06 19:15                   ` Yinghai Lu
2008-05-07  7:48   ` [PATCH] x86: update mptable v2 Yinghai Lu
2008-05-17  2:32     ` [PATCH] x86: update mptable v3 Yinghai Lu
2008-05-19 15:46       ` Ingo Molnar
2008-05-19 19:35       ` [PATCH] x86: update mptable v4 Yinghai Lu
2008-05-19 19:52         ` [PATCH] x86: update mptable v5 Yinghai Lu
2008-05-25 23:00           ` [PATCH] x86: update mptable v6 Yinghai Lu
2008-06-01 20:17             ` [PATCH] x86: update mptable v7 Yinghai Lu
2008-06-09  2:53               ` [PATCH] x86: update mptable v7 - fix Yinghai Lu
2008-06-09 10:13                 ` Ingo Molnar
2008-06-09 17:51                   ` Yinghai Lu
2008-06-09 18:11                     ` Maciej W. Rozycki
2008-06-09 19:09                     ` Ingo Molnar
2008-06-09 19:38                       ` Yinghai Lu
2008-06-09 19:46                         ` H. Peter Anvin
2008-06-09 19:49                       ` Maciej W. Rozycki
2008-06-18 21:32               ` [PATCH] x86: update mptable fix with no ioapic Yinghai Lu
2008-06-19  0:29                 ` [PATCH] x86: update mptable fix with no ioapic v2 Yinghai Lu
2008-06-19  7:18                   ` [PATCH] x86: let MPS support selectable Yinghai Lu
2008-06-19 12:13                     ` Ingo Molnar
2008-06-19 12:49                       ` Ingo Molnar
2008-06-19 15:10                     ` Maciej W. Rozycki
2008-06-19 17:39                       ` Yinghai Lu
2008-06-19 18:03                         ` Len Brown
2008-06-19 18:48                           ` Maciej W. Rozycki
2008-06-26  9:31                             ` Ingo Molnar
     [not found]                     ` <200806191213.10312.yhlu.kernel@gmail.com>
2008-06-19 19:15                       ` [PATCH] x86: fix compiling when CONFIG_X86_MPPARSE is not set Yinghai Lu
2008-06-20 14:42                         ` [PATCH] x86: check command line " Yinghai Lu
2008-06-20 15:01                           ` Ingo Molnar
2008-06-20 15:04                             ` Yinghai Lu
2008-06-20 15:36                             ` Maciej W. Rozycki
2008-06-20 23:11                           ` [PATCH] x86: check command line when CONFIG_X86_MPPARSE is not set v2 Yinghai Lu
2008-06-21  8:14                             ` [PATCH] x86: clean up init_amd() Yinghai Lu
2008-06-24 12:12                           ` [PATCH] x86: check command line when CONFIG_X86_MPPARSE is not set Pavel Machek
2008-06-26  8:23                             ` Yinghai Lu
     [not found]                       ` <200806200733.31477.yhlu.kernel@gmail.com>
2008-06-20 15:03                         ` [PATCH] x86: simplify x86_mpparse dependency check Ingo Molnar
2008-06-20 15:31                         ` Maciej W. Rozycki
2008-06-19 12:13                   ` [PATCH] x86: update mptable fix with no ioapic v2 Ingo Molnar
2008-06-18 22:18               ` [PATCH] x86: update mptable v7 Len Brown
2008-06-18 22:32                 ` Yinghai Lu
2008-06-19  0:33                   ` Len Brown
2008-06-19  0:49                     ` Yinghai Lu
2008-06-19  4:32                       ` Eric W. Biederman
2008-06-19  5:09                         ` H. Peter Anvin
2008-06-19  5:11                         ` Yinghai Lu
2008-06-19  5:27                         ` Len Brown
2008-06-19  6:37                           ` Eric W. Biederman
2008-06-19  7:31                             ` Yinghai Lu
2008-06-19 18:16                               ` Len Brown
2008-06-20  6:47                                 ` Ingo Molnar
2008-06-20  7:20                                   ` Yinghai Lu
2008-06-20  9:12                                   ` Andi Kleen
2008-06-19  5:20                       ` Len Brown
2008-06-19  6:26                         ` Yinghai Lu
2008-06-19  6:28                           ` H. Peter Anvin
2008-06-19  6:35                             ` Yinghai Lu

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=200805061041.40047.yhlu.kernel@gmail.com \
    --to=yhlu.kernel.send@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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