From patchwork Sun Dec 8 20:45:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898669 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCD4F12FF69; Sun, 8 Dec 2024 20:47:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690847; cv=none; b=mA3v/59xdIxR9sTYi154/4l7ZHbrtdbrgOyXtUGWP814KHYotrNRp4Mu74AC39+LheIJB4hUVH1Hdu0gUI7YDuD5MJ0nAEHchzdodT95uMQGPH0ZvJxDquCb/qoiPqiGPrmo0ETFjP8hpuBSXt3H/ENXUAMrWuLcKhSoFsr6mq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690847; c=relaxed/simple; bh=ogmAtJgEaFLWhDuyZKKcCqZcT06MJkx7e0moOOTVcLo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hZreUS22CVf0ya74MwhMfjpz87lFMbtGZJKzns7v184PLW466g1wNwtw/65KKM4GZdzopUxJr/VdqZeQ9CrWzD1Bg/BSpP3aKCBcklQHUIoft1Mw2iuBrhZNqlbT/MV5/OY6nxOblzDxyarblbmFrbmYmE2pkw8PvHMBTqmGg6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gdACvJPY; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gdACvJPY" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-434f7f6179aso2702725e9.0; Sun, 08 Dec 2024 12:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690844; x=1734295644; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3PpdJnIt0LB5LuubDznUPiNtcUhO58iUpeI8CzsV/cw=; b=gdACvJPYhdI/HOhtK2q11nJoO8fsIwdTNEET6yGxtRsv1pVq8QF/jjEvuBBxGUygMe ZFKWZ9QNCYNEXyIr0K3h8WSAFwbkY2m/dmrCqdfRzLbJgA1EiFnZWtRssB6JICPiK+fk G+3Zy7JthkMteJ+NYa36XbZIwn02TiIwyor1fAg0tegK4oWsUdciI+LA7tGqDf+9Cnbm NJlQ+zWK5D68vMcevDjpf9lTSV4IV1gxRFlWWckVFfnSvt9YXX1NNKgWlZlBQThUc6ou 0N1W5qS6r7Xg+y4Ow20b4b57h+aOQr9QrJ/foQ6+AMUhZ5HSabUychdf4Ou5FB4e2RcM xd2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690844; x=1734295644; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3PpdJnIt0LB5LuubDznUPiNtcUhO58iUpeI8CzsV/cw=; b=aIMn9buBOBIYww8atJdeF+8kaJ+loBcWj5OplNO5H0mVXcs+/hrbheJx3XzbzVo7k7 GGE6vW488TKgkAWVgDaAhqrqThnLmX8LKB3putp2+UnuZRz+VI9GoXgz7Io/nTxVzFof gMRP2+YtBjrfL0DHYeGBzUrVtUEh5arIutcLUl2oKPiFY37oQLBvLa0S+WWjCiDkOMaR bsR7aIrQY11mhf5TtXwADBpSfXjPWy/5355+L4VnmRIaz96/rF0vvyd5BDTEiiTE599q fZPcztQ1daNSGzCWogTWyEau1/kU1sqRjiUBx1yhzbYoUy2wTuzlsv3sh4HhKH+boSjm 3CcA== X-Forwarded-Encrypted: i=1; AJvYcCUckjdXzTmfZLHdN+bP9RWk/kCNoBDMrwsPD/eb6QKp6rl4oYnAL0zeBV9uX7vo3fE21q2Patkv/O72@vger.kernel.org, AJvYcCUpCQcL/pdbElNAxN9JQb0HK+CU70sIsfzM+93YX9LbTzUeiGUM8sIKPrjvmfFF9pMH6jV43z9dykyp1NB0@vger.kernel.org, AJvYcCWM7ahMLVF8/k2iNpAs5WgpYYuJi+uBQfoWKM2uUecajZ3/G3zXYZU5JZ5EddFL+CuOzDAXeyag@vger.kernel.org, AJvYcCWv4eUhcg6A+DkZ/dhgaW8Qnjkm4ejJa552FlcBDukFyD1apjnCQ3+4/pvGQKjNUuGpgSKCKQXFsogh0lren9A=@vger.kernel.org X-Gm-Message-State: AOJu0Yzd/uzvtfSDpoL7vXZYXEFy9KBzg+svHstZ74P06DrxbWgT9xSG DjcoWjytIVm9fJFGNk/9A+x9N7R/UWod3bdNOBOn7JTigUTMEIE/ X-Gm-Gg: ASbGncsBxp6Adm3WqomviKrpbgNjDrKLBJF6z3pPP9Sm/a1vHyUoG9b01gRyvOHbGNo UmZ0FOmP2NDVtgCoEi1qP6YXb5RD6WAPBPhzO5KmBoLvaDtADwFRdkui+6yjThLSjP9Nw8gX9cE Oivbv3Om3ogjNU0gbNmE3gLu6qDJPCBrdTnXedJ//rTEoOLgxmB0OLR+HaCbqfRJyCL9+OD01SX 83jnS9fERcJ9gF2Ka5ucn+3C3Z6xU4/DeFsY1NpbM8YE/jp4dqKPgiQNt8= X-Google-Smtp-Source: AGHT+IFdmj+6mXpKaatS+ZSrn1/J5DGo/OtucbepOlqgugKcinRIN8pfplGhkw0ngoIgy0n14MnuWA== X-Received: by 2002:a05:6000:1a86:b0:385:fc97:9c76 with SMTP id ffacd0b85a97d-3862b33d72bmr8784844f8f.3.1733690844014; Sun, 08 Dec 2024 12:47:24 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:23 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v3 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Date: Sun, 8 Dec 2024 21:45:16 +0100 Message-ID: <20241208204708.3742696-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use IS_ERR_PCPU() when checking the error pointer in the percpu address space. This macro adds intermediate cast to unsigned long when switching named address spaces. The patch will avoid future build errors due to pointer address space mismatch with enabled strict percpu address space checks. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Brian Gerst Cc: Peter Zijlstra --- arch/x86/kernel/kgdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c index 9c9faa1634fb..102641fd2172 100644 --- a/arch/x86/kernel/kgdb.c +++ b/arch/x86/kernel/kgdb.c @@ -655,7 +655,7 @@ void kgdb_arch_late(void) if (breakinfo[i].pev) continue; breakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL, NULL); - if (IS_ERR((void * __force)breakinfo[i].pev)) { + if (IS_ERR_PCPU(breakinfo[i].pev)) { printk(KERN_ERR "kgdb: Could not allocate hw" "breakpoints\nDisabling the kernel debugger\n"); breakinfo[i].pev = NULL; From patchwork Sun Dec 8 20:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898670 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A931319340D; Sun, 8 Dec 2024 20:47:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690849; cv=none; b=esvJ+ctvfg5ldhIaYcv4LAInB1DZmKhY/64FnoT6lNCB0dCUVSpNlFxL2GvOZDmA3kO41qJ7ADtQLERFnh6IpUvpfT1BF3xptXiP9pXGG+oiJsLy1UZjwG8ERvXK26X+aue615UOvy/Uxgy4soD1v3YLcVchxWiMsOE89pm4dXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690849; c=relaxed/simple; bh=unFCMuepgf1SQbq5AYrK8xHbDJUoge6TMBDvQpYj520=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X7w09Nf2+JGNTwIURyDIGPLHAh9LvbflttuTeVFsxyevSyX3y3rcsBbOgJCYlMj4izzX/GuBsacLFOiMt68PYpMtWR2rsgvBDyxN/JqE+UOib0jF6c//dJHyHyDjEeIaeJMReJvLs+Uz6Ci3EV8OT2pqs740EGFx6JBzOQROWHI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=C/IJhnA5; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C/IJhnA5" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-434e84b65e7so14658745e9.3; Sun, 08 Dec 2024 12:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690846; x=1734295646; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G+7I9gi8mucGgoO85kNahA3U27ot3S0RhfZIOhPcQEg=; b=C/IJhnA5iTjRrIlp33Zdxc55D3nyPccd+8y5VaHLD3mIlFpVnpP2Yn21EYY+WW5IMH umAqnotSk9shNZQS1vj1EbcI8CW37sKZ07WT6Aa1mxPsUKTkOnE2QhqQdrTaqctSGAHC lIUP3bzNWHsN4B/0zigUGmoH2nYISvPiTVRswiWg23dSEvHj9TJ8dL9vjLNP5uTnzSks /EZfwHs/ELFvPntIm7kJ9Z+aPnh3jLFiM4ffPe8E3yxv6E3jCes0LYIleeQrpvJ8PRdI 22DsohcZH5qYe0L4urYhII4g9261eelViBRE7zVC9klKPKPS3pbVlfJNWbgRW1SVMY1q 9G2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690846; x=1734295646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G+7I9gi8mucGgoO85kNahA3U27ot3S0RhfZIOhPcQEg=; b=NBfAn/AkL9M6Q7taPmXiG7IeJMscFJpGIAvR+xXeh1PzjVuWSg9HVO1fSZ+BwqmMMj Pg9jTwPXsP4QXwnJODuGtUgGPy78MIekqM9neheAlJnQUbMUJ3GsLAmeGasnsP1Bd4ll TtTGH1fROZoIvVnHymrNRZjTfEmu8RfYc/Z63wHxP2SeRpVNYNvnDuNYpdT4wAQe0Fnb VE+/AAxcpWtm2rgsATm56pNwZElj4qWcU+1hQYVIQ3J3wxddOU+XRKvikywzaO5phQUk EWjXsgmTa+v+rzBcu43ONoOLfzsBVKJpiRJzitFCEzxLTS+TpN4En5fuLwh+y4tk3VKh eTAA== X-Forwarded-Encrypted: i=1; AJvYcCUgOO7VNPNnZTbHvRCy83KbZw76f/wrZjLt6qRHUAk0N+e5aCXz1fl0zv2SwxHHzPZ60dj0GeK+id/hI0CHsEE=@vger.kernel.org, AJvYcCVcV7nJflQACZkTgt9TScQxZnD0X/F0yXdITwxjloCKmetvlrUhFx0KLBqOc4E0nJ6grN8ygxkDXzPZ@vger.kernel.org, AJvYcCXC5CiThquRObyG99kuzfzF8fa/2q17CDTNO/hSgiBRyack1LacVSImstw+udZBuFLK9JpmZpZ50Bv8/KoA@vger.kernel.org, AJvYcCXq2g2HWb4h3x7VrOc2Nbw4lTqxwkY1lElMLJ+QIkxGaThOR+BkUC35cKiJwrk86qvMp6+k8UZx@vger.kernel.org X-Gm-Message-State: AOJu0YyknRA3IelCrfHiHFCKI4wNgmphuXBuFNpBgKcgq3JhlX7tSX2m sWOBMShFrWPjAzJRzYe3DHIEKFG0j27G/fx5pPctH1v0q7ck0SZ0 X-Gm-Gg: ASbGncurTQ4E8it7d2J1ZYMxHsGImp4Q3jglmP/4jbeXs1xIUYSXQZObtSgrl2eb92n Ktv/H/85zrq4Cz3fRNPYPV6chAH+jVqVeErhPBWGz593si0ch1XpVnmIj39XBolWU+Q7tEE1qIA LTnHp3Apvh/vDFJ111swLsdjJ1m9eznQaAy0jiDwYnPUC9IqlKq0pWJQDMIkLLweRQAOvdIMTZF XztGEW3ImJjBsY3zkyEabVBNumD3dzMPyWxtGqiYe4dnL3FdOn1jf/gLvU= X-Google-Smtp-Source: AGHT+IEEx0rgQYQ9iMyor+TEsls9yO5cspee9cXj1IHwee/pJe4BPDGI+xtnRRqbb2a2nmwevxjJVw== X-Received: by 2002:a05:6000:471c:b0:385:fac7:89b9 with SMTP id ffacd0b85a97d-3862b3e4483mr7723302f8f.59.1733690845640; Sun, 08 Dec 2024 12:47:25 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:24 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" Subject: [PATCH v3 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Date: Sun, 8 Dec 2024 21:45:17 +0100 Message-ID: <20241208204708.3742696-3-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof operator when available, to return unqualified type of the expression. Current version of sparse doesn't know anything about __typeof_unqual__() operator. Avoid the usage of __typeof_unqual__() when sparse checking is active to prevent sparse errors with unknowing keyword. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Cc: Thomas Gleixner Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Brian Gerst Cc: Denys Vlasenko Cc: "H. Peter Anvin" Cc: Peter Zijlstra #endif /* __LINUX_COMPILER_H */ diff --git a/init/Kconfig b/init/Kconfig index a20e6efd3f0f..c1f9eb3d5f2e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -894,6 +894,9 @@ config ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH config CC_HAS_INT128 def_bool !$(cc-option,$(m64-flag) -D__SIZEOF_INT128__=0) && 64BIT +config CC_HAS_TYPEOF_UNQUAL + def_bool $(success,echo 'int foo (int a) { __typeof_unqual__(a) b = a; return b; }' | $(CC) -x c - -S -o /dev/null) + config CC_IMPLICIT_FALLTHROUGH string default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5) From patchwork Sun Dec 8 20:45:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898671 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56CBF197A92; Sun, 8 Dec 2024 20:47:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690851; cv=none; b=jVwi7bHWsXl6ZQp6JqGsA1CD21MbnN088p/YPt+HyHV6DVIT0gAFLgx3JQydvAFHFqRh6HvGlf1FiS+QptZ+YyYBsv+V0E5603+p0esE+FOmYEjHgKYbbctDMI91g5u1sFi/PBdQTqeH2V3JOzRM4A3HuxJI3KXiXrZ3UANi+MY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690851; c=relaxed/simple; bh=v4+aJNbD9jqPDPBZHZg0flI9bzYjUUxQkdbtOPZJKNc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FINXC3SB1xxv125hT+2hXO5710jvPweOJXSaZYDKQ+AsP1fptyvvcQ/E1WSW4tinL+hNNu1WkPycChZx+aWRhIpAEU8Sav1Dj7lUO4R+54Ek0xvLsBCWLMSwwT59Dnyk97I3QNTttDsCwBMWypfbRMX+QCYGJs2CWpRnS0Ox0OM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DBNaegmF; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DBNaegmF" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-434e84b65e7so14658915e9.3; Sun, 08 Dec 2024 12:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690847; x=1734295647; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4nHTtV9SwPVM1CI/6H4NJcvMXq5Ty5K6NAFveY7fTlA=; b=DBNaegmFaJv7KHERI/SlGvR13hrB+jpBjg9xBMGMiIV54DOR4ccYQtYwjd+kGcQCjr 0mlPevWJPz5ThJA2V9BEo0f3BC/3uWVoaBmVfhsTR/QE30wP2DbU3LE8KnaqWPuUGkS5 bwQJgliUZceNSFbPqnv44eSOCPBWR9twxLVCNyr5tCyIzVfv/KabNLqam69MdbqJ10Y+ iDtSlhy2Tfj6XTIBJ1yvEIoZ0n6ITJce3GHX2nXhbcT74fCLTShQM3lqXsI1SNnyUBXV zRYiyXmzxn3d1Gphs7oPnPwpwdKXUk/9SnjDGJLyVq7ZrX6uOSe6JYnwT/Y9QPJTbmWc dB0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690847; x=1734295647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4nHTtV9SwPVM1CI/6H4NJcvMXq5Ty5K6NAFveY7fTlA=; b=UgPo0xE1lpnnKGefYvZSHDO5UBmArDJdfV1Z4V+BdKp4MpYXgDL6LUk55TgsWpcBjO 7wIcXAUTgHK4VTYGDdVyROYHH5/9Y8onnqnC6AHwHgiuA+bd6bLywAmPJJdawGjzHLcB 5n9JKx+pC4fTOR/AlRvg/mANrpJEoIbEhRI/nh6CDHCw964FzbR5J1npGgZ6Ax3UVdts n91vgdZdjv8PRePCrRxG1OmYH4rV+t8Qdj3uDgxs8FpCzDmBcTWV7tGvCc9kixf0PLdk 0nat+6tDpp5x7OKgrbc6dd8FFsLpdOeaIMdx656v4WTXS46DI54boAaFyX3cJPIvM7+S MFcg== X-Forwarded-Encrypted: i=1; AJvYcCUpalzNOMCE0vO+p+Gn9Hx2RSNgozRz1zTD72gZriyPEYVGVIG0E9bfgZAiAn2JXJEpSl5RHLPX@vger.kernel.org, AJvYcCVOgXkGncuY713qB4RUzSdvJ2v9A1EJ/Qkw67zs8oqjvOmMfog9+Bp4/bh+XZR0nySdf8giadMrxQJd@vger.kernel.org, AJvYcCVeWmY0B5tDbGMf+dyE6R+z+vTi8XN7qbVceO68fsXK9/JZ94G1Xa3mr6K0wxkWFkaKBD2IPD12erHQAv7X@vger.kernel.org, AJvYcCWdokxfiEtGIXLOHbcQBHDc7dHwF/EHrUj64MvfXqafh7az9XiOobnf9kur55DAOGgLFwGnU3SxDZQxMFfx7SU=@vger.kernel.org X-Gm-Message-State: AOJu0YwpOqqeG1Mqk+Ur4T5PAvqhb7p9GXKhjw8/fuE15QZlIObhEXie artVX4IsXNyILbobMGEzI8McwxJDCec9LCm0pKMv3vtLq0hjw2JdE1JfzPRd X-Gm-Gg: ASbGncsuMnPDKKMGxzseLQzfoFVDYRKrS+qZjAPEfdO42Mb0reKj+orrvehm0+F/+CT CPIcS+siQ781hZEWztVBb6Lflq6CaWkHs48GfyMQKO4eqnhCCNr7Hzw/q7V/+bOOPE4fCJNKCWS jRJZEqcDKvqNgVYheJ3lKB7nyZ1LZ1YcIJHL2th52xlal42lho8bdKZ0fLw9wTKXVmJ/0OawlBQ +42Fd6TUQp9ZDXCviX80Ua/fGMZNIy38aEnpZoqkRzaa2ILstegsAjdiM8= X-Google-Smtp-Source: AGHT+IGhyfm67iqMr2DgS7OR5+qCYoBMZuU2f4+7la38+rQp8Jepy+V33WnABI+y4R5RoecbjJjnxA== X-Received: by 2002:a05:6000:471c:b0:385:fac7:89b9 with SMTP id ffacd0b85a97d-3862b3e4483mr7723323f8f.59.1733690847415; Sun, 08 Dec 2024 12:47:27 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:26 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Christoph Lameter , Dennis Zhou , Tejun Heo , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Kent Overstreet , Arnd Bergmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Will Deacon , Waiman Long , Boqun Feng , Linus Torvalds , Brian Gerst Subject: [PATCH v3 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Date: Sun, 8 Dec 2024 21:45:18 +0100 Message-ID: <20241208204708.3742696-4-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use TYPEOF_UNQUAL() to declare variables as a corresponding type without named address space qualifier to avoid "‘__seg_gs’ specified for auto variable ‘var’" errors. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Acked-by: Christoph Lameter Cc: Dennis Zhou Cc: Tejun Heo Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Kent Overstreet Cc: Arnd Bergmann Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Peter Zijlstra Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: Linus Torvalds Cc: Brian Gerst --- arch/x86/include/asm/percpu.h | 10 +++++----- fs/bcachefs/util.h | 2 +- include/asm-generic/percpu.h | 26 +++++++++++++------------- include/linux/part_stat.h | 2 +- include/linux/percpu-defs.h | 4 ++-- include/net/snmp.h | 5 ++--- kernel/locking/percpu-rwsem.c | 2 +- net/mpls/internal.h | 4 ++-- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index e525cd85f999..666e4137b09f 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -180,7 +180,7 @@ do { \ __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val); \ \ if (0) { \ - typeof(_var) pto_tmp__; \ + TYPEOF_UNQUAL(_var) pto_tmp__; \ pto_tmp__ = (_val); \ (void)pto_tmp__; \ } \ @@ -219,7 +219,7 @@ do { \ __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val); \ \ if (0) { \ - typeof(_var) pto_tmp__; \ + TYPEOF_UNQUAL(_var) pto_tmp__; \ pto_tmp__ = (_val); \ (void)pto_tmp__; \ } \ @@ -240,7 +240,7 @@ do { \ (val) == (typeof(val))-1)) ? (int)(val) : 0; \ \ if (0) { \ - typeof(var) pao_tmp__; \ + TYPEOF_UNQUAL(var) pao_tmp__; \ pao_tmp__ = (val); \ (void)pao_tmp__; \ } \ @@ -273,7 +273,7 @@ do { \ */ #define raw_percpu_xchg_op(_var, _nval) \ ({ \ - typeof(_var) pxo_old__ = raw_cpu_read(_var); \ + TYPEOF_UNQUAL(_var) pxo_old__ = raw_cpu_read(_var); \ \ raw_cpu_write(_var, _nval); \ \ @@ -287,7 +287,7 @@ do { \ */ #define this_percpu_xchg_op(_var, _nval) \ ({ \ - typeof(_var) pxo_old__ = this_cpu_read(_var); \ + TYPEOF_UNQUAL(_var) pxo_old__ = this_cpu_read(_var); \ \ do { } while (!this_cpu_try_cmpxchg(_var, &pxo_old__, _nval)); \ \ diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index fb02c1c36004..415a5803b8f4 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -586,7 +586,7 @@ do { \ #define per_cpu_sum(_p) \ ({ \ - typeof(*_p) _ret = 0; \ + TYPEOF_UNQUAL(*_p) _ret = 0; \ \ int cpu; \ for_each_possible_cpu(cpu) \ diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 94cbd50cc870..50597b975a49 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -74,7 +74,7 @@ do { \ #define raw_cpu_generic_add_return(pcp, val) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ \ *__p += val; \ *__p; \ @@ -82,8 +82,8 @@ do { \ #define raw_cpu_generic_xchg(pcp, nval) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) __ret; \ __ret = *__p; \ *__p = nval; \ __ret; \ @@ -91,7 +91,7 @@ do { \ #define __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, _cmpxchg) \ ({ \ - typeof(pcp) __val, __old = *(ovalp); \ + TYPEOF_UNQUAL(pcp) __val, __old = *(ovalp); \ __val = _cmpxchg(pcp, __old, nval); \ if (__val != __old) \ *(ovalp) = __val; \ @@ -100,8 +100,8 @@ do { \ #define raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __val = *__p, ___old = *(ovalp); \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) __val = *__p, ___old = *(ovalp); \ bool __ret; \ if (__val == ___old) { \ *__p = nval; \ @@ -115,14 +115,14 @@ do { \ #define raw_cpu_generic_cmpxchg(pcp, oval, nval) \ ({ \ - typeof(pcp) __old = (oval); \ + TYPEOF_UNQUAL(pcp) __old = (oval); \ raw_cpu_generic_try_cmpxchg(pcp, &__old, nval); \ __old; \ }) #define __this_cpu_generic_read_nopreempt(pcp) \ ({ \ - typeof(pcp) ___ret; \ + TYPEOF_UNQUAL(pcp) ___ret; \ preempt_disable_notrace(); \ ___ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \ preempt_enable_notrace(); \ @@ -131,7 +131,7 @@ do { \ #define __this_cpu_generic_read_noirq(pcp) \ ({ \ - typeof(pcp) ___ret; \ + TYPEOF_UNQUAL(pcp) ___ret; \ unsigned long ___flags; \ raw_local_irq_save(___flags); \ ___ret = raw_cpu_generic_read(pcp); \ @@ -141,7 +141,7 @@ do { \ #define this_cpu_generic_read(pcp) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ if (__native_word(pcp)) \ __ret = __this_cpu_generic_read_nopreempt(pcp); \ else \ @@ -160,7 +160,7 @@ do { \ #define this_cpu_generic_add_return(pcp, val) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_add_return(pcp, val); \ @@ -170,7 +170,7 @@ do { \ #define this_cpu_generic_xchg(pcp, nval) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_xchg(pcp, nval); \ @@ -190,7 +190,7 @@ do { \ #define this_cpu_generic_cmpxchg(pcp, oval, nval) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \ diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h index ac8c44dd8237..c5e9cac0575e 100644 --- a/include/linux/part_stat.h +++ b/include/linux/part_stat.h @@ -33,7 +33,7 @@ struct disk_stats { #define part_stat_read(part, field) \ ({ \ - typeof((part)->bd_stats->field) res = 0; \ + TYPEOF_UNQUAL((part)->bd_stats->field) res = 0; \ unsigned int _cpu; \ for_each_possible_cpu(_cpu) \ res += per_cpu_ptr((part)->bd_stats, _cpu)->field; \ diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 35842d1e3879..266297b21a5d 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -320,7 +320,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { } #define __pcpu_size_call_return(stem, variable) \ ({ \ - typeof(variable) pscr_ret__; \ + TYPEOF_UNQUAL(variable) pscr_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr_ret__ = stem##1(variable); break; \ @@ -335,7 +335,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { } #define __pcpu_size_call_return2(stem, variable, ...) \ ({ \ - typeof(variable) pscr2_ret__; \ + TYPEOF_UNQUAL(variable) pscr2_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr2_ret__ = stem##1(variable, __VA_ARGS__); break; \ diff --git a/include/net/snmp.h b/include/net/snmp.h index 468a67836e2f..4cb4326dfebe 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -159,7 +159,7 @@ struct linux_tls_mib { #define __SNMP_ADD_STATS64(mib, field, addend) \ do { \ - __typeof__(*mib) *ptr = raw_cpu_ptr(mib); \ + TYPEOF_UNQUAL(*mib) *ptr = raw_cpu_ptr(mib); \ u64_stats_update_begin(&ptr->syncp); \ ptr->mibs[field] += addend; \ u64_stats_update_end(&ptr->syncp); \ @@ -176,8 +176,7 @@ struct linux_tls_mib { #define SNMP_INC_STATS64(mib, field) SNMP_ADD_STATS64(mib, field, 1) #define __SNMP_UPD_PO_STATS64(mib, basefield, addend) \ do { \ - __typeof__(*mib) *ptr; \ - ptr = raw_cpu_ptr((mib)); \ + TYPEOF_UNQUAL(*mib) *ptr = raw_cpu_ptr(mib); \ u64_stats_update_begin(&ptr->syncp); \ ptr->mibs[basefield##PKTS]++; \ ptr->mibs[basefield##OCTETS] += addend; \ diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index 6083883c4fe0..d6964fc29f51 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -184,7 +184,7 @@ EXPORT_SYMBOL_GPL(__percpu_down_read); #define per_cpu_sum(var) \ ({ \ - typeof(var) __sum = 0; \ + TYPEOF_UNQUAL(var) __sum = 0; \ int cpu; \ compiletime_assert_atomic_type(__sum); \ for_each_possible_cpu(cpu) \ diff --git a/net/mpls/internal.h b/net/mpls/internal.h index b9f492ddf93b..83c629529b57 100644 --- a/net/mpls/internal.h +++ b/net/mpls/internal.h @@ -33,7 +33,7 @@ struct mpls_dev { #define MPLS_INC_STATS_LEN(mdev, len, pkts_field, bytes_field) \ do { \ - __typeof__(*(mdev)->stats) *ptr = \ + TYPEOF_UNQUAL(*(mdev)->stats) *ptr = \ raw_cpu_ptr((mdev)->stats); \ local_bh_disable(); \ u64_stats_update_begin(&ptr->syncp); \ @@ -45,7 +45,7 @@ struct mpls_dev { #define MPLS_INC_STATS(mdev, field) \ do { \ - __typeof__(*(mdev)->stats) *ptr = \ + TYPEOF_UNQUAL(*(mdev)->stats) *ptr = \ raw_cpu_ptr((mdev)->stats); \ local_bh_disable(); \ u64_stats_update_begin(&ptr->syncp); \ From patchwork Sun Dec 8 20:45:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898672 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8DAB198E92; Sun, 8 Dec 2024 20:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690852; cv=none; b=MY7uCNrRH3nyr7SX7B13SHXwOpY1P5/4ZyrH1kCavbUACQXnhWcQx3SDKV5RSP6EuNu0+RlO1eAv5U9WAQKgzyFxQG/rSm1scUqA/oaIOpvBpY5BJ0hzAzUZ/97p+OVDigjPokc4TLsndZgFi7hXwtvLcns6W5BrnfhIWuv8t9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690852; c=relaxed/simple; bh=Ze7dVGfYMmVKuhY42eH7V+YVP/tYMVSM7o7rJH/EuB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LSawShsul74ShzpQoY6kDcmx9xv7kRtKValgMCxD2oUsGcx+FZ/cvMV7iLR8H78m9+VaUQakdCdE2T02AXB36daWznpFdUIsTi6/H+fL3ORCdBcIMFNOYO2C/1yCVJXQZv63VsinropND0prgtho2cHR+Ik727PkMrRNGRHA5/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IfXmwqqI; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IfXmwqqI" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-385f07cd1a4so2595670f8f.1; Sun, 08 Dec 2024 12:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690849; x=1734295649; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sl02e1tbeNqkkscoGaVtIPs3YTZ0CcynxSRpc+0Q2zA=; b=IfXmwqqIv47Iu1UT254IrAXLcmIL2rHZS36dngWOibr/DoOTUIZFITXft/LwheJcln Q9U686BuYbAlG3DaaMPNF0yEmF3hnXqac0cMdr3Rqdqojk8ih5WUeE6YJrPPgPADfpBV OzkemphpzYml8TJtTOCTuVclQd05WxX9pG8gJZc+B6W2FdY4X80eHGRBNT/V+6XUk7Ew T5vH84ubTkFLcb5ToSLAEkyOp4osebrWGSKPXxOGOgYnBaQ049pI2+HsNHNe9VUUNon7 UODxbbeNoHRpnM1cLBMebhlyjvud53L5TkN0XqqjS35NLvkEF/rq8gefZbbtWLi6MQ+y HKIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690849; x=1734295649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sl02e1tbeNqkkscoGaVtIPs3YTZ0CcynxSRpc+0Q2zA=; b=tkULpjEHYwGb2k0LZOGU7GANDHbWMeRb71qmkSOX6sK9WdF+3MeUcw0GnhqibF6KjF xzNlQgfoMIcM2pRCao0e4mtAVFCa3sRSysfedd2QF48z826VH+92i2iN+qCPiYvZb/Az AckHtCV9auJdbxQ21vqh1SHh/CYozhfdVPTgrVubC0LKGzv3kidv7+govPQX7GuC3E28 SipnKWX/y34+wRN0zQnX3W7h3rnVNLSTh92vWuPO66nlV8Er7wg4Td/kHKs0C0pBBNPg UYCjwZKyieTbzTX70csKpSB/t+1lVnPiRhtr0TZ5BHfoZiF38QPw+SyugUkzvp4w837t +NbQ== X-Forwarded-Encrypted: i=1; AJvYcCV+MBN3nIvoXh/LI+zwZnSSjF+MffCw5qiQs3zRq88ORPL38aQ3LOpoccq8CPMqPJBHjFSOcFKteGZz@vger.kernel.org, AJvYcCW/FqjU3jPUsiZ0BlMXosp6psRilO19m5hz6KJ74EjjACl3gOW+t+6a09zupWAbVnoNbkmKHLo/@vger.kernel.org, AJvYcCWU86HdLtaqIPtPkJQOw04j9AIMPc2gTkxwY0jeFZ8B/vnWSFShBGlbqjiSNREw0AT0ChckW/DEItaMu/iueEg=@vger.kernel.org, AJvYcCXZzyNqi8q+giDZL4ppEnZMf6pKoU7PVMT7tHD9xEUcWKsEaoHadiLcSQk/kWhl2R95kupfra7+/ZX+jU3K@vger.kernel.org X-Gm-Message-State: AOJu0YyQILox+cwuHyQe5DP24XaLFr48vmIcc2zmLexKuWB6Y/HYejkJ E0oN1ETCVlaffiMQGv7zV8sWbvGhfhESdVv1zpZtrf1AjQtvbIkC X-Gm-Gg: ASbGncuEcWtYkZ43ki42OB4/HxCYBRcN9soramQdBVcfHXMSvtqNIV8ESnKGYM3WPwI J+I4VDkZr+CPJMegBf4V1hHcMCzw+BlYs4gvhtgJ/BnPDQpu9sH55Bu0gSWEtzwzBdRBzdJSGBV VYumTECQwiaGBW3x/ikJ8I6HCo4m1pLgU/90cIXdTzOvpOEJY+s8BoMYnG1KcW31VSRsnlaYv6R UEZ+P3rnpe6i+uQnpkBPuGgxlLnmTBAtWowBUTsQF1pFhcApwp+tbAqSsM= X-Google-Smtp-Source: AGHT+IEhGoPt0DRcYf/EuijpX+E47Uzih3ytt4xJbhowf411wPQtgH//qgvD2xRwzWN0Epd0De+3cA== X-Received: by 2002:a05:6000:a14:b0:385:f0c9:4b66 with SMTP id ffacd0b85a97d-3862b39b9b4mr8976505f8f.33.1733690848668; Sun, 08 Dec 2024 12:47:28 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:28 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Christoph Lameter , Dennis Zhou , Tejun Heo , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v3 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Date: Sun, 8 Dec 2024 21:45:19 +0100 Message-ID: <20241208204708.3742696-5-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use TYPEOF_UNQUAL() macro to declare the return type of *_cpu_ptr() accessors in the generic named address space to avoid access to data from pointer to non-enclosed address space type of errors. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Acked-by: Christoph Lameter Cc: Dennis Zhou Cc: Tejun Heo Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Brian Gerst Cc: Peter Zijlstra --- arch/x86/include/asm/percpu.h | 8 ++++++-- include/linux/percpu-defs.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 666e4137b09f..27f668660abe 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -73,10 +73,14 @@ unsigned long tcp_ptr__ = raw_cpu_read_long(this_cpu_off); \ \ tcp_ptr__ += (__force unsigned long)(_ptr); \ - (typeof(*(_ptr)) __kernel __force *)tcp_ptr__; \ + (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)tcp_ptr__; \ }) #else -#define arch_raw_cpu_ptr(_ptr) ({ BUILD_BUG(); (typeof(_ptr))0; }) +#define arch_raw_cpu_ptr(_ptr) \ +({ \ + BUILD_BUG(); \ + (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)0; \ +}) #endif #define PER_CPU_VAR(var) %__percpu_seg:(var)__percpu_rel diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 266297b21a5d..2921ea97d242 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -223,7 +223,7 @@ do { \ #define PERCPU_PTR(__p) \ ({ \ unsigned long __pcpu_ptr = (__force unsigned long)(__p); \ - (typeof(*(__p)) __force __kernel *)(__pcpu_ptr); \ + (TYPEOF_UNQUAL(*(__p)) __force __kernel *)(__pcpu_ptr); \ }) #ifdef CONFIG_SMP From patchwork Sun Dec 8 20:45:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898673 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 402441991C8; Sun, 8 Dec 2024 20:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690854; cv=none; b=CLVVSgVu0BZEiBH8nPanL2Gx2SzK+npWhWmb71RUTk0yhHhGsl2S/a1sytkl21f7JtCWWxTIlfEGDnt8KuM91gmmKoeaZKBLXf1VHl9t46PHQV64UVH8NLBayLHHVTJMJmwp8JORfpSvsnNLK/Uutklre2PJirP40QkB96+a+BU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690854; c=relaxed/simple; bh=VD2esfG+2A7H5xnu8x5ip6Z+n1iO/sQ6fWXzAj+5R9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=on1nIAgn3uJbm2ClLoqrAhm8rQuvXE4v7kgRbXSdJDVG/m55ZbfYn4ObVuPkPVhJzRYF28+lIToYiK1+2TzdY2kg0C7MVidZfQOiEwL0+c1Db4vHarf1Bp347ZmU7p5kY9EkXVmGVqNgwvJ+K2B92LIWCCdpPq2LObS15IQwc6s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JHiTaU3P; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JHiTaU3P" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3862d161947so1666871f8f.3; Sun, 08 Dec 2024 12:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690850; x=1734295650; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=JHiTaU3PxOmgrxeiAfhPeZ1i9kuouRuuqKjcwuUSuA4YVoM8Yfte02Ecrf3rlXXYmC Dq1oKofUJTKBcbJHIwgmfxozKFNJRgI+E+SLo7VKaGcSG6iJjME+w7amNCqUA15jBa+0 shM3X7jeOTJGeUaoobxYNqAzIIQskUUkJSTsSmUWyvJz0ldBeh7s7PSgAnXyP9MyBtOE rx5queEX+mif8lMEn06QQBc6hRxhEiwXF+1YBt04l34dDUKZLPysluxsWKpB5WnK5fJx whwM6tJMrDbZgShu9z0La7PsDa7iR6xOaJrejzBUNn/l1Un7e/WZ1zFPYteSaxCjL7qo rm5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690850; x=1734295650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=kt/xCRX2FoLKb38qcmc26ouGaZ9V+nM1VU/+ZRb81jkI1moNAXm1HwGjUoRosm1UJC I2+QwqFXWFtDo0HYvjGpuiK4JY7Ac6A/UQLCa5/JGEDUSas/ULtecAxzuzfhcRJFxcz0 u95evwMlfxzs5HfP8yiJ+HtSSX2cpObfDtli5oKhMekDc63p/GL5rDiaheAY9JvQFvj5 9mn8MU2+CDBePj311MMYjgBCFBBlwm5pDeAb0ZbBEKVYBMJZ4kZwQqC+1BEARcbVGB/7 0j87lTQetH1eylGmhqmI05e8755hVJfY8cpd2bm/0rwG8DiKnUQVFih99GhS4Tptgbh4 9Z+g== X-Forwarded-Encrypted: i=1; AJvYcCURJjf5OOAd9JWPmihROLdlbeDsAwcpqLmfO2ljPktT62uTetEBRuXase2OnkPlNMHJY3L/VhsWliolBVGb@vger.kernel.org, AJvYcCUThUvYwGybQTkmqxH4782JQwYLLyG9V8EJQvSBAwj+QFOIXKznP7W3CnuxpcwhJf21Cqd6KJku@vger.kernel.org, AJvYcCVGXsZUvPn2+GsgxctHafiDrD/o+OJ8xQypO1xjo1tNe/jNoeQR2SDheYXL9kIpfHMyeNohCNxm0KSXBCcxIWg=@vger.kernel.org, AJvYcCVPbqwg5mkyzVUQ48ziddpoKLiNfxpNrX5HHaft84pzzlOjd3hY52Qn2gihsob1y9VBRdNNpOIHTRlo@vger.kernel.org X-Gm-Message-State: AOJu0YzXqJFGbztDlgq0PvvvFHYhyXlu83JBkWQeCWO4j/Sd5pZNsRkv 4hf2iH2vflJyYvZ0PqhXfUH6fnqhjQ7tYI3vZiDPNCcNi8nholvX X-Gm-Gg: ASbGnctTVza//jYbr8V7Nkt75K28A/Nm303w40Ql67ApgvRNip67qq/Ka5FBQ8++Lc5 yG1SYLrmsJFSewlflYhOBVxk9oDQTKN1kSe70QxmK50WQF/rhyrQc/ZxcWAPOSVNey8LhK7enkZ acHyh0N274GaEicPWpJQQRy5CiNv2MAgrn5MKfHc08RPn4DqK5+ghH2g/7bmtIyE16UugnyX15L cZMuL+Dgzo5oAUyhUx+p8L6Q73zAvtHF62oe9/HlH7Oozk5Ai3ebIEipH8= X-Google-Smtp-Source: AGHT+IEgK+5BlWjK5hYmyAc92iK0vY/52y9egBCaI4T3OGpocF9n9vCZzb2/329/9E4vHrdt2CJvTg== X-Received: by 2002:a5d:5f8f:0:b0:385:f092:e16 with SMTP id ffacd0b85a97d-3862b3e3ae1mr6811496f8f.55.1733690850465; Sun, 08 Dec 2024 12:47:30 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:29 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Arnd Bergmann , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Brian Gerst , "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH v3 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Date: Sun, 8 Dec 2024 21:45:20 +0100 Message-ID: <20241208204708.3742696-6-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The patch introduces __percpu_qual define and repurposes __percpu tag as a named address space qualifier using the new define. Arches can now conditionally define __percpu_qual as their named address space qualifier for percpu variables. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Cc: Arnd Bergmann Cc: Thomas Gleixner Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Brian Gerst Cc: "H. Peter Anvin" Cc: Peter Zijlstra --- v3: - Rename __per_cpu_qual to __percpu_qual. --- include/asm-generic/percpu.h | 13 +++++++++++++ include/linux/compiler_types.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 50597b975a49..02aeca21479a 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -6,6 +6,19 @@ #include #include +/* + * __percpu_qual is the qualifier for the percpu named address space. + * + * Most arches use generic named address space for percpu variables but + * some arches define percpu variables in different named address space + * (on the x86 arch, percpu variable may be declared as being relative + * to the %fs or %gs segments using __seg_fs or __seg_gs named address + * space qualifier). + */ +#ifndef __percpu_qual +# define __percpu_qual +#endif + #ifdef CONFIG_SMP /* diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 981cc3d7e3aa..5d6544545658 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -57,7 +57,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } # define __user BTF_TYPE_TAG(user) # endif # define __iomem -# define __percpu BTF_TYPE_TAG(percpu) +# define __percpu __percpu_qual BTF_TYPE_TAG(percpu) # define __rcu BTF_TYPE_TAG(rcu) # define __chk_user_ptr(x) (void)0 From patchwork Sun Dec 8 20:45:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898674 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3BE6199EB2; Sun, 8 Dec 2024 20:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690855; cv=none; b=jkxrJR4fIxDctnoeBqi/1O3paU4cvQeH7oAmQ/SkO78b5hvCYbIOJgDtKYZ3n8ShUJKbc0AU/+/CV/BTijud/pZeCG06v3+H7zJbISIJQ9kVW+R8b9api57erQzkW/SbnVccXsV+wVVRbineeE0M6yFiiQlg0EFCV/V3MIXZGMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733690855; c=relaxed/simple; bh=3gHJZMqBlwbfBRUKCL4jcDgTquYDbPdPUUNGrhzl3OA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lH5phiW+HDEBzh00AAI60cTpg5k4+5uSPDbd8nsiuDqFA4kD24gSJrV2/4B1uo4531F3/clCfLHrrzP8aGLyfaqub68bBr3CkukPxvE11hlMzCOGcgUNkEgb8nJKfrBDD+nF89b5E2f2DafglkIvkVLU4vciuaihAa6FKvI0oo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GwikKHmO; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GwikKHmO" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-385dece873cso1671382f8f.0; Sun, 08 Dec 2024 12:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690852; x=1734295652; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6KOZI0Av9UpRI0wc6f07qNDNYBakRBN27GYpajM6B9g=; b=GwikKHmOulEwk37WW465skIoxx860CxZC4BQe0DbLf/EelgtW+Qqi2Athjn4TvZHMb hoN96a4Jlow0/iwTdcqHsMEvclZn4LdeEP53dd6T2lOyAq9HWFGcbRBenVkNde0qU1LN a3Z3iW9Izud6cd9Cjca29Ak+oNItS6EsM/QyRFtFJ1qfk4W6b8/Ehj4PefaU/EMOpw1e uwaEOz1WtrwK2KcAWZT/0zG/2VOgP3rQtaWyx4aH8mC1fYwdSH3Dgq3IOMyMt4k//F76 RUq8/oScF2HgRSd+LWbeh1TZzHfH9Kj0MlU1gP2iqBEoLJFpoX3GpTetdqLseXpyCOMI ebdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690852; x=1734295652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6KOZI0Av9UpRI0wc6f07qNDNYBakRBN27GYpajM6B9g=; b=evcxO5NN6IRHfvnB6UTEmBgOY1gKbo8CsXH7dO7nR7+xGKdOns8xT18cF89LJ1dF5W 35q40vZeJAnKNQa77kXPMjU1sST3I/OnHBZh1AcYgn5ZFC9izY3HdyXpi+OAeox/HjAE p8ynDChTTk7wyp9KjBZy0oZ/3NqDDvmUhxORTCiSUyw/PxbvbubddPAoqFm7wY3FW6Tu wBLZ5qVEt5Uh891eLmVofHY2Y8FEhmXlc49QjsTXh7RL4XnLsng08/9cLWIyAiIRNQ9X L//Gv6wh4vXaDjwI3OLkroVhfKsrPJO5jrJplbAFwegtMFdFDgPJ/zREF2VN8sffNkxz SYgg== X-Forwarded-Encrypted: i=1; AJvYcCU8GZPpNjeIUhJ1Bdi0W71WhGkbo/dJCZeunOu3gt338vhjzq/EFIoqjajy+o6kq0DGbfwC/XMdKKbEBWmXSdI=@vger.kernel.org, AJvYcCWbpgytGrKYEb7jLjALmWJZgTi6q7pxe5ra/hF5+6ub17yVy5S7fJ/dJ1Q9cGYHZc6VZUufihFVeaQm2MF9@vger.kernel.org, AJvYcCX0O9q/Isjy5HcNQdcI1IpuKtpwqXfuIv9o/TyhAQlkPHBX5ulV7QIQoR7ILEKGbvyZAADqfqtWdcBK@vger.kernel.org, AJvYcCX4HnRUrtQUaUTvKQsZtz9z44CszGEv5uUyxIZY4v72Jw32aeYQSkYyE3SeAZMxyGFhDKhUmhyp@vger.kernel.org X-Gm-Message-State: AOJu0YyghOp77/UGWukhHDLNoOqW3AfaYL9V8yV2mwM26nw8++YclHSd kVEdFepxJRjY4qrHm3LdyO0mWK2ujhJaAsWMmmuzhysmoKQe3oEB X-Gm-Gg: ASbGncvVInZR+agE+EayyHuesNWZCV2JHHzJL/oNgyFK3C66kYa3SpVOkfc4yRB0K5i 0p5A7qmvgoYzCxaej08ljf8NxH104BVyGg1+0k4sNg1AiKCle5H7bzj1DC94VwF2d7J6D84zGgC RSOa40p56dEzlK3WtJ73E+CORYSZn8SaXtHL6OPMVjILfYIz3XPsOEyAa3wPWI6uP7ydZmnBXup BMF3dRNHibF7efj2tLB445rynDoIvWjIF7cxFYWIzk1gIdOZXrWgM8Lmfc= X-Google-Smtp-Source: AGHT+IFoKEXuuJkWVyc6E+OV4Yi3aleXB7y+UqdQJgSPCnb15ZOKQ6PeUxcw/WuP8movSkRgO7EseQ== X-Received: by 2002:a5d:64ab:0:b0:385:f271:a22c with SMTP id ffacd0b85a97d-3862b3f289emr7788206f8f.59.1733690852077; Sun, 08 Dec 2024 12:47:32 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:31 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Dennis Zhou , Tejun Heo , Christoph Lameter , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v3 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Date: Sun, 8 Dec 2024 21:45:21 +0100 Message-ID: <20241208204708.3742696-7-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch declares percpu variables in __seg_gs/__seg_fs named AS and keeps them named AS qualified until they are dereferenced with percpu accessor. This approach enables various compiler check for cross-namespace variable assignments. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Brian Gerst Cc: Peter Zijlstra --- v2: - Add comment to remove test for __CHECKER__ once sparse learns about __typeof_unqual__. --- arch/x86/include/asm/percpu.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 27f668660abe..1ef08289e667 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -95,9 +95,23 @@ #endif /* CONFIG_SMP */ -#define __my_cpu_type(var) typeof(var) __percpu_seg_override -#define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) -#define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +/* + * XXX: Remove test for __CHECKER__ once + * sparse learns about __typeof_unqual__. + */ +#if defined(CONFIG_USE_X86_SEG_SUPPORT) && \ + defined(CONFIG_CC_HAS_TYPEOF_UNQUAL) && !defined(__CHECKER__) +# define __my_cpu_type(var) typeof(var) +# define __my_cpu_ptr(ptr) (ptr) +# define __my_cpu_var(var) (var) + +# define __percpu_qual __percpu_seg_override +#else +# define __my_cpu_type(var) typeof(var) __percpu_seg_override +# define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) +# define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +#endif + #define __percpu_arg(x) __percpu_prefix "%" #x #define __force_percpu_arg(x) __force_percpu_prefix "%" #x