Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I am working on memory dump feature. Now I can dump all memory out to a file by using a tool (0xc0000000 to 0xcfffffff, 256M bytes data),. However, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    2

    a question about memory dump of kernel code


    Hi all,

    I am working on memory dump feature. Now I can dump all memory out to a file by using a tool (0xc0000000 to 0xcfffffff, 256M bytes data),. However, I need to verify what I dump is exactly the same in flash memory.
    One solution is to disable interrupt and do checkum when system is on, i.e. capture a snapshot. And printk it. Then reboot the system directly to make it go into hardware boot processing part, then use my tool to dump data to a file. And do the same checksum operation to the file, to compare whether they are bitmatch.
    However, I encountered a problem here.
    Since my checkum function also need to declare several parameters to implement functionality, it means the value will be changed definitely. But these parameters will also be part of checkum... So when I read it, it maybe 1, however, after checksum finished, the vlaue will be changed to xxx. It will be different with the one in file for sure!

    unsigned int flags,result,i;
    unsigned char sum;

    local_irq_save(flags);
    sum=0;
    for(i=0;i<0x8000000;i=i+4) {
    result=readl(0xc0000000+i);
    sum+=(((result >> 24) & 0xff) + ((result >> 16) & 0xff) + ((result>> & 0xff) + (result & 0xff));
    }
    local_irq_restore(flags);

    My question is how can I do checksum? i.e. do whole memory checkum, and everything is frozen there? Maybe I should put my code in memory directly somehow?

    Thanks!

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,527
    This is not easy. As soon as you run a program, the system's memory image is changing. You would have to write some code that can run entirely out of CPU cache to do this, and not interact with the OS at all. Such a theoretical process could somehow snapshot the memory imsage, but it would have to be to a device that the OS is not in control of.

    So, all I can say is, Good Luck!


    P.S. I think this is the "rocket science" part of programming!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •