Skip to contentSkip to conversation

x86: dovetail: Fix compat syscall handling, account for new IDT entry

PATCH Applied Florian Bezdeka 2 participants 2 messages Apr 16, 2024 – Apr 23, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: dovetail: Fix compat syscall handling, account for new IDT entry

The following upstream commit introduces a new IDTENTRY for handling compat syscall. As that commit is now backported into stable trees it broke compat syscall handling for dovetail.

be5341eb0d43 ("x86/entry: Convert INT 0x80 emulation to IDTENTRY")

We no longer end up in do_int80_syscall_32() which has the dovetail specific bits. We need the same handling in asm_int80_emulation().

The problematic part in asm_int80_emulation() is the call to do_syscall_32_irqs_on() which basically overwrites regs->ax unconditionally. Linux does not know about the co-kernel syscalls, so we get -ENOSYS for each syscall result.

---
 arch/x86/entry/common.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/entry/common.c +12 -0
index 0220ca163a32..42e8cb036fff 100644
@@ -212,9 +212,21 @@ DEFINE_IDTENTRY_RAW(int80_emulation)
 
 	local_irq_enable();
 	nr = syscall_enter_from_user_mode_work(regs, nr);
+
+	if (dovetailing()) {
+		if (nr == EXIT_SYSCALL_OOB) {
+			hard_local_irq_disable();
+			return;
+		}
+		if (nr == EXIT_SYSCALL_TAIL)
+			goto done;
+	}
+
 	do_syscall_32_irqs_on(regs, nr);
 
 	instrumentation_end();
+
+done:
 	syscall_exit_to_user_mode(regs);
 }
 #else /* CONFIG_IA32_EMULATION */
Signature · 1 line
2.39.2
#1 lore raw
Quoted 35 lines · Florian Bezdeka

The following upstream commit introduces a new IDTENTRY for handling compat syscall. As that commit is now backported into stable trees it broke compat syscall handling for dovetail.

be5341eb0d43 ("x86/entry: Convert INT 0x80 emulation to IDTENTRY")

We no longer end up in do_int80_syscall_32() which has the dovetail specific bits. We need the same handling in asm_int80_emulation().

The problematic part in asm_int80_emulation() is the call to do_syscall_32_irqs_on() which basically overwrites regs->ax unconditionally. Linux does not know about the co-kernel syscalls, so we get -ENOSYS for each syscall result.

---
 arch/x86/entry/common.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/entry/common.c +8 -0
index 0220ca163a32..42e8cb036fff 100644
@@ -212,9 +212,21 @@ DEFINE_IDTENTRY_RAW(int80_emulation)
 
 	local_irq_enable();
 	nr = syscall_enter_from_user_mode_work(regs, nr);
+
+	if (dovetailing()) {
+		if (nr == EXIT_SYSCALL_OOB) {
+			hard_local_irq_disable();
+			return;
+		}
+		if (nr == EXIT_SYSCALL_TAIL)
+			goto done;

arch/x86/entry/common.c DEFINE_IDTENTRY_RAW(int80_emulation) · line 232

Quoted 10 lines
arch/x86/entry/common.c +4 -0
+	}
+
 	do_syscall_32_irqs_on(regs, nr);
 
 	instrumentation_end();
+
+done:
 	syscall_exit_to_user_mode(regs);
 }
 #else /* CONFIG_IA32_EMULATION */

Merged, thanks.

Signature · 1 line
Philippe.