From nobody Fri Jun 17 19:38:53 2022 X-Original-To: dev-commits-src-all@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 424EA85B86A; Fri, 17 Jun 2022 19:38:54 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LPq9964WMz3Qgx; Fri, 17 Jun 2022 19:38:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494734; 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=XXAUFBMO45Ehu5eDA886et1LQu8x1ezlovX+9TFrRo0=; b=DgoCvwTS29u7OiHh6XTM5Ox8RNjD10iFHUhIW3lUfoX5CIhxbyESWfU/0TbloylRE/SW6Z wwpEmwfsxCxNCM1qBWZzfZpUttb7va84/ainlxsz80NE414B+ugVGkhXMYs31HXzMWfaUC v5Eas79HOeVS1vyk+2UMczNPNGsYSPa3V2Q1r6oHqLsqlkKJ+jcvItbMa7ADSS3zgaBJHF uwarh2IaKLn51ZW9T1AV7bUWiot7MHHjr+JPrWiqi+QSiZ9h1KcgZ/r4peV+E/oyiRE8sv peaNZuBwptBmCN+t/qQoi6uSnXUJSCbn5mXzGrFdeNMAV//sINKtzoQxvrEokA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7369C257DB; Fri, 17 Jun 2022 19:38:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJcr2C015277; Fri, 17 Jun 2022 19:38:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJcr4j015276; Fri, 17 Jun 2022 19:38:53 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:38:53 GMT Message-Id: <202206171938.25HJcr4j015276@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 82fa7c3b83d8 - stable/13 - linux(4): Add compat.linux32.emulate_i386 knob. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 82fa7c3b83d841fb3e9071c41d39e92b8adb021c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494734; 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=XXAUFBMO45Ehu5eDA886et1LQu8x1ezlovX+9TFrRo0=; b=T44EGWPxNKIjoNfiXzgkZtETuKOb3pqkCyWDGTuQfV85UItPeqaVRjpPcnTtNVBe346H92 BCCCqMFfCRMkAmBXO4Cb7I/gCarzioIVI0iUOme+VFjJ3qcNSgx49N7FYEULwgAsc6sikc 8yJe84PW/BFPfb3eHvr+c/v3UNTGxEvNfR2i7whbAIZYqsrTpF6jl0DT1koFKEbldgI6Rk G9tiqTSod+asvb8MBwubKj5s2NjG0/CAvmbthdJNkqW3HMlZTn+JiRUTBF/zi7zlMuep0V JH1ngoB0tN2X7Q8kCQNuaL72/a65/8sPBmHk8scWkspG75W0OjlPTDlHcTHHfQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494734; a=rsa-sha256; cv=none; b=GN6E/WR+4alDNCjAsJWeo6Y+2reIJfInXFYgg3AsU652KPNyyD0DOexuO4oOz1G9gwiLRt cIRMpKshGEZ6IDPCztQ5naBrDHweQ8qwXphV6Q+J+JSOADQoCVdpv8nH3nVfbNxJa6xQXc TfLZVAz9VxymWZaMOvxLM3b6CSPEaZI7DcHlyuy/XsQaZSGc8RMn+GElOzVOTv+huyz8hY UhcnumpAmBgoEe2vgqNJ1h3f0ZQY3qSq7klFFTH0ITcuDSo9VuYMO/Z4GlaX5roscrNMpn NSF3Fi/r439emcHhCICYpVhY9KLQstGL1gus2bmqwLjECvHYbUEybTLBESlUJQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=82fa7c3b83d841fb3e9071c41d39e92b8adb021c commit 82fa7c3b83d841fb3e9071c41d39e92b8adb021c Author: Dmitry Chagin AuthorDate: 2022-03-31 18:01:09 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:33:47 +0000 linux(4): Add compat.linux32.emulate_i386 knob. Historically 32-bit Linuxulator under amd64 emulated the real i386 behavior. Since 3d8dd983 the old i386 Linux world can't be used under amd64 Linuxulator as it don't know anything about amd64 machine (which is returned now by newuname() syscall). So, add a knob to allow to swith the behavior and use i386 Linux binaries on amd64. Set knob to the new behavior as I think this is common to the modern Linux distros. Reviewed by: Pau Amma (doc), emaste Differential revision: https://reviews.freebsd.org/D34708 MFC after: 2 weeks (cherry picked from commit d5dc757e84d8dc1db987f3a17052e32621d6ea87) --- share/man/man4/linux.4 | 6 ++++++ sys/amd64/linux32/linux.h | 2 ++ sys/amd64/linux32/linux32_sysvec.c | 3 +++ sys/compat/linux/linux_misc.c | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/share/man/man4/linux.4 b/share/man/man4/linux.4 index ee2629092100..ecf633f39648 100644 --- a/share/man/man4/linux.4 +++ b/share/man/man4/linux.4 @@ -145,6 +145,12 @@ This might be reasonable or even required, because does not emulate the Linux environment completely, and missed features may result in security vulnerabilities. Defaults to 1. +.It Va compat.linux32.emulate_i386 +In the x86_64 (amd64) world enable the real i386 Linuxulator behavior. +For example, when set to 0, Linux uname -m will return "x86_64" even if +uname itself is a i386 Linux executable. When set to 1, Linux i386 +uname -m will return "i686". +Defaults to 0. .El .Sh FILES .Bl -tag -width /compat/linux/dev/shm -compact diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index f1f877181e47..1273ff485dd9 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -637,4 +637,6 @@ struct reg32; void bsd_to_linux_regset32(const struct reg32 *b_reg, struct linux_pt_regset32 *l_regset); +extern bool linux32_emulate_i386; + #endif /* !_AMD64_LINUX_H_ */ diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index e84b61580b42..227cefa92847 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -884,6 +884,9 @@ SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxssiz, CTLFLAG_RW, static u_long linux32_maxvmem = LINUX32_MAXVMEM; SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW, &linux32_maxvmem, 0, ""); +bool linux32_emulate_i386 = false; +SYSCTL_BOOL(_compat_linux32, OID_AUTO, emulate_i386, CTLFLAG_RWTUN, + &linux32_emulate_i386, 0, "Emulate the real i386"); static void linux32_fixlimit(struct rlimit *rl, int which) diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index fa7d364681dc..b1f465ef5a9e 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -720,6 +720,11 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args) * the string returned by getauxval(AT_PLATFORM) needs * to remain "i686", though. */ +#if defined(COMPAT_LINUX32) + if (linux32_emulate_i386) + strlcpy(utsname.machine, "i686", LINUX_MAX_UTSNAME); + else +#endif strlcpy(utsname.machine, "x86_64", LINUX_MAX_UTSNAME); #elif defined(__aarch64__) strlcpy(utsname.machine, "aarch64", LINUX_MAX_UTSNAME);