Re: [PATCH v2 seccomp 2/6] asm/syscall.h: Add syscall_arches[] array

From: YiFei Zhu
Date: Thu Sep 24 2020 - 10:17:25 EST


On Thu, Sep 24, 2020 at 8:47 AM David Laight <David.Laight@xxxxxxxxxx> wrote:
> I doubt the compiler will do what you want.
> Looking at it, in most cases there are one or two entries.
> I think only MIPS has three.

It does ;) GCC 10.2.0:

$ objdump -d kernel/seccomp.o | less
[...]
0000000000001520 <__seccomp_filter>:
[...]
1587: 41 8b 54 24 04 mov 0x4(%r12),%edx
158c: b9 08 01 00 00 mov $0x108,%ecx
1591: 81 fa 3e 00 00 c0 cmp $0xc000003e,%edx
1597: 75 2e jne 15c7 <__seccomp_filter+0xa7>
[...]
15c7: 81 fa 03 00 00 40 cmp $0x40000003,%edx
15cd: b9 40 01 00 00 mov $0x140,%ecx
15d2: 74 c5 je 1599 <__seccomp_filter+0x79>
15d4: 0f 0b ud2
[...]
0000000000001cb0 <seccomp_cache_prepare>:
[...]
1cc4: 41 b9 3e 00 00 c0 mov $0xc000003e,%r9d
[...]
1dba: 41 b9 03 00 00 40 mov $0x40000003,%r9d
[...]
0000000000002e30 <proc_pid_seccomp_cache>:
[...]
2e72: ba 3e 00 00 c0 mov $0xc000003e,%edx
[...]
2eb5: ba 03 00 00 40 mov $0x40000003,%edx

Granted, I have CC_OPTIMIZE_FOR_PERFORMANCE rather than
CC_OPTIMIZE_FOR_SIZE, but this patch itself is trying to sacrifice
some of the memory for speed.

YiFei Zhu