From: Jan Kiszka <jan.kiszka@domain.hid>
To: Philippe Gerum <rpm@xenomai.org>
Cc: adeos-main <adeos-main@gna.org>
Subject: [Adeos-main] [Resent][RFC-PATCH] Instrument smp_processor_id /wrt illicit usage
Date: Sat, 15 Sep 2007 09:51:45 +0200 [thread overview]
Message-ID: <46EB8F11.2010009@domain.hid> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 452 bytes --]
This is still in my local queue, don't recall anymore when we last
discussed it and if there was some issue remaining.
Anyway, here is a rebased set to detect calls of smp_processor_id() from
illicit contexts (non-root) on archs that bother about this. Only i386
is cared about so far, x86_64 and PowerPC should be treated similarly,
other (future) SMP-arch would arm the check automatically. Yet another
safety bag for porting I-pipe.
Jan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: instrument-smp_processor_id.patch --]
[-- Type: text/x-patch; name="instrument-smp_processor_id.patch", Size: 1238 bytes --]
---
lib/smp_processor_id.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
Index: linux-2.6.22-ipipe/lib/smp_processor_id.c
===================================================================
--- linux-2.6.22-ipipe.orig/lib/smp_processor_id.c
+++ linux-2.6.22-ipipe/lib/smp_processor_id.c
@@ -10,11 +10,27 @@
unsigned int debug_smp_processor_id(void)
{
unsigned long preempt_count = preempt_count();
- int this_cpu = raw_smp_processor_id();
+ int this_cpu = ipipe_processor_id();
cpumask_t this_mask;
- if (!ipipe_root_domain_p)
+#ifdef CONFIG_IPIPE
+ if (!ipipe_root_domain_p) {
+#ifndef IPIPE_STACK_INVARIANT_CPUID
+ if (test_bit(IPIPE_NOSTACK_FLAG, &ipipe_current_domain->
+ cpudata[this_cpu].status)) {
+ ipipe_trace_panic_freeze();
+ printk(KERN_ERR "BUG: using smp_processor_id() over "
+ "non-Linux stack. I-pipe domain: %s\n",
+ ipipe_current_domain->name);
+ print_symbol("caller is %s\n",
+ (long)__builtin_return_address(0));
+ dump_stack();
+ ipipe_trace_panic_dump();
+ }
+#endif /* !IPIPE_STACK_INVARIANT_CPUID */
goto out;
+ }
+#endif /* CONFIG_IPIPE */
if (likely(preempt_count))
goto out;
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: instrument-smp_processor_id-i386.patch --]
[-- Type: text/x-patch; name="instrument-smp_processor_id-i386.patch", Size: 498 bytes --]
---
include/asm-i386/ipipe.h | 1 +
1 file changed, 1 insertion(+)
Index: linux-2.6.22-ipipe/include/asm-i386/ipipe.h
===================================================================
--- linux-2.6.22-ipipe.orig/include/asm-i386/ipipe.h
+++ linux-2.6.22-ipipe/include/asm-i386/ipipe.h
@@ -38,6 +38,7 @@
#include <asm/ptrace.h>
#define ipipe_processor_id() raw_smp_processor_id()
+#define IPIPE_STACK_INVARIANT_CPUID
#define prepare_arch_switch(next) \
do { \
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]
next reply other threads:[~2007-09-15 7:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-15 7:51 Jan Kiszka [this message]
2007-10-04 8:13 ` [Adeos-main] [Resent][RFC-PATCH] Instrument smp_processor_id /wrt illicit usage Philippe Gerum
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=46EB8F11.2010009@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.