Message ID | 20231206172022.GCZXCtVoZtt4t2TLpe@fat_crate.local |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4256025vqy; Wed, 6 Dec 2023 09:21:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiP+ZXVJD+enBO1rxSIz0hUj9AMJ5h1aDRy9dr4SQcKgEXcSJ2HGG3/9pMx++nRDZpJMbk X-Received: by 2002:a05:6a21:7882:b0:18b:f063:3d78 with SMTP id bf2-20020a056a21788200b0018bf0633d78mr1309180pzc.38.1701883274286; Wed, 06 Dec 2023 09:21:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701883274; cv=none; d=google.com; s=arc-20160816; b=j47ArBe/P8dK5m03AfZgM3MQVZibUf20mZK42yHtxdUv8QMByCntI3UfVO5z7nkL4F MAEYUA1QMESLWOw2FLzLriArl8n7m0Rj/W6zW+H44v1747VSBBhhMtCEh2UoVckLlHpU q1liVB0ZAO18wGOxiGnfwkPPuhOXfDXyJrDjVUORFq01He0SOZSJqA4Wft/nHkNAWNN9 aoujMG6mQOfUzD1GOSdxJdocj3d7uC1/de0uDW8yq46nQ0r4ina/6SMn4201i/LgYs7f jeY9J3AtYwhVBkB75Gy8LE7httdIiKaNbdA4v8KSeOuHd+86BjDRr9rO2Aua6P6M7jBd Lu1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SEuXI2V3X/3Kx/69zzGav63YjHB73NgqtYnRloB+IFk=; fh=x7tgAp3UTdwCJoo3nncPbyjpkD3LzARVzJidJz0MiQY=; b=nfXKFLMhX2lE3TeVkf6qH1/UoFlUd4jiR+hKnZvxR6Xp1n3T9WLOuOyVAgY2Z0KESB YG9aqrCWsjHEl4VbUO0Vr70y4eEEClWKXZ/42gZBvgdpPmMCTakuJdJOFoiFp/kXgETH sOs2baUt6iNf9g+WkGjkbCUgk1ghQ3ExoK3jDWBIvc4n3vWTA1oeKm4mhBNRjcPrLxDc C8q940RWdmeVsxJThr4YfjrseF5mJzG+1JSrZSFcVIyAGcBuep8GA/IkIuPJCyrUA3JR aGhcx8WdGMRaMoFpVTWrIW3Iovy4ZrwysJ+ISLXpMTNQSfW+/wXwRdjl4pAHpIp/vut9 43+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=Dla+lMac; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id h65-20020a636c44000000b005c6763c301asi195218pgc.467.2023.12.06.09.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 09:21:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=Dla+lMac; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7EFEF808A96D; Wed, 6 Dec 2023 09:20:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378706AbjLFRUa (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Wed, 6 Dec 2023 12:20:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378608AbjLFRU2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 6 Dec 2023 12:20:28 -0500 Received: from mail.alien8.de (mail.alien8.de [IPv6:2a01:4f9:3051:3f93::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5496D40 for <linux-kernel@vger.kernel.org>; Wed, 6 Dec 2023 09:20:34 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id EDBFA40E00C7; Wed, 6 Dec 2023 17:20:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FIKI1gkZHfAe; Wed, 6 Dec 2023 17:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1701883230; bh=SEuXI2V3X/3Kx/69zzGav63YjHB73NgqtYnRloB+IFk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dla+lMacDWjBuJyMsEJsWRG24Y0kGMEcbY8gFoVhi47w9IzpBkylGZyzo/3M+WxIg WU3FxK6VxTVdx/LORD2NVamUqrFFXn3lPOJ/2cwLhu7c2+5o+920mMglDo/17+cs7F rpDhDKUxhO5JEPTMKAcL130wM4FHFE8YmR2dMWTGuHfhdOL8xBvsiQPBAAp26YHcQe OxqiT5dnPGCDJfFfy6L+FiObOmQirp7KljlqFNT1QtzBrzqhwVkdBjzc/hGg9qwnzF 6aT7jbSCEmPgHEuGWJAgUzUJtGAzYXUMTaDJmPBou51wfvASS4mcwZh7GNJ5GLD9xF TkgeOFlfEO1Asau7M8v5LHPbYcsaIng3QYo1qdyTZXNdVqVM+AkfTXq9AJoJazr2pL ySM7+sHX7gR5xgmXQRUv6rLhF9ZQWDE9xwZ7comppATf9bqrSFcgo9Cc2pmApWDW3I jRTGgGX9/S7ub+Kn7Gq0qtL6ANDHIV6DeFnFe00u03JIQur2ySTaAiQI//xOZnBK31 58q9rka8Jt3m8vqsfbYWeCc/KLjF8S29CvPmiHucQ1dejNp1ijxH3wKh08kzBF0jiu YrAX4TLdWcY9yxL4m0HHdacHHkp1aK0ygo4q0g8AB7uurbhkJNDONrGHIBO0tQiutb pcb1aVaicsjC4UO8RKvTBUtw= Received: from zn.tnic (pd95304da.dip0.t-ipconnect.de [217.83.4.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 2A7CE40E00C6; Wed, 6 Dec 2023 17:20:27 +0000 (UTC) Date: Wed, 6 Dec 2023 18:20:22 +0100 From: Borislav Petkov <bp@alien8.de> To: X86 ML <x86@kernel.org> Cc: LKML <linux-kernel@vger.kernel.org>, Nikolay Borisov <nik.borisov@suse.com> Subject: [PATCH -v2] x86/ia32: State that IA32 emulation is disabled Message-ID: <20231206172022.GCZXCtVoZtt4t2TLpe@fat_crate.local> References: <20231130155213.1407-1-bp@alien8.de> <20231130160903.GJZWizn+dPaaViFVKN@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231130160903.GJZWizn+dPaaViFVKN@fat_crate.local> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 09:20:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784004798052446001 X-GMAIL-MSGID: 1784553956690160783 |
Series |
[-v2] x86/ia32: State that IA32 emulation is disabled
|
|
Commit Message
Borislav Petkov
Dec. 6, 2023, 5:20 p.m. UTC
From: "Borislav Petkov (AMD)" <bp@alien8.de> Date: Thu, 30 Nov 2023 16:39:33 +0100 Issue a short message once, on the first try to load a 32-bit process to save people time when wondering why it won't load and trying to execute it, would say: -bash: ./strsep32: cannot execute binary file: Exec format error Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Cc: Nikolay Borisov <nik.borisov@suse.com> --- arch/x86/include/asm/elf.h | 2 +- arch/x86/include/asm/ia32.h | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-)
Comments
On 6.12.23 г. 19:20 ч., Borislav Petkov wrote: > From: "Borislav Petkov (AMD)" <bp@alien8.de> > Date: Thu, 30 Nov 2023 16:39:33 +0100 > > Issue a short message once, on the first try to load a 32-bit process to > save people time when wondering why it won't load and trying to execute > it, would say: > > -bash: ./strsep32: cannot execute binary file: Exec format error > > Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> > Cc: Nikolay Borisov <nik.borisov@suse.com> LGTM: Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> > --- > arch/x86/include/asm/elf.h | 2 +- > arch/x86/include/asm/ia32.h | 11 ++++++++++- > 2 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > index a0234dfd1031..1e16bd5ac781 100644 > --- a/arch/x86/include/asm/elf.h > +++ b/arch/x86/include/asm/elf.h > @@ -150,7 +150,7 @@ do { \ > ((x)->e_machine == EM_X86_64) > > #define compat_elf_check_arch(x) \ > - ((elf_check_arch_ia32(x) && ia32_enabled()) || \ > + ((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \ > (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) > > static inline void elf_common_init(struct thread_struct *t, > diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h > index 5a2ae24b1204..094886a8717e 100644 > --- a/arch/x86/include/asm/ia32.h > +++ b/arch/x86/include/asm/ia32.h > @@ -2,7 +2,6 @@ > #ifndef _ASM_X86_IA32_H > #define _ASM_X86_IA32_H > > - > #ifdef CONFIG_IA32_EMULATION > > #include <linux/compat.h> > @@ -84,4 +83,14 @@ static inline bool ia32_enabled(void) > > #endif > > +static inline bool ia32_enabled_verbose(void) > +{ > + bool enabled = ia32_enabled(); > + > + if (IS_ENABLED(CONFIG_IA32_EMULATION) && !enabled) nit: But why check config_ia32_emulation explicitly, its state should already be accounted for in ia32_enabled's value? So this check can simply be 'if (!enabled)' > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > + > + return enabled; > +} > + > #endif /* _ASM_X86_IA32_H */
On Fri, Dec 08, 2023 at 08:42:29PM +0200, Nikolay Borisov wrote: > > +static inline bool ia32_enabled_verbose(void) > > +{ > > + bool enabled = ia32_enabled(); > > + > > + if (IS_ENABLED(CONFIG_IA32_EMULATION) && !enabled) > > nit: But why check config_ia32_emulation explicitly, its state should > already be accounted for in ia32_enabled's value? So this check can simply > be 'if (!enabled)' > > > + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); ^^^^^^^^^^ If CONFIG_IA32_EMULATION is disabled, is there any 32-bit emulation to be enabled, at all?
On 8.12.23 г. 21:22 ч., Borislav Petkov wrote: > On Fri, Dec 08, 2023 at 08:42:29PM +0200, Nikolay Borisov wrote: >>> +static inline bool ia32_enabled_verbose(void) >>> +{ >>> + bool enabled = ia32_enabled(); >>> + >>> + if (IS_ENABLED(CONFIG_IA32_EMULATION) && !enabled) >> >> nit: But why check config_ia32_emulation explicitly, its state should >> already be accounted for in ia32_enabled's value? So this check can simply >> be 'if (!enabled)' >> >>> + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); > ^^^^^^^^^^ > > If CONFIG_IA32_EMULATION is disabled, is there any 32-bit emulation to > be enabled, at all? > Ah, the !enabled condition will then trigger so it will result in a false print. Fair enough...
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index a0234dfd1031..1e16bd5ac781 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -150,7 +150,7 @@ do { \ ((x)->e_machine == EM_X86_64) #define compat_elf_check_arch(x) \ - ((elf_check_arch_ia32(x) && ia32_enabled()) || \ + ((elf_check_arch_ia32(x) && ia32_enabled_verbose()) || \ (IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64)) static inline void elf_common_init(struct thread_struct *t, diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index 5a2ae24b1204..094886a8717e 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -2,7 +2,6 @@ #ifndef _ASM_X86_IA32_H #define _ASM_X86_IA32_H - #ifdef CONFIG_IA32_EMULATION #include <linux/compat.h> @@ -84,4 +83,14 @@ static inline bool ia32_enabled(void) #endif +static inline bool ia32_enabled_verbose(void) +{ + bool enabled = ia32_enabled(); + + if (IS_ENABLED(CONFIG_IA32_EMULATION) && !enabled) + pr_notice_once("32-bit emulation disabled. You can reenable with ia32_emulation=on\n"); + + return enabled; +} + #endif /* _ASM_X86_IA32_H */