IRC channel logs

2025-12-31.log

back to list of logs

<damo22>ok i registered the boot data in biosmem and got a console log now
<damo22>the remaining issue is GS
<damo22>Breakpoint 2, cpu_launch_first_thread (th=<optimized out>) at ../kern/startup.c:320
<damo22>320 load_context(th);
<damo22>up until here, GS is set correctly
<damo22>when i execute that function in gdb GS gets corrupt
<damo22>and it double faults
<damo22>switch_ktss breaks it
<damo22>where are the segments switched?
<damo22>aha
<damo22>percpu_assign() is called after the gs is reloaded
<damo22>you cant switch to the new thread and THEN update the percpu active thread using gs
<damo22>youpi: do kernel threads run as a "normal" threads? if so, dont we need to populate gs base address in the thread state for the kernel threads so they dont get erased?
<damo22> 11013: 0f 01 16 32 11 lgdtw 0x1132
<damo22>...
<damo22> 1102a: ea 2f 10 08 00 ljmp $0x8,$0x102f
<damo22>is that the correct offset or should it be 0x2f
<damo22>ahh i see you can do a 16 bit ljmp with 32 bit immediate
<damo22>but GAS has trouble assembling it
<damo22>66 ea xx xx xx xx yy yy
<damo22>0F 01 /2 LGDT m16&32
<damo22>what does the /2 mean in the op code description?
<damo22>ok
<damo22>looks like lgdt can only take a 16 bit immediate in real mode
<damo22>but the descriptor can contain a 32 bit address
<damo22>got to protected mode on AP!
<youpi>damo22: I don't know what you call a "normal" thread
<youpi>during my couple decade of working on parallel computing, I have seen so many different kinds of "threads" :)
<youpi>about gs/fs, we don't use them for implementing some __thread per-thread data
<youpi>we use gs for per-cpu data, see percpu.h
<damo22> 0x0001103c <+10>: 0f 01 15 72 5c 09 01 lgdtl 0x1095c72
<damo22> 0x00011043 <+17>: ea 4a 10 01 00 08 00 ljmp $0x8,$0x1104a
<damo22> 0x0001104a <+24>: b8 ef be ad de mov $0xdeadbeef,%eax
<damo22> 0x0001104f <+29>: f4 hlt
<damo22> 0x00011050 <+30>: eb fd jmp 0x1104f <protected_mode+29>
<damo22>^^^ the only conclusion i can draw is that the ljmp is wrongly specified because the AP executes and loads the gdt but it never executes the halt and runs away somewhere else
<damo22>CS =0008 40000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
<damo22>GDT= 01095c80 0000006f
<azert>damo22: what is the segment descriptor? If you are calling into a call gate, the offset is ignored
<damo22>it seems like my code segment is not executable??
<damo22>is that posslbe