在 2025/1/18 21:50, Ethan Zhao 写道:
Hi, Xin, Peter
While checking the asm code of arch/x86/entry/entry_fred.o about
function fred_hwexc(),
found the code was generated as following :
0000000000000200 <fred_hwexc.constprop.0>:
200: 0f b6 87 a4 00 00 00 movzbl 0xa4(%rdi),%eax
207: 3c 0e cmp $0xe,%al /* match X86_TRAP_PF */
209: 75 05 jne 210 <fred_hwexc.constprop.0+0x10>
20b: e9 00 00 00 00 jmp 210 <fred_hwexc.constprop.0+0x10>
210: 3c 0b cmp $0xb,%al
212: 74 6a je 27e <fred_hwexc.constprop.0+0x7e>
214: 77 17 ja 22d <fred_hwexc.constprop.0+0x2d>
216: 3c 06 cmp $0x6,%al
218: 0f 84 83 00 00 00 je 2a1 <fred_hwexc.constprop.0+0xa1>
21e: 76 29 jbe 249 <fred_hwexc.constprop.0+0x49>
220: 3c 08 cmp $0x8,%al
222: 74 78 je 29c <fred_hwexc.constprop.0+0x9c>
224: 3c 0a cmp $0xa,%al
226: 75 18 jne 240 <fred_hwexc.constprop.0+0x40>
228: e9 00 00 00 00 jmp 22d <fred_hwexc.constprop.0+0x2d>
22d: 3c 11 cmp $0x11,%al
22f: 74 66 je 297 <fred_hwexc.constprop.0+0x97>
231: 76 2c jbe 25f <fred_hwexc.constprop.0+0x5f>
233: 3c 13 cmp $0x13,%al
235: 74 5b je 292 <fred_hwexc.constprop.0+0x92>
237: 3c 15 cmp $0x15,%al
239: 75 1b jne 256 <fred_hwexc.constprop.0+0x56>
23b: e9 00 00 00 00 jmp 240 <fred_hwexc.constprop.0+0x40>
240: 3c 07 cmp $0x7,%al
242: 75 49 jne 28d <fred_hwexc.constprop.0+0x8d>
244: e9 00 00 00 00 jmp 249 <fred_hwexc.constprop.0+0x49>
249: 3c 01 cmp $0x1,%al
24b: 74 3b je 288 <fred_hwexc.constprop.0+0x88>
24d: 3c 05 cmp $0x5,%al
24f: 75 1b jne 26c <fred_hwexc.constprop.0+0x6c>
251: e9 00 00 00 00 jmp 256 <fred_hwexc.constprop.0+0x56>
256: 3c 12 cmp $0x12,%al
258: 75 33 jne 28d <fred_hwexc.constprop.0+0x8d>
25a: e9 00 00 00 00 jmp 25f <fred_hwexc.constprop.0+0x5f>
seems the following calling to exc_page_fault() was optimized out from
fred_hwexc() by gcc,
if(likely(regs->fred_ss.vector==X86_TRAP_PF))
returnexc_page_fault(regs,error_code);
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
GNU objdump (GNU Binutils) 2.43
default kernel config.
.config:CONFIG_X86_FRED=y
my understanding, -O2 is the default kernel KBUILD_CFLAGS
So, Are there any workaround needed to make the kernel works with
default build ?
or just as Peter said in another loop, manually loading some event
bits to make the
over-smart gcc behave normally ?or fall back to -O(ption)0 ?
Any idea, much appreciated !
Thanks,
Ethan
Rebuild the same lastest stable kernel with FRED enabled, default -O2 on RHEL 8.6, got
correct result:
ffffffff820a7430 <fred_hwexc>:
ffffffff820a7430: 55 push %rbp
ffffffff820a7431: 0f b6 87 a4 00 00 00 movzbl 0xa4(%rdi),%eax
ffffffff820a7438: 48 89 e5 mov %rsp,%rbp
ffffffff820a743b: 3c 0e cmp $0xe,%al
ffffffff820a743d: 75 0b jne ffffffff820a744a <fred_hwexc+0x1a>
ffffffff820a743f: e8 4c 50 00 00 callq ffffffff820ac490 <exc_page_fault>
ffffffff820a7444: 5d pop %rbp
gcc version 8.5.0 20210514 (Red Hat 8.5.0-10) (GCC)
whatever CONFIG_JUMP_LABEL=y or CONFIG_JUMP_LABEL is not set.
so the issue seems only about WSL ubuntu toolchain.
Thanks,
Ethan
--
"firm, enduring, strong, and long-lived"