From patchwork Thu Dec 5 15:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13895609 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 D4B50E77170 for ; Thu, 5 Dec 2024 15:43:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84DF86B017F; Thu, 5 Dec 2024 10:43:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D45D6B0181; Thu, 5 Dec 2024 10:43:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 602F16B0182; Thu, 5 Dec 2024 10:43:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 371E16B017F for ; Thu, 5 Dec 2024 10:43:07 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C013E161711 for ; Thu, 5 Dec 2024 15:43:06 +0000 (UTC) X-FDA: 82861323342.13.6C525C5 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by imf29.hostedemail.com (Postfix) with ESMTP id 579A712002D for ; Thu, 5 Dec 2024 15:42:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DvIw2NYP; spf=pass (imf29.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733413370; a=rsa-sha256; cv=none; b=vX8VS9Z6ocAuYqi56UVMx8ivbjye4wH+adLQ4iapO4PxPW7A+HEt0sUxP9rezat8Y/zvYd PqlMfB88yQJK9aEqgm/1flUv0WqrwUN9jdUTbxbrd4O8sR8EEuuDDWcHkQFioVYmyYhq92 QIEvRAiLvNDudGUYzz95vvWI2UzK7iA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DvIw2NYP; spf=pass (imf29.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.51 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733413370; 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=Gtsnajd748RmcqOV4pJa0tup0XYC14zQ+bwWhrz+BbE=; b=7dHc3dtDrfi/bwMvb/91Zrq/Mjeu1AmLKJdnwDfjXlIEXJZ/TMkqCj1iyY1tGI3tv3MYyB IYG0w5jrufU7P+wP5fjue7qECbc84SZ/jNhm5Wh4wcRfYgpJ22/B8yAFFd9BLdozZa6UPf hpgw6HxkWqyKItHTFkAjwoacehmua5M= Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-432d86a3085so7430705e9.2 for ; Thu, 05 Dec 2024 07:43:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413383; x=1734018183; 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=Gtsnajd748RmcqOV4pJa0tup0XYC14zQ+bwWhrz+BbE=; b=DvIw2NYPP45mX7vdaPXyN+IY9T05c/JLKRU5ohRfEq/xNfmlgiLwpqT9Yo0EhuJFZX 7f4uUkjHVFi4gU/iCvS2ESc+JUbLCtJW9cUvJIo7JDibiZBqN24qCZHoDihfqoZogHv9 nPKHzd0dKpBA0xgO7mbcj2sE3NacXo9E8bQDb0lUaEhsZG3nveFJ0t3bDOGjc6GhnyaP IPo3A69bx2oZxnz26YZJFsZ27MLayPRVSpXTg93MpuEKMeq2JD2WWrCN0I45Jgd+liqn Xnm5hRkdCmaWj3T8au2SzOuJzOf9EC6z0SHTjt8gBkDrwip/gXQXltnoLBuKqzYW1cJL ympQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733413383; x=1734018183; 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=Gtsnajd748RmcqOV4pJa0tup0XYC14zQ+bwWhrz+BbE=; b=jTiNSqdFl4I7uLvSy+f5RztP9QaiMNBn8ZN3uc++n9/nJsahY/0fefPzDXttkWl/ob HNQezIlQyIYVdsfdbEKkqSlj2wCHAHXuy6OXt9c9VnX9IyVHYcBL50cVlzr7kOyf3Hcy syBSzrhF/z6ZbWVNkovX8hlQHVLE+71vX1Q1EzNXchFnHqKV/MJJ7Oshw/onpiFc0unX K3nEBwY3iYWnUXQytLvgBYxBqD4UarJC1Ywbo5NzZIkZlY8EseB4X9s33VIou/LrjUas MfYL7VpkO9iEQ1oARLT5mKmvlLoHj7yxZg53qKuYRlH20e9lgl5f7TcFEWYltJdJqMvK 8izg== X-Forwarded-Encrypted: i=1; AJvYcCU3GVtiXLqzgilscGJfbUGQ9YGxs+qnREtI6VGI83FHTK1Hbf82Pt0SsKnNna6y9hRiPLJec3q2+g==@kvack.org X-Gm-Message-State: AOJu0Yz3bVQVkIxQnTiuUYD2pZVjgy3Ns/ARC0+p2j1ceq5KBnnveiBH aXsMFBP/R5pw2KkASclFCoDt+kkXnaDYfUdZYoQozi5TNM2oQIJv X-Gm-Gg: ASbGncuxQpYpFPhca5LawhYSPRB0h3c/ItGu52a1lOKWxAryXhCJhV9D0YFjajP9HZj OAXj4MiYxwN18YKwjAf69/ts8lszWaBAnBExztHEHTk8ZeEXJcwlmkJgxLEnLovCLQNMzs8Pmeu pkb6kblydgUOJmaiRudpJTkeJRdfdXnPGmv+baBdI0uSpunCI0gthNhaFNE+URlK7UbVRQEWhHY pe8/KzquLQOzDEOFklr0/8sLWCKOHQDRfCP+EEqAJbxCCrMFICd6GR0H/U= X-Google-Smtp-Source: AGHT+IHIQDuNJ6wnIX7o3Rq6VGxlYxR8KF29MJiQdb9I84zkEFXiZarY1wgT1F6E7EapNejJZs+W1Q== X-Received: by 2002:a05:600c:1906:b0:434:a1d3:a331 with SMTP id 5b1f17b1804b1-434d0a0562emr87553825e9.22.1733413383199; Thu, 05 Dec 2024 07:43:03 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434da11387dsm27020185e9.30.2024.12.05.07.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 07:43:02 -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 v2 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Date: Thu, 5 Dec 2024 16:40:54 +0100 Message-ID: <20241205154247.43444-5-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241205154247.43444-1-ubizjak@gmail.com> References: <20241205154247.43444-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rsp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BEM/vlHsX BroZ9NjI xsHTOwRWE9Jbuq33Jp+FaWpEkz1cuw7PZ9xcrwHtpnlbj1gsy1UQiRMHTB6e4PnSmUgFP65wJDcokcekucTuv4dFBnhtptoGq/I6i+Ao/jehrzI7qvgBRoVm9BbEfiWKE5CtxK8B3d/jPZavHZ6TO4hjtygLUUSAPtJbZ9np9P615EroOeSWdSUJbrvLxXLzIhYnvS0pEVkSGTIOolwnFoG/IpHZiKjCYeRi9a1DMvLkbH6B8D/ToQHdCOrDFrruZSMlpy0qGbHMi/P6e8nMBAh77mRU6zAjdtI76Z1bJ1qK66NUSomgHUvH+pqDJGhNH6A/zBBr0KTuutTHpF6RMu5h5SDBiFk2JSUboqTwEVyfFALsfRa7kyGCdmolcwOsv6VEgBL5gFZdjRMRMZrpKYQMCtMyilo60jC0/ghBBkObMTR5lt/FrNpnvK6RLVvq8etDjLAakR8GDnrcYRCBuzLiVz2C/hZ1UAvev5uJWNxg0vfVisCZkaBrqofK5oqktHPX4l7pbX3coEFeBNYqiHzrFYydiUrXuQ+/cQ4BmSIik4KT8ZGghKW4O2j8Z2BokuJV7xkgNk90MIeQYPXo8xSLkiIvT8CEoVdfRnygiWBALRLM+LAeM5Wb2kkmYWfse/t913O6MHYUedzhdbqU6WYTT8jC0cERDOE8d7S43Gl6X9ZCS+9EuQUcDYH5pqzo1MdiIRjzVBORXDYRntLK4Jfh+ybAHR+yu9TmDrL0k0ZvVqR4tF7uslxLTjHb+vw+QeAuz2rKTSzCn36lNr9DKycWlYA== 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 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 --- 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