From patchwork Tue Jan 9 08:44:50 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: 186276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp1519939dyq; Tue, 9 Jan 2024 00:47:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPyMS7sfEQdD87ZdyPjHISPWR8yrhjIowuX+owMXnNTvudftF3UWLnhhXSyWCNSfctl/sQ X-Received: by 2002:a05:6214:2345:b0:67a:caa5:66d1 with SMTP id hu5-20020a056214234500b0067acaa566d1mr5792278qvb.4.1704790040049; Tue, 09 Jan 2024 00:47:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704790040; cv=none; d=google.com; s=arc-20160816; b=m9oDFVHFFjd9MPwq/dE715hdwPN7pSdUZhdf6obE0gLEHDd/HNnU9uS51jg6ExuXub FxvJ9SHXub9D1zItlu6SEc7VOAEE6/t9A3QwN/86jQR6fwO/gVusi6rH9yHAYArNMm8u mixLTEvDaTzuThVNZ6b+mjz9ysXWdtBG1XAJgMXCcaiSwQDPtbK0YErY+nbsJK1idENb N3epdbxgSfUM8zGX2Gt++I5J8zA7ZP7nOTw/d2yVJYwdm9Eb8zT8SY8KdloWCezXhNxh exPWm9OGYo0IAo+Amk+mcxDlE0WylW8YmJ47z14VYQ2VXDfOUp0AbQucD7IVKIQcMkaR l9Aw== ARC-Message-Signature: i=1; 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:cc:subject:to:reply-to:sender:from:dkim-signature :dkim-signature:date; bh=GNNKALJWGEQ+WL9sfA5PJJAOcKbXtkYS0Lz2+98RA60=; fh=v55YLv43l06jzZIuVcSzfFMAhdBHKJkou3f2b9k8wUQ=; b=SQDeJ213EIvMhDf4cagfbSTNzxZl1NhCUChRXDZofXZAPGA8ngr0b3+plPjpzuqq7O 4VZ8S9YJS0CEJqGn37Y9C+w1U6XTTtyDDcXa+p8dAqylriMSAgE34WT6qdc0v69X7H43 I02dRsxM90ZTEumCFI9tjptDeTTd7O+n06sDZLdqx/N4h18VqdnjjjizpQklyHTwbp8C YW4duZFHMYHtzz1GJ2VxzsXTCoTtA28dVjgfyfJxbOsiHhLPqDaXdWotuev5WSgSXHpN dT/EtASQjb8iNCXHC0+o3qa9TduFuedflM0QNkEdnP/3XABskITvi83Vc4rH5PnUzvou rScw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lCTKaDwW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-20613-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20613-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 s11-20020a0ce30b000000b0067aa3350772si1826530qvl.392.2024.01.09.00.47.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 00:47:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20613-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=lCTKaDwW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-20613-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20613-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 D24D01C203C0 for ; Tue, 9 Jan 2024 08:47:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34144364B1; Tue, 9 Jan 2024 08:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lCTKaDwW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Q5QN0I8h" 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 DECD9BA38; Tue, 9 Jan 2024 08:44:53 +0000 (UTC) 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: Tue, 09 Jan 2024 08:44:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1704789891; 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; bh=GNNKALJWGEQ+WL9sfA5PJJAOcKbXtkYS0Lz2+98RA60=; b=lCTKaDwWEm6t+oYnJFz/+KOmUt/aCVJCIJAnEDqo/y+/3+yDNpIQeDtFsWzN+JNlXZiuLP x//t940TJd61ywLZWgpEInDwjmV4X6mKGAsXIUJ3ACqXTNObzG6nJz+tiek0/XWNqneCfP wkKsGQZepGJDAaPC8dFeuvt2HDlKXAi19C3+x7ht8zdE61QbLUbjJRNKWCiwwFqmZ5ZVt4 iXtWu2TX8HuGBvHPVUbfNuGneiwb1xvB2+9fMo+f+rBmRA6FEg8gFit1+HVE6zJglJp+KF QU3I2f9mELw7C2qxNCVGnrygx99xR1sQIVzUyXhc+HKh83I594cB3A+bLCqrNA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1704789891; 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; bh=GNNKALJWGEQ+WL9sfA5PJJAOcKbXtkYS0Lz2+98RA60=; b=Q5QN0I8hftQOOq+S70hrlOs+2OeJUoISVCqBWKbYUFdimldljpUVOCIGM+4mr1VIkyPpqi WAQHaTlM/GxTSBCg== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/percpu] x86/percpu: Use %RIP-relative address in untagged_addr() Cc: Uros Bizjak , Dave Hansen , Ingo Molnar , "Peter Zijlstra (Intel)" , "Kirill A. Shutemov" , Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170478989066.398.5617937863599879172.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: 1787601920577258448 X-GMAIL-MSGID: 1787601920577258448 The following commit has been merged into the x86/percpu branch of tip: Commit-ID: de8c6a352131f642b82474abe0cbb5dd26a7e081 Gitweb: https://git.kernel.org/tip/de8c6a352131f642b82474abe0cbb5dd26a7e081 Author: Uros Bizjak AuthorDate: Wed, 13 Dec 2023 16:03:15 +01:00 Committer: Ingo Molnar CommitterDate: Tue, 09 Jan 2024 09:39:15 +01:00 x86/percpu: Use %RIP-relative address in untagged_addr() %RIP-relative addresses are nowadays correctly handled in alternative instructions, so remove misleading comment and improve assembly to use %RIP-relative address. Also, explicitly using %gs: prefix will segfault for non-SMP builds. Use macros from percpu.h which will DTRT with segment prefix register as far as SMP/non-SMP builds are concerned. Signed-off-by: Uros Bizjak Signed-off-by: Dave Hansen Signed-off-by: Ingo Molnar Acked-by: Peter Zijlstra (Intel) Acked-by: Kirill A. Shutemov Cc: Linus Torvalds Link: https://lore.kernel.org/all/20231213150357.5942-1-ubizjak%40gmail.com --- arch/x86/include/asm/uaccess_64.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h index f2c02e4..01455c0 100644 --- a/arch/x86/include/asm/uaccess_64.h +++ b/arch/x86/include/asm/uaccess_64.h @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef CONFIG_ADDRESS_MASKING /* @@ -18,14 +19,10 @@ */ static inline unsigned long __untagged_addr(unsigned long addr) { - /* - * Refer tlbstate_untag_mask directly to avoid RIP-relative relocation - * in alternative instructions. The relocation gets wrong when gets - * copied to the target place. - */ asm (ALTERNATIVE("", - "and %%gs:tlbstate_untag_mask, %[addr]\n\t", X86_FEATURE_LAM) - : [addr] "+r" (addr) : "m" (tlbstate_untag_mask)); + "and " __percpu_arg([mask]) ", %[addr]", X86_FEATURE_LAM) + : [addr] "+r" (addr) + : [mask] "m" (__my_cpu_var(tlbstate_untag_mask))); return addr; }