Page 1 of 2

some questions about SMP?

Posted: Tue Jul 28, 2020 12:56 pm
by mkfree
I am implementing the drivers so that the kernel supports several processors:
1- I did the search in the bios area (EBDA) and found the entry _MP_ (floating pointer structure), I did the checksum, ok
2- Then I got the PCMP (configuration table), I did the checksum, ok
3- I identified the IO PIC inputs and processors.
4- When I read in the configuration table, the field belonging to the address of the local APICs, I get that this address is
in 0xFEE00000, which is consistent with what the BIOS says that the addresses for this type of device are above 0xC0000000.

This memory location is virtual?
Before starting to work with IO-APIC, should I get a physical page and assign it to this virtual address?

Re: some questions about SMP?

Posted: Tue Jul 28, 2020 1:04 pm
by nexos
That is a physical address. It must be mapped as present, writeable, and non-cacheable somewhere.

Re: some questions about SMP?

Posted: Tue Jul 28, 2020 1:08 pm
by nexos
Also, have you read the MP specification? The xv6 source code really helped me out as well.

Re: some questions about SMP?

Posted: Tue Jul 28, 2020 1:16 pm
by mkfree
Nexos,
If I have the QUEMU configured with only 256MB of RAM, how is it possible to allocate such a memory location above the physical memory, or am I doing something wrong?

Re: some questions about SMP?

Posted: Tue Jul 28, 2020 1:21 pm
by nexos
This address is not RAM. Instead, it points to the LAPIC registers. It is called memory mapped because the firmware (to be precise, the chipset) maps this address to the LAPICs registers. Physical address are not necessarily RAM. They can also point to ROM (the BIOS is mapped to memory, yet is on ROM), a hardware device (PCI BARs and the APICs), or video ram(i.e. 0xB8000 points to VGA RAM, not system RAM). This is very important to understand when dealing with device management.

Re: some questions about SMP?

Posted: Tue Jul 28, 2020 1:34 pm
by mkfree
Ok, thank you very much, I am already reviewing the xv6 code, I hope to clarify some doubts.

Re: some questions about SMP?

Posted: Tue Jul 28, 2020 1:35 pm
by nexos
To see more about why the APIC addresses can exist so high in memory read https://en.wikipedia.org/wiki/Memory-mapped_I/O

Re: some questions about SMP?

Posted: Tue Jul 28, 2020 2:00 pm
by mkfree
Ok, really the address decoder takes care of all this, I had not thought of it that way for this address, really my question is nonsense.

Re: some questions about SMP?

Posted: Wed Jul 29, 2020 6:14 am
by mkfree
Nexos,
You have tested your implementation with the bochs, because when I do the virtual memory allocation in the kernel directory, it tells me
PANIC (APIC write with len = 1 (should be 4)), disable the cache for this page, I even got the address via
of the rdmsr instructions to check the addresses with those of the bios and they are the same. Will it be an emulator problem?
the same with quemu.

Re: some questions about SMP?

Posted: Wed Jul 29, 2020 6:34 am
by nexos
Did you set the cache disable bit in the PTE when mapping it (it is bit 5)?

Re: some questions about SMP?

Posted: Wed Jul 29, 2020 7:01 am
by mkfree
Yes, (PG_CACHE_DISABLED 0x00000010)

Re: some questions about SMP?

Posted: Wed Jul 29, 2020 7:07 am
by nexos
Where can I see the code?

Re: some questions about SMP?

Posted: Wed Jul 29, 2020 7:55 am
by mkfree
Thank you very much for the help.

Re: some questions about SMP?

Posted: Wed Jul 29, 2020 8:34 am
by nexos

Re: some questions about SMP?

Posted: Wed Jul 29, 2020 8:35 am
by nexos
The APIC memory base should be a u32 and it should have the volatile keyword. It should work then.