물리주소 질문입니다

안녕하세요.
좀… 이상한 질문을 하게 되네요. 사람 하나 살리는 셈치고 답변 좀 부탁드릴게요.

[color=#8000FF:3berw1bs]아래와 유사한 방법으로 일정한 크기의 메모리를 할당받고 그 논리주소를 물리주소로 변경하려고 합니다.[/color:3berw1bs]

[color=#4040BF:3berw1bs]//user mode의 source[/color:3berw1bs]
unsigned long* ulptrAddr = (unsigned long *)malloc( 1024 * 1024 ); // 임시 논리주소값

[color=#8000FF:3berw1bs]위에서 할당받은 주소를 device driver에 넘겨주고 아래와 같이 만들었습니다.[/color:3berw1bs]

[color=#4040BF:3berw1bs]//device driver의 source[/color:3berw1bs]
// PML4E의 값 구하기
//
// A 4-KByte naturally aligned PML4 table is located at the physical address specified in bits 51:12 of CR3 (see Table 4-12).
// A PML4 table comprises 512 64-bit entries (PML4Es).
// A PML4E is selected using the physical address defined as follows:
//
// — Bits 51:12 are from CR3. // M-1:12 == 35:12 bit of CR3 //// CR3의 35:12 비트 따오기
// — Bits 11:3 are bits 47:39 of the linear address. //// 논리주소의 47:39 비트를 따와서 11:3 비트에 집어넣기
// — Bits 2:0 are all 0. //// 그냥 0 0 0 처리하기
//
unsigned long PML4E, VirtulAddr;
unsigned long volatile * ptrAddr = NULL;

[color=#008000:3berw1bs]printk("\n—> Virtual addr == %lX", VirtulAddr );
printk("\n—> CR3 == %lX", read_cr3() );
[/color:3berw1bs]
PML4E = ( read_cr3() & 0xFFFFFF000 ); // CR3의 35:12 비트 따오기
PML4E = PML4E | ( ( VirtulAddr & 0xFF8000000000 ) >> 36 ); // 논리주소의 47:39 비트 따와서 11:3으로 비트 시프트 시키기
[color=#008000:3berw1bs]printk("\n—> PML4E == %lx", PML4E );[/color:3berw1bs]

ptrAddr = (unsigned long volatile *)PML4E;
printk("\n—> pAddr == %lx", [color=#FF4000:3berw1bs][b:3berw1bs]*ptrAddr[/b:3berw1bs][/color:3berw1bs] );

[color=#BF0000:3berw1bs]프로그램을 실행해서 dmesg를 쳐보면… CR3값등 녹색 부분은 출력이 되나,
주황색처럼 PML4E의 물리주소를 access하려하면 아래과 같이 에러(dmesg출력 부분)가 뜹니다.[/color:3berw1bs]
Intel developer’s manual이나 AMD64 programmer’s manual에선…
CR3 -> PML4E -> PDPTE -> PDE-> PTE 같은 과정을 거쳐서 물리주소를 얻을 수 있다고 나와있습니다.

[color=#0040FF:3berw1bs]그래서 질문입니다.
[b:3berw1bs]1. device driver부분에서 위처럼 물리주소를 얻을 수 있는 방법이 있을까요??[/b:3berw1bs]
(위의 *ptrAddr 값을 받아 올 수 있다든지…)
[b:3berw1bs]2. 위의 과정들과는 상관없이 최초의 목적인 user단에서 할당받은 논리주소를 물리주소로 변환할 수 있는 방법이 있을까요??[/b:3berw1bs]
(위 source의 경우는 PML4E에서 access 불가로 막혀버려서 나머지 PDPTE 등은 진행조차 불가능하기 때문입니다.)[/color:3berw1bs]

//dmesg 출력 부분
[432623.710414] —> Vaddr == 7F52E92BC010
[432623.710420] —> CR3 == 1F9162000
[432623.710426] —> PML4E == 1f9162000
[432623.710432] —> PML4E == 1f91627f0
[432623.710448] BUG: unable to handle kernel paging request at 00000001f91627f0
[432623.710461] IP: [<ffffffffa00824e5>] hh_v2p+0x2b5/0x3b0 [hdiagl_dev]
[432623.710481] PGD 200503067 PUD 0
[432623.710492] Oops: 0000 [#10] SMP
[432623.710502] last sysfs file: /sys/devices/pci0000:00/0000:00:09.0/host0/target0:0:0/0:0:0:0/block/sda/uevent
[432623.710514] CPU 3
[432623.710520] Modules linked in: hdiagl_dev snd_hda_codec_nvhdmi snd_hda_codec_realtek binfmt_misc vboxnetadp vboxnetflt vboxdrv snd_hda_intel snd_hda_codec snd_hwdep snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy iptable_filter snd_seq_oss snd_seq_midi snd_rawmidi amd64_edac_mod ip_tables snd_seq_midi_event x_tables edac_core nvidia(P) ppdev snd_seq parport_pc psmouse serio_raw snd_timer shpchp snd_seq_device snd soundcore snd_page_alloc i2c_nforce2 lp parport dm_raid45 xor usbhid ohci1394 ieee1394 forcedeth video output [last unloaded: hdiagl_dev]
[432623.710634] Pid: 12280, comm: hdiagl Tainted: P D 2.6.31-20-generic #58-Ubuntu MS-7612
[432623.710645] RIP: 0010:[<ffffffffa00824e5>] [<ffffffffa00824e5>] hh_v2p+0x2b5/0x3b0 [hdiagl_dev]
[432623.710664] RSP: 0018:ffff8801dd94fe98 EFLAGS: 00010296
[432623.710670] RAX: 000000000000002b RBX: 00000001f91627f0 RCX: 000000000000001e
[432623.710679] RDX: 0000000000000000 RSI: 0000000000000086 RDI: 0000000000000246
[432623.710688] RBP: ffff8801dd94fec8 R08: 0000000000000034 R09: 0000000000025d48
[432623.710697] R10: 0000000000000005 R11: 0000000000000000 R12: 0000007fc0000000
[432623.710706] R13: 0000000ffffff000 R14: ffff8801f90075e0 R15: ffff8801dd8cda48
[432623.710717] FS: 00007f52e93bd6f0(0000) GS:ffff88002808e000(0000) knlGS:00000000f6a16750
[432623.710726] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[432623.710734] CR2: 00000001f91627f0 CR3: 00000001f9162000 CR4: 00000000000006e0
[432623.710744] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[432623.710753] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
[432623.710763] Process hdiagl (pid: 12280, threadinfo ffff8801dd94e000, task ffff8801ffd64410)
[432623.710769] Stack:
[432623.710774] ffff88020f8adc00 0000000000fef7c0 0000000000000008 ffff8801dd94ff48
[432623.710789] <0> 0000000000000000 0000000000000000 ffff8801dd94fee8 ffffffffa008261c
[432623.710804] <0> ffff88020f8adc00 0000000000fef7c0 ffff8801dd94ff28 ffffffff8111fa55
[432623.710821] Call Trace:
[432623.710834] [<ffffffffa008261c>] hh_read+0x3c/0xa0 [hdiagl_dev]
[432623.710853] [<ffffffff8111fa55>] vfs_read+0xb5/0x1a0
[432623.710866] [<ffffffff8152f634>] ? do_page_fault+0x194/0x370
[432623.710878] [<ffffffff8112005c>] sys_read+0x4c/0x80
[432623.710891] [<ffffffff81012082>] system_call_fastpath+0x16/0x1b
[432623.710899] Code: 4a e1 48 23 1d fd 10 00 00 48 c7 c7 9d 27 08 a0 31 c0 48 c1 eb 24 4c 09 e3 49 bc 00 00 00 c0 7f 00 00 00 48 89 de e8 b0 7c 4a e1 <48> 8b 33 48 c7 c7 b0 27 08 a0 4c 21 eb 31 c0 e8 9c 7c 4a e1 48
[432623.711005] RIP [<ffffffffa00824e5>] hh_v2p+0x2b5/0x3b0 [hdiagl_dev]
[432623.711019] RSP <ffff8801dd94fe98>
[432623.711025] CR2: 00000001f91627f0
[432623.711034] —[ end trace 11e755bb6628670e ]—
joseph@joseph-desktop:~$