non-unique APIC IDs

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
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

non-unique APIC IDs

Post by deadbeef »

Hi all,

I'm parsing the MPCT of hte MP Spec tables and get interesting entries:
  • CPU: enabled, BSP, APIC ID = 0x01, APIC version = 0x10
  • CPU: enabled, AP, APIC ID = 0x01, APIC version = 0x10
  • CPU: disabled, AP, APIC ID = 0x00, APIC version = 0x10
  • CPU: disabled, AP, APIC ID = 0x00, APIC version = 0x10
  • IOAPIC: address = 0xFEC00000, APIC ID = 0x01
Sure, I ignore the "disabled" CPUs. But: The APIC ID 0x01 is twice there (one for a Local APIC and the same for the IO APIC)! (Yes, I checked my printing and also did a mem dump and examined the structures by hand. So I'm sure that is what the BIOS reports.)

What do I do with this? Should I rely on the reported IDs or should I allocate IDs for each (Local, IO)-APIC myself?

Thanks!
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: non-unique APIC IDs

Post by gravaera »

Hi:

Did you encounter this in an emulator, or on real hardware?
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

Re: non-unique APIC IDs

Post by deadbeef »

This is on real HW. It's a HP Compaq dc7900, its BIOS is version 78661 (v01.16).
Qemu works just fine.
shikhin
Member
Member
Posts: 274
Joined: Sat Oct 09, 2010 3:35 am
Libera.chat IRC: shikhin
Contact:

Re: non-unique APIC IDs

Post by shikhin »

Hi,
deadbeef wrote:This is on real HW. It's a HP Compaq dc7900, its BIOS is version 78661 (v01.16).
Qemu works just fine.
For starts, try finding out what your OS thinks about the hardware. On Linux, doing something like "cat /proc/cpuinfo" might give the required information. On Windows, I'm pretty sure you could find out some similar application.

Also, posting your code to see if there's any bug in it might help.

Regards,
Shikhin
http://shikhin.in/

Current status: Gandr.
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: non-unique APIC IDs

Post by brain »

Do the acpi tables give the same results as the mp tables? Most modern oses use acpi these days to enumerate processors and apics, chances are that the bios may be buggy and its not been fixed as most users wouldn't notice the bug to report it...
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

Re: non-unique APIC IDs

Post by deadbeef »

Linux sees the same information, but uses ACPI tables. It reports
  • LAPIC with ID 0, enabled
  • LAPIC with ID 1, enabled
  • LAPIC with ID 0, disabled
  • LAPIC with ID 0, disabled
  • IOAPIC with ID 1
And it says it's using IOAPIC for interrupt routing and seems to use the IOAPIC with ID=1 and the Local APIC with IDs 0 and 1.

Is the IOAPIC ID relevant anyhow?
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: non-unique APIC IDs

Post by xenos »

Actually it's not the same information. Compare the results carefully:
deadbeef wrote:
  • CPU: enabled, BSP, APIC ID = 0x01, APIC version = 0x10
  • CPU: enabled, AP, APIC ID = 0x01, APIC version = 0x10
  • CPU: disabled, AP, APIC ID = 0x00, APIC version = 0x10
  • CPU: disabled, AP, APIC ID = 0x00, APIC version = 0x10
  • IOAPIC: address = 0xFEC00000, APIC ID = 0x01
deadbeef wrote:
  • LAPIC with ID 0, enabled
  • LAPIC with ID 1, enabled
  • LAPIC with ID 0, disabled
  • LAPIC with ID 0, disabled
  • IOAPIC with ID 1
Your code reports two local APICs with ID = 0x01, while Linux shows APIC IDs 0x00 and 0x01 for the two enabled CPUs.

The IOAPIC IDs are located in a separate numbering scheme, so there is no conflict if there is some local APIC and some IOAPIC with the same ID number.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
deadbeef
Posts: 9
Joined: Wed Apr 11, 2012 6:03 am

Re: non-unique APIC IDs

Post by deadbeef »

XenOS wrote:Actually it's not the same information. Compare the results carefully:
Oops, sorry. That was a typo introduced by me. The MP tables also report APIC ID 0x00 for the BSP.
So again, corrected, that is:
  • My OS with MP Spec tables
  • CPU: enabled, BSP, APIC ID = 0x00, APIC version = 0x10
  • CPU: enabled, AP, APIC ID = 0x01, APIC version = 0x10
  • CPU: disabled, AP, APIC ID = 0x00, APIC version = 0x10
  • CPU: disabled, AP, APIC ID = 0x00, APIC version = 0x10
  • IOAPIC: address = 0xFEC00000, APIC ID = 0x01
  • Linux with ACPI tables
  • LAPIC with ID 0, enabled
  • LAPIC with ID 1, enabled
  • LAPIC with ID 0, disabled
  • LAPIC with ID 0, disabled
  • IOAPIC with ID 1
XenOS wrote:The IOAPIC IDs are located in a separate numbering scheme, so there is no conflict if there is some local APIC and some IOAPIC with the same ID number.
Oh, interesting. I had assumed that the IDs have to be unique amongst all APICs (including both Local APICs and IO APICs). You tell me that the APIC IDs of IOAPICs have to be unique over all IOAPICs and APIC IDs of LocalAPICs have to be unique over all LocalAPICs. Correct?

Hmm... That seems odd to me. I mean in ancient times there was the dedicated APIC bus and the APIC IDs were used to address entities on that bus. So the IDs should have been unique amongst all the APICs back then. It's likely that it is not relevant anymore (maybe in modern systems the IOAPICs don't need a ID at all). But that's just me guessing.

Can someone verify/falsify this?
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: non-unique APIC IDs

Post by xenos »

I'm not too sure about all this, so please take everything with a grain of salt.
deadbeef wrote:Oh, interesting. I had assumed that the IDs have to be unique amongst all APICs (including both Local APICs and IO APICs). You tell me that the APIC IDs of IOAPICs have to be unique over all IOAPICs and APIC IDs of LocalAPICs have to be unique over all LocalAPICs. Correct?
Yes - at least that's how it should be on modern systems.
Hmm... That seems odd to me. I mean in ancient times there was the dedicated APIC bus and the APIC IDs were used to address entities on that bus. So the IDs should have been unique amongst all the APICs back then. It's likely that it is not relevant anymore (maybe in modern systems the IOAPICs don't need a ID at all). But that's just me guessing.
Indeed, there used to be a single APIC bus on older systems. Newer systems have separate buses for local APICs and IOAPICs.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Post Reply