From patchwork Sun Dec 8 20:45:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898661 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 B713AE77180 for ; Sun, 8 Dec 2024 20:47:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22BFE6B0389; Sun, 8 Dec 2024 15:47:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DDC26B038B; Sun, 8 Dec 2024 15:47:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02EE96B038C; Sun, 8 Dec 2024 15:47: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 D555F6B0389 for ; Sun, 8 Dec 2024 15:47:27 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 773C1A0632 for ; Sun, 8 Dec 2024 20:47:27 +0000 (UTC) X-FDA: 82872976746.26.3F7F743 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by imf30.hostedemail.com (Postfix) with ESMTP id C170A80012 for ; Sun, 8 Dec 2024 20:46:47 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EKTFDs4H; spf=pass (imf30.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.48 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=1733690836; 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=0Q1htcIuRyezgIO91i4eIT4UI9eyj4pep2QYYoTXvqX5Fp2DtLImWEBbLxP1+JZ0sH3vzz 3gWINvu/dETpVbXUdRc+Wk48c2SKmlOqKgmJ5cmO9oLgzxeF3ReXYt3YOp4YuNhHQIin0A 5OeJ8ii9c5k0bJKQEkcr81OTkyU3Av4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733690836; a=rsa-sha256; cv=none; b=IJSd4/BHt5cjM5gm8kpgJCsi7FXv96S+WohhtEso0tXw+O/a7D0ljaEnLVmr40aYeyR6fQ gS0T34yfaBUy9PKherjL3AVR6Pmu/jMnsXFbWT87p8+UrQkmT//m5yHTHKbXAiBiAEC47u 9hCBOp4VwqQ23bbnkH1hTtVYkUqbYZs= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EKTFDs4H; spf=pass (imf30.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.48 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-434a2033562so35263395e9.1 for ; Sun, 08 Dec 2024 12:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690844; x=1734295644; darn=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=EKTFDs4Hc5Xun3QQElEwR12NyeXMksa27QfSwtTA3aPdn48pFGuOLLfswJJ/i8VEBF MjIQOcUoLNhW7bbxQ3lXxTBB6iRpNTN3tw5CB+SbzCySXYZnl5giuc/6OTw6uXqR/QXW BWKmA7Iu8u5rIDP+B2mBGvFq81Tc3mxHkqprSjA+wMcRjcBLY0shAZUfGPTVhNaSBZ/W eQzyWQicq66FyeZe3b81rQaYcW9TCZblvbiJCzTBdROGUmpko/45VzOl6U1htkLsu5Gt 3Puinn6S3yYZ+W3sde1AOJRphhozz7K8BRjAaQIxWH9XuInW+BhwPjE2UFRagZV3yaSJ udGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690844; x=1734295644; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3PpdJnIt0LB5LuubDznUPiNtcUhO58iUpeI8CzsV/cw=; b=KgXSAfytv3bstZaRQ4RscJ6SUwIQ6UJAZ5KEFiigDN3IA/5v5wTFxkXBc0e09mX8Za IBHu10tAOXv9z5U8I7w1KiOhXuuTjeLo5SYk+gPhodTa7jGC8COMYlzscr2q9oaAU3jO e1GecWoO9dcxTMZju+hwVLGQW5NzZruDTYSDiRTkPd1SoMN6hj6WayrOUWMDERwwBcdw GNPEvyWYzI/EI2yl3/xvmMf+tHsiPwPxHDvYmIUjUbO/rWGWDuJQOU0shsThxxNMu13f 3JyFaYU7xrMiMiRhCzyAeNanBqjRgoz42CXvp/Z19yYzlPlgDDxUez+b//BAQ/+G9mhu tNww== X-Forwarded-Encrypted: i=1; AJvYcCVDi/idwK0WDiRrmY5ZPwD2RxFT1sfywj8AeiGZdw51HXO1JKqjHvbQjLJWntBO/VIeY3TX/ZJHzA==@kvack.org X-Gm-Message-State: AOJu0YwBhmVmgrX5FXuMb0t3jOCo5PXAsghcBMR4Ch3LNmMUn7nDd69T cBKSplk7JlcqETInBN0kmdzrEy6miSi643zsDg+C2HX5NmfuwMlY X-Gm-Gg: ASbGncuPHn2i3XGIof9Z0NAdNVoeYWe0aGH6ublbKndcToP9G6YPBTGZxsUblAs5FDF enIkuYLn8+ENZJRzt6jqWCnhuJkCbkUZ/WY/Tz9TEUmxnE41osUzvvp3Ozx0ysP/aheVSee/lBQ cF/qsWNOYqCbdq4nC7q8h/LnisO/nZ1jZtxZDV0lG1wgH7DT8touLm2p75vRUG/bn9f9VMMpmPr mm08tgSLpS6btvurQq2De2jNPvz2pkFFWDiThoLiGj4KZQ75pO10EaHjlY= X-Google-Smtp-Source: AGHT+IFdmj+6mXpKaatS+ZSrn1/J5DGo/OtucbepOlqgugKcinRIN8pfplGhkw0ngoIgy0n14MnuWA== X-Received: by 2002:a05:6000:1a86:b0:385:fc97:9c76 with SMTP id ffacd0b85a97d-3862b33d72bmr8784844f8f.3.1733690844014; Sun, 08 Dec 2024 12:47:24 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:23 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v3 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Date: Sun, 8 Dec 2024 21:45:16 +0100 Message-ID: <20241208204708.3742696-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C170A80012 X-Stat-Signature: 37mrn1hecwze57a3788dpcmx7puxicrd X-Rspam-User: X-HE-Tag: 1733690807-60139 X-HE-Meta: U2FsdGVkX1+0gtUrd0gqr0eIVlL56vddq6gbqvUhpeV+yAC2jBjwKyIAc23aquhxS1ZD0B5Fw1Ww4eMzL4ME0tA1yqf0L7ZiMbLVWy/HA5FK6BxlXV5MTANR9tMETrXhdXDbqxZxNYS4kkMwyWlnheIUMOeNs68UwgM84wwFwSAzgOhqWcY8zDExiO8G52SQPYOrcLLv1nqPwBWF322Z6s+p7RucyjZqLjrZpaDnJDvmk34O9H+BJ55JOEvXZGjgpmbv8dgFRGp+WYJ7Hh+ixmy1V5UtCor7UV0YDiNpB7mMIcvBbXiKWH6LsRIAj7ztAnbm/X3Dwcc3CNlpd9f5CEVu5gVErhLtouONZBgK5V5Bxh4DWbHT0Su5T8164O6MCvdxKhVGlo5+VRU2Joybe9WbrwNuiwjqYqricDyePApQ9XMbUdN4ynNkxisq42mY0cx2x52BpExLnFwtOVU90Wj2jOX57lY0gFKljsOZw2fHk6DMdo28ixrmTQp3uthFq2TW81DQKxNA2nhODu9LpCLtchNaUKTRR5leEuI7mKz3Uo8aqMpAb6NPn/VjG510idU+ShXpNlI5un67obIvsfZQQXMJT5hkLwPkVnFPJiOlae28tERto0nwBBbQaTfKK98/OuumUahoYrnuWZsOczVZEigxynNiQs2oI/x0RO6LdLhG6ZAq3dCAm49xjklqzjp0ZCahvP61FLO6cIqZ4Bim/gg7dFerqoVnjD6AWDKpYXy9Cj0LlrZ7mlFtjNXIdE1+LsDn546sZFVOFrCDVEGGY7iJRBAKWcDwledXfTptJXVnKzOy+kR5H+DkBxkxU3NB9x3Jek7556M/bqtiGWHSo2Dpa21IA6ys2hOIq5gOEYQb74HBjVfaa9KDQqy8kTW0vncy36+j6ui5wH5hKCvfwEEhRrtGP2hNTnTG7ol8jxq1DP7t+4In5EVBr6/6SgBAoQZap9ZFodDnNs9 poGGwgGd ru/7OihWF/4FlVvc94/VYwqBI6q1MSDFW4AYrYLiUXKUdLhm66fl54D0TnahakgRkx8nIUkV19cUuScM3Xzwv9SrjD8ObLZJGN2UqFVA+Sf1DkFvwm1xvhdxVu+t3+MKJNvNrucSq5z7wVKmXSQCs54vLm0hc4PV71AgBf35lcSoHaoIrNG9NvB/zHIlQ+l83YCDGNWgG/PZ3FywKpdeQ9Bu5HN6oMf2SLWm7lT8hl0iY0F5XAeFg2ajt5nURBk1vwJHT6j+2m2uefxgoLP2psjYDiM/B7h0wuwFTJuwQABz7N7eul38iwhWtkOr4ppltn1MCZNmwXNpYPmnzKXdju4x9bI/c8FYE4/nqQf8drt/dzTbhoRDHr6UbTlT23oROjnUaPWiqHhbcrIAmqT+ey9Gdbzr8cwgpFAw8OkgDz77PTfRKz1oXIHPobDBHTJnRUuW4jaSvp++m05g6H40fTpU6zua4Mt5G+B7alrBYujPP9whoV6LJATBUqAj4dWiZ5p/JJBvUiD2uwFqUYjfqiIG2f6zMsoSc9LUyCq/Q4WEihk9AoAZJiPVPC5UKHlQmHNeuA6V3r9Ud2igD3wlDHskiQa7hxnfpFp9GZKDN5495GAO35tnqRZqpPgbubi6dQHhxjfr4oEEA8+Nn4brUBDoEWobfAQYquJzDYTyWMXwApVPVk0xTGcevwjcr+koSlVYnimf0R9gvgYN8zui756kVi7n6MdTo7nR7+75cpbWPx3LgoGX0t1qsVLcvTHJgTUsb0Z1O1vJU8m8B2HfNMGYioQ== 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 Sun Dec 8 20:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898662 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 6B1D9E7717F for ; Sun, 8 Dec 2024 20:47:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDB4E6B038B; Sun, 8 Dec 2024 15:47:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C641F6B038D; Sun, 8 Dec 2024 15:47:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABA936B038E; Sun, 8 Dec 2024 15:47:29 -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 8A9726B038B for ; Sun, 8 Dec 2024 15:47:29 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 37DA580A56 for ; Sun, 8 Dec 2024 20:47:29 +0000 (UTC) X-FDA: 82872976788.10.A80D48B Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by imf02.hostedemail.com (Postfix) with ESMTP id 8B55A80012 for ; Sun, 8 Dec 2024 20:46:49 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=lUL2EhFx; spf=pass (imf02.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.46 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=1733690826; 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=tKnJvA5/HWiGQXgqtTHeswbmM5vs13cpwFWYFIFmEsm861NitKZs1y0bNrXJ4oE9eihBWU Pj5kUBa7rjmFv+Y5YV2Kk8fjnDz+3QOfsxtLoCttml4JS9F7qW/7KvoFAYCZ/Xeebajsyq Apq+rm8ipxPoN5HVa+OrNE2YZt/52zI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=lUL2EhFx; spf=pass (imf02.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.46 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=1733690826; a=rsa-sha256; cv=none; b=bqJ2UHjhKwDEKCVwWq4nQQoFC1zQVxz4LPH6/+JiuVTsPj5bD7q1PAY0QT7cO2DBQUmpMc 1OaD59MpIhUkQT5wBU92bi4YqykGqSU+JemWVRiUnkzHKBacDnOTiSBy+Nj4zGeYlljnQ0 1EhgtQxIg08pUmqP/6ge2YvDWBSYN78= Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-434a14d6bf4so38453615e9.1 for ; Sun, 08 Dec 2024 12:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690846; x=1734295646; 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=lUL2EhFxqZve5WsujojgqusGoUkUoTy3U+ss9PdQ12tX7/j4h89+RmM44wT5d+BJXU ZJrlsRTNoofTBOnKdwQC1I8ifn+kjaOGqlCQRh/cMq1082HR4/IWqvkubHUHwU1BtgHc tsTxwM3nkoZCHMB2cpkQ8VWbZ95iUP07ZIKtr0Fwl3CxaSTgRg7IdTwZWQfkAgQj2Crq ZkZsoRQikCZlIH5fWCNpUTHJtqxrASQcr1yyTCTftl8epN/rmqnoZ2Hg2ae7xPFDoXcO N3xX/RZO+TPNFKMIf4hrth1/sFGEIaFE9YEUIZRNq+BTW+dFwydFahivEjmGr+j9Xl5T hXzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690846; x=1734295646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G+7I9gi8mucGgoO85kNahA3U27ot3S0RhfZIOhPcQEg=; b=ZSvm3miBYq0YvnU4czpNQREvxnRcvh7wWGvcX1mctjpkT8TW6Uku5651pMVGNQIfzP yGz15LXZcKv29fN8Z5mQg0W7b9a2HLCle+uzv1oKoEeQPOU1xnxghxWLHujvCfGDANNx 3u9k03PjJzf5pbsEGSgDAv8MONULPpBIv5WqBSxgusZ1TIdWLeljVwacxd3/t0FJaFh4 gTwfZxT6TjZzdcsW3AnkZwL3xf7ZRt8p1G7KeWZKUQnL/qYzlfGNMZkRYTpcjVSsw+WG gCF3Zpx84bPO25Vv2Xyc6aW8pUehqNkvrY9+BmWZjpVwJVuw4TTwYecpdgpNFlqUHY+Z skNA== X-Forwarded-Encrypted: i=1; AJvYcCV7QuOVVg8ogCGZjuObETQPpYnHCq/aRO9lugPmQwgMyqmS5mEf3TJQiOfQBdtq9oJLmxqa0UV+ig==@kvack.org X-Gm-Message-State: AOJu0YweeXoQlKs6T/6B59AlAaUaC7D6H6LMazLUI9mrbKCnLH5oSLZa 7JmDuVcSIlL/IA77alyeJ7OX0mPdzSZxkC7wuEzJ4iDnqHwrT2VoO6kX6JTO X-Gm-Gg: ASbGncu0fY68gRjEUQv/6K/I/yBi7ZrNCWCs8GhI+uFIl9zXttMN3IhNwV3ciYFFLKq P7srSWYx2YbH3C3PP97TPHjDnuT7riLqyX+80Pd6RoYtwTPC85ZK/vy73mumwgpS4wBXKU2wgOd 2wL1Z0rokqIZvXWbKhDVDbgYn8DVu/cfBJaqmjTx06OC3k4QkLq3kG5kU0/ptXHNSQNSk6jz/9p rYnZe9sRA6Q4jgqK3zZ3Zs0hllgcSkfn6lb5IKqg0OVBdssXc5V8SrutG4= X-Google-Smtp-Source: AGHT+IEEx0rgQYQ9iMyor+TEsls9yO5cspee9cXj1IHwee/pJe4BPDGI+xtnRRqbb2a2nmwevxjJVw== X-Received: by 2002:a05:6000:471c:b0:385:fac7:89b9 with SMTP id ffacd0b85a97d-3862b3e4483mr7723302f8f.59.1733690845640; Sun, 08 Dec 2024 12:47:25 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:24 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" Subject: [PATCH v3 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Date: Sun, 8 Dec 2024 21:45:17 +0100 Message-ID: <20241208204708.3742696-3-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8B55A80012 X-Rspam-User: X-Stat-Signature: 7z13ww1zcpgdr814pr39b1ir9bjhnd45 X-HE-Tag: 1733690809-773643 X-HE-Meta: U2FsdGVkX19B2Pjk4L3F6aT1qvohrpcM2LSNdB1wRGWztx3ONnWtdJgXFpgzZYtVh8wra9dOb7GKjZ5CBwKgOC+vuE+CUBnki3u4fF5YX3+7EA9XE3NYS4SYHArM7RBII9/CnFUiXU1RWHLf5MNbdlfzEExg6z5J2/wfE4R+fMotVbTaSp50gjTxPix7dtAX7GDdD4MqLCVa3y2yPPuIq/5dz6txGBA/nkrwRYDOD5P8bV93XKshZdR5KPL09Rmwi9cb25AXK2BdmG3fF9jy0Me2lLAAgx/IyT6jSX63Df3r0DmMIyTae7dInKESVve7WQRh4eTZ1y/g2PqUaQsl+aDLiwutKcmSGCIGys2t+GWYOtuoVh8vui5JtW56njBLtXGcPxNdOR3CvptQ53jlFI9sxVGPBDPetXiC3prBfEX/4VTItwXBuyKtnWObqUZnB1Z59hlvkE/ger8ggM3b4YGDLxXApgT/bRzZhU6QNjlIIB7BMIXQMD2FJQW9ucXolzLZkNEsG1yWlz2D76GjdOzsyHUvkGqGK/1NB3aixOlLvfhlz4NUrfapQMg9AcdjXMuAAxK+ieUUg10pDa4YyLUbya5XeMjrhK0WTHCfMN88pJR30aKXFY2VmiSKo7l21RkBwc7ipIb0gzQ0s9pMsaFAXTDxU9Jy4C6Do53ndrGr/iWr00f2Xu1pJpPT4/Ji7RuLHJE90cjuED/Nbs8t0/NonBcndm1ROz/fPgxj60TziYkFJjJKVm7tIiTeph+OCoCrlhLqU00Nl4uFg9J9kPORcn9zZkOZE+6S/nRl9aqHbowAiDFpunW0E4OpftS0GZ/fb1kh8311f1CqIHOR+Fqrtec9637uzgSfxxqxmY/Z3WiLWmLzKdzQRA43lmpgFTtwL83uph+Wz2mpOX6bpIyP7fITHUcOzE8ONt/fej/BAsuMmu3lavIXbVmCSafkh7tKwJd0Yf8/AQyKRxQ ILHmaTPd wr3keIyi4YvCN9NByGn46wjb9iycclk/8lWpwVRcoPF+vMvNpgpaN1w7jCGilfVmZ3lcn5UP9Q30ExGDUp55rFSTPIp8MTN+k2hkYIONOco9kuBGFzixRSpUkyMxJLT70LcuNIviv7d26nmAF12gI1wS6h9kde0LmcuRLerTrOpw/opvvEl9Pi06xr5UaHrxd6PzVpWGSwGOwtu2F4HBnLdJ9n+6gxkWS+P48pF3+DMWgUEtTxqdlwZZxdAmkzole1p778qQzAxuhpIfAyCWEXj6NWCG01rP4mEE58kkANO3is2cp5310+Rw6egDf9Ft/y1uDGVv6BN+TK1CsBNdPOsqYR6ABpzFztBbc0rkH1+cngfJzxzjpwNMxa1zKvdpwfjuZq9TP1nKe4AakZIlFVoAQ+s4pu8kD16G0t0gX5BnP/GD027/hvwAEyyHoO6ZpnksoZrnZumAHZ5Hp6wJZK2XTK9Jg4Ye5cWIo39ZPv8rjRmGnNjpAeX+xjm+b585DiHi9W6OZNm7hdF2FeEoFxJgroPde63WJmSxszietC7cwUwyjKiVGTmS2hsQSQZUiVOoSFDZg7+f4ONAVOO7YJQ0prJuNPYbzNvdhX5nCVRvXwdE5P4utlaf7KC9aicCcQkZNywRQS6PNbtcS4XcA8h0hvnoqu4HlMh7/QjKqHbPZwSjV61wZg3tAnesj38GuTpMFWIbjKbVdaBsPK5DyyGtg0RSCNiazA9iuSqjJj9V62RDE6VeUEDY/Blz4Hz1vVul1vjgy5uwb5jzQKUd1gRJU4g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000016, 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 Sun Dec 8 20:45:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898663 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 AE227E77180 for ; Sun, 8 Dec 2024 20:47:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5EF76B038D; Sun, 8 Dec 2024 15:47:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D00F56B038F; Sun, 8 Dec 2024 15:47:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADE386B0390; Sun, 8 Dec 2024 15:47:31 -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 868416B038D for ; Sun, 8 Dec 2024 15:47:31 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3C2B4160A30 for ; Sun, 8 Dec 2024 20:47:31 +0000 (UTC) X-FDA: 82872976578.19.0F7103B Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by imf26.hostedemail.com (Postfix) with ESMTP id 2DAB2140008 for ; Sun, 8 Dec 2024 20:47:13 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jWyeA5Qz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.44 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733690830; a=rsa-sha256; cv=none; b=ot/KyH8XLVchdVn6SV8H93OqvMWfpGfGRoYI5dWBPGVLfVL3j7kupK5aLQqg2gw4dfuvPa AG4TfCtLAiVUZG1eKHixWh/kPNu54xd2XV5syae68eaJq3LmCVZ61FvVikHTSSxAi7Vx+0 JN48w4Nh9IFQh1J6CA+SLINgMTRobVg= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jWyeA5Qz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.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=1733690830; 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=4nHTtV9SwPVM1CI/6H4NJcvMXq5Ty5K6NAFveY7fTlA=; b=AfjL6hOhQk6l6RUvq6UJ5tYCWjQs63uiaXQmFUdFT6mmmYmTjvj2bAs/u0SNK+zWr44FiP UeAQiE+YiajEV/FFZEqXk4wM8lkVcjd3ptUyRPKRy9++l9keRLlXkftj3k+vk7jS5RHvSU IRMVesnuKviHcW1xG7vuIBXgBdIm+38= Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-385ef8b64b3so3092298f8f.0 for ; Sun, 08 Dec 2024 12:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690847; x=1734295647; darn=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=4nHTtV9SwPVM1CI/6H4NJcvMXq5Ty5K6NAFveY7fTlA=; b=jWyeA5Qzx9JqQhIb80bA/+YY7/0fSP4KKITqnBAGYkUKHwbS1ItbW+/MKAQqmkrOSw cQd4XG3CfbjMPa1wmA3huccdA1TAFzZdf2O8mEOyeV0DTcBcM/xeZcIlTj8Dcyt8qO+P FxGLvMj92g2MURoMmdB0enr1jxXx8RWpS++G9rra3fCMnBXfNnexHEXauHUTtPvQfKD7 DbdkM5XC+5+zqRu3d6vHsvZkZDDuR/U5jd/CaLswv5+KtlzIxNb5nbzaDpYVlMKXWq9i 4M+go9fXRHvIMzIRTh0QGNm1cURmWQJ3O2PkIg+f3D1tt3L8SLRVN2N3IJ+nTicAOcpZ lPDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690847; x=1734295647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4nHTtV9SwPVM1CI/6H4NJcvMXq5Ty5K6NAFveY7fTlA=; b=izE6nciv4M4xQ+SicfYC2hPwDBKff0JjsLog0fJ9lJdGpDVeKGR0W8dVN08lAOd92Y sz16Zw0xfw/yvowxZERIvxbFB/uyHJ66qPGz6gTytYvJlvNwBuoTGLwGNIapqZFJHZku j407nW5P1qYVN3n9mr9GZIWuguS53XfI4DDa2wByMoj8PzJ9GEviQeelTqpP36+EZ+xj 6XuCqGtPb5adMaEfGtrWozC/a1zAPuMw3Yvl2QdyFzcdlZyZVDaYkoz572PgvFB26v0h rXFGmevgs03e0RmVuGaA2lk1KWmQcyxDHORSrUkMhMDaJSYmzfURiNTgjtRTKUvKfBDc 23KQ== X-Forwarded-Encrypted: i=1; AJvYcCUNgLND7chZWRnYcaC2Bsowbyn2Fx+JTsNVHVBE+31VdkYPCWS9lt0a7bcthJHq+n16urekxbUPYA==@kvack.org X-Gm-Message-State: AOJu0Yz8/mWmOeGUnmZkNQymBow+XA/F+kk6DylJoyMf8IhcdVmwGRoy Dv9Rk7BKjxYUYUwpxA/U4pl9uLMV/iXBeYHBXLlKUjSGCYg9fu6B X-Gm-Gg: ASbGncvDrzqQXQpCpKT/04qwYdcFpOR+cxCZZdk1c0uWiY3/HIhGzBreVmfue1a7tuO hkdBrvaq1ircxXqSRVKSCb2tOHWqy1AJ3laWtItXA8J0lUc0FX2chP/CUNHb2r4wwJtZ6s90dMX Xl0vN8XmqJDy2+bGhi/SCWB1CBOx3nnkaZw5+DwIexLJmqkMt0RL4c8wKcX+q2sNKbZ9czDvWrG ftbgA6k4yadIxG++66nuYqPUjcF5oebYrQC60E8WHAFw+k9dz6uMiWrg54= X-Google-Smtp-Source: AGHT+IGhyfm67iqMr2DgS7OR5+qCYoBMZuU2f4+7la38+rQp8Jepy+V33WnABI+y4R5RoecbjJjnxA== X-Received: by 2002:a05:6000:471c:b0:385:fac7:89b9 with SMTP id ffacd0b85a97d-3862b3e4483mr7723323f8f.59.1733690847415; Sun, 08 Dec 2024 12:47:27 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:26 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Christoph Lameter , Dennis Zhou , Tejun Heo , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Kent Overstreet , Arnd Bergmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Will Deacon , Waiman Long , Boqun Feng , Linus Torvalds , Brian Gerst Subject: [PATCH v3 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Date: Sun, 8 Dec 2024 21:45:18 +0100 Message-ID: <20241208204708.3742696-4-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2DAB2140008 X-Stat-Signature: 9pt78x71w5eupbrbyygzjjcxnuwusd3j X-Rspam-User: X-HE-Tag: 1733690833-87138 X-HE-Meta: U2FsdGVkX1+fnFv2yqht301einX2Fr7FSivdIRJIhAbi3SlBvQ05j6VHPwNZcewU1fz+XOBPiLglj8nfmZwmsmpiuLA82K7YWbbeKVFKOyjLjLjshBbxYRIOUfz/3FNv3dq62lyzHs6Gne4L7mcc5Dr//Ol2tiESIleC+PU28xifQPThRIgXtlvXwLyGfCcnqP1rSJ7I/AzNB5Ly9FKR+gZ+GG39XyRHKoEonLLaWFAvhjkJHv7Jr/pmNE6bVKwsPWNsHP+/SqM7PjG8QbYuhU+dUigkOa0gGx7Xrv3zVsOPwQg2O0WnffAcou+F2wvqoACBjQYVTL692atWXTKOHb9mWWmvVbcAsZMH1gs/uRatNkKDYVzvE3KiMTqV1xvQYYTSVWPKQyXW6diQ5/QyYnW86UCbNOmPPRsiInKMBT8CWwIaE2QdwBtGyYBbTlOYAwLiSFQASdoi3KJWjXEdsVitKll3KlWA39md20BrtVGo34LQhyWVG22g7NkCQSPX6pPQvYTutLA8B8DrRGJ76m+BYK6Ur+6YIJjcK4DdyucvdUz+YudcZkL7J5OOnSVJWrxchXpPAKZ35tA+MeRR5RwFoO+pK1hMteiIg6FGAOnH8iIHwn1RpUpD2LihOp5fQR6nBH1VLvTY3+u4by/2lI38TEAXYxqAgb7mZ2NzVVRbeJxiyxC9yOKZvIiLhIk5BjfNDcHiPRbh/MEa4lxeQIH7TCSt5WPaYFncx1a3FjHTzxjHAbx5VAp4VCeLQdGbLsIUYXBFL7jI3jmZvfcMuzrHFETNC1cJHWoBWX0Cl0IkMz34l4FMqSLqtd3IQqLyOzcjvYatRSkhDHT/1aZt7UOyuQLT/scrldZOEnplJQ96+DyBHTy/561Jy4L/AgL3AoCZ2d/4srttsC4BeCyqJ7pGfYnvSE2iZOwg6L6y6KqVc1oQ40dsRdghmV1PwSXZiika15H93esm4tIvO7Z Yw9MpODL rS6Wnk7oBrXAxiv9z9CTv/z+SPwyHw1grltcsl92NeZqVO2etr7BNgEDcaTzTEfUbTbzmQ/qhzGFhzXlGJKYXO781UZkmrsiuaYtwf3XCgnP0jSTrByUa5wCIwfbh5061wqGda2vW9I9k4lGH0hO0X3+6gDByrDMHS3uuGZO8ieKoUInMiPWgJ18AWWtuqDoCZWCpjw1Z0eS7ddhMhkIeLaVMd8e2GzSWqd0x7ypA4xi+zW3+ypTxvzOVOF/YVCU2zpNlSk6DnbGFlp+ycu0cVnfwX8PVqGcmRVFlffBnhYc2QpkHLFzTpp7R6xsBwgEFa70z3LCrwJmLZadwpUpNm+sMy5rup2MXmowteJtbAytdxIEqzUNeVsZpBjAqqiDI/9DzInIyRrjSrAVBs8QOIlK7toZdkeBBLtH7fp9j3YcK5H9B0Ik0ucN8LQFWCXtJ/MwwRgIrYLCsM9fjmdEEeujpK+VzymPDKgesgP90BKy0wEyF+9USXtkGmu14/R295e5QKhk/3cvizG79kEsTByuAdVgs5VBwpd250eMO054qvcd1+cZOLaVpPmykRHcjKhw50VkDOubd4NSAWK6LcbYnu0SC3V7AAhzuhxcX9YF0+duJc6uJCPdxGb19ZWBiw7C651T+Rfr8RcbqYlMigNdosyPnYbs7b3AEey6Tv8ENaDVaiaVx2ehN/ReDmzGGzqlvnntVBWTfkdS/mQNoZNMPEj86lL4xC7KlOp1LoQAMWNq9eBrW/+Xef+wngPKcGSONYy4P8ZFFlE6msT3HLy4P+6eG1pZGq8WbPidTb8Oe9SAEL/smJH9kXIpkfSR8aKXtvtitPyEjbnSjp1I7B1tEoKpPRQFRoJ3X5agvYuDAcRDiQOpi52hA5vAdvzwEdjiaphU5BzDhP+3zIDqMqSKLO8MEYldPuTpM 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 fb02c1c36004..415a5803b8f4 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -586,7 +586,7 @@ do { \ #define per_cpu_sum(_p) \ ({ \ - typeof(*_p) _ret = 0; \ + TYPEOF_UNQUAL(*_p) _ret = 0; \ \ int cpu; \ for_each_possible_cpu(cpu) \ diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 94cbd50cc870..50597b975a49 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -74,7 +74,7 @@ do { \ #define raw_cpu_generic_add_return(pcp, val) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ \ *__p += val; \ *__p; \ @@ -82,8 +82,8 @@ do { \ #define raw_cpu_generic_xchg(pcp, nval) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) __ret; \ __ret = *__p; \ *__p = nval; \ __ret; \ @@ -91,7 +91,7 @@ do { \ #define __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, _cmpxchg) \ ({ \ - typeof(pcp) __val, __old = *(ovalp); \ + TYPEOF_UNQUAL(pcp) __val, __old = *(ovalp); \ __val = _cmpxchg(pcp, __old, nval); \ if (__val != __old) \ *(ovalp) = __val; \ @@ -100,8 +100,8 @@ do { \ #define raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __val = *__p, ___old = *(ovalp); \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) __val = *__p, ___old = *(ovalp); \ bool __ret; \ if (__val == ___old) { \ *__p = nval; \ @@ -115,14 +115,14 @@ do { \ #define raw_cpu_generic_cmpxchg(pcp, oval, nval) \ ({ \ - typeof(pcp) __old = (oval); \ + TYPEOF_UNQUAL(pcp) __old = (oval); \ raw_cpu_generic_try_cmpxchg(pcp, &__old, nval); \ __old; \ }) #define __this_cpu_generic_read_nopreempt(pcp) \ ({ \ - typeof(pcp) ___ret; \ + TYPEOF_UNQUAL(pcp) ___ret; \ preempt_disable_notrace(); \ ___ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \ preempt_enable_notrace(); \ @@ -131,7 +131,7 @@ do { \ #define __this_cpu_generic_read_noirq(pcp) \ ({ \ - typeof(pcp) ___ret; \ + TYPEOF_UNQUAL(pcp) ___ret; \ unsigned long ___flags; \ raw_local_irq_save(___flags); \ ___ret = raw_cpu_generic_read(pcp); \ @@ -141,7 +141,7 @@ do { \ #define this_cpu_generic_read(pcp) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ if (__native_word(pcp)) \ __ret = __this_cpu_generic_read_nopreempt(pcp); \ else \ @@ -160,7 +160,7 @@ do { \ #define this_cpu_generic_add_return(pcp, val) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_add_return(pcp, val); \ @@ -170,7 +170,7 @@ do { \ #define this_cpu_generic_xchg(pcp, nval) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_xchg(pcp, nval); \ @@ -190,7 +190,7 @@ do { \ #define this_cpu_generic_cmpxchg(pcp, oval, nval) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \ diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h index ac8c44dd8237..c5e9cac0575e 100644 --- a/include/linux/part_stat.h +++ b/include/linux/part_stat.h @@ -33,7 +33,7 @@ struct disk_stats { #define part_stat_read(part, field) \ ({ \ - typeof((part)->bd_stats->field) res = 0; \ + TYPEOF_UNQUAL((part)->bd_stats->field) res = 0; \ unsigned int _cpu; \ for_each_possible_cpu(_cpu) \ res += per_cpu_ptr((part)->bd_stats, _cpu)->field; \ diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 35842d1e3879..266297b21a5d 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -320,7 +320,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { } #define __pcpu_size_call_return(stem, variable) \ ({ \ - typeof(variable) pscr_ret__; \ + TYPEOF_UNQUAL(variable) pscr_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr_ret__ = stem##1(variable); break; \ @@ -335,7 +335,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { } #define __pcpu_size_call_return2(stem, variable, ...) \ ({ \ - typeof(variable) pscr2_ret__; \ + TYPEOF_UNQUAL(variable) pscr2_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr2_ret__ = stem##1(variable, __VA_ARGS__); break; \ diff --git a/include/net/snmp.h b/include/net/snmp.h index 468a67836e2f..4cb4326dfebe 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -159,7 +159,7 @@ struct linux_tls_mib { #define __SNMP_ADD_STATS64(mib, field, addend) \ do { \ - __typeof__(*mib) *ptr = raw_cpu_ptr(mib); \ + TYPEOF_UNQUAL(*mib) *ptr = raw_cpu_ptr(mib); \ u64_stats_update_begin(&ptr->syncp); \ ptr->mibs[field] += addend; \ u64_stats_update_end(&ptr->syncp); \ @@ -176,8 +176,7 @@ struct linux_tls_mib { #define SNMP_INC_STATS64(mib, field) SNMP_ADD_STATS64(mib, field, 1) #define __SNMP_UPD_PO_STATS64(mib, basefield, addend) \ do { \ - __typeof__(*mib) *ptr; \ - ptr = raw_cpu_ptr((mib)); \ + TYPEOF_UNQUAL(*mib) *ptr = raw_cpu_ptr(mib); \ u64_stats_update_begin(&ptr->syncp); \ ptr->mibs[basefield##PKTS]++; \ ptr->mibs[basefield##OCTETS] += addend; \ diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index 6083883c4fe0..d6964fc29f51 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -184,7 +184,7 @@ EXPORT_SYMBOL_GPL(__percpu_down_read); #define per_cpu_sum(var) \ ({ \ - typeof(var) __sum = 0; \ + TYPEOF_UNQUAL(var) __sum = 0; \ int cpu; \ compiletime_assert_atomic_type(__sum); \ for_each_possible_cpu(cpu) \ diff --git a/net/mpls/internal.h b/net/mpls/internal.h index b9f492ddf93b..83c629529b57 100644 --- a/net/mpls/internal.h +++ b/net/mpls/internal.h @@ -33,7 +33,7 @@ struct mpls_dev { #define MPLS_INC_STATS_LEN(mdev, len, pkts_field, bytes_field) \ do { \ - __typeof__(*(mdev)->stats) *ptr = \ + TYPEOF_UNQUAL(*(mdev)->stats) *ptr = \ raw_cpu_ptr((mdev)->stats); \ local_bh_disable(); \ u64_stats_update_begin(&ptr->syncp); \ @@ -45,7 +45,7 @@ struct mpls_dev { #define MPLS_INC_STATS(mdev, field) \ do { \ - __typeof__(*(mdev)->stats) *ptr = \ + TYPEOF_UNQUAL(*(mdev)->stats) *ptr = \ raw_cpu_ptr((mdev)->stats); \ local_bh_disable(); \ u64_stats_update_begin(&ptr->syncp); \ From patchwork Sun Dec 8 20:45:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9F1CE7717F for ; Sun, 8 Dec 2024 20:47:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 168FF6B038F; Sun, 8 Dec 2024 15:47:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 11B276B0391; Sun, 8 Dec 2024 15:47:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED5AB8D0015; Sun, 8 Dec 2024 15:47:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CDF636B038F for ; Sun, 8 Dec 2024 15:47:32 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 43A574050F for ; Sun, 8 Dec 2024 20:47:32 +0000 (UTC) X-FDA: 82872976662.01.08CC6C9 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by imf08.hostedemail.com (Postfix) with ESMTP id 2D650160004 for ; Sun, 8 Dec 2024 20:47:16 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=L6Nnop2v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.52 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733690831; a=rsa-sha256; cv=none; b=DTO0BSWXbK1wUogApdL3zsXM2LBjP4PM1MdKGs+SH/Xqad7y428fsJn53TpbhWk3d/hDya 25VBk4Ll65zrL+9y6pLXIUzofkUfFJEr0uRGyJZ2N0czxnPVNE5cndf+87mNhGSN4ViivR onoWsFlpaQuhEXujhjkhlw32VdE/0kY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=L6Nnop2v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.52 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733690831; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sl02e1tbeNqkkscoGaVtIPs3YTZ0CcynxSRpc+0Q2zA=; b=HyJDAeuEsTpA4fSiVG2bBF/FavSreQbNoSvJ4NRSA8igEkjbVQUbQXabEeb+lrD9Bmp/Mu 500+ODVxpvXRA1iImQ2fE4YYvCLNk7OHAEYZ2XhteEGcPDqBKrqgeO/adZATcOImfxJ64/ nOVkJnahNl/Dk22XdIKaJU853w/JEF0= Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-434f09d18e2so11223315e9.0 for ; Sun, 08 Dec 2024 12:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690849; x=1734295649; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sl02e1tbeNqkkscoGaVtIPs3YTZ0CcynxSRpc+0Q2zA=; b=L6Nnop2v5PuWR6M3q5qAR2Jwl9fR0DM1rZnY4SAv0VZhiXeQH0z4jq4IwODtiZFHdX TZ6YcfCRr30F6Ok+K49WgI7HDOxLhCMFrXsBp58vFYiHEQeQXW3UIc4LT5LIgnQomAb3 I6trnoxYmDf06EhcQ2jJZ9zL4Lj3q3UEkKcaS2A1ae8jetF13rMTJ5PsyP6UWG07o89f 5EaaBKGPSr/Ll+ZMxGh2iDv8kRbwh0FZEtjYzLnOLCY/P997F6tQjDPJeBNZjToBRwCB tYmAvmvn3GKXd4A457o6LM3n018AyYA76dqdwCiTE5P/P+oEbK7Y521pe9kzS7YgddQR EyUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690849; x=1734295649; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sl02e1tbeNqkkscoGaVtIPs3YTZ0CcynxSRpc+0Q2zA=; b=v6Xd5aynoJsEcd3qqg0dKEI6i1tPRQFXp47gHOge7mPet/y+rAj9UGo9gSljgKONOk S0XByt310gklY43S7U3kKI0/AeJqKIBWhi3oub/XqbU3JFsf93nleuZm/eK1Sbsp4CFr z5K6M7lrXJlcSX2evG6mlfIwAxEySPM3y7v43EHsNmJfn4HzZ4re/7v+EH/UGYb+KCF7 Dvi0pAQXDHcDvLFtjVDiYfhZdqrDX9NxSAdnGidECF8UaCJE6m9tC3STWQ6yJsFJ9CAq Imdo7Fg6HK3fDPJKk4smdTG3KQJxDAJpO4S2n7JcWoYBqBRKb7XgsmuOS87vHGct6XCd BafA== X-Forwarded-Encrypted: i=1; AJvYcCXtGb9xNicswfBZr9p3jo05dFmBxVAisOmFf6BXHmFep5mYHidLZy7cQemnD/Aj3OogZ2dzQrIgEA==@kvack.org X-Gm-Message-State: AOJu0YxrF+zBRYPUgfKN0h7eCjNs3QoJi5zoKEigDWLmYrtYjcsFxw+Q 6FiWBaSjBAN41yynfCdb7JKbunVDn5Cs1B2Ntlq9tZnkNpCSOEbf X-Gm-Gg: ASbGncvrQewfjEffG00htDyIzAfZbbdZ5Cf65IHev4hV4PeY3sqWmy4weTYnv/KLEDt vnRKm4niO6f3CHByf9ZPFNFBjuEaTQL9z/EjZQWCwdP3Hqk5gXxB1dyrykHaCacO4h9MVeVdN+z 6Mbxw0yTJ47n5rbKp2Wx65Q8h5S7ndKmc7kgdDLKN4Gojg9D67VYOkZKnU1MwJ+g+ygUDBHz7jl sAZreKDfJ75abGHFK5Kww2jX/342awzu0bfJoe5bBzLASW99QEqGd/y8dM= X-Google-Smtp-Source: AGHT+IEhGoPt0DRcYf/EuijpX+E47Uzih3ytt4xJbhowf411wPQtgH//qgvD2xRwzWN0Epd0De+3cA== X-Received: by 2002:a05:6000:a14:b0:385:f0c9:4b66 with SMTP id ffacd0b85a97d-3862b39b9b4mr8976505f8f.33.1733690848668; Sun, 08 Dec 2024 12:47:28 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:28 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Christoph Lameter , Dennis Zhou , Tejun Heo , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v3 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Date: Sun, 8 Dec 2024 21:45:19 +0100 Message-ID: <20241208204708.3742696-5-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2D650160004 X-Stat-Signature: 4ucy1q33r47qy4zisnx51d6s7ca5szca X-Rspam-User: X-HE-Tag: 1733690836-412754 X-HE-Meta: U2FsdGVkX1/ofvHE2dcs4XL7SDqln+HfLvMo/2qg8SrCobfM4QCXK9F5mzCNqf8CQ8bhAH1JuUcGLsxLyq/C47QLKEIYCpSVtlMdQN/r9AYhOuXXXpKNTyPVq4lb5PID4AZfKi6QZShYUO39yuSLDe+zoJU9CdqQ/C7aKw6Hm208hef+jMe9IQEeL3LJ38PMo7bwndTCPif8AU8aL8ZOdhU50H4HJii70vRPEuMCTUXeSX1P63H+JH7BwqIuiwOD/PCgTRhznuyCTJMwq2GfIdTTfUm3nZmGlM35a8ZkqGx4xfiWd+BgB09LA6VwSqoeHgtyJ6T8t3395lI1ctuGKUwq1SMhp6XOVMZY3n27TpoEc/0KnHiYMBWjs+aXq8wkvq9IY/SicGhBokNsgVHIUcuknRUt85G6UsTyldXJndzNKY9x7RcLDNZr/L/84PSeMOw6eSbffu87UUzACXVa7o3jT26P0tF5ISie9Clfxp2KE7O70uE1ZMV1BYiwstabPFSI/jI151GdIoy9ALHYVKCobKBMVSUK6gd9OyUmPONrqcF3RvPs05iVHe1KoOChu8glc4Lg9J/SZgMA++YlKF/kDEnB/TE2D7fk9e5nKGOYUi+pQ1MJmhEqweKonHLY7pj4QpQ7KGqYf7Wu7TfTyzBlTicIzch+DoL2rVyugPPiw8w73GkxSL/IKR6yQwz3lwADrgB5U2MWNFydCqWnx+ubq5BXlh0QxAr8nSFL1BfnQidtMOe50no30LcOHVg0uBds6se1mFTjo1XqEdWyd8teQc/0II/cHrCQNxXI+1ASqvMjhZw1DyRyE7Eb6wnA+HxDOd4vibBDdt1mTnsf3wRFrWb/VWd+ZOGTV6GPN36dpQFJwZAkTKKX8JXKUslIHKRQ0RwGfOEB2LsbRdM9Zq/mA8mOgW7Clh0tuEV+WHfEKgtMzrPRg9wj6z0SAMS0IlEvzgp19+1qoZRzp6E j5eh0HPn eBSLLnGnjQmeqMCrWPljcMeivGlcGj01+xOVuxyZ2QWcK/a7b2X0M/6BRnRTalFozW3wdtjkm5dCl9p/Ec20XXi5gfzAMyOlS/Airj9Jnq7SYmNPwk++77qKNfUQoanR6CxnK1yIsvtucEjvpi9pbwLY99y10/ljf7OYZxTNlJ2lMOaIo2Y5AmjmbyLvPYqh9KbPwtA5XLTcKeCibrq0WS7fYKFSOrfmVgAifk240w9Qh5+LunsnW27/ya0FkcbifLChFlGK1Ix+6tOcGzpoJU7dydPGBNpfZhp23+J4oVZMGbAsJD86B52LGeB+ROMqt09cjWP6tb3X77kVtY69q0nAEkUj5THRgOTmwSPwJ+oKBnZyBp4b64WPPZmHg2HyDU9+xck7QH2xUejyZ+HZjW9BX2cbIBLURR4HtYkJz1qxi1ojhvbpu5UQJeC1L8RFp0M0lB4GNKx6oFOtKoyV2Agm72+/m55kvcbLUDNz/Rd16rfLbkQPixGnF4ehDTCmIMCMhqTh1ziy5VU3lRQoImrHtqWt3iJUqKAvmKjx5MP+5wyw4UQr7uAGl33Lh1SoHuLQEu62f0b4sYLfKleE7Qh1cLEPPLnE2JrrdVdkEVPquPbycNiUAxC5CLsFDH1NskR5ts72b503w5fCY8hXfjSUv79WTD2GwcnrcZIa1CtFO1aImyBSWSUAiG7kYu1qgCVYOsADjhAoEvZCCcW1vIkeDJCb67+cSfaFsQoo3PBeNREA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use TYPEOF_UNQUAL() macro to declare the return type of *_cpu_ptr() accessors in the generic named address space to avoid access to data from pointer to non-enclosed address space type of errors. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Acked-by: Christoph Lameter Cc: Dennis Zhou Cc: Tejun Heo Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Brian Gerst Cc: Peter Zijlstra --- arch/x86/include/asm/percpu.h | 8 ++++++-- include/linux/percpu-defs.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 666e4137b09f..27f668660abe 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -73,10 +73,14 @@ unsigned long tcp_ptr__ = raw_cpu_read_long(this_cpu_off); \ \ tcp_ptr__ += (__force unsigned long)(_ptr); \ - (typeof(*(_ptr)) __kernel __force *)tcp_ptr__; \ + (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)tcp_ptr__; \ }) #else -#define arch_raw_cpu_ptr(_ptr) ({ BUILD_BUG(); (typeof(_ptr))0; }) +#define arch_raw_cpu_ptr(_ptr) \ +({ \ + BUILD_BUG(); \ + (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)0; \ +}) #endif #define PER_CPU_VAR(var) %__percpu_seg:(var)__percpu_rel diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 266297b21a5d..2921ea97d242 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -223,7 +223,7 @@ do { \ #define PERCPU_PTR(__p) \ ({ \ unsigned long __pcpu_ptr = (__force unsigned long)(__p); \ - (typeof(*(__p)) __force __kernel *)(__pcpu_ptr); \ + (TYPEOF_UNQUAL(*(__p)) __force __kernel *)(__pcpu_ptr); \ }) #ifdef CONFIG_SMP From patchwork Sun Dec 8 20:45:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898665 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 5443BE77180 for ; Sun, 8 Dec 2024 20:47:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00DC46B0391; Sun, 8 Dec 2024 15:47:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EAE2B6B0393; Sun, 8 Dec 2024 15:47:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D002B6B0394; Sun, 8 Dec 2024 15:47:34 -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 A69396B0391 for ; Sun, 8 Dec 2024 15:47:34 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EAB2CA075F for ; Sun, 8 Dec 2024 20:47:33 +0000 (UTC) X-FDA: 82872977124.15.45422C0 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by imf27.hostedemail.com (Postfix) with ESMTP id F011C40002 for ; Sun, 8 Dec 2024 20:47:08 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WOnnO6J2; spf=pass (imf27.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.44 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=1733690831; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=OZIqg4q07ByJfzsRAQRtNYzS6oyC+rl7FEs6rac2/RqtbJrfQr50AF5rYHJYnW1pRsLfvD zHNjhNYRI8PhR9hHU+J/1p9MyQwVVnx48Xqlc/UKQqt8ergTNQNiVaTm9TFhi7gm+rDV61 4FOTjDDAMF6kIqTFkMRsnNsA/EwAOPI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733690831; a=rsa-sha256; cv=none; b=0QG/P38yJKfS34kpaF5zzgULdGt0kEsQCx6uO5ltyeS0KmhpD6m4U0Yi8HzUfnD/4hEjLC 9qqwLeQkItrylEhJrZ+j/Pc32qygSByKHFJq9B7Hmj+Aagxqa7I4qGvwebRimbnAUv23/a TjR5qxh2Egdg6j3C5Ko1tR6Avg/mEZY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WOnnO6J2; spf=pass (imf27.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.221.44 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-385e3621518so2685200f8f.1 for ; Sun, 08 Dec 2024 12:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690850; x=1734295650; darn=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=WOnnO6J2K8oyBjkDuTWha/l25q0dKEZ0KEsLJ77FWuhEh1IrnXYZsxF0hs31oka3s3 m0GW9YpaX4gGM0DOmDZbU4khpkiYxAl5wk4dNOG9LPAJRJ/z1XzG5YCfMNJe41XYv8sr qCgFoH6VeLhvCVjvzB77b9WkvwmOMLSrnY65nxK8GG3WgcPSJyfAETjb+LHb6djAXYOt tnN4lfKp0np7A98HM8ZWxkppsUtApNhF55AnLX3ywCvXzPioFnmpGaQx84XZJ/1pQNno iY16LQudhGNtm7eFPSo1iwXNkKJf+7kOU54H3R2PZ70djPYvu5ks4l9Jzn5IJGiJm+G2 Zofg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690850; x=1734295650; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=lpxZkN6qtU/LqcgjrU7vkgJF3K/eY5zW7PK7Ftpb51VDpNmbWZ60jOIkm74sqPTE+/ 89poDalB54aKObj14bZREBFsXI+wacCEgD6CHLaWBOS8Eb7Cci80S1r+4Dpd+SEToxV6 QrAwvaOWF3YhqtWXdiHmcNZxGwoVeLffudpVuO9ZZarGm0f5ZtEZ0kAFlpl0lsQr0dr3 Vtz6od4P/Lnx9P1uKl5YI2p1uWgWLfCnB+zkC7f8TeZWcI67Z6X4sIMZ9BZ2Xn865w5i hTYRqccI/5V6gTtmaiOZjoohMfCNwek/clYMC3SCCH9IueozGeB/ThG5srgPmr8Aabw+ htOw== X-Forwarded-Encrypted: i=1; AJvYcCW0vRrMRUEvLrs/DjaKkr+0LmIEcNNx2UtFRvC3WJuZFtmr5iDGNtaiizU62lpLM5WYOxAhGMgCMw==@kvack.org X-Gm-Message-State: AOJu0Yy9aSHqRE1IhENZExdIzZGkSDK6CWFsdG0s5mnlaBCQVwA6aaXU mdakUJSDiU5sQuV//SDydTdJtFja1oxHUBXv/QLT3GLl2cgLuQWR X-Gm-Gg: ASbGncu19vdXGJuvCLdsW6ShNkkj7Kejh/4kanXz1nUntAtTKkJMGjZdKvjTymlfSQW 2f5GOKUicZqm66B1+SqyyX1Fh5JtVPjWpAXAb7bAahgY81K1Ca/8TVScoJj5Yoofat+cFd+B4+x MUmOj6Aie/6KTRlfZPMHOLK0XwaHSjCMkSDFCFy8kSYo7j9mvRGbBrJAUD9hR/l8DIAld+32J2A Jran8JWVM+UGnHAy/D61U25bhud2ykwe5g4b/xKI4ceJ2h0nyjYBqEJfa8= X-Google-Smtp-Source: AGHT+IEgK+5BlWjK5hYmyAc92iK0vY/52y9egBCaI4T3OGpocF9n9vCZzb2/329/9E4vHrdt2CJvTg== X-Received: by 2002:a5d:5f8f:0:b0:385:f092:e16 with SMTP id ffacd0b85a97d-3862b3e3ae1mr6811496f8f.55.1733690850465; Sun, 08 Dec 2024 12:47:30 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:29 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Arnd Bergmann , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Brian Gerst , "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH v3 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Date: Sun, 8 Dec 2024 21:45:20 +0100 Message-ID: <20241208204708.3742696-6-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F011C40002 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: zjs4fijduib997enoj56pxh64bfity4o X-HE-Tag: 1733690828-789081 X-HE-Meta: U2FsdGVkX18fwSORRw6FBjKqwsQ7mTlJ0wW0ZlJ3Mbi6+8I7Q2nPubXcOWksCbWBI1UieQdzDxqMSms8mHomcTOfTyBCyrt5W2A+sv0Bq524iV1lmQWgwiWRMWVfT931QDEr/E7JrdFPicub+9TMYpU6fUI7TfBB9Z/9E0xptX36yoHn24YdHmVK7jbG3/2adYG4WtMgPzr/yRXBUMQ4hEh+XzYPBMG+NAZZbLPa8gPIIZ6zQp+EYDB5fa8L+hkDZLvK6zPmw14VqHdck05PS7AcJxH3RLORszrIQ5pUrGVkeiz1InSq3g0kyeysw7JibFGcFyyJ1zex7MrGr1ZN/Bw5v+DFzIOgJEAATvgwS4mpiKEwGikfZYRECCFP370R3UhVcSqKbcu6zKYBrO+Pl3pRF14TRoAPAaLjD7U5u0GmEbi0fxnwnD5oLbBptR632Rh94CPq4VO1blA1zTyNLKf4xLN+O4AKdUuhVENXKPM7hTI7R4113o+cqrx8f3zipqLb8cTNGIikGfSlMu0/q9C5RG+A71hy8l/pcWf4kXtaI8sv2+MHfM+jvklBJTsGyShxD+Xkol91pNXvxqc0LL2hghGzgXZhQW9OauMbzJgue7zqv+DdKdUMQJFY8wtpcYtZJe8JTlvxdnXe5Ze+NrwJpkCIBNOgHw4GeWBeHN8f/Z9+HQKn2OqhpwN5hOJgKKjW5BwAvk0ROXqqDEGj4ynitiyEUkeBbVXSbSSrRVglhNYVm5i7YDM5zCcRK3uxpqDWfMJU1dLv4DOWdumc3gy0Bb8kw2wY4DdnLwWn2nTP3SwriN/xu/yAgoBbejfVQZLptmrUOsUUoy7Sbb/GpRpgWoaJvy7ClxUSqtmHb4XrtYeU0ugiPhoAQZgCnmddP+WpQhw3MMD91lHtSc+YcqXtdi9cUp1h9WhdTXdRIo6guixo8dXus1HVsIEB9IYEAByn4Ck6YLgah94Bg6p 2xW30E31 AshxClT43CVbVUFXk8ZKp9LaPg2OCZ1A8XUIXy07GMZjJmCGvUu0f9i2RjoNDJb4RIq2skNa3VfntjJrh0DMACOnyYkGyN2EOC2n+/OsQBHrDmea/i0H9t8fHBUI5qU92QuqbdlP5V0hQ9BZj6coUX9ma0Xs51Dpf+ML/uKfU9LQW8rArMqHZgzl05rbBQEKyCPOmRt50WewOsE0Jl6RYp1xDLRbEr1nMGIdT6B3eHUSBz4uswluodZNfS9Gtb/5Rx81wumkn4oUZiwUfB5lqGByRtv3euE5959/l7+vCkELDhFe6EFrQaBftpxAmYRapz9X7OKglJXA8rjbfKSrREnBIh/she0kBfpEPxAarDbnFBDdxrdllu3Za9qGUun4oIWGngYhj6VWMR7WRdvdUSIgLCB/zmL+ehzzBC6qKIGOeBCrduTB8phyGmVh1yGGcOgjRy3J+BkjLXZqKJOyH+HSUYw+6x8LGOp9WIRbGhjjIc5WQ0lcND2jAEVI0EBMP2hDY10OXBvHfhLuRN9+ekyckvp18fgDDfN/n9ibTLV5vmT7CwvwICBXE9POp8+g/mWHnGP5oqvoALpV2vAJFGtr2+Nw2y9d2DV4P+0Zo/CzwWLg5WnTQHMmL2mnMp2ONM3iIE7xUWtfF9gWFeCDBLZIvtzo8rgpHLXYYusKksM0VMLBg5FZcV0o7NNX+bxTmpvSf/zhd4Ky9AUVNMjNX1+hAs0QBoepS7+vx4PGiEWxVj/S7vB4wg3S3Vi3d3kys04tO 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 Sun Dec 8 20:45:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13898666 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 A56B6E7717F for ; Sun, 8 Dec 2024 20:47:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5615E6B0393; Sun, 8 Dec 2024 15:47:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 511526B0395; Sun, 8 Dec 2024 15:47:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33CE36B0396; Sun, 8 Dec 2024 15:47:36 -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 11E316B0393 for ; Sun, 8 Dec 2024 15:47:36 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 88812140691 for ; Sun, 8 Dec 2024 20:47:35 +0000 (UTC) X-FDA: 82872977082.22.640D035 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by imf20.hostedemail.com (Postfix) with ESMTP id 9A2CA1C0002 for ; Sun, 8 Dec 2024 20:47:12 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=G6yqIP4J; spf=pass (imf20.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.42 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=1733690840; 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=6KOZI0Av9UpRI0wc6f07qNDNYBakRBN27GYpajM6B9g=; b=8bXXy1n/y5yAzbhnKOxswTQahrgV5HPECspxkPVO7MtLkFcPiWy04rrfaP89DSibwgLZvQ W5Yqg4K/R+VYqgVzm/Z19QKxkSxPObUbNmIbvF34jp9BxTPKlbGaV+aXypIbMaWY6VHYDQ ByUT97kB0rFIJ1nn88Q2lmD72CPQSrE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=G6yqIP4J; spf=pass (imf20.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.42 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=1733690840; a=rsa-sha256; cv=none; b=IBQSaBYpNsKkhQiljiBDJWaEPbYcrcwUv9xfbXzuhRs5l0lq8VR6KxoOyw0qWFjRRpbTDe DPavZQJfrHj4bKLF7LvBzzVP9yT4ysiCZ4wy/MFaDsYKPAEihhgAFetFa8Rxu0vgkOpCwR dYQa0vsztCUVqcvvVyP4TQcKyQOdVOM= Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-434ab938e37so23915135e9.0 for ; Sun, 08 Dec 2024 12:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733690852; x=1734295652; darn=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=6KOZI0Av9UpRI0wc6f07qNDNYBakRBN27GYpajM6B9g=; b=G6yqIP4JWR8M9CQR5aoNOnj331Ct1dT9AWvPFdcwtm4VgmoRciKTsoVgo3r7mc9dK5 Gt7UkMi84ZuviC9/r17tfA+TKCKLqUQ9ctYih1H9uDotYY/SPjMgu9kVvuTJ6iLiNOw+ PpJGdBguyta0FvdjeCwabIv/xgdP2z84JqWDt8oeOJX2d8ZwW/fTZmeWyxWXH1WRWUVj sRBlU48344bOjQ5y6r0HIFVQmPjwScqvIFzSiCrNb/EqmFV/lHoQ8loAqf983odub9oG LgXkjk5HAtrzdMh+ppY6MBackGfPBFqQ0laBYXvV0NdeZm5ZWZC7wRroqLZJnunEY8Pa VZmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733690852; x=1734295652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6KOZI0Av9UpRI0wc6f07qNDNYBakRBN27GYpajM6B9g=; b=NyRqMI7RRdXqfPHampJO/zdU2eGYNtnk7hrEe33e7c3kKaZ+gG9Uu5GFtdWQxcKqDu /nCapNt/Z6DAEcLjizsqbUGCoVPRBpUW+ViBn2iPfXYYwhPgStzOCRSeZtLIAJOtBEDn Kj36726obEt+CzIpi946fPVe5mANuKFeAQSIJx6/EzZOS/0tK8hBr2BXxgzZ6Lz9H39i cD3VaPFyKhPhDol/DZ2j5+63P14QtwEP3xxTY9emkPBL9MaR8Qcbp7I9or98CkRXItss Hi54BXVcxZgHsb56PqUs5q1HkPi+1mK2UJTQgOIrStnQVv71X5kDZUWa3GWAOTY0LKvS o1XA== X-Forwarded-Encrypted: i=1; AJvYcCUybXXnQ4WVa8h13yYUflob7pKjPeEkmLo+qO9UeIREMvU9om6SOoxm+JTouLLRp2q1Ejz1zHtRGw==@kvack.org X-Gm-Message-State: AOJu0YwMRBgV9kAHdqf6SAxBUSBBXmjj/UoXVtMgniEVhr7IRH9Rbau2 zrP4KezExWN8g/ARKk+q9n1yQ3vWknVBsao8LzkK8qpYNao/8OhS X-Gm-Gg: ASbGnctRvgzGlEL4U+uu483POgNjbtGSPTWGM9+ItbgVhFxfRqsXYO+GmrjyvNqLy6J yw8JVhmmsnqK+WK+8hK+3I4PnAb5aTG4AubL5RZ5FjK2o+kR90o8HL6fq8VtmFEjA7SSIpaA4Pu k3+9P+Vmu2EdiU9mnYS5UOS3pmm59FzhhHQEET9pp4ffp8XYWbGBkVcFOdREbeeYV6MWaUp2MoU 8KWEEP7MltNyFzQ0d8BJTBaLRkpjYKDKm3WySV4I0H3FuR5zp79qyv9SHk= X-Google-Smtp-Source: AGHT+IFoKEXuuJkWVyc6E+OV4Yi3aleXB7y+UqdQJgSPCnb15ZOKQ6PeUxcw/WuP8movSkRgO7EseQ== X-Received: by 2002:a5d:64ab:0:b0:385:f271:a22c with SMTP id ffacd0b85a97d-3862b3f289emr7788206f8f.59.1733690852077; Sun, 08 Dec 2024 12:47:32 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861f59cc6fsm10874975f8f.34.2024.12.08.12.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 12:47:31 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Dennis Zhou , Tejun Heo , Christoph Lameter , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v3 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Date: Sun, 8 Dec 2024 21:45:21 +0100 Message-ID: <20241208204708.3742696-7-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241208204708.3742696-1-ubizjak@gmail.com> References: <20241208204708.3742696-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: esu1du7tmkzpo3gmda8gn87c6tw59f8z X-Rspamd-Queue-Id: 9A2CA1C0002 X-Rspam-User: X-HE-Tag: 1733690832-738606 X-HE-Meta: U2FsdGVkX1/yg32/d4ihbOLEUlRUKi7hVVadp3g5IKMH67HI6W9P+CRgZYaiMzcLHJdB66MFAt2CwdgzD7WW+w5GCQMpbjrDJDdwjgS5a2z6qiZuDpxwMPyIpZNCdlrZ6Ozjey9b1dGGhiqTMpceUEbzF7BzLjQGxTvF8keXkT6ZK4FB15706kODuhPaDPdNyRy9IfJMcXcx9Sr+NLf0WOwLi6Ws8nMfe24nzG2n/7rQQdtvJ0YKTJSTmXGdv4VFMWFEoqF3fg0LMBu+xKOQiETfn49PsGIgI+89LfCEe25hdkMQ9apXAKUiO5vasd7jUrRxcqPOqU0lCi6weNcRf6DZTa4QeWjGm38la/D83918rKVSoFee5fv4y77M70pxA6Rf4ZDxVuP3YKYTtwyVsGJr/3EIHNLEVsFGxfhLqLiUJjUFyYZNoW0XaKUOrNCkp4ZRxhItV1dkybVoP5YLFR9JL6PYFcjKPkcIAqSMYFHIkUL8NKFKmvRTKxcMYLkLLEHIngLQ/1npz+vhGPIyQtkP4Z9OVdNUf21L/nGOArFeWmzD6bapLFXuVvyjYK3+57Pkdme2c2IB8KbDTwQo7lYnG1dQqoKXBLbou/droT4g5QYJm7zGfZF/P/eGrJfoFiiL4inBPLQyzbCZia8AG4iX+LNmpiQXJUv5GGjFyHASNWAesZWAR9rRzbi9iV4thGa8DfyJ0717IUCtZCbRqd53bL85ZYrz/nIDJEkaWMzDSjXnCRXPotEWzcmTxYiy1kg9Sc41jg/EVxEkh+Z447A29uEU0vNhSDo74OlP6yW1hZuXm1TVIhJj/zMY5c2dUzgxIfJBRNy4KAkJgqYxmudQKIFlo998N+iU01zzPBSjTi4tCYoKfF9pDZ/+C/xo+oT66p6qzxQamYXrlMtB82nRE9SB3Oc90jumGdWZHZh/0f53ZfWLplpkxIHm4JMZVJikactW5qpcOFRTsGw 6xfn/ju9 HcPUGlm2B73nInEc401P5uI6I2nFlq57/DlkgHWRrMUmQhc98UNyB+k+eMMwZzX9eQ8pcH6ZrdJjHMGzGupf6Mpps9UGvRmcoj/kXRBoFQVZWPaTbSu8ORRXPTJg1pKjlU19PRPCcV9pV84AvvNvMBheXuYeVV1q2J72iwS9NK6/PVIu7YDv6Ja0B7caIQZ/reXwV43M7QHrw8WL+AWYERT8qwmluZtQ69WRQQjEV11rBItmIbRo6sYOPcTEuSqRGQExsYeFhCu0N+ATp8GGSnl8k5OcRjmPJ79Ejo+Chsa5dXBl3HRUZ0xhCw8aU+q0H5yLX4yD4lFuWdkNVrqhAxdsiW+HC5GECdm+vE60m43A2u4Fi9eQ6LkVQmmQgywQksvo8odvcZBXCc94MNtSV6WykI34eNW8yQEM5OIk+Omhx2jQpYCF5kIK2exDbjELyXnVO+qAZr6Z6fyPS5xqdcWV3HgMZvuJReY3hlCDUG9Rbi0Hsnto+0b5cgBjp4TnOG9uJc+xuY+fy4lEndeYCClyfJbhhRlwrI24aCf5g0Z+hlm5wLEIA0tmCERc7JkgEwJPtbQAzJCMwFmXOKvgbdcoLk1psB3gXZ6rgnph4ooFFpRKfg4pdP2ajvZKtosd9CmcLMb553LUsqEnUUEQxLO3nsmP6saYeK0Mwv1jwktHsL4sSpNzz2vdJZKv4LzWWtEwUZfbq61pYRm05Lzvz6SowQHZgVU0APglV 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..1ef08289e667 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -95,9 +95,23 @@ #endif /* CONFIG_SMP */ -#define __my_cpu_type(var) typeof(var) __percpu_seg_override -#define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) -#define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +/* + * XXX: Remove test for __CHECKER__ once + * sparse learns about __typeof_unqual__. + */ +#if defined(CONFIG_USE_X86_SEG_SUPPORT) && \ + defined(CONFIG_CC_HAS_TYPEOF_UNQUAL) && !defined(__CHECKER__) +# define __my_cpu_type(var) typeof(var) +# define __my_cpu_ptr(ptr) (ptr) +# define __my_cpu_var(var) (var) + +# define __percpu_qual __percpu_seg_override +#else +# define __my_cpu_type(var) typeof(var) __percpu_seg_override +# define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) +# define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +#endif + #define __percpu_arg(x) __percpu_prefix "%" #x #define __force_percpu_arg(x) __force_percpu_prefix "%" #x