From patchwork Fri Dec 15 18:09:58 2023 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: 179503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9474778dys; Fri, 15 Dec 2023 10:10:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHV8fS+vW8A3MRC3BRVcsPnHnfI9Slx8JZGWfmUIw19RBPj6ykeFtGys+CieV4zRSOXeQNQ X-Received: by 2002:a17:907:944e:b0:a19:a1ba:da5f with SMTP id dl14-20020a170907944e00b00a19a1bada5fmr8865769ejc.134.1702663820782; Fri, 15 Dec 2023 10:10:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702663820; cv=none; d=google.com; s=arc-20160816; b=WET5K+T04YzZwPFZV0L5xWcgAQXEw/8NJXNLZjqBw3xd5ynvIqUWj447tQ4VpuwET0 d2Q/x4msrTw6GCozlJRM/XgUmkXiieHUMzrdAzGreukOv/IvRB0XZ82Gcz/Xl1zG7Ng1 IoGcoqQRLi3Li8Jc05/XpGWXGGewO6q9/OomSYdXi5V0ZU70pFgoweRYMTO5bqViH8G5 TNKWbP/u5yhWYsg7mxg5U1JLMq4vMkD3DadIei5Dt5VlplIKnSQ/A7fSuQAOM1LDg2dN AKhgNM0kqj16zt2MdOOuexydQZe+De0uCfkcbzJRUSl/22Ufsprfmpf9GvlUSFXP5YRM g+8Q== 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=g6WxWSr9My4EqInVfw9NRhqNdCjVoy5l5OLWMaXqDD4=; fh=Yp/5gEwxgKLFZsFMSxQy1c8GuJOzNkfTozXQS+Nu5A4=; b=Y+WV4fr4cnrNikUye2lL6JwIAO+G9IcTBW0BdAgPpkUs70DM42H9JyQ42+4ytil9ZI Ln9hFNVaMd3RIYTpfQIi4VClTVvEoiicd7+4QUBMAeGHboPbrncrGdIv2O16VEqKtOGp mGZkWAm88eUdbDYbY9l4loYzONRN61LbM8t28vTCAMEcM4UFhXJpwiFqKjU6aSyKQFy5 BZuEdag1HKcnuzJshCTCe+Lvwa0kk+pFCbkfLokahEmLbdxcvt8pt1bcbH9v3HvjL2kU 1ag5K5W6KeUvk9Abw5TNsGeJbRwTD4BLN0B+dourIKw66kjLexpwgtjJJx6Wz7VX4nx+ G/aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1TzQ1dA8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=yt5bl1GU; spf=pass (google.com: domain of linux-kernel+bounces-1504-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1504-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g7-20020a170906594700b00a1dbda310f6si7580800ejr.592.2023.12.15.10.10.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 10:10:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1504-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1TzQ1dA8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=yt5bl1GU; spf=pass (google.com: domain of linux-kernel+bounces-1504-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1504-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 644131F21AAB for ; Fri, 15 Dec 2023 18:10:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF2ED3EA64; Fri, 15 Dec 2023 18:10:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1TzQ1dA8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yt5bl1GU" X-Original-To: linux-kernel@vger.kernel.org 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 D7EB630129; Fri, 15 Dec 2023 18:10:01 +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: Fri, 15 Dec 2023 18:09:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702663799; 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=g6WxWSr9My4EqInVfw9NRhqNdCjVoy5l5OLWMaXqDD4=; b=1TzQ1dA85+4kXIccjiUhT2CD2sLuibuO8rAnwABdyM5uGkYyvDDPQ7UsOJgBiiV83y81yu MfN5XqzzIG6vpd/n6QqMk7Fz+xJ8vuwuLRjCtGWY7S3QGk/mLA+mx2ri1Pcibiw6i1GtDb flh7brcXNIGJ50Zzk72nq095hGBM1HcTdxovGeaQj3fwAWPhuz85qQXoKlo78sYjXMy8qJ 2oEnDKFp8LyALbK4rf2FFK8V4STh/ATvQQGdydXewMY1XGeUxsJVB6nuYmwY9eplamKteR Efu5CReik8e2lgMlhH3voWIEnwZ+ivs5lweM5uncpS93K+oR+mVr+s+ZAgcWTA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702663799; 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=g6WxWSr9My4EqInVfw9NRhqNdCjVoy5l5OLWMaXqDD4=; b=yt5bl1GUlWg7Ua7cgwSDwh7sHBFs6smKzoMyxuY2fhBnrI/3qGMxr850jjS29FUDe/j7UH 6o2TLcZTHw7axXDQ== 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/mm] x86/percpu: Use %RIP-relative address in untagged_addr() Cc: Uros Bizjak , Dave Hansen , "Peter Zijlstra (Intel)" , "Kirill A. Shutemov" , 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: <170266379864.398.7891451489965815897.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: 1785372418072476480 X-GMAIL-MSGID: 1785372418072476480 The following commit has been merged into the x86/mm branch of tip: Commit-ID: 91c17d7b04498ffb52939a18eb7e28fd23c9b654 Gitweb: https://git.kernel.org/tip/91c17d7b04498ffb52939a18eb7e28fd23c9b654 Author: Uros Bizjak AuthorDate: Wed, 13 Dec 2023 16:03:15 +01:00 Committer: Dave Hansen CommitterDate: Fri, 15 Dec 2023 09:50:14 -08: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 Acked-by: Peter Zijlstra (Intel) Acked-by: Kirill A. Shutemov 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; }