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
---
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;
---
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 { \
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Adeos-main mailing list [email protected] https://mail.gna.org/listinfo/adeos-main
