LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Little Help Debugging some MINOR kernel assembly (https://www.linuxquestions.org/questions/linux-kernel-70/little-help-debugging-some-minor-kernel-assembly-616915/)

Norweed 01-28-2008 01:47 PM

Little Help Debugging some MINOR kernel assembly
 
What I'm trying to do here is add an overhead to every single system call. I can do this either by modifying ~320 C methods or I can do it in one place in i386 assembly land. As you might have guessed I'd much rather make this change in one place, the problem is I such at assembly and I'm having a hard time finding a resource that can help, so here I am asking for some help.

I'm working with the 2.6.22 kernel, and I'm trying to modify the arch/i386/kernel/entry.S file (I think that's the path). Right around like 370 or so is the main entry point after the processor interrupt has occurred. Here's what I have now:

Code:

      # system call handler stub
ENTRY(system_call)
      #THIS IS MY LOOP
        movl %cx, 100000;
mylblb:
        add %eax, %eax;
        loop mylblb





        RING0_INT_FRAME                # can't unwind into user space anyway
        pushl %eax                      # save orig_eax
        CFI_ADJUST_CFA_OFFSET 4
        SAVE_ALL
        GET_THREAD_INFO(%ebp)

                                # system call tracing in operation / emulation
        /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
        testw  $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSC
ALL_AUDIT),TI_flags(%ebp)
        jnz syscall_trace_entry
        cmpl $(nr_syscalls), %eax
        jae syscall_badsys
syscall_call:
.
.
.


As you can see I'm just adding a loop that does something minimal like add some values together. It fails miserably. I'm sure it's because I'm overwriting something important and not putting it back, but I don't know how to do that.

Any help would be GREATLY appreciated as I'm dead in the water here.


Disclaimer: Yes, this is part of a project for my CS master's degree, I'm not trying to get anyone to help me cheat on my homework, just need some help. The real part of this assignment is doing the analysis on the effects of this overhead. Just want to get that out there.

Norweed 01-29-2008 01:24 PM

I changed my code a little bit but it's still overwriting something important.

Code:

ENTRY(system_call)
      #THIS IS MY LOOP
      pushal;
      movl %cx, 100000;
mylblb:
        add %eax, %eax;
        loop mylblb
        popal;


I just want this stupid loop to eat up some processor cycles and not affect anything else. Any pointers on what I might be missing?

HowDoIProgramIt 03-28-2008 10:32 AM

Quote:

Originally Posted by Norweed (Post 3039038)
Any pointers on what I might be missing?

I just stumbled across your post while looking for something else; you've probably figured this out already and moved on, but just in case...

Do you think it's possible that you've discovered some sort of race condition elsewhere in the kernel code?


All times are GMT -5. The time now is 01:18 AM.