Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp137748rdb; Thu, 25 Jan 2024 10:23:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHlUE8dFRXPr2EISUQcttevCTZpF8GbN/5vdbCkEC1Ws88m532yFH8SZpaSOmflaFaotoT X-Received: by 2002:a17:90b:882:b0:291:582:205e with SMTP id bj2-20020a17090b088200b002910582205emr345526pjb.47.1706207008224; Thu, 25 Jan 2024 10:23:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706207008; cv=pass; d=google.com; s=arc-20160816; b=ocZ+Njop3Rtq3Uh818w7VHlldH2J0h/I2yq/+Uxvi29VLSXgeoTZ0axRsFV1Za3zLS HufjdImgz0EkjbXxUZ99eM4MR046cibY8vm9jjOgdBLo/it+WCN5gIgJjIQtqPtB0KUp Uy9XGs3Ga61rZmIjZeBIAhpJ9KWql5GK9l94HG5VR0W96RiF0Q6FOL6tKsMVtLVNHSaE a6SLrgbnRdVahsUgkTa2G56qBtUJJxTzadAgLx/YmEPiNVN9S5klpt+ZxcMcRD7oOzcD XWYpZIYpCyPByuhgBQW+klhnf1iCXiS2pNMM3HJhYnnQhD9tAnj2csPUUOBa7vA93Afu XIcg== 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=1hUlY3EST9IjvwQzc1dDjjNYJjeGjsK9DgloKu2C1Es=; fh=M75m9DP+PYHvyePq+354sB+T5eC4AdSPryu0QpLePNY=; b=nYOut5auUeXvzDj46b0wp+HGgz0AXrwzdLKNRPfRJXL8fKvRHn+U9yJynWiDfGbG38 U2pH8gFgSWFbXRW0XPto0sUHkKSTICSNSohfuNQtZqm0EJZVfwylA7ghTiXyoiEI7udy V0mgAp3R3m8MAWndz89l5qLJ81jzt9ysEFZyCOjrsWi1K1FX9PFMX6JqmHRg4cggBPZh WMxquJWEc/xsJIbwAxCtW1bAmsTekfvrhdJnWzXPjuWn/TAzOLK9nTwXZovfluJS7OHd /9/DRPevI1+t2RJCdjiOHLegzQ10DQufWXhyXDDZ7cmPdf4ms3zpj4mLYVZFbquAPqqB rcng== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fyYFkb2a; 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-39085-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39085-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s13-20020a17090aad8d00b00290ecb34f8asi1700767pjq.144.2024.01.25.10.23.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 10:23:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39085-linux.lists.archive=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=fyYFkb2a; 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-39085-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39085-linux.lists.archive=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 130F4299DE7 for ; Thu, 25 Jan 2024 18:22:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87A581350ED; Thu, 25 Jan 2024 18:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fyYFkb2a"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UJAK4lbY" 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 18A7F1339B3; Thu, 25 Jan 2024 18:21:21 +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=1706206890; cv=none; b=fW+im07xnrPvc86yLQng0QoCKDpBIOvJMmWL50OeYzN9H+FuB+hYf+XU5jB3C6+7fkeZ1Ch3GBZ/CN4rvemQWh459QJMkYZdlc54e73D2W2eVk/OpQUcQSc0ujCSUVcUOShRLSXKXWVzxoEw3ndzcT9qqn/34VYHMVXJxiIs3y8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706206890; c=relaxed/simple; bh=UxDDlR2z5AY7SvptNlGAU/vMC2pOYN9KgWH/l153KWA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=gOVC/eCtgTSza8n5w5StcV96mYdr7O8mY4ixIiKN42eVn9uww6a0JMCi22dfB7MSkvSlv3MCCLWc8F+7sZvL86hB3GgmxTBnj/u+92QC6QTQmD3TfpwWf6/7T0B10ol0MWv+0/7lY8RuQYJhpW/ymLTUpg2wamhfdgrbZX6j0YI= 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=fyYFkb2a; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UJAK4lbY; 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:18 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706206878; 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=1hUlY3EST9IjvwQzc1dDjjNYJjeGjsK9DgloKu2C1Es=; b=fyYFkb2aPRFKYIY61o2eJVYAKW29xKE2krIfNbNn9I2j9TYGOpVlT/HZS6o5hRc0eOSaPQ 4btnclLjQZBza9sILq8jZXor/E+2Py6JxwSlY8OF6WMYf2Z8bYnW/kBkU8M11N2ZBHNVL/ 8lZujenAC0WwUdCIIyvWfQu35frL+VvJe5u9fXEqyz0/eWd1HzDNQE7XcZ6RMO2fTat9YR f5EFL5owWll0jK8UiRatXw2/cZm18d+RBRIISVIUUFKar2GArj43I3dcnMx4c0ofIfv41f F3R9zS9AMNthdUoOvCVEi1GTP/bYGyr65kvWkesD7ngCx4q163oc39KE5EeIcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706206878; 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=1hUlY3EST9IjvwQzc1dDjjNYJjeGjsK9DgloKu2C1Es=; b=UJAK4lbYC/agviFUVjizXKpZmDISyNWzr7H8sWCr3wywC3PTrMe85aN2t3WYVasH0jPkkW 2tvCSmc6SPd/vhCg== 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: <170620687817.398.17653307848383085841.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/fred branch of tip: Commit-ID: eea48ae4c9c766ba24fda42a0b3387c942240bba Gitweb: https://git.kernel.org/tip/eea48ae4c9c766ba24fda42a0b3387c942240bba Author: Peter Zijlstra (Intel) AuthorDate: Tue, 05 Dec 2023 02:50:19 -08:00 Committer: Thomas Gleixner CommitterDate: Thu, 25 Jan 2024 19:10:33 +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