BOCHS + SMP error

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
chrisf
Posts: 3
Joined: Sun May 10, 2009 2:48 pm

BOCHS + SMP error

Post by chrisf »

Hello,

I'm writing software to enable symmetric multiprocessing. Currently its being tested in BOCHS. My software can locate both MP tables and parse them fine. The problem comes when trying to send the INIT IPI. It looks like it's never actually being sent. I'm guessing there are two sections of my code that the problem could be in: the part that initializes the APIC and the part that sends the IPI.

Here is the section that enables the APIC:

Code: Select all

;Set up spurious interrupt.
mov eax, [es:0fee000F0h]
or eax, 256d
mov [es:0fee000F0h], eax

;Set up error vector.
mov eax, [es:0fee00370h]
and eax, 0FFFFFF00h
or eax, 0Ah
mov [es:0fee00370h], eax


;Set up timer vector
mov eax, 00010021h
mov [es:0fee00320h], eax

;Set up LINT0, LINT1, and performance counter INT
mov eax, 00000700h
mov [es:0fee00340h], eax
mov [es:0fee00350h], eax
mov [es:0fee00360h], eax 
The ES segment register is correct ... I have two GDT entries and the value in ES allows for access of all 4 GB of memory.

Code: Select all

MultiprocessorTestLoop:
mov ax, 10h
mov ds, ax
mov ax, 18h
mov es, ax
lea esi, [MultiprocessorCode]
mov edi, 8000h
mov ecx, 6h
cld
rep movsb
xor ebx, ebx
mov eax, 000C4500h
mov [es:0ffe00310h], ebx
mov [es:0ffe00300h], eax ;Send INIT

mov ecx, 87654321h
TestLoop:
mov eax, [es:0ffe00300h]
test eax, 4096d
jnz TestLoop
mov ecx, 12345678h
jmp PMEndlessLoop


call MultiprocessorWait10MS

mov eax, 000C4608h
mov [es:0ffe00300h], eax ;Send SIPI
jmp PMEndlessLoop
mov ecx, 100000d
NopLoop1:
nop
loop NopLoop1
mov [es:0ffe00300h], eax ;Send SIPI again
jmp PMEndlessLoop


The code above will loop infinitely at TestLoop. EAX will always have a value of FFFFFFFFh.

Any ideas? Thanks.
Hyperdrive
Member
Member
Posts: 93
Joined: Mon Nov 24, 2008 9:13 am

Re: BOCHS + SMP error

Post by Hyperdrive »

Hi,
chrisf wrote: [... INIT-SIPI-SIPI sequence issuing code snipped ...]
The code above will loop infinitely at TestLoop. EAX will always have a value of FFFFFFFFh.
a value of FFFFFFFFh in EAX means you have read garbage. Just look from which address you read...

Code: Select all

TestLoop:
mov eax, [es:0ffe00300h]      ;  <--- should be:  mov eax, [es:0fEe00300h]
test eax, 4096d
jnz TestLoop
That's also the case for the rest of the second code snippet.

Just a few notes:
  • Don't broadcast the INIT-SIPI-SIPI sequence. You may start broken/for a reason deactivated processors.
  • Don't use fixed addresses (as FEE00000h). First, that would have saved you headaches. Second, the APICs could theoretically be mapped to other locations.
  • To help you with the two issues above, just obtain MP Spec tables or ACPI tables and parse them to get the information you need.
  • There were more things I wanted to mention, but I forgot by now. Oh well. ;)
  • EDIT: Ah, I remembered at least one more issue... Your technique of waiting a "certain" time:

    Code: Select all

    mov ecx, 100000d
    NopLoop1:
    nop
    loop NopLoop1
    
    isn't a good idea. That may work on one machine but on another (e.g. with another CPU frequency) it may fail.
--TS
Post Reply