[PATCH] syscalls/x86: fix UML syscall table
From: Dominik Brodowski
Date: Thu Apr 05 2018 - 16:16:23 EST
To differentiate the different calling regime used on x86, the syscall
functions received __sys_x86_ as prefix (instead of sys_). This breaks
the build of UML on 64-bit x86, as it re-uses the same syscall table.
To fix this, replace the __sys_x86_ prefix with sys_ during the generation
of <asm/syscalls_64.h>.
Fixes: syscalls/x86: rename struct pt_regs-based sys_*() to __sys_x86_*()
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: x86@xxxxxxxxxx
Signed-off-by: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
diff --git a/arch/x86/entry/syscalls/syscalltbl.sh b/arch/x86/entry/syscalls/syscalltbl.sh
index d71ef4bd3615..d6376b87ecb2 100644
--- a/arch/x86/entry/syscalls/syscalltbl.sh
+++ b/arch/x86/entry/syscalls/syscalltbl.sh
@@ -20,17 +20,47 @@ syscall_macro() {
echo "__SYSCALL_${abi}($nr, $real_entry, $qualifier)"
}
-emit() {
+emit64() {
abi="$1"
nr="$2"
entry="$3"
compat="$4"
- if [ "$abi" = "64" -a -n "$compat" ]; then
+ if [ "$abi" = "I386" ]; then
+ echo "emit64() called for a 32-bit syscall" >&2
+ exit 1
+ fi
+
+ if [ -n "$compat" ]; then
echo "a compat entry for a 64-bit syscall makes no sense" >&2
exit 1
fi
+ if [ -n "$entry" ]; then
+ # For CONFIG_UML, we need to strip the __sys_x86 prefix
+ if [ "${entry}" = "${entry#__compat_sys}" ]; then
+ umlentry="sys${entry#__sys_x86}"
+ fi
+
+ echo "#ifdef CONFIG_X86"
+ syscall_macro "$abi" "$nr" "$entry"
+ echo "#else /* CONFIG_UML */"
+ syscall_macro "$abi" "$nr" "$umlentry"
+ echo "#endif"
+ fi
+}
+
+emit32() {
+ abi="$1"
+ nr="$2"
+ entry="$3"
+ compat="$4"
+
+ if [ "$abi" = "64" ]; then
+ echo "emit32() called for a 64-bit syscall" >&2
+ exit 1
+ fi
+
if [ -z "$compat" ]; then
if [ -n "$entry" ]; then
syscall_macro "$abi" "$nr" "$entry"
@@ -53,14 +83,14 @@ grep '^[0-9]' "$in" | sort -n | (
# COMMON is the same as 64, except that we don't expect X32
# programs to use it. Our expectation has nothing to do with
# any generated code, so treat them the same.
- emit 64 "$nr" "$entry" "$compat"
+ emit64 64 "$nr" "$entry" "$compat"
elif [ "$abi" = "X32" ]; then
# X32 is equivalent to 64 on an X32-compatible kernel.
echo "#ifdef CONFIG_X86_X32_ABI"
- emit 64 "$nr" "$entry" "$compat"
+ emit64 64 "$nr" "$entry" "$compat"
echo "#endif"
elif [ "$abi" = "I386" ]; then
- emit "$abi" "$nr" "$entry" "$compat"
+ emit32 "$abi" "$nr" "$entry" "$compat"
else
echo "Unknown abi $abi" >&2
exit 1