From nobody Wed Apr 29 03:50:32 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g53HF1njqz6cX3F for ; Wed, 29 Apr 2026 03:50:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g53HD6Mqwz45tF for ; Wed, 29 Apr 2026 03:50:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777434632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cM/bfFHtHzG8xLyZdYv45w7LyEz1eLOOW4B/etdU168=; b=kKHof7UqtPqAm7gYV7JfZqPBF7H7Hut/DaqGToO42mpHCZy/GdmodGkA6xKXLOCSre8sA5 1ibI8hQKeod7M2REE6Aq3llmqLhmTa1ZgJ6EZBY217qZDA3CLeVZcC/E23OIHG3KE3iobU myYaEhL3s2Ado6G81gsZElLV/6XEIXI88KeSYeh6B3MDJH7xLtHFPIbT0szm9y159IHQT7 KDtZgqa0S0FFGSFOqWCIZp8uwR0O3XF18XwdstsVC7C2gciWUKhHnj8zpy2uV7F9iv/LJQ m/bcUyNnxeos+LeIv0+ppy65FdnwYKtS12hBT1gh/1I7ounNAqKH8lutRHudWQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777434632; a=rsa-sha256; cv=none; b=y4UROrBn71/ORgN/E3hyoO2UpeQdDVB+5md9AfgMGsb2AwnzJvZmQRrc78M4YMiN4+fzqk bYgK9p6ceuqBrgNk4YSJ5d/Bm2+AGV4oud1irpwt9fgMFH9cTIoHcqo/OIDwY5ZHQZi/2O 2u3MzAI4+77okoxQGYv0J/IS8hnFv+kgLKoHSlCsItodvXp9IGGyiVja6NM8TLW8o8VeBx Isna5JYzfG+k6QI9rJm6uE4ZLV8az1UNgmcZAgv2vo5rAvPjUNMOWoAl1cDKtysIAGWCc/ R+iVVcDkMk9DN7OtkVNax59LXea8HmL9Ldkz+s+/3ISPOlWeid7MqREhClIfvA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777434632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cM/bfFHtHzG8xLyZdYv45w7LyEz1eLOOW4B/etdU168=; b=xI+ItfiFUVwpGhC/D4OkoTdPET1saGzmRw+LF7ZMawtYLA6W2VmvPi2DUWZx2nwAyn4tfJ Mft5TVs+t9Dp4GTeB/sRA1/B4EchIZ0Jv3s24aWUM8HSjCy1nadqsyfDyz762MlS3bzFlm 908Z3+4xCWJhjE89zLI/lGIZqZ6XfF5guG70V6o1lEAKFktMp3MAsYuPRBYN6Br8EsweAx a3p2q53z1zhGArWC7MJc/057V62xoOhiUduWw5YUj1W+sh5/LZV1R3JWk4KXOMCeEsd2I8 AQN3qGechxPDD0RsfY79TXdQRrvQIAOO/wYtaexABwIJsEtjW55FmKH/8jIT1g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g53HD5d5Dz7k7 for ; Wed, 29 Apr 2026 03:50:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 447ea by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 29 Apr 2026 03:50:32 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 2c2ec6bbc9cc - main - tests/sys/arch/amd64: add a program to check INT $0x80 behavior on amd64 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2c2ec6bbc9cc7762a250ffe903bda6c2e44d25ff Auto-Submitted: auto-generated Date: Wed, 29 Apr 2026 03:50:32 +0000 Message-Id: <69f18008.447ea.6ea1652b@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2c2ec6bbc9cc7762a250ffe903bda6c2e44d25ff commit 2c2ec6bbc9cc7762a250ffe903bda6c2e44d25ff Author: Konstantin Belousov AuthorDate: 2026-04-27 04:23:36 +0000 Commit: Konstantin Belousov CommitDate: 2026-04-29 03:49:46 +0000 tests/sys/arch/amd64: add a program to check INT $0x80 behavior on amd64 Requested and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D56654 --- tests/sys/arch/amd64/Makefile | 7 ++++ tests/sys/arch/amd64/int0x80.c | 94 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/tests/sys/arch/amd64/Makefile b/tests/sys/arch/amd64/Makefile new file mode 100644 index 000000000000..34f3c90c4082 --- /dev/null +++ b/tests/sys/arch/amd64/Makefile @@ -0,0 +1,7 @@ +TESTSDIR= ${TESTSBASE}/sys/arch/amd64 + +PLAIN_TESTS_C+= int0x80 + +BINDIR= ${TESTSDIR} + +.include diff --git a/tests/sys/arch/amd64/int0x80.c b/tests/sys/arch/amd64/int0x80.c new file mode 100644 index 000000000000..e03462a6dccd --- /dev/null +++ b/tests/sys/arch/amd64/int0x80.c @@ -0,0 +1,94 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2026 The FreeBSD Foundation + * + * This software were developed by + * Konstantin Belousov under sponsorship from + * the FreeBSD Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __amd64__ +#error "amd64 only" +#endif + +/* + * The check to see how "INT $0x80" behaves for amd64 native ABI + * processes. Before bd8edba0792b71be3f8ed5dea9c22287e95c986a it + * executed syscalls with amd64 calling conventions. After that + * revision, it should raise SIGBUS. + */ + +static uintptr_t int0x80_loc; +static int signo; +extern char after_int0x80[]; + +static void +sigill_action(int signo1, siginfo_t *si __unused, void *uctxv) +{ + ucontext_t *uctx = uctxv; + + signo = signo1; + int0x80_loc = uctx->uc_mcontext.mc_rip; +} + +static int +fire(void) +{ + int res; + + asm volatile( + ".globl\tafter_int0x80\n" + "\tint\t$0x80\n" + "after_int0x80:" + : "=a" (res) + : "%0" (SYS_getpid) + : "rdx", "memory", "cc"); + return (res); +} + +int +main(void) +{ + struct sigaction sa; + char signame[SIG2STR_MAX]; + int pid, res; + + res = 0; + + memset(&sa, 0, sizeof(sa)); + sa.sa_sigaction = sigill_action; + sa.sa_flags = SA_SIGINFO; + if (sigaction(SIGBUS, &sa, NULL) == -1) + err(1, "catching SIGBUS"); + + pid = fire(); + atomic_signal_fence(memory_order_seq_cst); + if (int0x80_loc == 0) { + printf("int $0x80 does not raise SIGBUS\n"); + if (pid == getpid()) + printf("and syscall worked\n"); + else + printf("but syscall did not worked\n"); + res = 1; + } else { + sig2str(signo, signame); + printf("int $0x80 raises SIG%s\n", signame); + if (int0x80_loc == (uintptr_t)after_int0x80) { + printf("at expected location\n"); + } else { + printf("not at expected location\n"); + res = 1; + } + } + exit(res); +}