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: 13898664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9F1CE7717F for ; Sun, 8 Dec 2024 20:47:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 168FF6B038F; Sun, 8 Dec 2024 15:47:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11B276B0391; Sun, 8 Dec 2024 15:47:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED5AB8D0015; Sun, 8 Dec 2024 15:47:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CDF636B038F for ; Sun, 8 Dec 2024 15:47:32 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 43A574050F for ; Sun, 8 Dec 2024 20:47:32 +0000 (UTC) X-FDA: 82872976662.01.08CC6C9 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by imf08.hostedemail.com (Postfix) with ESMTP id 2D650160004 for ; Sun, 8 Dec 2024 20:47:16 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=L6Nnop2v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.52 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733690831; a=rsa-sha256; cv=none; b=DTO0BSWXbK1wUogApdL3zsXM2LBjP4PM1MdKGs+SH/Xqad7y428fsJn53TpbhWk3d/hDya 25VBk4Ll65zrL+9y6pLXIUzofkUfFJEr0uRGyJZ2N0czxnPVNE5cndf+87mNhGSN4ViivR onoWsFlpaQuhEXujhjkhlw32VdE/0kY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=L6Nnop2v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.52 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733690831; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sl02e1tbeNqkkscoGaVtIPs3YTZ0CcynxSRpc+0Q2zA=; b=HyJDAeuEsTpA4fSiVG2bBF/FavSreQbNoSvJ4NRSA8igEkjbVQUbQXabEeb+lrD9Bmp/Mu 500+ODVxpvXRA1iImQ2fE4YYvCLNk7OHAEYZ2XhteEGcPDqBKrqgeO/adZATcOImfxJ64/ nOVkJnahNl/Dk22XdIKaJU853w/JEF0= Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-434f09d18e2so11223315e9.0 for ; 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=kvack.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=L6Nnop2v5PuWR6M3q5qAR2Jwl9fR0DM1rZnY4SAv0VZhiXeQH0z4jq4IwODtiZFHdX TZ6YcfCRr30F6Ok+K49WgI7HDOxLhCMFrXsBp58vFYiHEQeQXW3UIc4LT5LIgnQomAb3 I6trnoxYmDf06EhcQ2jJZ9zL4Lj3q3UEkKcaS2A1ae8jetF13rMTJ5PsyP6UWG07o89f 5EaaBKGPSr/Ll+ZMxGh2iDv8kRbwh0FZEtjYzLnOLCY/P997F6tQjDPJeBNZjToBRwCB tYmAvmvn3GKXd4A457o6LM3n018AyYA76dqdwCiTE5P/P+oEbK7Y521pe9kzS7YgddQR EyUw== 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=v6Xd5aynoJsEcd3qqg0dKEI6i1tPRQFXp47gHOge7mPet/y+rAj9UGo9gSljgKONOk S0XByt310gklY43S7U3kKI0/AeJqKIBWhi3oub/XqbU3JFsf93nleuZm/eK1Sbsp4CFr z5K6M7lrXJlcSX2evG6mlfIwAxEySPM3y7v43EHsNmJfn4HzZ4re/7v+EH/UGYb+KCF7 Dvi0pAQXDHcDvLFtjVDiYfhZdqrDX9NxSAdnGidECF8UaCJE6m9tC3STWQ6yJsFJ9CAq Imdo7Fg6HK3fDPJKk4smdTG3KQJxDAJpO4S2n7JcWoYBqBRKb7XgsmuOS87vHGct6XCd BafA== X-Forwarded-Encrypted: i=1; AJvYcCXtGb9xNicswfBZr9p3jo05dFmBxVAisOmFf6BXHmFep5mYHidLZy7cQemnD/Aj3OogZ2dzQrIgEA==@kvack.org X-Gm-Message-State: AOJu0YxrF+zBRYPUgfKN0h7eCjNs3QoJi5zoKEigDWLmYrtYjcsFxw+Q 6FiWBaSjBAN41yynfCdb7JKbunVDn5Cs1B2Ntlq9tZnkNpCSOEbf X-Gm-Gg: ASbGncvrQewfjEffG00htDyIzAfZbbdZ5Cf65IHev4hV4PeY3sqWmy4weTYnv/KLEDt vnRKm4niO6f3CHByf9ZPFNFBjuEaTQL9z/EjZQWCwdP3Hqk5gXxB1dyrykHaCacO4h9MVeVdN+z 6Mbxw0yTJ47n5rbKp2Wx65Q8h5S7ndKmc7kgdDLKN4Gojg9D67VYOkZKnU1MwJ+g+ygUDBHz7jl sAZreKDfJ75abGHFK5Kww2jX/342awzu0bfJoe5bBzLASW99QEqGd/y8dM= 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> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2D650160004 X-Stat-Signature: 4ucy1q33r47qy4zisnx51d6s7ca5szca X-Rspam-User: X-HE-Tag: 1733690836-412754 X-HE-Meta: U2FsdGVkX1/ofvHE2dcs4XL7SDqln+HfLvMo/2qg8SrCobfM4QCXK9F5mzCNqf8CQ8bhAH1JuUcGLsxLyq/C47QLKEIYCpSVtlMdQN/r9AYhOuXXXpKNTyPVq4lb5PID4AZfKi6QZShYUO39yuSLDe+zoJU9CdqQ/C7aKw6Hm208hef+jMe9IQEeL3LJ38PMo7bwndTCPif8AU8aL8ZOdhU50H4HJii70vRPEuMCTUXeSX1P63H+JH7BwqIuiwOD/PCgTRhznuyCTJMwq2GfIdTTfUm3nZmGlM35a8ZkqGx4xfiWd+BgB09LA6VwSqoeHgtyJ6T8t3395lI1ctuGKUwq1SMhp6XOVMZY3n27TpoEc/0KnHiYMBWjs+aXq8wkvq9IY/SicGhBokNsgVHIUcuknRUt85G6UsTyldXJndzNKY9x7RcLDNZr/L/84PSeMOw6eSbffu87UUzACXVa7o3jT26P0tF5ISie9Clfxp2KE7O70uE1ZMV1BYiwstabPFSI/jI151GdIoy9ALHYVKCobKBMVSUK6gd9OyUmPONrqcF3RvPs05iVHe1KoOChu8glc4Lg9J/SZgMA++YlKF/kDEnB/TE2D7fk9e5nKGOYUi+pQ1MJmhEqweKonHLY7pj4QpQ7KGqYf7Wu7TfTyzBlTicIzch+DoL2rVyugPPiw8w73GkxSL/IKR6yQwz3lwADrgB5U2MWNFydCqWnx+ubq5BXlh0QxAr8nSFL1BfnQidtMOe50no30LcOHVg0uBds6se1mFTjo1XqEdWyd8teQc/0II/cHrCQNxXI+1ASqvMjhZw1DyRyE7Eb6wnA+HxDOd4vibBDdt1mTnsf3wRFrWb/VWd+ZOGTV6GPN36dpQFJwZAkTKKX8JXKUslIHKRQ0RwGfOEB2LsbRdM9Zq/mA8mOgW7Clh0tuEV+WHfEKgtMzrPRg9wj6z0SAMS0IlEvzgp19+1qoZRzp6E j5eh0HPn eBSLLnGnjQmeqMCrWPljcMeivGlcGj01+xOVuxyZ2QWcK/a7b2X0M/6BRnRTalFozW3wdtjkm5dCl9p/Ec20XXi5gfzAMyOlS/Airj9Jnq7SYmNPwk++77qKNfUQoanR6CxnK1yIsvtucEjvpi9pbwLY99y10/ljf7OYZxTNlJ2lMOaIo2Y5AmjmbyLvPYqh9KbPwtA5XLTcKeCibrq0WS7fYKFSOrfmVgAifk240w9Qh5+LunsnW27/ya0FkcbifLChFlGK1Ix+6tOcGzpoJU7dydPGBNpfZhp23+J4oVZMGbAsJD86B52LGeB+ROMqt09cjWP6tb3X77kVtY69q0nAEkUj5THRgOTmwSPwJ+oKBnZyBp4b64WPPZmHg2HyDU9+xck7QH2xUejyZ+HZjW9BX2cbIBLURR4HtYkJz1qxi1ojhvbpu5UQJeC1L8RFp0M0lB4GNKx6oFOtKoyV2Agm72+/m55kvcbLUDNz/Rd16rfLbkQPixGnF4ehDTCmIMCMhqTh1ziy5VU3lRQoImrHtqWt3iJUqKAvmKjx5MP+5wyw4UQr7uAGl33Lh1SoHuLQEu62f0b4sYLfKleE7Qh1cLEPPLnE2JrrdVdkEVPquPbycNiUAxC5CLsFDH1NskR5ts72b503w5fCY8hXfjSUv79WTD2GwcnrcZIa1CtFO1aImyBSWSUAiG7kYu1qgCVYOsADjhAoEvZCCcW1vIkeDJCb67+cSfaFsQoo3PBeNREA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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