Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Slawomir Rosek <srosek@google.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org,  "H . Peter Anvin" <hpa@zytor.com>,
	Shuah Khan <shuah@kernel.org>
Cc: Betty Zhou <bettyzhou@google.com>, Wake Liu <wakel@google.com>,
	 Kazuhiro Inaba <kinaba@google.com>, Jeff Xu <jeffxu@google.com>,
	 Alistair Delva <adelva@google.com>,
	linux-kernel@vger.kernel.org,  linux-kselftest@vger.kernel.org,
	Slawomir Rosek <srosek@google.com>
Subject: [PATCH v1 1/2] selftests/x86/ldt_gdt: Skip int80 if not supported
Date: Wed, 17 Dec 2025 13:59:31 +0000	[thread overview]
Message-ID: <20251217135932.3153847-2-srosek@google.com> (raw)
In-Reply-To: <20251217135932.3153847-1-srosek@google.com>

The IA32 Emulation support can be either removed from the kernel,
disabled by default or disabled at runtime. The x86/ldt_gdt selftest
crashes for all of above thus is_32bit_syscall_supported() helper
is added to skip int80 syscalls if they are not supported.

Signed-off-by: Slawomir Rosek <srosek@google.com>
---
 tools/testing/selftests/x86/ldt_gdt.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/x86/ldt_gdt.c b/tools/testing/selftests/x86/ldt_gdt.c
index bb99a71380a5..b178392e50c0 100644
--- a/tools/testing/selftests/x86/ldt_gdt.c
+++ b/tools/testing/selftests/x86/ldt_gdt.c
@@ -62,6 +62,18 @@ static struct user_desc *low_user_desc;
 static struct user_desc *low_user_desc_clear;  /* Use to delete GDT entry */
 static int gdt_entry_num;
 
+static bool is_32bit_syscall_supported(void)
+{
+#ifdef __x86_64__
+	return system("((zcat /proc/config.gz | grep CONFIG_IA32_EMULATION=y) &&"
+		"((test -z $(zcat /proc/config.gz | grep CONFIG_IA32_EMULATION_DEFAULT_DISABLED=y)) || (grep ia32_emulation=true /proc/cmdline)) &&"
+		"(test -z $(grep ia32_emulation=false /proc/cmdline))) >/dev/null 2>&1"
+	) == 0;
+#else
+	return true;
+#endif
+}
+
 static void check_invalid_segment(uint16_t index, int ldt)
 {
 	uint32_t has_limit = 0, has_ar = 0, limit, ar;
@@ -147,6 +159,7 @@ static bool install_valid_mode(const struct user_desc *d, uint32_t ar,
 	if (!ldt) {
 #ifndef __i386__
 		/* No point testing set_thread_area in a 64-bit build */
+		printf("[SKIP]\tNo point testing set_thread_area in a 64-bit build\n");
 		return false;
 #endif
 		if (!gdt_entry_num)
@@ -676,6 +689,10 @@ static void setup_counter_page(void)
 static int invoke_set_thread_area(void)
 {
 	int ret;
+	if (!is_32bit_syscall_supported()) {
+		printf("[SKIP]\tNo 32bit syscall support in a 64-bit build\n");
+		return -1;
+	}
 	asm volatile ("int $0x80"
 		      : "=a" (ret), "+m" (low_user_desc) :
 			"a" (243), "b" (low_user_desc)
@@ -716,8 +733,10 @@ static void setup_low_user_desc(void)
 
 static void test_gdt_invalidation(void)
 {
-	if (!gdt_entry_num)
+	if (!gdt_entry_num) {
+		printf("[SKIP]\tNo set_thread_area support in a 64-bit only system\n");
 		return;	/* 64-bit only system -- we can't use set_thread_area */
+	}
 
 	unsigned short prev_sel;
 	unsigned short sel;
-- 
2.52.0.305.g3fc767764a-goog


  reply	other threads:[~2025-12-17 13:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 13:59 [PATCH v1 0/2] selftests/x86: Skip int80 if not supported Slawomir Rosek
2025-12-17 13:59 ` Slawomir Rosek [this message]
2026-01-23 16:54   ` [PATCH v1 1/2] selftests/x86/ldt_gdt: " Borislav Petkov
2026-01-23 17:07     ` Dave Hansen
2026-01-24  1:01     ` H. Peter Anvin
2026-02-13 17:26       ` Sławomir Rosek
2025-12-17 13:59 ` [PATCH v1 2/2] selftests/x86/ptrace_syscall: " Slawomir Rosek
2026-01-12 11:23 ` [PATCH v1 0/2] selftests/x86: " Sławomir Rosek
2026-01-24  1:18   ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251217135932.3153847-2-srosek@google.com \
    --to=srosek@google.com \
    --cc=adelva@google.com \
    --cc=bettyzhou@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jeffxu@google.com \
    --cc=kinaba@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wakel@google.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox