From: Jan Kiszka <jan.kiszka@domain.hid>
To: adeos-main@gna.org
Cc: Philippe Gerum <rpm@xenomai.org>
Subject: [Adeos-main] [PATCH] harden MTRR access
Date: Sun, 28 Oct 2007 11:42:12 +0100 [thread overview]
Message-ID: <47246784.8070402@domain.hid> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 347 bytes --]
Running Xenomai's latency test while firing up X not just points out
once again long delays due to MTRR fiddling and wbinvd invocation - it
simply locks up the box! The reason is that MTRR fiddling needs hard IRQ
protection, which this patch introduces. Note: I focused on standard
MTRR, skipping the legacy CPUs (and dead MTRR code).
Jan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: harden-mtrr.patch --]
[-- Type: text/x-patch; name="harden-mtrr.patch", Size: 2799 bytes --]
---
arch/i386/kernel/cpu/mtrr/generic.c | 8 ++++----
arch/i386/kernel/cpu/mtrr/main.c | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
Index: linux-2.6.23.1-xeno/arch/i386/kernel/cpu/mtrr/generic.c
===================================================================
--- linux-2.6.23.1-xeno.orig/arch/i386/kernel/cpu/mtrr/generic.c
+++ linux-2.6.23.1-xeno/arch/i386/kernel/cpu/mtrr/generic.c
@@ -392,14 +392,14 @@ static void generic_set_all(void)
unsigned long mask, count;
unsigned long flags;
- local_irq_save(flags);
+ local_irq_save_hw(flags);
prepare_set();
/* Actually set the state */
mask = set_mtrr_state();
post_set();
- local_irq_restore(flags);
+ local_irq_restore_hw(flags);
/* Use the atomic bitops to update the global mask */
for (count = 0; count < sizeof mask * 8; ++count) {
@@ -427,7 +427,7 @@ static void generic_set_mtrr(unsigned in
vr = &mtrr_state.var_ranges[reg];
- local_irq_save(flags);
+ local_irq_save_hw(flags);
prepare_set();
if (size == 0) {
@@ -446,7 +446,7 @@ static void generic_set_mtrr(unsigned in
}
post_set();
- local_irq_restore(flags);
+ local_irq_restore_hw(flags);
}
int generic_validate_add_page(unsigned long base, unsigned long size, unsigned int type)
Index: linux-2.6.23.1-xeno/arch/i386/kernel/cpu/mtrr/main.c
===================================================================
--- linux-2.6.23.1-xeno.orig/arch/i386/kernel/cpu/mtrr/main.c
+++ linux-2.6.23.1-xeno/arch/i386/kernel/cpu/mtrr/main.c
@@ -149,7 +149,7 @@ static void ipi_handler(void *info)
struct set_mtrr_data *data = info;
unsigned long flags;
- local_irq_save(flags);
+ local_irq_save_hw(flags);
atomic_dec(&data->count);
while(!atomic_read(&data->gate))
@@ -167,7 +167,7 @@ static void ipi_handler(void *info)
cpu_relax();
atomic_dec(&data->count);
- local_irq_restore(flags);
+ local_irq_restore_hw(flags);
}
#endif
@@ -237,7 +237,7 @@ static void set_mtrr(unsigned int reg, u
if (smp_call_function(ipi_handler, &data, 1, 0) != 0)
panic("mtrr: timed out waiting for other CPUs\n");
- local_irq_save(flags);
+ local_irq_save_hw(flags);
while(atomic_read(&data.count))
cpu_relax();
@@ -273,7 +273,7 @@ static void set_mtrr(unsigned int reg, u
while(atomic_read(&data.count))
cpu_relax();
- local_irq_restore(flags);
+ local_irq_restore_hw(flags);
}
/**
@@ -726,11 +726,11 @@ void mtrr_ap_init(void)
* 2.cpu hotadd time. We let mtrr_add/del_page hold cpuhotplug lock to
* prevent mtrr entry changes
*/
- local_irq_save(flags);
+ local_irq_save_hw(flags);
mtrr_if->set_all();
- local_irq_restore(flags);
+ local_irq_restore_hw(flags);
}
/**
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
next reply other threads:[~2007-10-28 10:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-28 10:42 Jan Kiszka [this message]
2007-11-06 21:18 ` [Adeos-main] [PATCH] harden MTRR access Paul
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=47246784.8070402@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=adeos-main@gna.org \
--cc=rpm@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.