0xAX / linux-insides

A little bit about a linux kernel
http://0xax.gitbooks.io/linux-insides/content/index.html
Other
30.02k stars 3.37k forks source link

Regarding your's article: Linux kernel memory management Part 2 #747

Closed ZoranStojsavljevic closed 4 years ago

ZoranStojsavljevic commented 4 years ago

Linux kernel memory management Part 2: https://0xax.gitbooks.io/linux-insides/content/MM/linux-mm-2.html

I have created the following github repo: https://github.com/ZoranStojsavljevic/ldd3-skull-revisited/tree/main/skull_revisited

I have problem understanding the following code (in skull.c, rewritten by me):

145 / Use ioremap to get a handle on the ISA region / 146 base = ioremap(ISA_REGION_BEGIN, ISA_REGION_END - ISA_REGION_BEGIN); ...snap... 151 / Probe all the memory hole in STEP steps / 152 for (add = ISA_REGION_BEGIN; add < ISA_REGION_END; add += STEP) {

When I print in STEP (64K) the base +add for these 6 ISA segments, I am getting the following:

[33650.277938] resource sanity check: requesting [mem 0x000a0000-0x000fffff], which spans more than PCI Bus 0000:00 [mem 0x000a0000-0x000bffff window]
[33650.277942] caller skull_init+0x37/0x1000 [skull] mapping multiple BARs
[33650.277943] --- ioremap addr = 0000000057c4c58a ---
[33650.277949] a0000: EMPTY
[33650.277949] --- ioremap addr = 0000000057c4c58a ---
[33650.277953] b0000: EMPTY
[33650.277953] --- ioremap addr = 000000008e44dea5 ---
[33650.277954] c0000: EMPTY
[33650.277954] --- ioremap addr = 00000000ca362387 ---
[33650.277955] d0000: ROM
[33650.277955] --- ioremap addr = 000000008e6f11dd ---
[33650.277956] e0000: RAM
[33650.277957] --- ioremap addr = 000000004d2dd7df ---
[33650.277957] f0000: ROM
[33650.277958] --- ioremap addr = 00000000aa51dfbf ---

This seems to me very odd! I have two questions here:

[1] Should 64bit virtual address look like: 0x000XXXXX_XXXXX000? First 0x000 ==>> 48 addresses + PAE extension (4 bits) Last 0x000 ==>> PT size (page is at 12bits minimum, should it be aligned) to 4K address (0x000)???

[2] Why the 64bit virtual addresses for ISA are random (should VA be adjacent, so these 384K addresses are assigned to base +384K END consecutively/in linear fashion???

What am I doing wrong here???

Could you, please, inspect very quickly the skull.c code?

Thank you in advance, Zoran


ZoranStojsavljevic commented 4 years ago

Actually, I made mistake in the presentation format. All this now looks as it should be.

printk(KERN_INFO "--- ioremap addr = %lx ---\n", (unsigned long)(base + add));

Implementation issue closed... But there are some other architectural issues I am trying to explain, mainly to myself!

Zoran