From patchwork Wed Jan 31 07:21:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 194541 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1721936dyb; Tue, 30 Jan 2024 23:22:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkmurvC64b+nIEkO7hSeNGqvs4oBy6/y+iK3du+W9B2eez4fn/+XxITk+C+zLrr92L0xwB X-Received: by 2002:a9d:74cc:0:b0:6de:6ad0:d34c with SMTP id a12-20020a9d74cc000000b006de6ad0d34cmr837708otl.9.1706685719960; Tue, 30 Jan 2024 23:21:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706685719; cv=pass; d=google.com; s=arc-20160816; b=YfmPi3QMKmdy3pfSPWGhmMgbnD+LhQ1WLq0kpfmiU2EFv4PyiNQK8RqH/E3WpVIZSU tScGqVwQGpUJ0NExv9I3rSCY5eZFuUpYKyjQeFPPydqdSVbRZj+aK+afKBgOcIMBTzKm MIIbnLO4WrVcqo+CfrKFugp8kQ5rCJblP+UMnCurBZ7O8PfzvqbjenI3ENnrwGMt1zgz 0Pmd8kwxb18UOPfTlZ9xvTRg6K7rcLwaOi/h9rGqKcOe+vUMJKO7WaYKA6nyfx/p/JrF CiXjN16l9YZP6Emkp8Z58EgevL/5rLjCfqcy7znnE4HQs3k5UtFkfDIrI/z/dhcpWB0/ /Yvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=o2dB0bQNI8TQ5FCEGQ4jdKzUAJaB0VSGEjyZQOGhhwg=; fh=bDxXD50Zjhtnvm+YpKRoN5k5TLcFIvP3PLWntQUiN4A=; b=n4jr55AsLidt6aIac6A/CjQ3VlkF3L68906Q1r4aC5YuP6scFqwPv92ML2psl+GBHL kKTxzbkiXwbIcrgVqH04etL75kJXvNAXxd/FjVnxEEnMq18TwUvu0BV9QlDoJstyLnNl XA0JPL0y6CwrTbyAYnj297MRwJmoKrw4/NuRphNOmAPRd82XmB0CSDsAl9uP+6cX4bjZ c9o1H2PKtAFcDOHfYkmgpZTx3dhf5BWhobMTNQyuQTjLNn6L3pegngv4/fycokpMY+p+ gF5REGnbzmPIA9i9gX6owu5uNBnO9fnm/VC4vUnCqplXyK4wTuahzRKXgdlwkqyVXfXC ESPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CcWvyQ5d; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-45891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45891-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCUjZsD4i/MtxFz7h7fXnmFV4iE5q5h3NdshD11GIQWrP7uE3Mv7gMWe3eTNgMM8ts4ULu1+Uawxw4v2FBT4KF4D8ApNaQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h7-20020a636c07000000b005d6eb428618si8795133pgc.168.2024.01.30.23.21.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 23:21:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=CcWvyQ5d; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-45891-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45891-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 B59D6283823 for ; Wed, 31 Jan 2024 07:21:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0BDF5B5DD; Wed, 31 Jan 2024 07:21:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CcWvyQ5d"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zFWHaeN8" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 356475024D; Wed, 31 Jan 2024 07:21:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706685671; cv=none; b=pZO0z7/fuMILsOT3dV8TYD89eK5K/yM3DVDBI58O7i+TXcWjUcQv9fGDrZ6JHCsCQE5rLX4ZdGyFFdBWDW39zFExUheNNq8AnPvHVipjMXeNJWkqnlkbef/+PPBn0SF85bcxrNmutmMAzybAYY2vF7OcTBeoxERiyjLzV96UvLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706685671; c=relaxed/simple; bh=5B4XxpE7BFkb5epemDLCRZir6hrVpFKrMhQQI3jMzfA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=gu0ren8fDxhKVu9Sh2kVGk3e9TQV3YSPSF4plSRQaifGYjNvQeTknL/jU2pmQhhbSgGtWOpXJgcmtEk21aWb4m803hQevsC34BXNRNICwDq8pPqgZPdz41bXLIyuEQjityTIErC5xmMpjzBEusFzTjxgG2W+FlJ/DyvA6wZ2gEE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=CcWvyQ5d; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zFWHaeN8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Wed, 31 Jan 2024 07:21:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706685668; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o2dB0bQNI8TQ5FCEGQ4jdKzUAJaB0VSGEjyZQOGhhwg=; b=CcWvyQ5dHPDlh0xR2YTiacqX0SHR5pvJqo5TLuj555tu5NRCQaAtI7o2bRVtturzwLeglf yz/YjnNKIUtM/rDbEKWud4mI4Mp+SiZ+L3W4iT55jBT1YMF6vXuU6wXCXxRpiw6ykKe6XQ aCMVTrHSKlDG2PKs/G+Jft+ZyYeZiWA9flRwgBTMesDTC6PxpqniTjjLU+NjeJzXeIFYUA TwQyHEEO/HaHA7EMsA1uWN2YSRHwogFYmniM6urPSCvzqAvlCz+Qs1xxJd2R4KWaiCWBYY 9a1WB12ecu3mYCAey4/5Bxk4zsQrRZf3DVL/FbIZCdId4xACZkJFjalOf3GVFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706685668; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o2dB0bQNI8TQ5FCEGQ4jdKzUAJaB0VSGEjyZQOGhhwg=; b=zFWHaeN8OOb6J4LRWEdofslzUPoNk4s7fADBoS8z29mDrE5yXVdXyHdwQ+3VQ89wCQfuaS ZGALmMp8OzgTyADw== From: "tip-bot2 for Xin Li" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fred] x86/syscall: Split IDT syscall setup code into idt_syscall_init() Cc: Thomas Gleixner , Xin Li , Shan Kang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231205105030.8698-34-xin3.li@intel.com> References: <20231205105030.8698-34-xin3.li@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170668566746.398.6148981179388974383.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784440873358324177 X-GMAIL-MSGID: 1789589685070646388 The following commit has been merged into the x86/fred branch of tip: Commit-ID: ae46f3978ae4eb9da013ff9963f105de2db2f8ec Gitweb: https://git.kernel.org/tip/ae46f3978ae4eb9da013ff9963f105de2db2f8ec Author: Xin Li AuthorDate: Tue, 05 Dec 2023 02:50:22 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 30 Jan 2024 18:20:36 +01:00 x86/syscall: Split IDT syscall setup code into idt_syscall_init() Because FRED uses the ring 3 FRED entrypoint for SYSCALL and SYSENTER and ERETU is the only legit instruction to return to ring 3, there is NO need to setup SYSCALL and SYSENTER MSRs for FRED, except the IA32_STAR MSR. Split IDT syscall setup code into idt_syscall_init() to make it easy to skip syscall setup code when FRED is enabled. Suggested-by: Thomas Gleixner Signed-off-by: Xin Li Signed-off-by: Thomas Gleixner Tested-by: Shan Kang Link: https://lore.kernel.org/r/20231205105030.8698-34-xin3.li@intel.com --- arch/x86/kernel/cpu/common.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index c3a1757..4f5e4aa 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -2066,10 +2066,8 @@ static void wrmsrl_cstar(unsigned long val) wrmsrl(MSR_CSTAR, val); } -/* May not be marked __init: used by software suspend */ -void syscall_init(void) +static inline void idt_syscall_init(void) { - wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS); wrmsrl(MSR_LSTAR, (unsigned long)entry_SYSCALL_64); if (ia32_enabled()) { @@ -2103,6 +2101,15 @@ void syscall_init(void) X86_EFLAGS_AC|X86_EFLAGS_ID); } +/* May not be marked __init: used by software suspend */ +void syscall_init(void) +{ + /* The default user and kernel segments */ + wrmsr(MSR_STAR, 0, (__USER32_CS << 16) | __KERNEL_CS); + + idt_syscall_init(); +} + #else /* CONFIG_X86_64 */ #ifdef CONFIG_STACKPROTECTOR