From patchwork Mon Jan 27 16:05:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951589 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 0F00EC0218A for ; Mon, 27 Jan 2025 16:07:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DE542800D4; Mon, 27 Jan 2025 11:07:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C9976B015C; Mon, 27 Jan 2025 11:07:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66AFB2800D4; Mon, 27 Jan 2025 11:07:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 468796B015B for ; Mon, 27 Jan 2025 11:07:26 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B60EEC02EC for ; Mon, 27 Jan 2025 16:07:25 +0000 (UTC) X-FDA: 83053711650.10.C50ED7B Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf20.hostedemail.com (Postfix) with ESMTP id CA3E01C0009 for ; Mon, 27 Jan 2025 16:07:23 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OIHxLIiZ; spf=pass (imf20.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.50 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=1737994043; 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=3PpdJnIt0LB5LuubDznUPiNtcUhO58iUpeI8CzsV/cw=; b=13uoeEuOAUDeU2sBGlX5vh5ANGHasr+UQ2OuOgeNuQ0p7XjjxinLaRJUqSQKkadA/lfcca /Us2JjqGkaeZOafsBw56RG9cFxD3gdnl91SVE5epOSlmU/onNtinV9urmZAxefnQ6e68/9 YGQGqLRbDMRxsx+eJrBoMtR2GwU6U8o= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OIHxLIiZ; spf=pass (imf20.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.50 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=1737994043; a=rsa-sha256; cv=none; b=3J0iF8OalOUnWSpL+SX4oQI248ULtfRduugFm+SwUQPcAgwNDJddA+kPxc3v7IZlBA/Kvq ZRtf3yt2bLmvPRpwFpMK6fFgnT0b01gjnZsXidZE19F8H53Gq7870Y3TvK/LvPHacuPu2V VeHWAOl30QIRwfunSuVbnS0AFiGlRK4= Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-ab39f84cbf1so895047266b.3 for ; Mon, 27 Jan 2025 08:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994042; x=1738598842; 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=3PpdJnIt0LB5LuubDznUPiNtcUhO58iUpeI8CzsV/cw=; b=OIHxLIiZGFEYxnRxlJRXw6tc8tD/NtAduCjfyIBcbHt2ByVs5uK98LDU7I3Zu1kg8N ATwkA9/vkRmqsJUMfApQvb8y5DOxR8RR39pgO6fOyzdmltSf4rIGLT9Ub1A3oRXudufs LgWQfCn9J3HMwm0IzqRLvnLzVIrNWiiV+DOhnnEF6zT9C12n3cyymqDtGWv8uH26ITuy 0kf3wgLAfxfIGhG8yILxPt9h+8tM/jAXfZ+hy+GmVoQoDcn8DPfY+b57HLimUwzHdh5D l3eylDeSqFLZVdMG2fJ1BEHYYcG+skBM2Gccmp6mtZots457W/0JZMMj4k7UjArkg5w7 IF7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994042; x=1738598842; 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=Bvppy0g3exPzIRftGPCn50wNHppYHgtwwvCO1u+ePTMoIVjN3ImjH1Sh9vy7NJ2Uo8 20vasFOhYDlsKSSbpXg0ijAKW5Y3Qj+ypq1NO8K//HMQbcIgi7OLjV/m165b9v4iZ6Hg U+aqBCvd8S3mN82ADblfHDYvMOrA8Be5haMhui7nhctiZNYTpYDk0+tzZzzzqQ7uGiOb Z67v5STkTu6QQQBgCKsCHG5DqTCXbdqXD9RNOYl+KGc2zaF63tACm/cjivnQfTpLyadh 7IEfT55dmcqkwG4NZ/GmHHATAbwzCsVrn1vOhIA2jO+1Sbv5W8KfLmJt3rI4KrnUu4PF jf4g== X-Forwarded-Encrypted: i=1; AJvYcCX3tth4L+hjN9O9rcmZ6rlWMWLSKORH3sucnawzkJoHrs+jAy08c8WWtw5TmxuvKBAtYTHT7u5rAQ==@kvack.org X-Gm-Message-State: AOJu0YyrSKCX7ZxCjFc++fGcQV4BKmu9E7VdwTpOdnrYpJdh85MqpWV2 DW+8glAOOq5PbXaLLpRHSdWhKIOHtrfsUj1FRAm6ckWVboj6HYqH X-Gm-Gg: ASbGncuVwn7yIF6VqOsBWZkKjAGOHL8OFf6adRxhqiylHSi5TNHxXe4LDwCuI74ZZkT 79gTcC15RiB8wUzTY7s+lUwTIbozztzi2ddSBFQ+zK0ASIBQCjjVFDnTzoIh2GvpHYZtKFhOeb3 qftAydsEeYrVpYOk+GDx9VeSjygwqYPp9fqTlG0B3vsgNCcpkvz3NTiBE6NLnIMW2F+MBoee2Wl +ddR2qTZoSOz5h8tlXSgI4pDwyzWh5CLUfWwEJKKXX4id5cTrXI0atrUrcTX0TAGLAQjplUyk3Y HsWaKfP2EC7PLA== X-Google-Smtp-Source: AGHT+IGxHekg6wyKtSsIHlBYr5ZZfkRZgv/1+kkXgRb8vYd9lhSt2dayN8UQWL8xHzS8S9+szifYTg== X-Received: by 2002:a17:907:930c:b0:aa6:557a:c36f with SMTP id a640c23a62f3a-ab38b378436mr3836172866b.46.1737994041908; Mon, 27 Jan 2025 08:07:21 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:21 -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 v4 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Date: Mon, 27 Jan 2025 17:05:05 +0100 Message-ID: <20250127160709.80604-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: CA3E01C0009 X-Stat-Signature: ouanatjqadij1q1c51e7kujsfiriwq4h X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1737994043-241342 X-HE-Meta: U2FsdGVkX1+ZhL0MBPrEVQsje6QOYrTC7XQp8fATTbLWyV+095dDlslS5FTzwVAM8V82e0AHOTkwpnfPF4Z9qZsIS1wPuvRAH+x2WXJJUx4jXHpTq2M0JCQSEB/ERICZlyFmZjeWGluq/Dy0PcwJGcGgW7sZ81M/h4fAYTIDW7R5uVfwGuQQgTm8X8YJ6+nXPnbhqWMgPKyhxMYt9MB7xTzxX9isBExVQez6bzCcsoDKkk54p4KqLPQjes1Hgq5n4vO3bVI1whddZdQe6ehca2Yu9I2oAjN6EV79ATj05u2aZ9N+TxtCyFkI+T5MhnzppjCPQycaH35v1N43VG9PURoqMluBEJ8onpg+mEWhnDN61j8dnxoGw1/gRw/V4x87mbmLzAbWDWOjU02wK8X60Y0cy/Jr2cIEFKMy6Njxb9sLjm5/azU0FIjX3mt2jabfHAXHR3mIXSpYkLHqYS0YD1K2aODRvrGLEZGx27RsnJJobHzzq440Q2/O7/4dzJuPmIOOB5+4t5YbBhPTyDFWpzhSdAKYAvRtMDRAepH5jWT4eUr8UsV4vhxf/6cVXxAlx+VI42e4TPXgteHldUbL2mchJ8TAsOFlK1q5Y14UTGWVzYtlh56WHfvffC/vzf24TKP//vkf835IKaZ3b5IBU6Mb6EhlCJa2z+ZDh2rcn9WQb5mhLVUwQYX3WxWngZ66ql+EoaQxJP9F+4fAFFc9KAQlp2UVNQv5cBTuOFKJy2zYv7a56u9fmEtzhiuEMzi22rHroSRzR6e51bkNZR8h7sdCgIjSXM6epCMEMAia7tdaQEGeXRxCIyi8wEVhJTcOhE32+vxdKHqdctvOlQeDiQyutRbW7eY6NcFo+d2Zxwisv2KzEMts34QtdUOCTtUcOYMgUrKGnu3w8KJlI2kJbA5rgHMj0NXGZL5b4zRZbvAXF2UW31eUfq03ww/kR6sT+RKnbeGXOCa3HxTCpET Bay8WZi+ ff2wF4S43snFH4bvojQY21eDUBaZXBN3PRztztn00ZAuohKvI61tKXLLuSCL08FBGFxPpop7JQS98/qwWwcqJxO5+/QgbXPIQT9ISHAWVgac9HHfsnU0qknl1xYCzllpoWgl1T4+ggyHhM9sL0Jajwtugal6Ilraut7psvI8Ct0/CE33ybxiPPyl2F9nT0SbjiaUNTPxducLAB31EzTN7lVwadlEyvIfzNmaBwSlyHSwiASIHXI2+4qleTUqkUEEx+vwslpywduqjkDhyS0gxStQmt9zSTKGiCsBWiMh4rbd1NeDfeKkNJH02MVP2gPfFTM02Vj/L6L9z/LeVET+ww4RijLsm06X49HzCEfj4GNHULZM9d0AX6M2qX8/dUAk1APIaUgHAOU5xQvxoXLth5AUGT1zipS1SgZjEgGDu1x3BXTUawrnxak3l0hLEScfYdSLfGkjjp0z7KVLZgQq7WQFBcUQ3SIDNm6TAA8CArHGiw17/qMQAOeIRawspJMDc80WZ1qbc8VZB2TFV0p9fDrzjkhPF3XT9ZzZkWZE6GwhlnH51BQkJm6ahR9ozUBy43CwyCyDKv/js0fwkmOHzY3RGYpkJ9Ys6md9TorcB0wZNbEHiNjmqdiuASL+Xj49luXmQagh/Q+5TMCOCNogtVS33IknNW5w9kRDt/V82bJlzvboOYdKXpR7Ts5qe++dM5f51rsDOvPOKalkuMqlSsa49Tz/YAW1ByoafZOksenmhhkcQW3EfxDjUIl5aOrFSbvbYMHRy44PdLwMuy39g3NtSTw== 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 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 Mon Jan 27 16:05:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951590 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 CC304C02188 for ; Mon, 27 Jan 2025 16:07:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 903B86B015B; Mon, 27 Jan 2025 11:07:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 88DEA280115; Mon, 27 Jan 2025 11:07:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 706BE2800E8; Mon, 27 Jan 2025 11:07:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 500246B015B for ; Mon, 27 Jan 2025 11:07:27 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0A5311C7103 for ; Mon, 27 Jan 2025 16:07:27 +0000 (UTC) X-FDA: 83053711734.24.1EC53B6 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by imf11.hostedemail.com (Postfix) with ESMTP id 21FC140010 for ; Mon, 27 Jan 2025 16:07:24 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FvmC06LH; spf=pass (imf11.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.53 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=1737994045; 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=kq9/i3Ta5l2MI1vOWLuY/2sULLk+AJ5LvhrOAI9bZzU=; b=xTCOP2LUmi5B9jy5zVV7cZbXLj+mSdfRs+q9PmIGNBsv1W7a2eNysl34Jcp04J/J5dG4tY RdolIGenGX+/NbtIRl/XNz5QSxVVnB6McpklDpQmjkODdJuWy47xQFZepkW1Ek/TMSr4go zzjJf88Sn+d72YWiEY+V0iu+a8pjNEo= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FvmC06LH; spf=pass (imf11.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.53 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=1737994045; a=rsa-sha256; cv=none; b=vIORSi668fB3RFEpiOEO12IlpTh6kvMxEzi58KGN7fqeTcBuiqrpuUqQK5yDZJhuAg97ww SfTXzWcSFpO8NWq+tJ7VTRfR09UIsU72QrywODDZoqs64EPTkITLOLzhfZ+1vDR/0qdDG0 z/QCLEDQkVkp/qAvNT9GYFDq/CLIlfI= Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aaf6b1a5f2bso1149884966b.1 for ; Mon, 27 Jan 2025 08:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994044; x=1738598844; 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=kq9/i3Ta5l2MI1vOWLuY/2sULLk+AJ5LvhrOAI9bZzU=; b=FvmC06LHTeX5Xyqd0iny6vg/L0iCenHCsa2vQEJPSe9G+2jiD3UPJAr1pSyrIrj1aJ I66O+feRKNGc6v0qy5jjbfGuG7TXOxrd8n7BBwOoJBPsQdA8Du4cB8+ONrlr+qViPKFS FKtC/T1D+R/ri/KaSxWvw8sOV1OkBWRAsV6AtErNi54K7KiPNo7brlrUlMp3WWQ2jUbn 2vzLXWz+Wy2BWy4wHP+v1vvv9+SXbWq7PZWgVhZTLUVsxbvHEJvWYIRNg6sdU0TSeKSw yUelAx3UtI/svZB+4Y4PBklLVHahmJ9ni3vqC6Y7Mo+xc28I4WY8hCIs7h1uXxHuL8Jv 39Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994044; x=1738598844; 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=kq9/i3Ta5l2MI1vOWLuY/2sULLk+AJ5LvhrOAI9bZzU=; b=L9e5qE6tTIBoHFQiFKrp3QxBEU0JeSg19yx2EkwX4X5qlMysvvHxKeuX0sMaCwFIvU Ypud0pvqt4Ygh/DcxgqxLnDBi+lTbPzROm5739NfIDV0WFe3zQm/riUhGgF4OMRVmFrm pwUx5FAJDu+Xi/lkuOWc1oKbZ8IptMeDG4jV+wM72joLk7kJXmHEl+PBNLqSciyaT8rx TIqZf4VzkeiseEOJVBjo/FBLXZ2+7rammTYmwiSVPldaI+tMysK1WTzDjAmudg+1r6be Ab4OEv88JPnlTTK7V9rdPqTPufHXKOcek+XceKYIBl07PF/qBUFkABLYgOmE2X2Jz5wi Jf7Q== X-Forwarded-Encrypted: i=1; AJvYcCU1jouJON+OQKYfVxbjmT1+qGP/lhhqoTqfLqz+ruPA1ik/xx16CMlHAL2E/+aAMkNDwrcsvSncRg==@kvack.org X-Gm-Message-State: AOJu0YxO3h1APj08uH/fUZozCqDpUGYlvsW13dkj7aCpqqipfZEYlz2B DIMmFvMvgpOmJgUAhNkTrUufwYGU+SR3BRaiHqeyAsjwVpQHPg9v X-Gm-Gg: ASbGncv2yF7INd3S2J00BrUpRNPgpDhx52wHm32r5u4bxaeDb9AD6NkCfg/1Q7NPefR m+m6TFAdRCbgavX0KJZqhVYewK8KCHwlzc2TdLW9xd2C9QkDUZwqtFT8tP31wrkmpQZskFG4vG5 dSRubA4VItW2KYOnkJAlMnQWnObkbLTY3J3KOos1XKag6N8Mda501pUGc06DFrLw6SJWjA2G9Kf u8RQNnh4epMF81EywxVQSdOD+Jcr1Sh18U/eJs2KPpYdllaUi8kLPqB2QnonhHGDTf6uNgVdzDp ZsVhfguXy4q14A== X-Google-Smtp-Source: AGHT+IGps2FOyGZFh29HU88UQXaUARQyvefInzqR9JwB8VX2QVMTmcMPtTLVQtl0rzI1dpYkZKybuQ== X-Received: by 2002:a17:907:72d6:b0:ab3:4d1e:4606 with SMTP id a640c23a62f3a-ab662910720mr1670846366b.3.1737994043332; Mon, 27 Jan 2025 08:07:23 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:22 -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 , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH v4 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Date: Mon, 27 Jan 2025 17:05:06 +0100 Message-ID: <20250127160709.80604-3-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 21FC140010 X-Stat-Signature: p1ymryd4cj8dq614zht66dbmaejmbimm X-Rspam-User: X-HE-Tag: 1737994044-877641 X-HE-Meta: U2FsdGVkX1+xdtPogZj4k5vruIBwqO7BNfUpz/XpjLn3lWioqGgX2KmA1+2HbPXh/wv7DCg/k77IkL3r6pmlYgVDNcNMF4We6SJwhdjz9tX8y9BBK/sZaM/knL6Lr+cRiQ6tzRLTCv/SFbMH2jA3nOV2XlLKA5ILgC4/lUpMewQQyRm5LXjpxumO3J1iywHcu+wT6c9uwkD8HeY1eoaG+O7R2XbAZszg6sTOLM0KHg/4RvBGAbLeRb6rsc188E3Xe7FziIb1rf1MbAjdKHbinu00HIoPGuVD2H66zni6D7pogjdy9IZnciQdUR+vzr2dIxIn2rxopZTBFBoiAh0iMmt6kIrw29ePSqknmiYzUEWUZlv2KU7gT3nwFckcD4/JM7N9VgnW9p3vdMsawmPDYZ+wcnohieicPVKILd2SO07a/iCH5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VZ+CBCaDQRHGo52OH/D3+kRmFDbIPkKFsMrzuR1ZZyGVzRGrE6DI11IOnX/sUtv4fJuhE0Hcl+QNOA2szZDApp6m5KWXlBaMhvtHe5l+86zyDs6ZEvVvPoORGG324NCGXunojzGVy+KaEGDwfoGg4MbHjvN+NNjMGW1i01arU85kwPiw7pKHhmg83W/exuCi8uVub/Sy/4Q/I= 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: 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 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 --- v2: - Add comment to remove test for __CHECKER__ once sparse learns about __typeof_unqual__. v4: - Do not auto-detect compiler support for __typeof_unqual__() --- include/linux/compiler-clang.h | 8 ++++++++ include/linux/compiler-gcc.h | 8 ++++++++ include/linux/compiler.h | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index 2e7c2c282f3a..4fc8e26914ad 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -128,3 +128,11 @@ */ #define ASM_INPUT_G "ir" #define ASM_INPUT_RM "r" + +/* + * Declare compiler support for __typeof_unqual__() operator. + * + * Bindgen uses LLVM even if our C compiler is GCC, so we cannot + * rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL. + */ +#define CC_HAS_TYPEOF_UNQUAL (__clang_major__ >= 19) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index c9b58188ec61..32048052c64a 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -137,3 +137,11 @@ #if GCC_VERSION < 90100 #undef __alloc_size__ #endif + +/* + * Declare compiler support for __typeof_unqual__() operator. + * + * Bindgen uses LLVM even if our C compiler is GCC, so we cannot + * rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL. + */ +#define CC_HAS_TYPEOF_UNQUAL (__GNUC__ >= 14) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index b087de2f3e94..a892c89ac28a 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -191,6 +191,26 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, __v; \ }) +/* + * Use __typeof_unqual__() when available. + * + * XXX: Remove test for __CHECKER__ once + * sparse learns about __typeof_unqual__(). + */ +#if CC_HAS_TYPEOF_UNQUAL && !defined(__CHECKER__) +# define USE_TYPEOF_UNQUAL 1 +#endif + +/* + * Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof + * operator when available, to return an unqualified type of the exp. + */ +#if defined(USE_TYPEOF_UNQUAL) +# define TYPEOF_UNQUAL(exp) __typeof_unqual__(exp) +#else +# define TYPEOF_UNQUAL(exp) __typeof__(exp) +#endif + #endif /* __KERNEL__ */ /** From patchwork Mon Jan 27 16:05:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951591 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 11DF7C0218C for ; Mon, 27 Jan 2025 16:07:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9D386B015D; Mon, 27 Jan 2025 11:07:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B2826280115; Mon, 27 Jan 2025 11:07:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92BE22800E8; Mon, 27 Jan 2025 11:07:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7401A6B015D for ; Mon, 27 Jan 2025 11:07:29 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 192A7C02A4 for ; Mon, 27 Jan 2025 16:07:29 +0000 (UTC) X-FDA: 83053711818.19.F21DEA4 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by imf01.hostedemail.com (Postfix) with ESMTP id 105BB4000B for ; Mon, 27 Jan 2025 16:07:26 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=atR7J5XX; spf=pass (imf01.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.41 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=1737994047; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SuZxe+AfFouuIU0wQHkXEH3/7ewa5etNqEUu9GIF73k=; b=vofMl7pAahEW00mD2JWHYOMNfbto2QCAZ2lbDksxnO237Qq2//DEgRJNOVZffVcou6j3xN qTUK7wEEs/tp2sQ61FDbfrm6wUF6iPlucXYUr0X7eFGli1dvxhNu4rUkzACVb9ayygPxal 49+qM21wTP5rOJ7eb6rog3t/3Tr0m2c= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=atR7J5XX; spf=pass (imf01.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.41 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=1737994047; a=rsa-sha256; cv=none; b=KE0n13KRhWh8cgzqi2oznv9wvr5AxXaKlxE2Gv+9JRWe2bUODDZlFGToj4D4OQ2HjROIId emfe8gVGZ8Yg3e+TlB2mqusZKySc4R2fawJSl5CDaBRZu+dFGDbSV3LiQ0iy/7eckrtYiq 0O9crpnEM3L6AqtPsxl9E7Q/2mS4fks= Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-ab2e308a99bso902332166b.1 for ; Mon, 27 Jan 2025 08:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994045; x=1738598845; 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=SuZxe+AfFouuIU0wQHkXEH3/7ewa5etNqEUu9GIF73k=; b=atR7J5XX4UGpF6G3X9xGGQwwuMHxydphVh0ht5M8Tl0+Wx3r+x35HBIXo9UAfRkuNz DorLF796ELKs8jTEZmNam8TmaN7llRaM+RimkIDT2YobGro05QsKNTKxa2nC+E6Y73TZ +TU19CjnuYOSDYXbLPdg4kQx4IEEAAVEP2nFhd49+gYwUFfLAdpBptZf8qhiC2Hs2IjI 29J4YmpcO/BjCIqzQnpU2PLhQLUQmDX7mSNmKTVH3voV6z3k2r8mJTyhP0+VE0RduRNS E4zA8FqVIRbEfGB6onRrbfDwiDTe3QrAMenxsQZZJuWyuxm34jWRoPVV/D8GZ0bJP4wh n/EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994045; x=1738598845; 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=SuZxe+AfFouuIU0wQHkXEH3/7ewa5etNqEUu9GIF73k=; b=ntYIm7BHnLbgmGo6S4P5Asj5N6/FQksRcpLtsiKsv5OYJgIpiBr1BaUq6vp602l/XB 0agj+NpnZaSQwxFCai5pEObs4DoOblfayuoYJcck0bPBtky5or8FwvlqOnh99wBepTa0 TacuMDjOHXKxwH+z6hq6T5yW3hrwoVw67kWs89AX6c7Q9zO76xriUglDznvsHa9zUJqL c+ckDpuDtcZDioy8sCQutwfP47lSf5Q3SVubXcH3gCBFoIhuUPUJFkLdtHT88FCz7U81 NcK/4vzuu+Ft/Nc/nsPMI5La+NyLELOjSd6Aem/nVWZXl0KHEjGvCa0sEfXQGcU0WWuQ BwDg== X-Forwarded-Encrypted: i=1; AJvYcCWltQDteETd/rf95sIeYDUVcnIj5/WIWgg5pM3ymmbkx6ZDelsaiBcsunvmNnXgncrVw4o9VZtHWA==@kvack.org X-Gm-Message-State: AOJu0Yy/62szKU1udw0pgZPF9gR2NWeiOSUDPDGY6W33BZ/j8zSXDuEq WtHHJr+t83XTRCCPcOMtHDLcnLA1DrnmkdZCteAitbbFMDNvNC8i X-Gm-Gg: ASbGnctA+iR8oiyw1AqzuOvIMC7RInyOl5wQZSpOHOqqnhZiHKVmy94aiJpD/tQTkUa akalrKdy9ajQl7NnnPsnsnlreArHIYcG2UwvbcuT9Q/sddtzJTmK8YG8pCSyUmUBvf5VXb9K7zO lO0YuxaXiEK8SQV9Gpam0oppm2maTKRpoY1GnNe/tCffHkk7Y46q4pFga8MjE9Z2QTlbwUdlF2D PzndPrA2tJ2dkYZ/4osEYMKxE5Qa2j/eqswlmMX31o9NWxSnGj8m3L8YvGAeYLn/QmuEwSSV5H2 5faV61uUdmu0ew== X-Google-Smtp-Source: AGHT+IEhkb1QlpKpjEVh9Qlf5cg4BvflbRVDsJrlA2oE2R2yIM44Ae2Zi5eaJQiOnUdYAJplTRaD5w== X-Received: by 2002:a17:907:7e85:b0:ab6:59e0:b756 with SMTP id a640c23a62f3a-ab6629cce1dmr1786130466b.14.1737994045166; Mon, 27 Jan 2025 08:07:25 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07: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 , 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 v4 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Date: Mon, 27 Jan 2025 17:05:07 +0100 Message-ID: <20250127160709.80604-4-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 105BB4000B X-Stat-Signature: d6h5j7rakzy5rzbmge7gbx4keuje64bg X-Rspam-User: X-HE-Tag: 1737994046-220638 X-HE-Meta: U2FsdGVkX1/T3Mop5pOBoPVON7cKcfGbv3pm+Ww9ORzhi6AKbked5hqzJj0MDN9DKLnNnKmLAR7pLCtxHXP+9LwakzHaTtV+VtYh5l4av1IzDsNSQm+P6vsWDV6ijKfbz6habdH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LGpSLsdr4iEQBU39aWk0a2DO5g53LkIlkud7/ggGsyOMiSU5r8vNDRxQke3WmJ/2g5W0rTHaoQTjWX1HjgdupnMEuj+GOj0wCWER3hgZwIGv1cUqcJIEeK8W42TLyoZRQGQNRGFwlEbwWX/OP+7TCP1OAvLzPWIvQNBjShtRMyKrBdZbmlraG6K3My2aIrUnUAtfK+gj/r8w9s3b4BHIdBb3PvF+QpkaD91fjc7hR/9x3yOJkl6HHMg//sX351SnyS8K+NEyOcogOr9VLclwpJt0toVb9lu4Q1hLQ/OSvqLP4AlRUfU0V8suLB7+In3mH3Q86dX62sRTIX/KDHjajpgw1smWk2IEPFuuirm/QXfDf8ESj4TkaJG6dHwRV0sA9rV6mcXnn7ZA6iPEMeSKZUw9vdmqrI9MB85Go2DFFPjvbabZYrTt/la0T+6gdTqjV8XeH/8uqes87ROGZSeyqhUqC1dUhS/hHt9ubTO8xL1+4SIvILwfZTsG3+rnM/sRfXgmxAAUAHEg0rlYBoSuYBfDYvdBP3TIUNrDHRxNJFgp/Y9VLL+tZwiVXlJ7JtojOumtKGIHevj2UC6/ofkcsxbutyWMAz/3JgZZBvzmlguE914+P60nSzAQhXvaCkuuA096Qi5KmnwEpUkG8Mn5JT4HTVKksEwlRUcH+ns6st69+I8OsY0Ra8cCXGq2J1XGVyQKaRZWtsw 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() 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 1a1720116071..e430a32050c2 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -609,7 +609,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 5b520fe86b60..79b9402404f1 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -317,7 +317,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; \ @@ -332,7 +332,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 Mon Jan 27 16:05:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951592 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 2EB4BC0218A for ; Mon, 27 Jan 2025 16:07:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16EB82800E8; Mon, 27 Jan 2025 11:07:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F0C66B0160; Mon, 27 Jan 2025 11:07:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E34852800E8; Mon, 27 Jan 2025 11:07:30 -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 C0F556B015F for ; Mon, 27 Jan 2025 11:07:30 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6B9D11C7132 for ; Mon, 27 Jan 2025 16:07:30 +0000 (UTC) X-FDA: 83053711860.06.335E9E1 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by imf30.hostedemail.com (Postfix) with ESMTP id 757F280013 for ; Mon, 27 Jan 2025 16:07:28 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WstyVLCI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.52 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737994048; a=rsa-sha256; cv=none; b=PyvPvdLM8D7iT70cZIkw6X8ylGR7fqDQbiZ9cM3bPWQvkeELNkMfAWaEdrKumdHQVpCN7R lJnIxAQtqBYmspviFMxbReO4+sxLrSfNKOpALtLs124DMwvn5xkc9Syln5XOpj2jwSLvWC 6inlahTGo15tGlFdlv9tjKqDukI0kcY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WstyVLCI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.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=1737994048; 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=eOGOr4s5yiF+IlrjEXheryEMyHp3uedGamtyEKhbkyY=; b=5svehoK7aXwvc6aj3w4ZtQd0tog+S1bmdXdbjWfo/8lKTXE0KBupSNGdfImUaNn/URJ5rz 4rOsxUrwA9WTvq/p0KQmhEJ3ktt0C3MjsinDONYo46kwB4QjWPe+63K3ILokLM4xxLn012 d+PUaVqced7LpdorKog6HXTo2HAeq/M= Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-aaee2c5ee6eso953982666b.1 for ; Mon, 27 Jan 2025 08:07:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994047; x=1738598847; 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=eOGOr4s5yiF+IlrjEXheryEMyHp3uedGamtyEKhbkyY=; b=WstyVLCIn4sIIT0INP9lb0iVPg+Tmcc3mCXwQRlrS9Oc1TovjiYbsXLq0kxtCyHdcw 2QRH5XEbv9YBRSds6jSn916wrxlrQmwIyy8WvljG2XjigWfk2dOcaFHHMktI6B6VJLKp g5QdFPVyZpD0EBz+A5CZyW8wYx1NMTODMyr9Zr+RTi/vF5Szknnlb3ArzPJh7BGyekOV uzzDbcU9JPMLXyEzoagJxd1punv7CZZbA8dobVFKdLVD/ERWkVSi9Eh2I8zd3CRoFgbp haneJ63NnF09nSNiKKIvSFy9cTs2vaRjj/isJOtOVyhg3OPkrWrMAitxsb0ORPXCuXmW y/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994047; x=1738598847; 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=eOGOr4s5yiF+IlrjEXheryEMyHp3uedGamtyEKhbkyY=; b=kjEdh6Qlomh1ZfKmRqPnhuVnKOm08epVMMam5q+2UTJBhvq0OZcluny/H4EuvQwbat Hx76g6anXEry0XvvfsuIYnCu51sVwEhFpTT51ZD3j7btANan3ex4nrtseZoYTNmWsdSq +ijV39mo6IM1xXj7Jsmk2ZghQTKChru6M6uogrsfDtBtyoWH9NCMpM6nJ4MdjIs8reJ1 /YPisl7TE7pRhdwfK9+ygJy/peH7HtMalnV21de/Ety67HDrqELHFecbr4L9Woin5RIQ HMCBfrRaRMHFufLpcfpQi56qBk0jzQyLWjeK3nG0QoOeFLUdUE4csouu1AXuQWoqQlb6 A6SQ== X-Forwarded-Encrypted: i=1; AJvYcCXEKOmrqg4eupiqvwIx0kebrWpMssukRQU3mhbDH7Q5rCRwLSgxlzxd59zstEx2LHRCW0w3DQy2nw==@kvack.org X-Gm-Message-State: AOJu0YxR+LbtmiQ2Gz9jytCnef9+hFeFO8plIzrKqJfz4nY6OpxwRrrN OaUBPo24ahgHlOrYF3deGYpDIREepf2CWkSUhghVJpCN/j4Uhht1 X-Gm-Gg: ASbGnctKS4t9HEixEYigL/RD+FUwmPekQSidxZ9GwzQxIGFe0rDMn5fR2c2rKPwWmy7 JZo66qjepfbYbxerjT5SMcTBw72ZJBQlHlvZqRYlwQFdDiOlb2wOUYUs+c0rLnTQWUByyX3+H9Q XHEr8aM2t/ndmrWcHky1Zoltj3xtI0A1N5bMeBy1tkDLnhdFi4ODgEGYsEw4FoXnrndwLdDIE00 HfHBz+liufr3MHo3lwLE3RT5oP0DrXQGZ4o416vuRYXQlXMqGs82wtnystGeLhPgSrtPDtJlxVC qKd0UZNkLhd9UA== X-Google-Smtp-Source: AGHT+IERCLQXnCU+YIaBBJp+oaHBkoRX9ZwnjjcfabyvezHHAG9ec22+X9u8D1546w+n0uGxAoPHpg== X-Received: by 2002:a17:906:2cc4:b0:ab3:a3b4:f91c with SMTP id a640c23a62f3a-ab3a3b4f9b3mr3132086166b.34.1737994046774; Mon, 27 Jan 2025 08:07:26 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07: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 , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v4 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Date: Mon, 27 Jan 2025 17:05:08 +0100 Message-ID: <20250127160709.80604-5-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 757F280013 X-Rspamd-Server: rspam10 X-Stat-Signature: zw1ftj6sa5esurxay8s18c7a3omz3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vovBBDPSwVf28AqKSyxYDmfxm62rdWbCmbuFUwSfa/QRwW0jqLUA4q7Eiucw45LTID174NMjWbvlgRQ7vkF5oDQ+caJ7q35OonasfxitYVY6tqHLcr54jmKYpoPgAozPyDHrPpyIR1pBFiI8zBHGcOpKusATk1fBGPkGhITG26rveeDmLPDTevMNfqVBYtF6guksAgkUM3CMWUDNb9qZx+fwKGD+TMleONw66pvI7DPvkCQvABvK/MFjs08riYD7YJusydI1bbxTg00PCc0pIDOlM2Uy9BghfrmO5lhHaNJw+Ac9JsUOfn39lzq1QQpKqegz0nYrZDbvTUDiE7LONsfKlT20JYYtRcJQ5Yn/vb57UGA7PuJXPL6IIVAGHE0N+gC3A8+uWduJDaNNrs2FV6fy3UNRfINX198uwjIwnoOhfZtfE/b1DjJ33DP8DxFtJgOualYVDbua4FK7NRH6dOoMJMY9awiK3/7vEDqrN712k4ttXMGFso48WADJQvQQWRkNMdWJS3u+fRiNTnZgu5pexsekiQBxx3O88nKBOzt1sipOxdEipMiWFuctT/70NORlFq/5Va7++AV1CbtsOkPU8I36gI+5zP647QOO9/8wrQLdPR29pXM45RQRg+UH6EbU+GyFI5K4pWRlS7f0ysHHewUKsXAP9blVO7+G+/r8yRvlxZSB3C0heZ7u8qQMapfdE1hsc4DZTI1F2N9/lBPsoqCswDI5eA== 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 79b9402404f1..a7cf954ea99d 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -221,7 +221,7 @@ do { \ } while (0) #define PERCPU_PTR(__p) \ - (typeof(*(__p)) __force __kernel *)((__force unsigned long)(__p)) + (TYPEOF_UNQUAL(*(__p)) __force __kernel *)((__force unsigned long)(__p)) #ifdef CONFIG_SMP From patchwork Mon Jan 27 16:05:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951593 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 24F01C0218C for ; Mon, 27 Jan 2025 16:07:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92C55280115; Mon, 27 Jan 2025 11:07:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B48A6B0160; Mon, 27 Jan 2025 11:07:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E082280115; Mon, 27 Jan 2025 11:07:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 491CB6B015F for ; Mon, 27 Jan 2025 11:07:32 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0A5FC14014F for ; Mon, 27 Jan 2025 16:07:32 +0000 (UTC) X-FDA: 83053711944.24.93A1A86 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by imf14.hostedemail.com (Postfix) with ESMTP id 09D9C100020 for ; Mon, 27 Jan 2025 16:07:29 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i8he+5mf; spf=pass (imf14.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.49 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=1737994050; 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=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=Rs28O5wqzH0MY94jpgUf/h1gxLQ7upqlIUkB+EXa9xaZaI1vcJJGZgCM2r+nhda2UDtzCJ K5TW4QQGs4hi6ct1nrtElaFyW3j93JTu0jE0DJSHaylb4eSD8waKkoRKy8kzgWGrGc78AB ktwtpRIVy7XlVA6ke/vII8GZxt0TTuo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i8he+5mf; spf=pass (imf14.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.49 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=1737994050; a=rsa-sha256; cv=none; b=6oqvdoIYbJrDFk3SIrcPlB3A/6UctOXrZMzaD1NBiGxBC4f8gLKjq0xWBpAAIUVFWmadDx 0jB+XWw6r80pdFC1uhelPnd+CkyTzERJ1wO1HFy28L0e3X3lWCxr+eEsPNCR8aI3nIoWKj v5yazt+dlvUljXDyGSdsIruUbFRa1RA= Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-ab633d9582aso823278866b.1 for ; Mon, 27 Jan 2025 08:07:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994048; x=1738598848; 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=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=i8he+5mfWgR4MNMNhz2e70GUY1QkBEAnyWScheb/EyL3/45V40SF5Zjkm2qEKsHPZu OeKDEjh/NNEgxS4wEaPLck1DPSwtC8KAqAkLfHg5XfuHsIENE6e+mKdOvJxo5rF8XZJG 9luv8FqedndOv3XAiA6om9QPIu0T3+8cwK87dr6wi+EAPMc2YBz5dhMHKiTEy/t/hG+9 zqTFAe3FMuXOgiqcT6B7r9gykvesf1qIMYtRYWUqoJQjgDNg5mPpxOPhQcCn2FCNQjg2 wQM6ccDeLelGZFQtm2R60NT5EI196CQxcPVloh+Zcq5kVH1LCPZI/DcD7/9XObJC2pTR xv3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994048; x=1738598848; 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=PUkXOZGVI8Saa4BK1eWfcaqWqwdxbddipdf/JJOFC4UayhrwYRBK8fROAxf2iYTkAJ aZR/0cWhxMet1y606nIosC3Tfbt3jbF0lKDLrIev19yPdV1qwvx+js1dg+yvskKsXZx9 x1e+ULGTGbLoiAYWtECFyFpKX2yzhrNLGv+gzpJDVlAC7GQR6KqkEVHkHIpmlEtg/w5g kuyu6rCrgf7vmnr2clFH9t4HFP4VfUaaFnLB/Xj1/eUxPiX5YsMsGZLUUu8M+hRrPbDc y5VfgfGBiQAvZrDmKEytmyDV+4AyFRit7Smvh1HgGY4S4S05vMW6fwapT2VcLpI8Jjjo 8UqQ== X-Forwarded-Encrypted: i=1; AJvYcCVAhwzlcRNemSfcpieqPL6bGAHh0t7xJd9I6Rm8K+5bfgKP7qcj31HPXb/aT3I+5wmf+ywSXDGN1A==@kvack.org X-Gm-Message-State: AOJu0YwDzO5C/FOAamWiDnm/fDVubs9d8VQgwYKyCln0Uwbx0gI+arSv SFxEX9gLzkbGbCIvfaDlt084YQ06uX7bXKUTC5CpV/49T3OIFBAJ X-Gm-Gg: ASbGncv8NzfMsnranQfWsVMOFU3TkKNuzYaaRRXurVJyAv9wS9d9vxEMQqneW9FBUKN rkcFw3zaaFfz6/SXcxEXUIjie8+FFxkg5DC0AgNvQus5WUdgp78aUbpj3mrgvvzyiCRmEQG6L22 pby8gOmhiH2SpMfPB0cQVs9Ery8A73F+iDxa/C283hMl7awKAOObQ9Mlo0I5VnvQFZHCd6QjbzX 0KYQ5YzCZ/NGzHEMbR2zdOEwKj/QEzGf4O260HTjz0cA9ygRss9pTVmxD0bT6AumFLK+yNHcp1J f0Hdwmu9sJkPTw== X-Google-Smtp-Source: AGHT+IFAuvcto44xbfJbzToMqvasWkjx8mJOE7NNj1gZKmPQ5KI6lBKJIGSybMmZDHGSQog3h29n+w== X-Received: by 2002:a17:907:1c19:b0:aa6:acd6:b30d with SMTP id a640c23a62f3a-ab38b4c63f2mr3942830466b.48.1737994048224; Mon, 27 Jan 2025 08:07:28 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:27 -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 v4 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Date: Mon, 27 Jan 2025 17:05:09 +0100 Message-ID: <20250127160709.80604-6-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 09D9C100020 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xmomhmakg13e7es1ykk5k65arqmf8oak X-HE-Tag: 1737994049-25067 X-HE-Meta: U2FsdGVkX18u6meUnHmR3jJnwKCrG6UGa7BI5DT34B/XAl+6I/g2UeeHxFHYm3ax/3Y1ehQN/JW7iKQCknwkdILYi3SdAzG8pJIUSrT0MMZdPVOqF75t9qIQxnQUH8eB9IxgkBIuzgHmqYP19KEPVgFF7xTEB/6HvnwdQCe2kbkWFVq6thCt4YC9c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sXx8oq7TvBof6y6Yt3g9SDMirloOaDeIDZ5TlgFJ1d7pXy8kWjodcT5V+RFIDzkLVLNNNzRK545kT7cCj3vcY/Vtlwj4a9wqhOotSZnOfFxXUkMdMocbSJg6Ut6oAZUhihi0nsJ6zknayC+lRRfhSpJy4wg68xwou0dGTzosRpQeQ/WYK5inQU+/HEU/rATob3nfcaWHWBADllHBXzfZuqEk6CFNp2rko7X8YVl/YjlPN4KtpX99Q0HCIUBJ8jByWQGZ83tj8RGMA0lfGq5cCvI4q7m9AMkbq1KLPp/si0BqabppL+PAFHe3CZXfJvi+DmutvgqH/B8rcn29LJ/A28b0rQLt4FaT8bxknfUoQjVlL+BKkyXylYMlz8+/88pIOORBD7sytVtBbb0JuXEWq2cdxTCvyBW+vOiLeZAd0Krqi96qOm6DXPkq4qVc0bGcniWWy1cuMAzVwrVPdMyOVzYYlGJP5Wg10jRi/z6 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: 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 Mon Jan 27 16:05:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951594 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 0ABA8C02188 for ; Mon, 27 Jan 2025 16:07:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E38C76B015F; Mon, 27 Jan 2025 11:07:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DBF516B0160; Mon, 27 Jan 2025 11:07:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC37A28011F; Mon, 27 Jan 2025 11:07:33 -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 9B52A6B015F for ; Mon, 27 Jan 2025 11:07:33 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 52DDB80358 for ; Mon, 27 Jan 2025 16:07:33 +0000 (UTC) X-FDA: 83053711986.21.02B94F0 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf08.hostedemail.com (Postfix) with ESMTP id 5BA5716001E for ; Mon, 27 Jan 2025 16:07:31 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IfifjK0Q; spf=pass (imf08.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.50 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=1737994051; 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=lrZpQikn3aM6B3Iqd/Ucnjx7jHzSyajd3QTmq9Vwrvo=; b=pjwwRMkJ45AQ6QYOxKtDzJpNlneGy3UnaqByNgbCc3q4EsTS/PExsbgnl26ztwdVKR6gyD ytRVqQqu/+CHNizJhWCUOvM7umSxVJhumSpkk4RvbopfwzAPswDdiZ/W4LvugMSqln0WZG BbtN1RMKcbEU/vs6PWr2J/0KgmT29I4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737994051; a=rsa-sha256; cv=none; b=M+Py6ksuE9riWsFC52C5Q6X13DVRosZo3X1wCgviqsuANR9Ff42yTBQlvwVhvH/fOS+E9J ua/4Z1nW+fkYkAQoeVMERNk/fGqB0mlCc+qz5m8QjkuihpJVfXiLj9iUL3GQNLfFiI5DHg mWigqwEAHsUrjjduLj6kGzcXuz/dRSg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IfifjK0Q; spf=pass (imf08.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-aab6fa3e20eso773482566b.2 for ; Mon, 27 Jan 2025 08:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994050; x=1738598850; 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=lrZpQikn3aM6B3Iqd/Ucnjx7jHzSyajd3QTmq9Vwrvo=; b=IfifjK0QwhVcgNHrHRyAWTf3KHiYudpdtEdS2uD+i4AYGAopIncoWm3ewzAOBrmVQj pjU0gA1i2PPNw7iEyrqazVFrnVZUI7VeyNZaG0USSqYT5XoUEqTlMX0AONAtwR8GzG+Y JBJOOYGgnoYz83AupLlUO3kdY9WUKtxW9iydkMPsZJ/3oafsEHycNvtQztOrJshNEXlT /r0O88hUFRUBDmxwmk9CJ2jRnPY3Sx/O5nG4icXZ7T2qditAvckI1TAxr7A6wV3429m4 /+Z+b72Y0qhWOeDreBN7M16TkMOkmfAhUWlP9y3gYzfh+2J0kYRVQdwqxu13TS/bFX09 V6ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994050; x=1738598850; 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=lrZpQikn3aM6B3Iqd/Ucnjx7jHzSyajd3QTmq9Vwrvo=; b=YP23k6Ht5LybWuP8dE2+q61E/01exgh/dlqFIBH6yNZXzINX2dTKN9umKzMbtphqR4 Qq524H5fjH+/twfkQKEY86/QiSx8myiK0ltG6rrH/E79XiBdyqekNoNSrDPzbeH0I+2/ akEjlx9P2FmLRxcWZ4/UJhYu0V36v4kHviU8g2URb3DPji/+HwnzPTDayS9uWiyEfzwG O132NPV8gzOUJgWdOqEjBLkQOr1seujQvar0A7dmMzq92Vb84GqaUb2NqnrwTyU+Pk5A yQtaCPvQklZgjxvCaTEkfWwMsccCpEsNzAMtzKK2kC+MjarYZ9muCDFXr39ErvUlgPPE ZtXw== X-Forwarded-Encrypted: i=1; AJvYcCWLYTLmaBxhfJQ54EVijvICczoe0Ktxi89Zt5tshUirs55nvcyXjjwmwO/yNwRq8HGRp9klgHE1yQ==@kvack.org X-Gm-Message-State: AOJu0YyjgfTDoeo9mGnPl6vaOn4rCAc5hRPD1tLFd/5F2Hk0JDSxi3VD BKSV05pL8EORtmGnZYs/Y2Bnsj5d+olYl9piwN/oirj1zArcRAcY X-Gm-Gg: ASbGncv+tYh3ZtUa6f+yeAeJspaW73qZ+vNBXJI8R7i9ebPsoHzWRhmSA3x4VWgTXXt XWIalNN+leYNG7klvdS4VWQzVApasoqsMRvnQOfQOXUoUbKqnbESWwYauQhK8RYjPO5ny4Bcs+M ns0Xq1UJVQKQ3NypedC6xAgV5E+B9iJy3cSkNYNvF/XBJ6u+wt+l902r60udATUinNFLwVjoOlK YeOPl3QpHGCIuG1k8hA3BAENzIT+tsIDGSGXdTL0a+WuYICxAMcCMB9yUBdlWCeXqtzBOmdI5Zp j1QrOISZjLqLXg== X-Google-Smtp-Source: AGHT+IHVilwWp86cIXuCPcSCEjAlKAPSZRo0H0MsLWLvAzoRKeZuFBp6uVwp/VtMeJUTjVHCLgUcfw== X-Received: by 2002:a17:906:4f8c:b0:ab6:362c:a8ab with SMTP id a640c23a62f3a-ab6362caa41mr2246025266b.29.1737994049651; Mon, 27 Jan 2025 08:07:29 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07: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 , 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 v4 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Date: Mon, 27 Jan 2025 17:05:10 +0100 Message-ID: <20250127160709.80604-7-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5BA5716001E X-Stat-Signature: 61cxer9dhch4scyjgtaek6obyu7pcth7 X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1737994051-156138 X-HE-Meta: U2FsdGVkX186jH/9Ou5PLbi/PymUThTh7l2QKdP0otneBHBNWI7GybOIB5v6wjC951RHKs/Fa+rWVPym7W8w0QRXxm71v+92CulmEKQztYAIGaqv8za13TzrWQgGBcIwx8UiTjqvMwOyGdoNo+0sqwakl2WIjXBrmeqnATCblTNW8IQNS0R29uKDWYUIqFY4uFD8xmR+NS5gUIn1/sth7EWs0iLPtUKP7/N63K5GweJ7cNZoW5gwqOafLJFSmZaw7lRONHt0TzjmJj9/u560hMT30Z3aXh76vtUtQ9Y8KBH7vgYFOkzlAyfIqsYfXsVW3aoGGYpKS7FZmt8O42WhJnUGgo9QfbOKB+ZSQDiAdtxCN66ygUMt2UNEAlop+UYFLLvUcUXHxd3HNMK3KK6tud2O3EB5TBPzs8BZU8GZZYA/gbRc6nF6hAZVMTWkCu+PZtA2jEMskRM7pTHk6MRQTy8BDlio0bEjU2XaG1lL/hFOt13ISy9U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pLxYQDni+Q/Xx5DeUpebDKkokIqdmXwIXlJ560U2Fn2Nf6hGkvHxgM9VLmJcrsi8KZ/pdGNZ/UINooPeE21LWiiEBbykpggsjHl9BGLDrj0iLeb8scNQg+Ctw0MhJAmUhR4Tbw 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: 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 --- arch/x86/include/asm/percpu.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 27f668660abe..474d648bca9a 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -95,9 +95,18 @@ #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))) +#if defined(CONFIG_USE_X86_SEG_SUPPORT) && defined(USE_TYPEOF_UNQUAL) +# 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