From patchwork Thu Dec 5 15:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13895612 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 1DAA2E7716C for ; Thu, 5 Dec 2024 15:43:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B1396B01AB; Thu, 5 Dec 2024 10:43:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 73A776B01F7; Thu, 5 Dec 2024 10:43:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CBEC6B01F8; Thu, 5 Dec 2024 10:43:11 -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 226FF6B01AB for ; Thu, 5 Dec 2024 10:43:11 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BC5C71C84B8 for ; Thu, 5 Dec 2024 15:43:01 +0000 (UTC) X-FDA: 82861323258.30.3C3479D Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by imf06.hostedemail.com (Postfix) with ESMTP id AD5FE180003 for ; Thu, 5 Dec 2024 15:42:48 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TH8ulI9d; spf=pass (imf06.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.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=1733413363; 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=LO+TOySxT4HwHfCR71XNsU0xJM1piGYnmNKa3hb0hwgEz5W4V71YWAQv+OGhI3n2//QHyY DFhoTNtOaavO+B+xJKkfqRLz2VEveaAFhzbfgW7ki9RQJ4t5krT1O9sO+MroSY5AQ0N7z2 Oubxsetc/6QipDzvMNkL1RVjEarFai4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733413363; a=rsa-sha256; cv=none; b=LLSM0XcqGrz/wKT/t4aecr/BrDFAsE7ivPLd5J9cb7OQS0zRj6IN4/JC9aVRrfNju1nSW0 tR36fLA4WIEEmfwyU5FLKE3eL8d/NrUIFnspy7lI5qD34s0rnS4INojgziZwGwgvHahW7p 8Hq/RljCh0BL409kBEbjV42ICZUdf+I= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TH8ulI9d; spf=pass (imf06.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.41 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-385d7f19f20so530397f8f.1 for ; Thu, 05 Dec 2024 07:42:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413378; x=1734018178; 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=TH8ulI9duaE+xpI4vDEJEdxVPOhGW9BNKSaQHIzLRpiHYc8mHShktB6G+1TqEb9ouc ISkMfPxETwnIHQJs+bdV1T5Acilx3o6LyN+IWDoal6k8MrpxGgP2DwOnmPTSjWSevMRI VnJogQfvoEK74ydZpHkJ8KPnOK7/UfG5RH2UNQEq3UrgKQizDMl0DvxJ/BJdJ+PNgxEa V1R4ZhCUgXvw7Z0D44IauIrAQTdCFSdddqojoRIlY7P/qhC4sGdp3TCxGemR40AwsSpS OntFPGZh9DhlpZdyJsWMnpuGOhtOBAC0KgFemzdbY+jgCV1CK5XTyhmF20NBeKKBWvSX e48Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733413378; x=1734018178; 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=oGqxqkwsvXbEGRGaNzzNqgXmQtcplWZje/lneoLU0HvmP4H+LK4GXwVEV9stFoE8mA Bixbr2QnSS8tX6bNxNvSuq+wVff0idE2+3Zh+q5DVLR2NgIIE4EeceW19TzAfGw2od9u SFu5wQop6cC/awecQZAh2jSXZhue4nxFMunta7V7+t6kBFVdE0uL9KUuBeE3P1VlCKJh X2QPf6ibx6wwQvn7+YD4XS3xbbchV4SKxMyx7BJjDuUXOmrIxfZOEAl0+8OwmBK+PxCk WK8uq/TlDFvsk02IO6UQRu28m6eYlPBB5hzv59LpPwzSpDMIF4z8RbwVS4tAP52pacDu zqBQ== X-Forwarded-Encrypted: i=1; AJvYcCUFZ9gw4Dc9TAtBSXsH2D9rIRKKwnugdKnSdW6oUEV8m0wEw5yImgxHGX6bZbPHHvfeDU4JzgaZig==@kvack.org X-Gm-Message-State: AOJu0YztubwcjnKrYT4L1o0nZ/9eErJSTBM+fUzWTD5p2T8hpMgOGu50 BLHd97f29yYRsvLtOal5ID6AIYBEUUGGbsFuC0E+GgZ6yRS06e9G X-Gm-Gg: ASbGnctd1jYeLKPUx9AmFY/I6IEVUONrQWKLeCnxUbSngRtPIkEAOinIPHzyAL8Ki3D TkdKJYEtcGirkIqeAUJ1xbXkP7d9j3wzb1a1fOlT97MGf1DO+EziiOEAFnM5GSvhkbQ0REAgcMT F/o64ntmJidJCVHCbIeixRLR2sNnj2KhRb05bB/M+rty9miJgyFUROWnxVF4GiJj3f6x5gEo+1J daCOrTxLKA7+vxNbHY25C+wZYT31uKZZQ+Ui9viUrNVhnbNUVJQOtYZrOc= X-Google-Smtp-Source: AGHT+IHjT8E7BvyXoaNZ42se9YSKI4Pj1z26eB19khUL1Wi5cgUCpT69kmrNNvwAPzpn4fbartlnOg== X-Received: by 2002:a5d:47cc:0:b0:382:31a1:8dc3 with SMTP id ffacd0b85a97d-38607ae5ee6mr7265481f8f.35.1733413378249; Thu, 05 Dec 2024 07:42:58 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434da11387dsm27020185e9.30.2024.12.05.07.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 07:42:57 -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 v2 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Date: Thu, 5 Dec 2024 16:40:51 +0100 Message-ID: <20241205154247.43444-2-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-Rspamd-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O1wfdKtPL RlFQR+Qa UbDQzNekPnDPPeLgvaK3bq4SeI52xOxiL8eZDRCdeMOJdcb3HAe18QsdPUhcb64+WXyqhWjkgzqlWFAY72RcaDhNlFte1b7fl00oNWeYET5QtHJpv7F5y8H4HFcT2tdfeN7eKTm/3B0nlV18PTtozhxTJEPx5XESkojXz0Ebm8ebgzrzGIrocG8hTqFP0sx95MSPEogLSclYLgl6lYjur3J8wE7q2DJsyssnYIZX1en3vO6E02P6RwWQbi/JB+eY2eCp6A/yrlUu3jolvS+mBxXnbizjAvEjsc7G4JWm/Lxgz31Uic0MZpliA4/Kdp075qNbXsQzSOU3HcZW4gEuood9htX9/+8h6SXwTVKVj4MuZJkK1UPSVk9Ci+b5S519DofikthMoFMrwMLwxi7VmkR5oAXFuy1Q+14OhPadwqXwGJUcEGzLLpkckNBcfrHXdSuU7S3db31E2m9bEw/pi3CdHO20PUW6hPWKIQscW7rimW3pZ6w85BUvyg88tqeaVkODkqktgyP1sqmccnQFlpJc/m3HLgnbvarOG34kdNP8TEq8Jt1aYF1BFMhMoQd+5UTTDayKyje5VtfNfg/y6ecz0tljYylKMAG/K9wozKB74tFrtV66CZp/5qGPmU/Evv2vhKKky88lT0KN3jbG8bgzag0nkOMhS2VE7Mm92YL1Hn6okKYlsNa3ZXANLcluKCK6dTKmj/WodbSFZj5xgzniokXAiB4pv/eQRGmLKbitqf5Ig/QCBu9KbfmN+s+INAt2EUHfaCvJFj7MXjIRUcWgAbg== 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 Thu Dec 5 15:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13895607 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 24BF7E7716D for ; Thu, 5 Dec 2024 15:43:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC0906B0176; Thu, 5 Dec 2024 10:43:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A48036B017F; Thu, 5 Dec 2024 10:43:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84DA56B0182; Thu, 5 Dec 2024 10:43:03 -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 611776B0176 for ; Thu, 5 Dec 2024 10:43:03 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 29A6C1A1702 for ; Thu, 5 Dec 2024 15:43:03 +0000 (UTC) X-FDA: 82861323384.24.51EF17F Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by imf01.hostedemail.com (Postfix) with ESMTP id 2E1FE40016 for ; Thu, 5 Dec 2024 15:42:48 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=URVoHoAY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.47 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=1733413374; 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=G+7I9gi8mucGgoO85kNahA3U27ot3S0RhfZIOhPcQEg=; b=lkSxWVfwCghUpOG0XVqAiEhpfulYyE87pr3+GoSUkMfeRMxRlsn8twTk/470LUJyXuqmeR 6mln5S3PfxaD6AtXm/ZsC0pwT3c3pGIRSSwLZuRIVacU+L9lI3Fz9NDLxOD5i79Q2VUlnZ pQ0Oz5ctVAXtZVKvbM8R31wEbeXzJH0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733413374; a=rsa-sha256; cv=none; b=1loa+ZP0yxd2yzsUkTYxtoJe8mmQENY9TlPLXMuEHh3H5Am6uafVklA/B1fB9ClLRbGCa0 WkC9vrVII7wzQvmDlQQu1rZWRhM85oDCxR5W7BHfwPl85nFXC+eQNNvj3+dKrRHBrz7v3k Jqr8cJGRZt3LcR5UjmX/B+Xsibx8gtQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=URVoHoAY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=ubizjak@gmail.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-434b3e32e9dso11390175e9.2 for ; Thu, 05 Dec 2024 07:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413380; x=1734018180; 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=G+7I9gi8mucGgoO85kNahA3U27ot3S0RhfZIOhPcQEg=; b=URVoHoAYc68lz7Aldrd/URv1D5oxsM6/DeRkJoI0jNfoRtxWefJ1KMrWZvVaUWZfJ8 8zWrNrrrjXF2htFhTfsKh60HJBmfw1hYtLDu1TjBAQpOm6zZhWyRZbKbU+vRbe9cnEEP lXtMeQIHVlCUXblmtoE8PMD/OEYcrDVYVf6TcEH3eGW7mu5aGm+sa73ZgDvElsdJy9/W tRmQrpOoUAJUkvN1nGRy6T/4Mbldu5+6pkJHc5DiPMYToy0r6nAQL8SQM77qxUPvSYf7 5YY9TrEZzldSQv/TJY59xPjPXs0k3hTpcHFJTfsJkdJoqSOk75s2FcMwjddQewGM38HA tvDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733413380; x=1734018180; 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=h/jrX1ZC9MKB+FMo5RxdUBVTwf0ywanTTTu/CZPWLm9byLhFp3UkghJ7MCKyD7xA0O UTYWBfcNfFarYM0LGQCd55mAc80+FvVFu189Uh0Q180Ze1AG8Hk+lkVH4mfYEmknlNvB T8lOJQ01Nkj5sHChDz4SzsQqttAZO9DZGz8rbFxdqxb3UYd99UWe8maCzM0vSDfJKhRd GoZBOupqW93r5XzzAbr0lxkYsgRaIa1lb9Kafeu85u2FVKqq4+cfcPKxh9UOpjqTzCuz Lf3/rfaN36TM6dT5hboxGZaGFmmi8C4cqF782PbJsOqpPmW+Wdkpm1rIPPtX3V2IIJ+0 MCwA== X-Forwarded-Encrypted: i=1; AJvYcCVkehBD4vUCG58odq0Rh7YMTGqJ7u3Iqbj3NbNHpkxoMqsg2Xl5zwK4aKAt3BY8qGd2nPDfGHkZhA==@kvack.org X-Gm-Message-State: AOJu0Yyv90T9RlSV2M+8tSGRh5RwrtxOPsO99/+6ikyPt2td2V0se44V BsUAZftU3Z2Yz3FOUXqXqYV+yTdJf4jYiHPNK9TPSBjlXMaoYODI6iFvlH1W X-Gm-Gg: ASbGncuwu1WVeIMB2StN5IXniMJabXVHkoue3ngUBjEc9Yjp4ZM7yUft1XfNV7VdLeT 42Kd8xSmjPEj2UYafDKz7z8iWI9C3Yx4sB9lkbq0mcSNAZMEykXcpHuJcwfLyuJSslV2OfI70DM Tc8VRMLXol4fPiuVwHowKCaQqIg7bOuFI3A0XtpU1rZiNQOWV8Tb0ka2k60XZKAQQvOfuVo7iCI 6YKGtQq0Z1RYq4Y7/3bHEo58b1XbQTFx4xBda0wQQEsAg/QMbczSpdfPJw= X-Google-Smtp-Source: AGHT+IGfxs/UDP+NchJ2Ajwu/cJXwUlfvxqHc9BB8+DQufR3ysgRKYw2o+8A68R7dOOef3F4mH8x2w== X-Received: by 2002:a05:600c:83c8:b0:434:a962:2aa0 with SMTP id 5b1f17b1804b1-434d0a1533emr87442155e9.32.1733413379677; Thu, 05 Dec 2024 07:42:59 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434da11387dsm27020185e9.30.2024.12.05.07.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 07:42:59 -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 v2 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Date: Thu, 5 Dec 2024 16:40:52 +0100 Message-ID: <20241205154247.43444-3-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-Stat-Signature: rkwaacac3nnf7ryhmo6kwtb39u39qkn8 X-Rspamd-Queue-Id: 2E1FE40016 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1733413368-984325 X-HE-Meta: U2FsdGVkX18N0E3XgiKdaYeeztUhwxi9LX6uRsuLjrHQ4OoBVC7+QhbljjaZjDaD8xf/weLdP7BvF2DJscMCgZZKf+Z3uvhnaUapnY1IuZHxJxWjij1BDo9qHyYazJokVR/GPAIkgV/U7LsWj0v+8wgjDJuvmWigsWT6ZXhiddKp5lLMk/Stif8mQ2O12NzvI7PVq3Y+h7xqBdt6Z8X/LFTr0TZfyjjg5ws5GZAcmplhvvzDK4P5xJMm+h899SJ0sHiIfhntI4meKFMQS2CgR6IslfbaUqzyF+Be13EDgml7ZDUfM8ecPATzBXIRTsCYcJWMx+CWNouXkIcH5TibbYEWD/pQ+HctqYdicP3IpJLh0coboibhKkoAQMqF5CbyatxZKMNJvR0Jw5I7taQCuo9gDkhjkvltMODrQdiJ5NPciOv2p1seYyAksyq3gKhvZL0FiuiE8r6hSQjyWe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AXG2Ir+3k7gmkJ4eO8yW1x2POEVnTwPoOrduop5gqx7VVyVLc5iSqiqYklpWAfW44AzoeM208Ekj+hnN6VQUuHTs9RPQMk57mvALPNTBtjJuNT5NutDkjblVsAiET2nvcU2FDCeSorJxGTJG+JswbLCKdb4bouSmhE6jN7Naphudeus+SM4L8gLc034uZBfRskLuRhgHoNpx/j6cMwcC0iM7DEAQClGo3Gw== 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 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 Thu Dec 5 15:40:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13895608 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 AA0F7E7716C for ; Thu, 5 Dec 2024 15:43:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3934C6B008A; Thu, 5 Dec 2024 10:43:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 31C0F6B017F; Thu, 5 Dec 2024 10:43:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D2886B014F; Thu, 5 Dec 2024 10:43:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D49E06B008A for ; Thu, 5 Dec 2024 10:43:05 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 24CFBAF475 for ; Thu, 5 Dec 2024 15:43:05 +0000 (UTC) X-FDA: 82861323384.21.E9851DF Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by imf02.hostedemail.com (Postfix) with ESMTP id CCDE18000E for ; Thu, 5 Dec 2024 15:42:32 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jSkcg1fS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733413368; a=rsa-sha256; cv=none; b=L4rfArwl6EI0LSWSTDzFGnPMFd0V7Ces6Yzud6xk91KAoF083ebESI5/KqTUtR96y6r4yW EGUXBUyRwPPOjTNcGlqSv4Qa8Gku7YGeCUbKJ29S7vNg03RKNbI0Qn/a3f2h9sbc1qXA6q XVlWmzJWQ1+ohyTMpN7PDe2mJ3yHbn0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jSkcg1fS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.44 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=1733413368; 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=ZP45adl0m/JgLHunU63kkKsbCdYBQc86IYFQ7X6p794=; b=t62GnN31QwwfkXF8ndIa3Kpj6Szqaq7HFhaXiOyClcJLAlld6g3G0BxXVbDUEz5sx3W8fl LWUvhkEiBZbKNw0OOVrSNN3EyKdtjyHA8sGFuEanuScbzXXjOM8zlUwuDTRauyjc2xTMzF iXS+w39wxEdzhKnxSmdPELLPlSLxg0M= Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4349fb56260so7447815e9.3 for ; Thu, 05 Dec 2024 07:43:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413381; x=1734018181; 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=ZP45adl0m/JgLHunU63kkKsbCdYBQc86IYFQ7X6p794=; b=jSkcg1fSswGSrPmjT5K5EFGH6lWKSHZj5UakmpibW8d+e32JwCJQxepbS7rRIdtikT rL1xoqc6ZHtBRqlZwcCum74DsEqlBwqXkisRwrx24CtDCgirMmTIJYL2ulFdAMeoiidT GqfKbWBW/Yp86Z2CwaUfG4iqT4fN+zJA4t2uLzp5uQDyH7ORphRbKvxzxTr0HaynqzjN kMWbhr8biagBka6qOwKD2N2mruixBl6rZfZvBvi9M7cB79wM7t2dNH9ChdzU1jqFdosm xzeKFaaZR9YLD3rwplV81lTze0tNhEmaS/QHdquEjJHa5+tkdTHqny4BZA0nr1VWYV8C dDwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733413381; x=1734018181; 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=ZP45adl0m/JgLHunU63kkKsbCdYBQc86IYFQ7X6p794=; b=ZNlag1/HkfGAZBiSY1pkaml3HilE9CemEOOO88jQ+lhfhL26s+P+a3AleyBaIH6T4m bVaiVIHaDAPR5hLAZ2LUEBT4IS2QfkeuyREqRZKFIpRND2mOPQkbBwuRlJykwj5q6DEb F+rpqm2SyNNo+/5zZfn+O5qWJR7EJFxHhstzv1q7XH1XTeoff2pMSv5clPlM3i/K+V3Y 1F5nkoRiRW6OiUDMADA6XizWwD/ny0+gAVtw+pokEcLDAf8AwePl0AU+QaABLNkt4Mpn tN8lo2pfi12xLkbgs51Vl979Jl5zIeLltxKj2Yha3XWAYh8JuxVhMPG85pnGpN1oG2RQ qWqQ== X-Forwarded-Encrypted: i=1; AJvYcCU0DUraSSBZDVmcTeZ+HjociHZDvWqx1ci3GmXh07idrGTDyg0MqGvyELwiIaiaFKdoDBNDYymeIA==@kvack.org X-Gm-Message-State: AOJu0Yzful7sKojMRo0HbBkb3OJ09Y0xmxnbiCpAkH4NQDxK+kJnNoCg qgIO2doO3mXUYLyJDB+RwKmUx48pc62rM/M10avnXL4rWr7sFEVP X-Gm-Gg: ASbGncv6KNQihVVAAaJuSnFJfongWrH4uzqAXUqhXa8H9eqVoCl93zhJ99duu7JjKRd 6CouANxSFKdCgJtSvr/qnMSdNc5Hla4XZlaQ478CF8owE+wzV/lF4MxgViDp/68EeBgjh9Q/fsT s+1+pQjlKGwvt44hn1Cv+FNz/6FIZToqqwVmCwZEbW3GDLoohw8kIR2FwrA861+xPo29yQ+7jmU kIQLR/KvdIYgK0vgYcKWfbr5muyBhmh6okx9XgHm7UUUoKLOba2f49/bjc= X-Google-Smtp-Source: AGHT+IHlSg504pBumLfceXQFWDia6MAuCEjJGazacj++iFQVK3VDRzhe2tl+FybaLA5HFJZH550yXg== X-Received: by 2002:a05:600c:570a:b0:434:9f81:76d5 with SMTP id 5b1f17b1804b1-434d0a06619mr87843265e9.22.1733413381210; Thu, 05 Dec 2024 07:43:01 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434da11387dsm27020185e9.30.2024.12.05.07.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 07:43:00 -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 , 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 v2 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Date: Thu, 5 Dec 2024 16:40:53 +0100 Message-ID: <20241205154247.43444-4-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-Rspamd-Server: rspam04 X-R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knPnV 0SgDFZFS UDDyjoAuQeF5GUNMiosQRoUKxNXKFmmhypCLRfNreZ10lv+54o87Bn4jeKcDeC5xejklxau2r303YvjWeBHfLUHiUIE0yBtGbGQSVGf2ngaG5xvYbWzIV0mbQgFxjmxYuB0Q0xBn40dtn2glwxKWZndDSWqK02tWQUQveFcQOdh8FNpzKvNFvPEm4b4KbwIHzpcBm60VcQEnLq1OtpDXSD1h8EbzjI69V+DZjdt1KdMlsJ6+TbOHyoTbfgWj3XfA1UgIKgAqhLNVRdtHkVCjQ2pelx7Vlgx/Dr0H2sTMdyzln2gB+ehSl5bxmPmuTShbTBZ+XBRqG91DAKDb/jHT+uhkE6+31ReqqsE3Qmz4uTHxvgGRu2z87ibRvgxXcOogqbu+PtL83DChKpGUv52oJvSRor0ZvVBNprG6ISLRApeTDNOQ9OYzffdxosJybY8cUHc0rXyOeF/EpOUyAG45I6uPM0zz2jyHY0FQCR4J9FAFRE5pji1h1zNofkFnu+E8jo5DjkJel1OVcw8U2XzkyTLTfW8ZXM3ldhmSzGUzgYio3WZ0Qvbg8VseEvtYHqPCinVPt9ffz5u+6hvgI29l6ZDM+VjBN0FriV1puvWj7+ZyO4MuhW3czXOnaUolKDpwjpoMRRkSSojXMXRGSTXu9CSS5/QrNN6EbdI+v8naxeDELOJtDZ7gqIymHRz2ClQkmjqWbdpasJGuDKA+2/i1mi0lk/tYTw2FaBvyKc0j4pa6gkBIWKhq94gE3Qr4uLr2Aw6BZVlAtAlIdnbAnYz58JpMJVQFPCLxLMee1deJNRX0pfA/mHXLke9AHMvtQ6VzUd8fFED0nqGscbLpVESWvnHK/yDXLNrwbYL3VY+CDTrAftJlxe3CtR0KUJMuoGhri88UdKwjCfmS4BEv6R9dvHgHknNBDvE0+UuPC 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 Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter 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 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-Rspamd-Queue-Id: 579A712002D X-Stat-Signature: 6d9dcbbzixd3o3xioojyxmipqnssu8uw X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1733413362-778183 X-HE-Meta: U2FsdGVkX1/F1gHvPqVqbc+Hu6vh3feNscKsoxGU8I5c8+x/qMH0KHPLChkSeyR/X1qedion6ZvkuXLYjQxxf6E8O6nzEdnLSgL7KMzSuj7B3AzPKkCxtcvQ5NnfXYDqVRfklzwIEV0bniki0QiqDAyVYeNhbisU4iBHQW99c0aBRzVuLk87KK23YcZcnX4HJrVxFivVVL4Xy2TbztQkbRyc5ADpuE6Kooh+ryhge0kv85tEu0RmAxjwwszw65tG//T4zupuVAulnQ4OevylxerlbWfq3rtczCDl/qiArIj0smHrZ3kvwr81Kspp39VDwLMhE6tyqcDFIMABYZW1cNaSou+VOiLjhOkWGrkgdhsmKeFmMiTTMUYHrDW55zqOv2McGe7mZtxHl3GrRruv7JQSJZg5Ka6nU4x5osl0So5cWj8DS5N9CpFCvLl5FCCvLXi/s67dTJshgdwcu1kCRm5cGhNpZ5CVxfSBMAtOCCoPNw/Tn8vaOdI4Pnnp5VNpQm5BaeK002zdwRknz3SG84AlH9+xd4hk8mcXEt4ahSO07/nsLqs8DmuoO7Lj0Y1mdPESI26iUWmKdVB2WlV5zDdscwLMkRFHP2nOoGuVtw9XKHA4Ov3wzrpPqhNMXgtyglwKIarcDTjeWzn7tGukF5Rq40NzcEzgOpYmeSzg9Y8/8V5/Hz8oJKqxrbFVlsycJLcdxXauJeJJvRRkFQA8lMaTKOl2wo9qsrQiNYHME2xOtbFRcGS6tMiz1zjMXEq2/r22oi+TzC+YItlV3V/Sywdz96guRPegiR6HqkF6dSNFBnDWu+Dc48snxW5UFn4Se8T74zZ7Xjl+K+4ynJu+HeQ/w2VJufIXhO35wNuoreFaC9Go7YuWIeiC+6b0YcEpYqM7uaY62JL2IXD2o57HxTrtjphakxYYwmDMbTM+wRzawGZHhF4J4whAb7Iuur+ekTjRrug8qDBEM/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 From patchwork Thu Dec 5 15:40:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13895610 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 11F93E7716D for ; Thu, 5 Dec 2024 15:43:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA2D86B0181; Thu, 5 Dec 2024 10:43:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2D216B0182; Thu, 5 Dec 2024 10:43:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5C696B0194; Thu, 5 Dec 2024 10:43:08 -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 8F7596B0181 for ; Thu, 5 Dec 2024 10:43:08 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5160281425 for ; Thu, 5 Dec 2024 15:43:08 +0000 (UTC) X-FDA: 82861323888.28.9BBD1D3 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by imf02.hostedemail.com (Postfix) with ESMTP id 22E288001E for ; Thu, 5 Dec 2024 15:42:35 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GOasxY6X; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.42 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=1733413379; 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=DJNYPM738NzsA6HHUsuEIDtHtfWH4Z1j0zTSwQJI8Og=; b=qozSEuKsKqXSHLAqKpUnhyoYgQIadPy9Rflk7bNhoGhzdvG9RBADMLEKK29jmWBqTtFWoi O/KIYNnD7guQVmvDQkl8mksN82k19QrkOriuqNOWU4q6X3TyAAX55Sy8p4TJz6kmqwyZNh ZtJKU54YLOIp9yGBwTcEMVitE8tdp3g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733413379; a=rsa-sha256; cv=none; b=l3Z/S6+lLcoX91qHCvoKqfaNXpfpW62YzcBddwnqKvnMYHLfLVw9zHe3jyeeQmhVD9lpOL MuevrQ3MiTOlz1I69PEuAdSaOPec5+GAv+oVeSHjKtMkBKPMgnozvRGCFe7I0w+foCjxML Qu2QF3JEcUuVAjvuD8TI9oEdzpH1/TU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GOasxY6X; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=ubizjak@gmail.com Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-385e87b25f0so1353314f8f.0 for ; Thu, 05 Dec 2024 07:43:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413385; x=1734018185; 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=DJNYPM738NzsA6HHUsuEIDtHtfWH4Z1j0zTSwQJI8Og=; b=GOasxY6Xu9dc08icAKgeuHAWD6uc0f8YF1JvK3l0RfYBEi6vxPL+YEfC22uM62xdpd 3jPZU6liTny3Xk8/D8vQUyiLhWj4bAWUXYziN8sTVhrGmprHQBie5APk+2q5evgk22d4 +lczzf/vsb7cCw2CzcZRDPpb9Dh6u6KuG1QBCQqfZfMSY/eNIopi8neMraFgoWQpVokF Ya3TjPLEk7DVrccP5rURt3TLfIZP017oJQyBhwd1/lAzTqsX2e9nEcNSoeSoHwIrhh8o r8F9BH3oUrRssZ8Vo9lSrTIJSGUcpqHNFkUGMORkwcb36TeoBHDCKz6dXI7ukZm/ThR/ tokw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733413385; x=1734018185; 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=DJNYPM738NzsA6HHUsuEIDtHtfWH4Z1j0zTSwQJI8Og=; b=i3R8t0tLzKKYg/wgdBkQ0YAkaYoIDW/zN+S0jQ6faxNnYQFRMeZn7AD7zId6eGqVJh QhLiNTGU8P3SNw6Z+2aWJYp60CJ3uDU8vTDInKHF0SaGX2wEqf9Xrz6/ijULY9eh9vYB lqkHu89384a5l+b5O47TcUn1lYpYSPlGUQkMkTBOTeorgD2W43c16MkI2kYN87G3b+Hc /+L55IkWb6/4LxXVNHY6mXW2Yno+KgQthzEU2tv0XPZNosX0cvFa6k2aaPH86KthD/Z3 VVThP3OcbKji6yCtL73HIeC4SITpSn7SqCvHx+ihTNRsxXH5DOLcKWHlYJyAN0BE/5XP sjdg== X-Forwarded-Encrypted: i=1; AJvYcCVFp1QLBXqj3kObi4mtMUWgZtSert/tgjsREnmC7GCBbCjqqxDrHAlqbMwTTfiFh+6KchjFBAbpBw==@kvack.org X-Gm-Message-State: AOJu0YwfB+JY0+nZRASkonoEVrWQYBfGqPCTkOIxWZDJqDdWCYw5SJH5 YhiAj0GM6RSXRpUIR7G2Mr6mNe4MnSs5Il+dm9BeqcaK3VE/1SQd X-Gm-Gg: ASbGncs1gRAZ5a8Pn4qLKZMa0g7rk5GNKOREMyg+9ox7htccNTv7nqYN01ooEwaAsqF PvJGmyAgjFzTAYm7ndK/qjZJNLN+NbGr3g1FPckjnJufiUvwnH43eNah/pUSIYddzaIu5PRxiNG Mw/bivLNsynoSFCFcCT4wYMUI6QFJB5yaCO96vi8KseHi53onx9b3gP49vmZMjVNtD9g28ePetR 83bMgJU47EaxQjtW8YPWzrOx4DYhhDC6y0pNlF8T3oTikgmsj3zxr+iHFA= X-Google-Smtp-Source: AGHT+IGn7dKioDdwzHt7K3WXKx3wPwP6zSj6uvEE4p+BYKAxaPsN8hx7Tq/Sjh+LihcUt5zH/T9B9g== X-Received: by 2002:a05:6000:1ac7:b0:385:df84:849b with SMTP id ffacd0b85a97d-3861bb5d3d0mr2805156f8f.11.1733413384489; Thu, 05 Dec 2024 07:43:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 07:43:04 -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 v2 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Date: Thu, 5 Dec 2024 16:40:55 +0100 Message-ID: <20241205154247.43444-6-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-Stat-Signature: jz1jwohnn4n8u9u856y97twyrcrre53c X-Rspamd-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ySEZ8Qc2nz9+GDnYqCrlM5pT4+vt0wURCOiMAZKuGzc6GM95HWhvdn31aCzOEZkvVBdhrdgMX72jdKerMTDawu91ynwc8K0RO0VQ1MyEpMb+ZRLQ1G6AWZlVBjS500pskmBATPY6SGMGOkrssBjlScsTiEMgA4JSedIghG+zEtD40bWInRcgsnQ4Ng0tD94TLk2D1/YVOP5481V0biZcv5ksYgzbn0fY97FOIw+haHovtm18Pq6KgpkJ6Q4XcND9BiO9fTn/9QZbt5O5sjAVdFaKTinEIsI4mMYVldDM6w6sCKY8bjKdP86NJhqXlUnmVo10HDBYYqwQonsDmKc8bSgLiJ3r4UG3bn3OdiZFsv+CG5LLoMU5aLr40EJt08xdGp0FOvleRFjAGCxjppb8fi8y3KV9ivXBIWqhoCCtskd3qGZ4sOxlns5gp/jEdYp+Ibcv/Jfc7ZQGT8TB1VEhhtUGjKoflvoxFWdLnE3gQK636duKvBXlgQOmm3g8LSdnbAHfHYAQakqcsHz9cCgiM3LBjT0FcIVaSkrqnSuoG4KOl2S4KORIrEBw0OC6FhPxURX8cuB6UcNsI7kafhQ0dmR8dH6ZQhsGfyIGGq1VzhZnz94WEEbVoZ+EeLNUwX3o1c5VdYCc8JHbiKSEoc5PNEB5AI0Lm9xp3xYJgORg1Zamrt6JthZODVmZUtwN9UtO8QLjmoImO5L+0nHA6KrSjNDi/pE2EHG9ibT8fUwmug4d432ILK 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 per_cpu_qual define and repurposes __percpu tag as a named address space qualifier using the new define. Arches can now conditionally define __per_cpu_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 --- include/asm-generic/percpu.h | 15 +++++++++++++++ include/linux/compiler_types.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 50597b975a49..3b93b168faa1 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -6,6 +6,21 @@ #include #include +/* + * per_cpu_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). + */ +#ifdef __per_cpu_qual +# define per_cpu_qual __per_cpu_qual +#else +# define per_cpu_qual +#endif + #ifdef CONFIG_SMP /* diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 981cc3d7e3aa..877fe0c43c5d 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 per_cpu_qual BTF_TYPE_TAG(percpu) # define __rcu BTF_TYPE_TAG(rcu) # define __chk_user_ptr(x) (void)0 From patchwork Thu Dec 5 15:40:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13895611 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 4FF73E7716D for ; Thu, 5 Dec 2024 15:43:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCC836B0182; Thu, 5 Dec 2024 10:43:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D55206B01AB; Thu, 5 Dec 2024 10:43:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7FC96B01B1; Thu, 5 Dec 2024 10:43:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9245A6B0182 for ; Thu, 5 Dec 2024 10:43:09 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 46D38C13EA for ; Thu, 5 Dec 2024 15:43:09 +0000 (UTC) X-FDA: 82861323720.15.5450A8B Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by imf06.hostedemail.com (Postfix) with ESMTP id 3C88718000B for ; Thu, 5 Dec 2024 15:42:55 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=N2AJlwRu; spf=pass (imf06.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.43 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=1733413371; 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=odscJvo7yyRgZdWr5SFETqd0CUulL/qOTPh5EL6fxjU=; b=W54Fk+MjahGbysMdUJhm1O+afqaJSS4Wf5doD5jYCF+DI1TfZBOrfRja8mxpaG/kMblhvY o07P5PEii3pU07bkx27L8dUIUECXY39vUNrFlLxYOnaagyBMphgk/cVz52/CphBiwDWlXl u6uGtYUbrq/INuG5o8X/x1DqzKXHs2M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733413371; a=rsa-sha256; cv=none; b=k2zYM90plHYDCkpKOdS6W95ICf4nETqbWB19/CLKVgZGX+dkPGRh5/jI0D894R8PGwOv7B /uCJiq/c6UaYSfj924UHcuRKRqJi8lemaUxl1C1SLvZmuL+JniSiL5HaynQjjkRRPcOXvo 2TL7f9pLKQDu+a2HGEVswjVTq3dkZKk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=N2AJlwRu; spf=pass (imf06.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.43 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-434a099ba95so11275645e9.0 for ; Thu, 05 Dec 2024 07:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413386; x=1734018186; 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=odscJvo7yyRgZdWr5SFETqd0CUulL/qOTPh5EL6fxjU=; b=N2AJlwRuZ9CtH28BbiD3B9R7X0FjAYY5JUicsGNd8e+MRW51fXSwsnuknf9bpRUZvr jeIaY+b2UZthMBxRnk9InF4CYc8HFzHJ9o6UkBO0NTR3pH3nRA7ulzgpirRPzxKQ63FF 1sgRu3FzallCDwiRk7uBH+GCpnOxbNQdm2s0KWjK9s9+c9oIvfGCYLB0xKZRXXV+cIaA z0EkFivm99KMgxw2NiO8BUn9N0eAVN2Y/PneWhan4P9qmU/+ePPTp5U6J1hi7lWKP8Oz +xtf5HkpmV1CR5zcVeY9PJ2b/VvHYnXthijS8LnaXKFZnPYlkENMOwK1CV1ZeM30lUQW WXCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733413386; x=1734018186; 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=odscJvo7yyRgZdWr5SFETqd0CUulL/qOTPh5EL6fxjU=; b=ZmYpjC6tQh/UaTOHhefAyWMqHCELuh5fJCGmhTghkuyTClZoT5x27Nyg5B5Uvkkptp TdMD75I8SQrZV6FZapU+Hr8RAbMGsPYCyR6aksRIoOtPWtPugM2F1hOWNh9UVRxg2opL /F0sZBPVjB6VhEWXv6YAbftpdFbB+vmQJjipMNQKvE32D7YCwh/OCsgd824U8Gd+LZR3 L7QyIrABkeqp+qZJgH1ivpfVC1xsPIkE+w4s0s80EYNj2EO5onJrvpfg0JBhPes0c32r AiHeM8SW9sT3HxQNqgLwdsW4NfG//PI5rKtKLwieFBOHrL7iRmmquWr2h7o7V/dIup14 KL0Q== X-Forwarded-Encrypted: i=1; AJvYcCX3TRukx5QVQpN81q7SXIW+vy47xUWowipxIyaASjQWaiAiPDPXcSCnDHY659khQdWkCIVJw0waxg==@kvack.org X-Gm-Message-State: AOJu0YyKq0uoAODJZMLOkYN5xuogqDOLto5nRZp7jZSSLtrqk/LLahLI Gm+xxM43PgQhkZuA8MZEbg86Nn4JjfNAIB20DFdKWP2sWTB4DWp6 X-Gm-Gg: ASbGncudJ4rWB+B1U9PlFzXv3KtDTe7Q7x6zGCLsdxR6Us7U2F5z02r+uJr9hzJwQME e/BG2Du23vkAE5wz8lvE06pfchD4ZkaBoQKy9zX4dQSeu/PHkk5U/5Y2+jTUGfG+v6KLLmOxr6O Q8Vt7rzbCKcn6aMwFId3iXeXanscgomD0lq2VHDZZF/SdZnwJ5IVQkrTlFMJGBYGQOMZ3DS49rW OfflJLFou2XoyOugZ/CmKeitQb9jfxVAB376QiffUi4QPHu8Upt9kYbCyE= X-Google-Smtp-Source: AGHT+IF5RwdGt4iaJz3BNz5kdah1/Sk6wyASmafTW1KvNAjQ+M3+nH5m+qMafwPkfEqTJkWyuAIxsw== X-Received: by 2002:a05:600c:19cc:b0:434:a90b:94fe with SMTP id 5b1f17b1804b1-434d09b4fdfmr111120535e9.10.1733413385757; Thu, 05 Dec 2024 07:43:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2024 07:43:05 -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 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Date: Thu, 5 Dec 2024 16:40:56 +0100 Message-ID: <20241205154247.43444-7-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-Rspamd-Queue-Id: 3C88718000B X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: wcdkbqetguuhyesyjjcaqobg43uxy94s X-HE-Tag: 1733413375-369758 X-HE-Meta: U2FsdGVkX18o3kcUm43ybkcMobupv3pYUvjindP27rmxXJIvSwNifjZTxyKyTNEl0b0CbqJOo/Af81P9IM7HujwSEHUvqQW92jZZkDMC9WiJnR2XNJX91r9LY++DbupZSRclDfhQnz9rWs3rk6nannuxEDF9BrFq4lenn4HZ4qrj2/zpmHnhq7+eTGiRLBO1a23mtjeIQIpjW15HjKxuRK6XGxXrpAu4H4bGCVS4U0HISCpfdC3m7+pR8vlo0Y5ToxCqwjjpWurUnwFK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RnbpHthieztM9j4uCjDoBrziUc7224brHrvik+ceJR0JqqDC0Qt87hu0avgDjuBZW+yw8uNVDyussVjjOIEa4WV/7IhysXOEWJnCtkTzzof0UW8a0iZGCfVDPqS+oFATCnY6QDhXAaShRhaj72VK4eYyDsWgAa89cApBcVkgv7n2rEmP8nvjseizVAbOfeJr/rErH3JIz4bza2Oxo1PI6Tu5v06L1GZfzkg8h6BZAhz+VblNzRTE7JDhO64C7hQx2daO3Ygn7ET3RsxYktJ7vlRmsriSq4Cpvvbwug/XcLtdSfbXFL7MKCuzIe613lnmUgVXn1ZT0oYDbCsY6Q68CERW8UG+kaEmbnQ4J56msLPZow8x+TJzcJ+4WCaA7yhvYLfalLBGuwdUK 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 --- 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..6be1eafa76ec 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 __per_cpu_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