Linux.com

Nekoto

Nekoto

  • Linux.com Member
  • Posts: 3
  • Member Since: 26 Mar 10
  • Last Logged In: 28 May 10

Latest Posts

Posted by
Topic
Post Preview
Posted
  • Nekoto
    access user task stack from kernel control path
    Hi, for a research project I need to access the kernel stack of a suspended process from the kernel control path. Furthermore I need to search the user stack of that process. I know that through the SAVE_ALL macro all register values (ss, esp, eflags ... ecx and ebx) are saved on the kernel task stack. Now I need to know how to access the user stack of a process with the combination of ss and esp values if the task is suspended or maybe paged. Can anybody tell me how the address translation is performed using ss and esp? I will appreciate it if anybody can help me. Best regards
    Link to this post 28 May 10

    Hi,

    for a research project I need to access the kernel stack of a suspended process from the kernel control path. Furthermore I need to search the user stack of that process. I know that through the SAVE_ALL macro all register values (ss, esp, eflags ... ecx and ebx) are saved on the kernel task stack. Now I need to know how to access the user stack of a process with the combination of ss and esp values if the task is suspended or maybe paged. Can anybody tell me how the address translation is performed using ss and esp? I will appreciate it if anybody can help me.

    Best regards

  • Nekoto
    kernel module: no symbol version for struct_module
    Hi all, I try to build a simple kernel module on Ubuntu 9.04 with an self compiled (make-kpkg) 2.6.29.4 Kernel. The kernel module is a simple "Hello World" example listed below: [code] #include #include int init_module(void) { printk(KERN_INFO "Hello world 1.\n"); return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye world 1.\n"); } [/code] The Makefile which belongs to the module looks like: [code] MODULENAME := anytimeKM obj-m += $(MODULENAME).o prefix := $(shell rtai-config --prefix) ifeq ($(prefix),) $(error Please add /bin to your PATH variable) endif CC = $(shell rtai-config --cc) LINUX_DIR = $(shell rtai-config --linux-dir) all:$(MODULENAME).ko $(MODULENAME).ko:$(MODULENAME).c $(MAKE) -C $(LINUX_DIR) CC=$(CC) SUBDIRS=$$PWD V=$(V) modules clean:: $(RM) $(LINUX_DIR)/.tmp_versions/*_rt.mod *.o *.ko *.mod.c .*.cm .PHONY: clean [/code] The compile process works fine except of the following warning message: [quote] .... Warning: Symbol version dump /usr/linux-2.6.29.4/Module.symvers is missing; modules will have dependencies and modversions. .... [/quote] When I try to insmod the module I get the following error message: [quote]insmod: error inserting 'anytimeKM.ko': -1 Invalid module format[/quote] dmesg prints: [quote]anytimeKM: no symbol version for struct_module[/quote] Does anybody knows how to fix that problem? I will appreciate it if somebody can bring some light to the dark. Best regards Nekoto
    Link to this post 09 Apr 10

    Hi all,

    I try to build a simple kernel module on Ubuntu 9.04 with an self compiled (make-kpkg) 2.6.29.4 Kernel. The kernel module is a simple "Hello World" example listed below:


    #include <linux/module.h>
    #include <linux/kernel.h>

    int init_module(void)
    {
    printk(KERN_INFO "Hello world 1.\n");

    return 0;
    }

    void cleanup_module(void)
    {
    printk(KERN_INFO "Goodbye world 1.\n");
    }

    The Makefile which belongs to the module looks like:


    MODULENAME := anytimeKM

    obj-m += $(MODULENAME).o

    prefix := $(shell rtai-config --prefix)

    ifeq ($(prefix),)
    $(error Please add <rtai-install>/bin to your PATH variable)
    endif

    CC = $(shell rtai-config --cc)

    LINUX_DIR = $(shell rtai-config --linux-dir)

    all:$(MODULENAME).ko

    $(MODULENAME).ko:$(MODULENAME).c
    $(MAKE) -C $(LINUX_DIR) CC=$(CC) SUBDIRS=$$PWD V=$(V) modules

    clean::
    $(RM) $(LINUX_DIR)/.tmp_versions/*_rt.mod *.o *.ko *.mod.c .*.cm

    .PHONY: clean

    The compile process works fine except of the following warning message:



    ....
    Warning: Symbol version dump /usr/linux-2.6.29.4/Module.symvers is missing; modules will have dependencies and modversions.
    ....


    When I try to insmod the module I get the following error message:

    insmod: error inserting 'anytimeKM.ko': -1 Invalid module format

    dmesg prints:

    anytimeKM: no symbol version for struct_module

    Does anybody knows how to fix that problem? I will appreciate it if somebody can bring some light to the dark.

    Best regards

    Nekoto

  • Nekoto
    change user mode value from kernel control path
    Hi, for a special purpose I need to read values in lxrt user mode which are changed in the kernel control path. To avoid expensive system calls I register the address of a user mode variable (int) with a new pointer in the task control path: [code] typedef struct rt_task_struct { … volatile int *tp_status; … } [/code] To register the variable I introduced a new function in the api.c file: [code] RTAI_SYSCALL_MODE int rt_register_v(int variable, void *address, int size) { RT_TASK *rt_current; if (!access_ok(VERIFY_WRITE, address, size)) { return -EINVAL; } rt_current = RT_CURRENT; switch(variable) { case RT_VAR_TP_STATUS: rt_current->tp_status = (int *)address; break; … } [/code] In my user space program I use the following code to register the variable: [code] int anytime_assign_tp_status(const int *tp_status) { if (tp_status == NULL) { return EANYTIME_INVAL; } if (mlock((const void *)tp_status, sizeof(const int )) < 0) { return EANYTIME_MLOCK; } if (rt_register_v(RT_VAR_TP_STATUS, (void *)tp_status, sizeof(int)) < 0) { return EANYTIME_INVAL; } return 0; } [/code] ….. I call the function with the following command: [code] volatile int tp_status = 1; … anytime_assign_tp_status(&tp_status); … [/code] The registration works fine. In rt_schedule() I am able to access the user mode value with *(rt_current->tp_status). To chance the value from kernel control path I use the following line of code: [code] if (rt_current->tp_status != NULL) put_user(3, rt_current->tp_status); [/code] This also works fine. But after a lxrt_context_switch(prev, new_task->lnxtsk, cpuid); call in the rt_time_handler function the pointer new_task->tp_status points to the same user mode address but every access to user mode variable like *(new_task->tp_status) freeze the whole system? Furthermore sometimes it is possible to read the value of *(new_task->tp_status) and the content isn’t longer 1 or 3 - its 260348 for example. Does anybody knows the problem? I avoided swapping with the mlock call so why it is not longer possible to access the value after a context switch? Best regards, Nekoto
    Link to this post 26 Mar 10

    Hi,

    for a special purpose I need to read values in lxrt user mode which are changed in the kernel control path. To avoid expensive system calls I register the address of a user mode variable (int) with a new pointer in the task control path:


    typedef struct rt_task_struct {
    …
    volatile int *tp_status;
    …
    }

    To register the variable I introduced a new function in the api.c file:


    RTAI_SYSCALL_MODE int rt_register_v(int variable, void *address, int size)
    {
    RT_TASK *rt_current;

    if (!access_ok(VERIFY_WRITE, address, size)) {
    return -EINVAL;
    }

    rt_current = RT_CURRENT;
    switch(variable) {
    case RT_VAR_TP_STATUS:
    rt_current->tp_status = (int *)address;
    break;
    …
    }

    In my user space program I use the following code to register the variable:


    int anytime_assign_tp_status(const int *tp_status) {
    if (tp_status == NULL) {
    return EANYTIME_INVAL;
    }

    if (mlock((const void *)tp_status, sizeof(const int )) < 0) {
    return EANYTIME_MLOCK;
    }
    if (rt_register_v(RT_VAR_TP_STATUS, (void *)tp_status, sizeof(int)) < 0) {
    return EANYTIME_INVAL;
    }
    return 0;
    }

    …..

    I call the function with the following command:


    volatile int tp_status = 1;
    …
    anytime_assign_tp_status(&tp_status);
    …

    The registration works fine. In rt_schedule() I am able to access the user mode value with *(rt_current->tp_status). To chance the value from kernel control path I use the following line of code:


    if (rt_current->tp_status != NULL) put_user(3, rt_current->tp_status);

    This also works fine. But after a lxrt_context_switch(prev, new_task->lnxtsk, cpuid); call in the rt_time_handler function the pointer new_task->tp_status points to the same user mode address but every access to user mode variable like *(new_task->tp_status) freeze the whole system? Furthermore sometimes it is possible to read the value of *(new_task->tp_status) and the content isn’t longer 1 or 3 - its 260348 for example. Does anybody knows the problem? I avoided swapping with the mlock call so why it is not longer possible to access the value after a context switch?

    Best regards,

    Nekoto

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board