From patchwork Thu Jan 25 18:21:15 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: 192221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp168167dyb; Thu, 25 Jan 2024 10:22:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtNUvtKabISNYH7tOrpiYELwjeWDqjDKi9S4g/pSrfguNPFenBDab0fLIhHbDEXrIdm6Tb X-Received: by 2002:a05:6808:3a13:b0:3bd:9d8f:f692 with SMTP id gr19-20020a0568083a1300b003bd9d8ff692mr216552oib.36.1706206934428; Thu, 25 Jan 2024 10:22:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706206934; cv=pass; d=google.com; s=arc-20160816; b=RKq1kF6w5OSuh8TTVqFs29CFgEd8GGCC5cJgEdSjpzQZX67qIKJ4PTbFwjzSWjw4Oe w8roOgeyKeWuWNPNv4GuNWzWkFgBpw2MfteYwJ9JpOrXtujroflRSVMtZ6zhVH2lA0+Q RjCdaeOkVvKOZvvKgDi1zfQHkFpgDdDlcCCctz3ec6diDNy5hVnzHW2t8DvzyHuLyrFx +DzHYh3rq6QJTbgKAPhiakQgwJSO7wMMez+Q4+qFhbyYDVbhmL7A39RBuhL+Wd9OSZlD XytQjaSk/HkqiLoCZmE8Eq5EhNvb7ToICRyeHSsl2sq/NeVQq4TKdCtPn7m7MDHR+4Gr Zoqg== 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=odfmItu9ii7bshFD1zgZ+iKaiIffEG96qGJUw2rFCu0=; fh=M8oePJ6pBcJVpb0uoTdjAiGvNu4Xsux9OBt8HKsrav8=; b=euHGxId9R6J0O52/XvAzohll//6ur+hj3zgPoASxKo1mAkOkcqh9UOGkLzgh75yg8b jSroc4SbPBNZ0UvDzovKqfZRb0Yf+ruJV7dtur5dOLupODLYFDCQh6aI0AtFkWKvijlt xGDgRYBuGdr6F6zvRDkpby8O/Qn0M+oECqaLPDbQ0rRGzIJNrg45ko7k8RfOdFjW01kn 1MRCzGVO4co3aYf8TGOWfIQxUbpo4PaVa8eouvESSCMGUAb8ogub6LGMNBZtJdRksVC4 mSGLCKvL6k8AqZrKwJbCZBDMc81F915pJWNYAQr5FIjyMrCAHsSQJ424eWVkyjT+zkY+ n5ew== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1TTxtzNn; 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-39083-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39083-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c8-20020a05620a268800b00781935ddd47si14105776qkp.402.2024.01.25.10.22.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 10:22:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39083-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1TTxtzNn; 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-39083-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39083-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 39CB01C25CAC for ; Thu, 25 Jan 2024 18:22:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB9D51350EA; Thu, 25 Jan 2024 18:21:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1TTxtzNn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gvfv2sRZ" 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 50FF9133983; Thu, 25 Jan 2024 18:21:18 +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=1706206880; cv=none; b=R7wB+Q0WB8RQCWORD+LfKtfY5PKn4L/WCHBkDlTTJ/MQ8DVvSdlWkQ+p+AL51WzgcjBzBL/Ji+WV6rPjBZhUt23taCpQsqWHkAKC1rsi7OnV9wK+9v4V5bwuRR84P3uQi24jmHwTvmZwo1B5atQazJqKGWrp8DmFY9vcVg0P+DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706206880; c=relaxed/simple; bh=9/i3bkP68fhQln9ksOZI+1RMoK9UoRvjJg6qLLKUDKY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=aqlGdqgOfJuFuJn4kdFz9cfnMoZYELR+6j1vMqv+k0gBPIySarXONaA5XjmCXwsSv67ftMZwb9jMAmdHjcBot4SZ95DkVfd8d9yacQU74j3fkduodP4nMdvgK78Wxbjr9lV3+v5OHc0DGAJ4yzx8B5SrKN8tFSwk8SIOJ2rcuvo= 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=1TTxtzNn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gvfv2sRZ; 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: Thu, 25 Jan 2024 18:21:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706206876; 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=odfmItu9ii7bshFD1zgZ+iKaiIffEG96qGJUw2rFCu0=; b=1TTxtzNnhMjx/WSHc6VEFrR1Z3CpUKgAAtorBBFYtNbP+F3MwBOpmJ0TWsJ+7elBLvW/pR iJIYyWodnKC1gmU3STBwFZ/WdTCsT1z9mqte5M1uyjdBANiv3uDNZq1eqbJUuyNAfNDSW1 RJ48ERjoZBrn+JYEPl+3F09rsEfBmwF7hz6dpHaDd7qW6JSDpSuVenrYli+uVaT6L74tdT uIqUoREkU9q2vRBDvg+KvRmDLK01gHDfmuz/MWr5w/9m19Dt+frGZUIXHbYxwqGqaDAUoa DYrvuDH6uu7S3ls5RSXhYQS9/pbILW3Y+XV0CiNUudJhMYlGprFnBNIf5BTBfQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706206876; 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=odfmItu9ii7bshFD1zgZ+iKaiIffEG96qGJUw2rFCu0=; b=gvfv2sRZXSvabSyxszFwm5S1rvYHwVip73+qCVYU3YZgV2eTs+/msXfOErNIL3K9DNDbK7 7d541SuMzn4xOYDQ== 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: <170620687560.398.9888968561553903874.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: 1789087642265494936 The following commit has been merged into the x86/fred branch of tip: Commit-ID: 10e6d5d2a44789e1a4e57b9fd45c511b4187749b Gitweb: https://git.kernel.org/tip/10e6d5d2a44789e1a4e57b9fd45c511b4187749b Author: Xin Li AuthorDate: Tue, 05 Dec 2023 02:50:22 -08:00 Committer: Thomas Gleixner CommitterDate: Thu, 25 Jan 2024 19:10:33 +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 204f4c7..399f0d0 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -2069,10 +2069,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()) { @@ -2106,6 +2104,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