Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: Add generic stub_syscall6 function

This function will be used by the new syscall handling code.

Signed-off-by: Benjamin Berg <benjamin@sipsolutions.net>
Link: https://patch.msgid.link/20240703134536.1161108-4-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Benjamin Berg and committed by
Johannes Berg
542dc79f dc26184a

+38
+22
arch/x86/um/shared/sysdep/stub_32.h
··· 80 80 return ret; 81 81 } 82 82 83 + static __always_inline long stub_syscall6(long syscall, long arg1, long arg2, 84 + long arg3, long arg4, long arg5, 85 + long arg6) 86 + { 87 + struct syscall_args { 88 + int ebx, ebp; 89 + } args = { arg1, arg6 }; 90 + long ret; 91 + 92 + __asm__ volatile ("pushl %%ebp;" 93 + "movl 0x4(%%ebx),%%ebp;" 94 + "movl (%%ebx),%%ebx;" 95 + "int $0x80;" 96 + "popl %%ebp" 97 + : "=a" (ret) 98 + : "0" (syscall), "b" (&args), 99 + "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5) 100 + : "memory"); 101 + 102 + return ret; 103 + } 104 + 83 105 static __always_inline void trap_myself(void) 84 106 { 85 107 __asm("int3");
+16
arch/x86/um/shared/sysdep/stub_64.h
··· 80 80 return ret; 81 81 } 82 82 83 + static __always_inline long stub_syscall6(long syscall, long arg1, long arg2, 84 + long arg3, long arg4, long arg5, 85 + long arg6) 86 + { 87 + long ret; 88 + 89 + __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; movq %7,%%r9 ; " 90 + __syscall 91 + : "=a" (ret) 92 + : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3), 93 + "g" (arg4), "g" (arg5), "g" (arg6) 94 + : __syscall_clobber, "r10", "r8", "r9"); 95 + 96 + return ret; 97 + } 98 + 83 99 static __always_inline void trap_myself(void) 84 100 { 85 101 __asm("int3");