From patchwork Wed Jan 31 07:21:10 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: 194544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1722203dyb; Tue, 30 Jan 2024 23:22:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/69Tmt4ZW1uBWQzk1ZFzKE7UMkH3bYCtEWXKJPbiFkQZfWzYcAgxFeHkGznKUSlkKCNcZ X-Received: by 2002:a05:690c:f88:b0:5ff:48fc:94f8 with SMTP id df8-20020a05690c0f8800b005ff48fc94f8mr721160ywb.39.1706685769191; Tue, 30 Jan 2024 23:22:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706685769; cv=pass; d=google.com; s=arc-20160816; b=h2gsXmMMUSX/Exut+2i3HhLqgBkfXrkwVspymvB85W6nEgb2Y4q2+X91FW5+0tXtZr sUz3Oo2oGEwOXpH7ENo0uAV6yC5LCXR4KZZ6RCMMUotdF+O3C3znSdATG4tdRjs2rxA+ EgH5L2DFVnBSO83/YHGiAIIF5UQO1tEKVZnPDInWT262bxkNo9n4Vko8/ZN99VgwCf3A ekSSdHswc0/nWD6xq00LTwJvpOynqByAviR3HVxZB5Nm1OPAam56bBjZ1IFOwTdLv5Xj ey3gwW2mPN6VROfyMP1l+eV9RI9tfGgr42HW9287gmprNOVi/38A35eA0iK81S5z8Efa z+zg== 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=RVveiR25OSyQ6043d2mbGU7kRo7eHnFy8CfWCFHNWzU=; fh=z4LOXvvAC82oROD5j2OTlGTP9gID+JcKYlIegOEIqqo=; b=IFcny5iWQzA//X8/pU8w29sK2avIiTMALl6mT3gBi3dwju8rDS+zTl4XvDQOocSk0l 6RsqDlapsg4sXeXqPs5206DbM8yMd4eZftsdmyLhvkpRnWOMe1Ls2eB1DHeHCMdZkIOg ba41dFZuSoTBfcn2MzoHZxUICSFplufhfjzz/moe2SzN5LRq+s9NwarPAY78MijYVmSA br8B4ZLVAegYCsoErF+UIp6cz56aW3qHobczpeztaCfZa5lRSQ28bq8ldeCV1JQHzLSb OFw229F5H71Z+h8QCdi3JLXFJELG8KKVHR+4zz3xRWL1myoFHO2e9J4hgjFNhZ4mv8qs LcYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KJQ4diPd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=sBUQCrXO; 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-45895-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45895-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=1; AJvYcCU2wkUY9oAnAH7qoM5KRV+K7Wz3sVuuubpRxmVwnG1/gqIg97ODsHemMg4KtxpMXmjvlZNIW7/p3pjsWbdY8F9eUXm9SA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g4-20020ac87d04000000b0042a4a0c231fsi11651278qtb.424.2024.01.30.23.22.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 23:22:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45895-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=KJQ4diPd; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=sBUQCrXO; 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-45895-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45895-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 024AF1C24EDA for ; Wed, 31 Jan 2024 07:22:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 743456311A; Wed, 31 Jan 2024 07:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KJQ4diPd"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sBUQCrXO" 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 A8C6E55772; Wed, 31 Jan 2024 07:21:12 +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=1706685674; cv=none; b=UYVpItk2i6bgI9+xwxcaCoW8G817nxwtVJMOzTRZSNuQKXiDw1jzxOyRvwQ8gjQrvmFGwpAlkB8dbafJrN0wZQ8+AJSBj3crL9/do218UJ0VRQRUuObc0Z+28FtFne/phmoZ5Biaj0Czg6uGkPBec4/tXIh4fglhgRWPFwbOcm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706685674; c=relaxed/simple; bh=inx/MoK+nX1XWfZsDYJQySbJPkdyyH7g5uCrznK3rHY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=SeVJEPfAKjblDvDEv2QT+vF9sCKdmLmMWlJ4HeckyArNMhgVsG70ROL5N5BEupvY6kHdBrM68ag/qXkFBPJH5n2csxeCxPLARJw967EkUFJsnKa+5zs43y5L+TI23NRPkxVuSpwZHLkpnocnUJgS8qYyI5q4YkZchNUpH5FBeqQ= 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=KJQ4diPd; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sBUQCrXO; 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:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706685670; 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=RVveiR25OSyQ6043d2mbGU7kRo7eHnFy8CfWCFHNWzU=; b=KJQ4diPdrg4+jcMMDOGCy1XFIAIEf+GG3SuZYVu0KaUIKg44h8bQBuT70hpPCMKvJxGGJx KY0BFeLH++8o5+DoitJTbey3aSvVWueeMdjXEpOkMencZZZlNwTf0SqEfgoP2XOPeba0fL hIO87AqVVCzh3z1SwsY5RF2NlLeSywUrsuco24eRh6idHCKCRJVCZLndS8b/UO7dwpnNmQ 1iz5n6lgyoXQWhINH9LRlibTtS6b1Q5wB43QoNkyaFZnJuQemou27AjPNQH6oFN31ugi28 RlL4jk5qb8kPFAKwBGHFNZKJgDnXtbvoz7OoW7BfhE9Ai8GtrHCmzS3UcWqm1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706685670; 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=RVveiR25OSyQ6043d2mbGU7kRo7eHnFy8CfWCFHNWzU=; b=sBUQCrXOsMt4NYlT0Csk1kG0TXFNn12d6kWf/tiC/IMaXEij6tRgXYwSxi3DpQSEhg8mIo siekqfNrLiWA4pDg== From: "tip-bot2 for Peter Zijlstra (Intel)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fred] x86/entry/calling: Allow PUSH_AND_CLEAR_REGS being used beyond actual entry code Cc: "Peter Zijlstra (Intel)" , Xin Li , Thomas Gleixner , Shan Kang , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231205105030.8698-31-xin3.li@intel.com> References: <20231205105030.8698-31-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: <170668567005.398.8952019391894934362.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: 1784440849523979408 X-GMAIL-MSGID: 1789589736816137643 The following commit has been merged into the x86/fred branch of tip: Commit-ID: 8c968f4df73c62be94229c7dbbb330ba9fadbd50 Gitweb: https://git.kernel.org/tip/8c968f4df73c62be94229c7dbbb330ba9fadbd50 Author: Peter Zijlstra (Intel) AuthorDate: Tue, 05 Dec 2023 02:50:19 -08:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 30 Jan 2024 18:20:36 +01:00 x86/entry/calling: Allow PUSH_AND_CLEAR_REGS being used beyond actual entry code PUSH_AND_CLEAR_REGS could be used besides actual entry code; in that case %rbp shouldn't be cleared (otherwise the frame pointer is destroyed) and UNWIND_HINT shouldn't be added. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Xin Li Signed-off-by: Thomas Gleixner Tested-by: Shan Kang Link: https://lore.kernel.org/r/20231205105030.8698-31-xin3.li@intel.com --- arch/x86/entry/calling.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h index 9f1d947..3ff925b 100644 --- a/arch/x86/entry/calling.h +++ b/arch/x86/entry/calling.h @@ -65,7 +65,7 @@ For 32-bit we have the following conventions - kernel is built with * for assembly code: */ -.macro PUSH_REGS rdx=%rdx rcx=%rcx rax=%rax save_ret=0 +.macro PUSH_REGS rdx=%rdx rcx=%rcx rax=%rax save_ret=0 unwind_hint=1 .if \save_ret pushq %rsi /* pt_regs->si */ movq 8(%rsp), %rsi /* temporarily store the return address in %rsi */ @@ -87,14 +87,17 @@ For 32-bit we have the following conventions - kernel is built with pushq %r13 /* pt_regs->r13 */ pushq %r14 /* pt_regs->r14 */ pushq %r15 /* pt_regs->r15 */ + + .if \unwind_hint UNWIND_HINT_REGS + .endif .if \save_ret pushq %rsi /* return address on top of stack */ .endif .endm -.macro CLEAR_REGS +.macro CLEAR_REGS clear_bp=1 /* * Sanitize registers of values that a speculation attack might * otherwise want to exploit. The lower registers are likely clobbered @@ -109,7 +112,9 @@ For 32-bit we have the following conventions - kernel is built with xorl %r10d, %r10d /* nospec r10 */ xorl %r11d, %r11d /* nospec r11 */ xorl %ebx, %ebx /* nospec rbx */ + .if \clear_bp xorl %ebp, %ebp /* nospec rbp */ + .endif xorl %r12d, %r12d /* nospec r12 */ xorl %r13d, %r13d /* nospec r13 */ xorl %r14d, %r14d /* nospec r14 */ @@ -117,9 +122,9 @@ For 32-bit we have the following conventions - kernel is built with .endm -.macro PUSH_AND_CLEAR_REGS rdx=%rdx rcx=%rcx rax=%rax save_ret=0 - PUSH_REGS rdx=\rdx, rcx=\rcx, rax=\rax, save_ret=\save_ret - CLEAR_REGS +.macro PUSH_AND_CLEAR_REGS rdx=%rdx rcx=%rcx rax=%rax save_ret=0 clear_bp=1 unwind_hint=1 + PUSH_REGS rdx=\rdx, rcx=\rcx, rax=\rax, save_ret=\save_ret unwind_hint=\unwind_hint + CLEAR_REGS clear_bp=\clear_bp .endm .macro POP_REGS pop_rdi=1