Re: mmap problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear All,

          Attaching my experiment files.
          1. kmmap.c = Kernel module
          2. mmap.c = application
          3. Makefile
          4. kscript.sh = shell script which will build the kernel module, does insmod and
                            execute the application.

I have PFN defined here to experiment with IO memory as well as VGA Controller memory.
The rest of the experiments are as written in the below mail thread.

Please check these files, and let me know if I have missed anything.

Thanks,
Prabhu




On Mon, Oct 4, 2010 at 2:46 PM, Prabhu nath <gprabhunath@xxxxxxxxx> wrote:
On inspecting the flags of the PageTable entry that holds the page base address (20002000) I inferred that the page was not dirty (i.e. the page was not written or updated). The following flags were set.
0x237 (Refer. arch/x86/include/asm/pgtable_types.h from the source code 2.6.34).

#define _PAGE_BIT_PRESENT   0   /* is present */
#define _PAGE_BIT_RW        1   /* writeable */
#define _PAGE_BIT_USER      2   /* userspace addressable */
#define _PAGE_BIT_PWT       3   /* page write through */
#define _PAGE_BIT_PCD       4   /* page cache disabled */
#define _PAGE_BIT_ACCESSED  5   /* was accessed (raised by CPU) */
#define _PAGE_BIT_DIRTY     6   /* was written to (raised by CPU) */
#define _PAGE_BIT_UNUSED1   9   /* available for programmer */

The following bit positions are set. 1 2 3 4 5 9

When I write into the virtual address, then the page should be dirty and I expect bit position 6 (blocked above) to be set, but I see that it is not set.

Which function is responsible to update the flags in the page table entry. ?

Thanks,
Prabhu



On Mon, Oct 4, 2010 at 12:25 PM, Prabhu nath <gprabhunath@xxxxxxxxx> wrote:
Dear All,

         I have an 512 MB RAM on an Intel desktop machine, of which Kernel uses 256M for all allocation for kernel as well as for user
         programs. (by passing mem=256M as a boot parameter). Hence I have 256MB of memory which I can treat it as IO memory.

         System memory is associated from 0x00000000 -  0x20000000 (512MB) in the physical address space.
         Memory addresses from 0x00000000 - 0x10000000 (256 MB) are used by the Kernel - memory management. Subsystem
         Memory addresses from 0x10000000 - 20000000 (256MB) is used as IO memory

        For an experiment, I used mmap() to map a page (4K) in IO memory (page base address 0x20002000) to user virtual address
        I used kernel function remap_pfn_range() in my kernel module's mmap function.
 
        This is rightly mapping the physical page to a user virtual address. But when I write to that address and then read. I get junk
        value.

        To just verify, when I mapped the VGA controller memory to user virtual address things are working fine.

        Can you please help me to resolve this problem.

Regards,
Prabhu




Attachment: kmmap.c
Description: Binary data

Attachment: kscript.sh
Description: Bourne shell script

Attachment: Makefile
Description: Binary data

Attachment: mmap.c
Description: Binary data


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux