Message ID | 20240127093728.1323-3-xin3.li@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-41151-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2395:b0:106:343:edcb with SMTP id gw21csp409036dyb; Sat, 27 Jan 2024 02:09:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvPk8HTWldybRLMXyhub1gpbGLHLmnIeGAKaGBd1PVqxCtOA6I3dS5rgDJqc7mowc75Eny X-Received: by 2002:a81:af4c:0:b0:5f7:2c10:e166 with SMTP id x12-20020a81af4c000000b005f72c10e166mr1355243ywj.94.1706350174892; Sat, 27 Jan 2024 02:09:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706350174; cv=pass; d=google.com; s=arc-20160816; b=Nei1HqD17suGhkBa/p/Sv1ZZGyUNVrbnaPMkS32N7o6Y2QqwynKbc5tW+kcN3XuSF8 kafP7d2OWW8a90fiRS2RVeXc757ZaTY8JZFu4NPAh3fKEUVi6ov8T4JJMPtEERkGKNfD VVLxO5bn6PEFrgqyFvYenJlyMqMOqDm1Z9lIfqfPseULfM+z0OZ73oBo7k4G9AToqcoM Q/UGtZzFy0ZeiCPUkwKgEewaBkV+oCgZpD774AjoA0mAc7g5MLmxeV2NH9knDvHMTjlu X7Q5pfJKUwlT7UrVh4jMDIECTFlmZMDGZeZSmT0qOIAoXEKdmAKNdIdRsU6lwf2/9rPR opNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Wt+7P4pphgVv77idLjoNzsqDTpU8fMNKnFwke/8hwL8=; fh=eoqNldmLmBswfN1zMWVVrnsIvNovukkqS6g9u7sxTHc=; b=qBuBMygUrljT0K8AGVDfm2nDUm3cuyJ2HMopLpyYs7BjFlglxMEanJTjF2D57/xXo6 tq2+8XnYZ5Vb2Xs8mX6IIf6ec16vPyOenhRqjR7cOjaflxRk9g35tG2pdzMBhog3M3t3 Tk5lCP77vBto9DGvX1+c3uwBigQndIyW7CQZiMA1pw/KBmoQcUdRZJYUcse+3zBdpF0N 6vXDh+k6tYPqoBVfz7TOnpoQ7WmI8jU1gc9LfOoA3V1BkG5aHMun2hnxKfgKW89lbNW6 5NhPPA9RVqKPzUcuPP2FF1p838CkhRRxCRjHKtc4rmfQSxIFdC13za6yRaXLPa4wjkNS v2Ig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FZI86kCx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-41151-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41151-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id iw1-20020a170903044100b001d88a7092d4si2533900plb.239.2024.01.27.02.09.34 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 02:09:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41151-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FZI86kCx; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-41151-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41151-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A027C2845E0 for <ouuuleilei@gmail.com>; Sat, 27 Jan 2024 10:09:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB0C621106; Sat, 27 Jan 2024 10:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FZI86kCx" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5AE21EB32 for <linux-kernel@vger.kernel.org>; Sat, 27 Jan 2024 10:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706350137; cv=none; b=VlyufzOkmL0lU4ZXs8Wasz+4ME9CW6sUKDMvYZaGFMiO1ny/oURMXKUNH6yfr2ve5CgnZATY1iyA9XVIc6Kh9UbEvb1l4H/OTIsa8n1nQiqC1vb1Aykhf8vnQN9GIpoj4O+pN5BhHyy5wzh7896eUg6ysZkCoql2px9EmkPUpA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706350137; c=relaxed/simple; bh=Q0bhMrxpzirRicWRr76Yp7IjH2KX2X0N9M5pN7rBDOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aXCrJA5d1Ao67+Nzonx7H8+L+pL+fOeHWgI6vchqdYM9+WQVV6luZO8toxXmIa660R/FI+/S8WrAIZOyF71lbg/H20m5cAZCKz9mLQX7Yi6v0IveWWN8gohebHcOb0CuLQstFnnILbw+5ViPLoePO1hAQR3l7XEDL7hz4thdgy8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FZI86kCx; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706350135; x=1737886135; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Q0bhMrxpzirRicWRr76Yp7IjH2KX2X0N9M5pN7rBDOU=; b=FZI86kCxsv9/+Z7PgqLu8vqRIiE7Y0gSgE3/8JG0xO/u2Ad5BL0luetM BScQ1b484Gaykahg0otPDfZ5/8MjowzBrF7VJjft4BIMyvLnGXnNoto30 4dotHcxgQrmKVNteBrpdm9XQbFEWxVwVUnxeNYyA0c2qJip8HnqHuFP7s EY16FQ9WmDqbA2WrWpJ9aAxEncp6m+Bf5IEY1dBfGfTV7Ql8TBq76rZ8N LA4Z+i9zhe2mtTYFm7Af0CzYeiTjPvJhYqNmhDq+DNHabeD48n8lLe4ih WBRix6NYY4WaVmdZteqLw1Hm2BvO8VTQiOlwpHgF6SyDVFUG1a/I6ckEJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="16190982" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="16190982" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jan 2024 02:08:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="736923492" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="736923492" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga003.jf.intel.com with ESMTP; 27 Jan 2024 02:08:52 -0800 From: Xin Li <xin3.li@intel.com> To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, ravi.v.shankar@intel.com, andrew.cooper3@citrix.com Subject: [PATCH 2/2] x86/fred: Fix build with CONFIG_IA32_EMULATION=n Date: Sat, 27 Jan 2024 01:37:28 -0800 Message-ID: <20240127093728.1323-3-xin3.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240127093728.1323-1-xin3.li@intel.com> References: <20240127093728.1323-1-xin3.li@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789237841259967326 X-GMAIL-MSGID: 1789237841259967326 |
Series |
x86/fred: Fix two build issues
|
|
Commit Message
Li, Xin3
Jan. 27, 2024, 9:37 a.m. UTC
When CONFIG_IA32_EMULATION=n, int80_emulation() is NOT defined, fix it.
Fixes: 5e0636a41485 ("x86/fred: FRED entry/exit and dispatch code")
Link: https://lore.kernel.org/lkml/20240126100519.GBZbOD3xFB0v3mp5B1@fat_crate.local/
Reported-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Xin Li <xin3.li@intel.com>
---
arch/x86/entry/entry_fred.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Sat, Jan 27, 2024 at 01:37:28AM -0800, Xin Li wrote: > When CONFIG_IA32_EMULATION=n, int80_emulation() is NOT defined, fix it. > > Fixes: 5e0636a41485 ("x86/fred: FRED entry/exit and dispatch code") > Link: https://lore.kernel.org/lkml/20240126100519.GBZbOD3xFB0v3mp5B1@fat_crate.local/ > Reported-by: Borislav Petkov (AMD) <bp@alien8.de> > Signed-off-by: Xin Li <xin3.li@intel.com> > --- > arch/x86/entry/entry_fred.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c > index 06d00c60ea64..ac120cbdaaf2 100644 > --- a/arch/x86/entry/entry_fred.c > +++ b/arch/x86/entry/entry_fred.c > @@ -62,11 +62,13 @@ static noinstr void fred_intx(struct pt_regs *regs) > case X86_TRAP_OF: > return exc_overflow(regs); > > +#ifdef CONFIG_IA32_EMULATION > /* INT80 */ > case IA32_SYSCALL_VECTOR: > if (ia32_enabled()) > return int80_emulation(regs); > fallthrough; > +#endif > > default: > return exc_general_protection(regs, 0); > -- That .config is still not happy after this: ld: vmlinux.o: in function `fred_entry_from_user': (.noinstr.text+0x177a): undefined reference to `do_fast_syscall_32' make[2]: *** [scripts/Makefile.vmlinux:37: vmlinux] Error 1 make[1]: *** [/mnt/kernel/kernel/linux/Makefile:1158: vmlinux] Error 2 make: *** [Makefile:240: __sub-make] Error 2 I'm pushing the latest state I have here: https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/log/?h=tip-x86-fred Thx.
> > When CONFIG_IA32_EMULATION=n, int80_emulation() is NOT defined, fix it. > > > > Fixes: 5e0636a41485 ("x86/fred: FRED entry/exit and dispatch code") > > Link: > > https://lore.kernel.org/lkml/20240126100519.GBZbOD3xFB0v3mp5B1@fat_cra > > te.local/ > > Reported-by: Borislav Petkov (AMD) <bp@alien8.de> > > Signed-off-by: Xin Li <xin3.li@intel.com> > > --- > > arch/x86/entry/entry_fred.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c > > index 06d00c60ea64..ac120cbdaaf2 100644 > > --- a/arch/x86/entry/entry_fred.c > > +++ b/arch/x86/entry/entry_fred.c > > @@ -62,11 +62,13 @@ static noinstr void fred_intx(struct pt_regs *regs) > > case X86_TRAP_OF: > > return exc_overflow(regs); > > > > +#ifdef CONFIG_IA32_EMULATION > > /* INT80 */ > > case IA32_SYSCALL_VECTOR: > > if (ia32_enabled()) > > return int80_emulation(regs); > > fallthrough; > > +#endif > > > > default: > > return exc_general_protection(regs, 0); > > -- > > That .config is still not happy after this: > > ld: vmlinux.o: in function `fred_entry_from_user': > (.noinstr.text+0x177a): undefined reference to `do_fast_syscall_32' > make[2]: *** [scripts/Makefile.vmlinux:37: vmlinux] Error 1 > make[1]: *** [/mnt/kernel/kernel/linux/Makefile:1158: vmlinux] Error 2 > make: *** [Makefile:240: __sub-make] Error 2 Sign, I'm sorry it still doesn’t work with GCC. > I'm pushing the latest state I have here: > > https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/log/?h=tip-x86-fred Because clang can compile it, I checked the generated assembly code and see that clang optimizes it by simply converting ia32_enabled() to false when CONFIG_IA32_EMULATION=n thus never calling do_fast_syscall_32(). It looks to me that the following patch is better than adding another #ifdef CONFIG_IA32_EMULATION around do_fast_syscall_32(). How do you think? BTW, I have tested it with both GCC and clang with CONFIG_IA32_EMULATION=n. Thanks! -Xin diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index c7ef6ea2fa99..01342d343c19 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -81,7 +81,7 @@ static inline void ia32_disable(void) #else /* !CONFIG_IA32_EMULATION */ -static inline bool ia32_enabled(void) +static __always_inline bool ia32_enabled(void) { return IS_ENABLED(CONFIG_X86_32); }
On Tue, Jan 30, 2024 at 03:22:01PM +0000, Li, Xin3 wrote: > How do you think? Interesting. For some reason gcc doesn't constant-fold it away like clang does. > diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h > index c7ef6ea2fa99..01342d343c19 100644 > --- a/arch/x86/include/asm/ia32.h > +++ b/arch/x86/include/asm/ia32.h > @@ -81,7 +81,7 @@ static inline void ia32_disable(void) > > #else /* !CONFIG_IA32_EMULATION */ > > -static inline bool ia32_enabled(void) > +static __always_inline bool ia32_enabled(void) > { > return IS_ENABLED(CONFIG_X86_32); > } Looks good to me. Lemme try it here. Thx.
> On Tue, Jan 30, 2024 at 03:22:01PM +0000, Li, Xin3 wrote: > > How do you think? > > Interesting. For some reason gcc doesn't constant-fold it away like clang does. Even more interesting, gcc doesn't complain it with the attached config File in which CONFIG_X86_FRED=y and CONFIG_IA32_EMULATION not set. I compared the 2 config files, nothing suspicious to me. CCing PeterZ to give insights 😊 > > diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h > > index c7ef6ea2fa99..01342d343c19 100644 > > --- a/arch/x86/include/asm/ia32.h > > +++ b/arch/x86/include/asm/ia32.h > > @@ -81,7 +81,7 @@ static inline void ia32_disable(void) > > > > #else /* !CONFIG_IA32_EMULATION */ > > > > -static inline bool ia32_enabled(void) > > +static __always_inline bool ia32_enabled(void) > > { > > return IS_ENABLED(CONFIG_X86_32); > > } > > Looks good to me. Lemme try it here. Thank you very much! -Xin
On Tue, Jan 30, 2024 at 04:30:34PM +0000, Li, Xin3 wrote: > Even more interesting, gcc doesn't complain it with the attached config > File in which CONFIG_X86_FRED=y and CONFIG_IA32_EMULATION not set. Yes, CONFIG_IA32_EMULATION=n alone is not enough. That .config which triggers it has something else which is causing this but I'm not sure I want to go chase down what it is...
On Tue, Jan 30, 2024 at 03:22:01PM +0000, Li, Xin3 wrote: > diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h > index c7ef6ea2fa99..01342d343c19 100644 > --- a/arch/x86/include/asm/ia32.h > +++ b/arch/x86/include/asm/ia32.h > @@ -81,7 +81,7 @@ static inline void ia32_disable(void) > > #else /* !CONFIG_IA32_EMULATION */ > > -static inline bool ia32_enabled(void) > +static __always_inline bool ia32_enabled(void) > { > return IS_ENABLED(CONFIG_X86_32); So I always-inlined both versions since they're small enough, see diff below. That works with this .config, I'll run some more overnight to make sure... Thx. diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index c7ef6ea2fa99..4212c00c9708 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -69,7 +69,7 @@ extern void ia32_pick_mmap_layout(struct mm_struct *mm); extern bool __ia32_enabled; -static inline bool ia32_enabled(void) +static __always_inline bool ia32_enabled(void) { return __ia32_enabled; } @@ -81,7 +81,7 @@ static inline void ia32_disable(void) #else /* !CONFIG_IA32_EMULATION */ -static inline bool ia32_enabled(void) +static __always_inline bool ia32_enabled(void) { return IS_ENABLED(CONFIG_X86_32); }
diff --git a/arch/x86/entry/entry_fred.c b/arch/x86/entry/entry_fred.c index 06d00c60ea64..ac120cbdaaf2 100644 --- a/arch/x86/entry/entry_fred.c +++ b/arch/x86/entry/entry_fred.c @@ -62,11 +62,13 @@ static noinstr void fred_intx(struct pt_regs *regs) case X86_TRAP_OF: return exc_overflow(regs); +#ifdef CONFIG_IA32_EMULATION /* INT80 */ case IA32_SYSCALL_VECTOR: if (ia32_enabled()) return int80_emulation(regs); fallthrough; +#endif default: return exc_general_protection(regs, 0);