From: "bibo mao" <bibo.mao@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org
Subject: [patch 0/1] remove existing enclosed mtrr region
Date: Thu, 9 Oct 2008 16:17:15 +0800 [thread overview]
Message-ID: <fbd277f20810090117g7b916d2fia201b9184d41bd7d@mail.gmail.com> (raw)
Hi,
This patch is remove enclosed mtrr region when adding new region.
Signed-off-by: bibo mao <bibo.mao@gmail.com>
thanks
bibo,mao
kernel/cpu/mtrr/main.c | 35 +++++++++++++++++++++++++++++++----
3 files changed, 31 insertions(+), 4 deletions(-)
---------------------------------------------------------------------------------------------------------------------
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 6a1e278..6e212f3 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -303,7 +303,7 @@ static void set_mtrr(unsigned int reg, unsigned long base,
int mtrr_add_page(unsigned long base, unsigned long size,
unsigned int type, bool increment)
{
- int i, replace, error;
+ int i, j, replace, error;
mtrr_type ltype;
unsigned long lbase, lsize;
@@ -351,7 +351,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
if (base <= lbase && base + size - 1 >= lbase + lsize - 1) {
/* New region encloses an existing region */
if (type == ltype) {
- replace = replace == -1 ? i : -2;
+ replace = i;
continue;
}
else if (types_compatible(type, ltype))
@@ -391,6 +391,20 @@ int mtrr_add_page(unsigned long base, unsigned long size,
set_mtrr(replace, 0, 0, 0);
mtrr_usage_table[replace] = 0;
}
+
+ /* remove existing enclosed region */
+ for (j = 0; j < num_var_ranges; ++j) {
+ if (i == j)
+ continue;
+ mtrr_if->get(j, &lbase, &lsize, <ype);
+ if (lsize && type == ltype && base <= lbase
+ && base + size - 1 >= lbase + lsize - 1) {
+ /* New region encloses an existing region */
+ mtrr_usage_table[i] += mtrr_usage_table[j];
+ set_mtrr(j, 0, 0, 0);
+ mtrr_usage_table[j]=0;
+ }
+ }
}
} else
printk(KERN_INFO "mtrr: no more MTRRs available\n");
reply other threads:[~2008-10-09 8:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=fbd277f20810090117g7b916d2fia201b9184d41bd7d@mail.gmail.com \
--to=bibo.mao@gmail.com \
--cc=akpm@linux-foundation.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
all inboxes | Powered by JetHome®