Strange paging issue

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Strange paging issue

Post by bzt »

It must be something obvious I'm missing here.
I have a screen buffer and the framebuffer mapped similarly. Or at least I thought, but sometimes the screen is not mapped. The problem appears on qemu and on bochs as well.

Here's my log:

Code: Select all

vmm_mapbss(3E000,7FFF00000000,3CC000,2097152,800000000000001F)
vmm_mapbss(3E000,7FFF40000000,FD000000,2097152,800000000000001F)
vmm_mapbss(3E000,7FFF40200000,FD200000,2097152,800000000000001F)
vmm_mapbss(3E000,7FFF40400000,FD400000,2097152,800000000000001F)
vmm_mapbss(3E000,7FFF40600000,FD600000,2097152,800000000000001F)
OS/Z panic:  --- page fault 14 --- @20A3A1 copyarea  
 [ Code]   Data    Messages    TCB    CCB    RAM    Sysinfo  
[Registers]
cs=00000023 rip=000000000020A3A1 
rflags=0000000000013246 excerr=0000000D 
cr2=00007FFF00000000 cr3=000000000003E000 

rax=00007FFF400DE400 rbx=00007FFF400DE400 
rcx=0000000000000020 rdx=00007FFF00000000 
rsi=00007FFF00000000 rdi=00007FFF400DE400 
 r8=0000000000000600  r9=000000000000011C 
r10=0000000000000C80 r11=0000000000000000 
r12=0000000000000020 r13=0000000000000020 
r14=0000000000000C80 r15=0000000000000C80 
rbp=0000000000200000 rsp=00000000001FFFA8 
...
[ Code 20A3A1: copyarea +00C8]
00C6    jnz	20A3A5h		;copyarea +CC
00C8 -> repnz movsd	
00CA    jmp	20A3DDh		;copyarea +104
display/fb 3D dbg> x rsi 
  Code   [Data]   Messages    TCB    CCB    RAM    Sysinfo  
00007FFF00000000:  * not mapped 14 *    
...
00007FFF000001C0:  * not mapped 14 *    

  PML4 800000000006B01F 0.....WUW.  508      PDPE 800000000006C01F 0.....WUW.    0
  PDE  80000000003CC09F 0.T...WUW.    0      (slot allocated)
display/fb 3D dbg> x rdi 
  Code   [Data]   Messages    TCB    CCB    RAM    Sysinfo  
00007FFF400DE400:  00 00 40 00  00 00 40 00  00 00 40 00  00 00 40 00 ..@...@...@...@.
...
00007FFF400DE5C0:  00 00 40 00  00 00 40 00  00 00 40 00  00 00 40 00 ..@...@...@...@.

  PML4 800000000006B03F 0...A.WUW.  509      PDPE 800000000006D03F 0...A.WUW.    0
  PDE  80000000FD0000BF 0.T.A.WUW.  222      (slot allocated)
display/fb 3D dbg>
The only difference I see (other than the addresses) is that the frame buffer's accessed bits are set.

Same problem shown in bochs debugger:

Code: Select all

<bochs:3> page 0x7FFF00000000
PML4: 0x800000000006b01f XD ps         a PCD PWT U W P
PDPE: 0x800000000006c01f XD ps         a PCD PWT U W P
 PDE: 0x80000000003cc09f XD PS g pat d a PCD PWT U W P
physical address not available for linear 0x00007fff00000000
<bochs:4> page 0x7FFF40000000
PML4: 0x800000000006b01f XD ps         a PCD PWT U W P
PDPE: 0x800000000006d01f XD ps         a PCD PWT U W P
 PDE: 0x80000000e000009f XD PS g pat d a PCD PWT U W P
linear page 0x00007fff40000000 maps to physical page 0x0000e0000000
<bochs:5> creg
CR0=0xe0000011: PG CD NW ac wp ne ET ts em mp PE
CR2=page fault laddr=0x00000000c9ff6000
CR3=0x00000003e000
    PCD=page-level cache disable=0
    PWT=page-level write-through=0
CR4=0x000002e8: pke smap smep osxsave pcid fsgsbase smx vmx osxmmexcpt umip OSFXSR pce PGE MCE PAE pse DE tsd pvi vme
CR8: 0x0
EFER=0x00000d01: ffxsr NXE LMA LME SCE
XCR0=0x00000001: pkru hi_zmm zmm_hi256 opmask bndcfg bndregs ymm sse FPU
<bochs:6> xp 0x3cc000
[bochs]:
0x00000000003cc000 <bogus+       0>:	0x00000000
<bochs:7> xp 0x5cc000-4
[bochs]:
0x00000000005cbffc <bogus+       0>:	0x00000000
<bochs:8> 
Any idea why isn't linear address 0x7FFF00000000 available? I've invalidated memory, and have CR3 reloaded. I think they both should or shouldn't work, but only one of them? How so?

Btw, physical address 0x3CC000 is reported as usable RAM in E820 map. Oddly if I boot with TianoCore, the problem disappears.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Strange paging issue

Post by Brendan »

Hi,
bzt wrote:Btw, physical address 0x3CC000 is reported as usable RAM in E820 map. Oddly if I boot with TianoCore, the problem disappears.
If you're using 2 MiB large pages, then they have to be aligned on a 2 MiB boundary. Otherwise 0x3CC000 becomes "0x200000 with some ignored/reserved bits".


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Strange paging issue

Post by bzt »

Brendan wrote: If you're using 2 MiB large pages, then they have to be aligned on a 2 MiB boundary. Otherwise 0x3CC000 becomes "0x200000 with some ignored/reserved bits".


Cheers,

Brendan
Arrrghhhh, I knew it was something obvious! Of course you are right, thanks a lot!
Post Reply