It should be noted that there is generally not really any reason to do this, and you should especially not do this to implement some vendor specific quirk.
Even in the example of the `sys_stephen` syscall from November 2016, it already clashes with the syscall number of `sys_leftpad`, proposed upstream in April 2016[1].
Can anyone help me understand why transitioning to kernel mode is architecture-dependent? I’m not clear on why the linux system call kernel entry code in arch/x86/entry/common.c has to be in assembly, instead of C.
The mode is actually tracked/enforced by the CPU but the implementation differs per architecture. For example:
> The hardware severely restricts the ways in which control can be passed from one ring to another, and also enforces restrictions on the types of memory access that can be performed across rings. Using x86 as an example, there is a special gate structure which is referenced by the call instruction that transfers control in a secure way.
I posted this nice, real life example here back in February: https://twitter.com/RichFelker/status/1357733309737021444
Even in the example of the `sys_stephen` syscall from November 2016, it already clashes with the syscall number of `sys_leftpad`, proposed upstream in April 2016[1].
[1] https://lkml.org/lkml/2016/3/31/1109