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: 13895614 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16E9921C9E3; Thu, 5 Dec 2024 15:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413381; cv=none; b=ezIGDW6ztWzYqEC9xgHVYYIWG72SdKE3l8TlF/ZD6eCtsJGuUtAuzsbUhJnUZrcEamf9og1hRxAJFzH5LqLVvyc7HyqvGaeKgJpxvgJLFvyRlvd69MTYcKEYpm3gTRbwe+Bkuu9p9jfu6xl/Xu1SAd9ZHiqq0rWYo6T6k+6+C14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413381; c=relaxed/simple; bh=ogmAtJgEaFLWhDuyZKKcCqZcT06MJkx7e0moOOTVcLo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AaD6gJ73EqvERTpPO+IvRX8YwrKOXG8Rra8nekJJIMDJe2m0J69iB9awcWz0KEivDZxEshLwfSFY//uR1fYdPRQAtAVIfTCFJ/zq3MWYAlyhwr5PYEBzIezYOx8/GidtXUU0A6Q9GgODYAAjzW6lCtRBS16gw7nvpB3jdaGKzXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kYdp8o10; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kYdp8o10" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-385e96a285eso648154f8f.3; 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=vger.kernel.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=kYdp8o10PdUAVd1FH7v3qN/VH6NqkwSVbMerHVWE0o0kh6lZJyyuUhyeY9wk7K9+1F q7JE2IOUGrkzDW2D6H8eIozpqa4dXYc0WMKfsfFzGbpZpv/lhHHorft2jphF/bDYi71c 5n4jPiC1hH6uDb9nbMLNkgJootDmOwetEiuQlJnw3+3d5BCrpuWl5Iytz9rVUXG1aRMu vhoFzrsbt6ew2Z8uW4PKcxWgBLGy/J0WAB+YXkdbRVMWhXPf07+hvgLu1OqtwRsYFbBt EZkbgeDrL04yX6udmQszCnqY0SBde6oRr3Y/F6Uc4zZ0CyXaw4OzXSIrYQUzKYDmemPO 1ivg== 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=Z+72ssIV35+8u1ghwsT9skRSPEyPhjPuciHxCsS597vDJGKPjQx6dpzWI7T0g2UjNZ iXXNjjD00jqDA0HhnOTnhlldsWOWnufqVideZC+1/SnPeJZZRxc6/qXgThKWx6fCDdnp 6cnbxxZwyREYBNuj9LuBtF7C+oUqxai9d4qRCYEBHFjca/8XHZ6mZAQHddtWW/egKQ3K qA9JAbUUrmGC1zOwAXoCsB8XO2G9Zn0UuArzxIkPQu9/iadUrT6KlrqAltKD0aznpbRm X5863pyd8MsRZ2mnTgKAKfnNyp2REdSWRFqe/YfrGV54e4z7SVWI2D7UZVSJFsGTJkW8 pVHg== X-Forwarded-Encrypted: i=1; AJvYcCUvgJ9gOL7MzNrIgfqMR/48ljkSmYoGRgB91PYmWU/OTC4xlTDspQ4XO3o7H2Z6aFw4fFHIu8dkmf+GKygB@vger.kernel.org, AJvYcCVhmeXOw0cOWIJ/HvvNNbEnY5E6muMd4RLrn0TzMxYKhkJOSNiByozuc2ro1a0byDoTrjKwAes4OejQn01C0aw=@vger.kernel.org, AJvYcCWFlj/pySuzQL1SXKbksczoiGIUi+Ej36DsDolzE2HuKnCKB3PmMBONf6YcMCe3qCVRQWtbNS+P1JpF@vger.kernel.org, AJvYcCXQk5HjcG+d2QT0uYsodqtkSnHEwz/I8YUriu2SIpbT5FHJko2y/eF0meL4E5p5j+l/R/NoBxu1@vger.kernel.org X-Gm-Message-State: AOJu0Yy11rrsTbfbI9poITA4oXHECSlc/VM4t93JKdbEfQvA+VX8Raiu pfoPbDi9vNFTADJHOG2y38OLUSHu18YZi/aZSScCfR0H80IIMdC6 X-Gm-Gg: ASbGncs4dxuRA+hZRFVqxMA08TJRLcw+w89dmGTnUMC629qgs7XJH/Z1T/+frnGfHTr x2pm/Njku8UVszuKeo6CbxTyy6Isp5ZwDCu3AZwBkNqtJczSZ3Dusj35cYoRpHvofmxII0X372/ i6/sINH+9bVriaEZpjwAtpQxj4ys8Ri+qdwSJSyUPMSPXMz66qDHeMJy31O0hqL61jZGxZMdNV+ exPN6IBgUB0PiVQ3U35+PIJy+elv8kjWhL9zFqaC823/BfffoXZ2L0PL6E= 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13895615 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B36721D598; Thu, 5 Dec 2024 15:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413383; cv=none; b=STJCkBgq9NW0cw7lkV4dmCXtA1FzmsFWVXG0N+qxWHc+hDG89/DPazY/uMDzXE410wHhzKXLPNTgQJu0HEvP1kiUSFMF9vzBjDtVvs8JoM0Y273u/1Q6x7E+7oLz1YUIcSikSLmKhIoS5xVnZ47brom2stPQ1Re5ClQr51R7bHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413383; c=relaxed/simple; bh=unFCMuepgf1SQbq5AYrK8xHbDJUoge6TMBDvQpYj520=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YjR+K7vL23gcKqp6uDcdI0XiGhQ6Ej2BtHsSaqFFq46ZoxhY2uD18U2O0gDFhi/Ww+ZH+nXOMyl2/gs5M8M8jbLDm9IT0TdKhvGynrkRW9iD8BX3mVc9v+rCWIZ+b9EAuPsCiJOHqZAS4Z6YXY09pRcl3eqAESi6VI7WimzBFBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h1NEN0vU; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h1NEN0vU" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-434a2f3bae4so11372355e9.3; Thu, 05 Dec 2024 07:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413380; x=1734018180; darn=vger.kernel.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=h1NEN0vUEoWlo9MYLfR8mIwXQTJoVQgQ5DeLt84drU7UWhI2vXuO7s6xeDyLu5QzBs fmp8RT/RI+FLkbKdFM1vXqmBUJ60vy8kOW9zTqNXEgjbpJ0z2Z6nUNB7WtUj8Fq9awrE DPsPc74f3fXvO8zQci0HxefJ4jCX5/F2gaSe1aWn6jWIlceQ0A7YASh8Hby3P2W1agBu zKfbu7OZ2qdnWgOxIjXOqBueAw8NerjuJGaZDxDsEWpW/SE8E+9u+jFG83vKmjFta3ep /UpGxug478g7Cpsp1ZQR9i5YFWZWLn2B4mq5ONEbglWa+IoMSLuuSreGLDhs0FYT1AUt tStA== 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=rcoU/7sTIYMu+HjczdiiRTi/K6NZkc7dhd/AZQsJR3Tjyl2wUc3QYz0Fm9LxKmD6tE sJqdSjFTs+BjyJA8PiYU81UQ2RoYHdiAGX62JND2t6ZD9AIqKvbn44TU4Y8vHhSr69VR inFVRUZ/VEPM7qaD9HWGlmP2sfdoHq+xQOSUcp+X4wGCOK/WkpYcPXz/iXF9+CydQxBG TI5OcwW1+/mZAMwJHM70DBlmYcjev5WV+0gug0+AiAaOMRUKz+dmhIYjih6qEAkdXUIh JlTSx3gka2vaVRv2hfjyMMR5GD1Zcp+x9fmdinbkQXwQq2l2N8A0KJd6hIPA0nArg24g yvMg== X-Forwarded-Encrypted: i=1; AJvYcCUrLl6RzSUlVLNAUpGy26j1m+CxDT77M/x/gfSz+S+ajItHDjjCxaGCZEgSjnqlQXYlPnGKIRd3jttB0F59PQQ=@vger.kernel.org, AJvYcCV3vxBpdMNw+njvj3SifsIniJ4vHhnEG4/IP//IZ1/WKaFYYbkT0r8iyOgonLN6rssi2wEacgCI@vger.kernel.org, AJvYcCXPkNokZtGyyQ1n1hQH/MzEBgOlDmEr4igtjjyYDjI6hOjFf1+hHhvauyEvd8d5HXEcEODnphZ49w9a9z3T@vger.kernel.org, AJvYcCXtzOlXxlD+suMtV0gzZL6uHVUrQcV1AKsVnsqcpW+bs2szupeagxzinID5VNPy/si7VW2u1S5gYDKc@vger.kernel.org X-Gm-Message-State: AOJu0YzZwgPgEGZ7CwJjzdtZ1Zl1VWTg+hih+Ym3hSry7KrjY9Wp6Vuw 4NgWiFGwhItesiRlIfdum8vE4j0VAcoXARgtGUySmDWJt0jz/AhY X-Gm-Gg: ASbGncuCozX2YVO/jab+c4G13jsm3HDIuL3g8LXexnkt9ITSvYnCeZO1JMTeyhfV7WJ wtlJnYyi2L2oQMvmuSDHWN3SDEcYO9gEpkPeBPS6ANqpPXEFNpZPwx/FAyCIcocbRQ824B85Ik7 ARIjTzJMbcsv8sivMC7K+JXzmT4d93HScZXgbzGJKtkGNRDOilfzcEqy5XUUDnVjR34ajunW42Q Kdgwhs0iyFXpgU07YkYEguqtnHkq5RukeHMebnstDxwxtaMVfcP2ahgMv4= 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13895616 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36429221449; Thu, 5 Dec 2024 15:43:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413385; cv=none; b=qXjsdypJqxEd8cVYd2QSSam93nEbH0uFQLdt3wbPLcM4rjjO5w3PTwVsGniiaa2lSPKhrmobKBrOr3AA/cPMJvB+5+dvFkFFzVNoss+8C2Xj7Pp+s7nEmaZk5Mu0wQKf/naY5KnELFquGFU99oBhwZDnsm9mCoJYDuRnwwhHGSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413385; c=relaxed/simple; bh=X8NiumfnTTX9YgbmHddxFsVSlZc7+dDUKK6o7LQP9GM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IXCLbbKPb0MtKt+z4JuqfCs0xWKS/MI5XCv6RPJuTXpMRPflOZyuxhNT8t5gAt4pFnmHKPlhPs+Wv2xyTXxmQyPQHi8n9+aBRHcRaV4Eja48FkgNCPYUpxpL74xHzS6aKJZvskQxRs1iGu5pRX521kg7h8EcneBRV3ngp/NG1tE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KmBBzpEI; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KmBBzpEI" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-434a9f2da82so7459515e9.2; 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=vger.kernel.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=KmBBzpEIN09nzeZG/UAhJ8DLPdS2bX74dB5mRx3Hz846DrENlihy63TVT2Ts70CgoF ExQGzahnvtKfn25QvYEvDQe4cbDvEpkv5DaFU0WOczHq5HG3SUEwN0mjle9Q3T+Ivu4k XvugqFpgjtdnkH3RQkRlWxvgNNrdTnGynBY4lyJBpGfyMkMG1s9BQnzSeUeVsM+yWqxH 8vP7wNkWvWn8NAcpoqKAneBF16J8BffTTKowwUB/2GKAgFrjmWp9UgHV3CC5GMKHScFC /AoM57rCI6zsCJRdcgHeD3ejBfl5YzjoGhKFZacB+6ocmuBx43irguvtPnTkJSWDVQjn 5j/w== 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=BJOzpe/oJ42YRwBGMo6z0/72Q2F9ZsepOZVVFvl89iICrBLGgbK4vWnPHtnQae5uiB PygH4TE3ArXPLa0btEO1DftObqV41Bcseffo22QiLI5WKIufHZuz6Jg+j6o9Cq29rtls oDcFALCeXMrkpYDcS9NiYK3s0Aaw9tuZBf1+RkSGlxKf64vqqWxmzfo//9evzN1tHsuH LBZGhB6qOz6qis0lfoY0e0uAmnC7o52mCczzBEUeLXo9kL/5sOUa7GCRpV5eMiB6czJG VEa15ophDyOVy7i9gUWx0HYqaq37A4dzcZFc8dJd3eNcntJ76U2HDEQcNo6gOL631i0X F6Uw== X-Forwarded-Encrypted: i=1; AJvYcCUNt34kKS5q+7L+MoxN4/HLH4YBWRn1Vb9UOO1fzKKOnz71ndl1WoKAfog38DB63U2I9VtV84CWt5RnefijtYE=@vger.kernel.org, AJvYcCWFA5UCgkXxRIZDkTtZY5/TOKPuo2qoC4Xanizs+0jnywlgxlbkgsXva6IHQ/GnG0QJhgRVSPS0Sbh+99Ct@vger.kernel.org, AJvYcCXFybuiH3O9KQxhNAfGUx5wbIo4Rw3SECT+37jlIFMkMZ72fBVAOfAtX8rz2On8dMQBct+6cLMPksvk@vger.kernel.org, AJvYcCXmGLSxM6a6HIl9OnmpnjZKy1zG8tfgwfnUH8itgPZD8qEhpupxNQKzl46bQLEsTPyT20TOOEw7@vger.kernel.org X-Gm-Message-State: AOJu0Yw7DEfdQ6qstIraUEBGfJZ+auNlQY+VNM8E6RCL/LW5dgErxCHo hxoU3J6XKPQjTBLf/bfolkHleSnjgu018yCopU5wl4jar1muQgQz X-Gm-Gg: ASbGncu0O4UqGyH+KYFOCaG/tbgsa9gmr3fUv/zyT+zOiKZRxqVutj+CffC0VJY58KR O2uqRor/NhSPEgXufZ/XxBPC+whMZnrqMpfL2muDWqLwYL0Rqao/S9NW+I8QZn/h8IF0Cx7mGLb AEv9Xl/AvKuZ2OzlRFknap+2Me1UOtL8VJ+XXxeclC8SMM/ivf4weuAIYElOfJUAKSVscRuPYnb 3NG9wMkZpTC10jfq+7qcJiY/wPYgsyJ2jhb+l1Bh0ZX+qi+EWZhvTmkjlE= 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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: 13895617 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D23521CA1F; Thu, 5 Dec 2024 15:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413387; cv=none; b=MD6SSuRJd8ZNtKYqsMUTmL75N/eIL8WDUUBZwhQV6MTN/yWvo0JRFj2i/udf/sO0W2ru6g4cUyo/YS21pezDVQFs6+OY8xStiE9rpIH6cYoG4r/eglyMhTIvhnwcAB+uJcKvlBKDOrpuTNo5eSV1MGm2yxQ8ypFklpyYW4xZDTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413387; c=relaxed/simple; bh=SzhyOtEUlK1I18A/FRrdDPLMEZiQ14djozclmiZRTbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SnQaJ2NeVCHpPNeIWjB13f9QI6IEFBd+b0+oEQSEF/TViN2Xd9lbLvsQwp2TDa53/9Y0b0OI4LH2vDiaxbRMrF/KNhOwHEJGnyS5K4J3T2eeZE6yfJ+1dnnj6og1u0P14sDKH0GsUk0XzFZthvgMmXRFZ7Obwg5GOeSmdmCTezA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eDSJ0WY4; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eDSJ0WY4" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-434a752140eso7419565e9.3; 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=vger.kernel.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=eDSJ0WY4/FCDwq2DzY7sODawMIeM5l82rPmwAjJC987LutZfNnI93KmJpuhT+lsgj1 pKGisQJ3vIHCRdhrEix2d1/dvUk2Ddj73Cu8OMKSM+NwSsPqJi9kl/st2G/SkehvK9j3 lFngvPYbxkJY+6AKMNCjWAhXsNzatNJLFJN0TjbDzlu8iF2MeTNPspr8R77cZ4Z3kcPx lO1OlczyftvssrSVA2aDH6/ewLBCsJ2iBvTjvDkQBGr5DWsW9YpDEchJveJCEqS29bTl DkUJ/pKg/52adGJWlIVmm5E9f9Po7O1zv4EQDMMM/Nt7VpmOVwBlGu3V8WmPjzo8anzE YtXA== 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=u2oX2BFzfvsXxo1LpEOH+Z8oqDjhT+jtMvMJutUqhm16SWem1x8hGvG/1sEXRLbbMX DsfN55Di+e6JNPOXEqj3vZzhb/ROt9WEkl5dKbpSKSDxG6Qd+yosJAz20n3Ue917b9pd e5IUT0zCXHo3e1/hnpkjy+xNA3gTVeMnstRjPnefaZcxP2L4OkKQnyfrAN79FOs2vcG0 2mnrE01WUgft6kPnbehCjIFnFlAJNnhWuwix0NGuheXWmks+3wNN34JGrXANtD3s23qg F+kjPozu+/DHpa/nOptxEYIbNpnENpmWbSkckB4L3N3HynBwSO/pBUrI2l+NhVouj87x +2mA== X-Forwarded-Encrypted: i=1; AJvYcCVYmnkuPnxa6I+zCosXc+4TE4tWz8NNxookQCql6PFkp/mbgkX49IQLwTjvy36GKiYbj9v45lneOvAfFlp4@vger.kernel.org, AJvYcCVisWjdGbX3SMu8ljqrEogx/gCaFxMy8fit7wHHmDL7wEfHA0dvtHytkvuC9vYaLyu7nIBvh717PYPhjqlWpXQ=@vger.kernel.org, AJvYcCXXvCO3JoBwducJ1iUleycdcwhOHM07ZNXDHL8G+UHF/qYIGsmR5pcLoPN42Co2CZUeYnvX3Sm+8Jvk@vger.kernel.org, AJvYcCXp7L1YyYQ7Qc5hBfJ4pACH4P/2JT70KH7mdktNdwWxjw4juHKQK5dxRdnMaqsGz2gaG3A7qFtb@vger.kernel.org X-Gm-Message-State: AOJu0Ywvo0Tg1/5BsN3ZxO89HPydCn7vREYGeoAXQukQ++lrQsgIBH5D xHOT9EXW6om6TrH4fSW8X6Ph8pKCouVo2fbVKhDmANozPlS70duX9NP0+XMJ X-Gm-Gg: ASbGncvnbHDdnq4mFcxVlb0p2hUZOdVa9UOFqb7FvT1V5J5jaL0sZWxC7wVDgMixbvI bKsckak07OEA1tJVbMpl5V11IWjyEzRE77SZUC3apkk9rboD4H+Au97NEbBOUHXqo/kAVbRRowP jugwh81suMQ7Wa9fbczuFH8AdDlQXHwbafnaYY15Nx7/pTukXNkT7ju5JjljNfXaR/4YbfE6N4h ECUdZP5HJtqNBY0rCqsRn+KWJXfCQUlluX6Xa4CbosVmh+RThDv4l8Xqlw= 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13895618 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7400C22258E; Thu, 5 Dec 2024 15:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413388; cv=none; b=gvQ7bt34g3eJUNv9gsNshL235jFdhhQtEumuwJiDfdGaZGw40UeItTbIX8sA4AN6S1jQub/n696koEpD0IF1jD7TCJtQ2OSOdeUc4I9o85eoIKvxXp6PVa8lw8ucQypQoKvuGhS2bEAY4GYgXY46dZiYCCOdThJiMYcNUJV1GAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413388; c=relaxed/simple; bh=ktV65QC69LkK7D1GQXmkIK0gDDH2eVmDfQ/nHwDJYe0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ePc+cUzjWVFbjHXZSw/RyQVyvkKTo504N4kYaeBLam8WX7O8aoLgfR1tb+WZDRRBIMt/IiqHErzBbazHsoEwQnQWxRc7lSduj2VD9NENfPmVqQYe+UZZQnAFF8vSdUWilm+RfpgrXHezWu3i8wylVsNNoS6drlK6nIGH8fbfySU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RGBowfRR; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RGBowfRR" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-385dbf79881so1406834f8f.1; 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=1733413385; x=1734018185; darn=vger.kernel.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=RGBowfRRrqipHUMn0zu1FqonY0cYxVJTEs+NDXEveFRd59LfjyMYnmWgP75S5vn2a2 uMDltCJD2GWbjeiXxiUslKNZtkHI2I3TAsX5oOG9bFxxPBy3szTrls+E4VZsU5pU7FHQ bWCo/uGNHM/5+Id8lldbVE9I4V4x6W7ashCDaWgWvvRmJBdWHGKcrq1F29CmbyxKJOe/ sOlwcZLWnGXQVpcndF5nHw72FZmVkSR/5ZI6s3azm4y1a1fW1UuqRMVTY7GXMgfMXXcg c0LWxrS4Cr6sVBUcFO1iANTkMFL+qqSobIBIABPgjA+va14pBzQ8ERkC3WYliHTKjni/ +pRQ== 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=vmCUC3imJzNukd1WiLIs0c+SB+9WziCDVKt3ItaFvj4vXww+b7uY1ksGpDylKdnejc tdsntuRoWtSXYrtZtBxNCpfXkabXApunQ9oku0XFSJcZUiWt5ay43r6f6aundl4/ZebD o4AMWnGjA9ZFlFc5fX46Z3gJSD13qCrjIXpNfcIgmxbhWeggO2vRQ5gvea/0TkyxvPo2 YszDRPqQSC28ZmTjotImWIdto9stBn8KcZuyHusUFWG6QSMhr8qSWQUAXejM8JundKnx ZzUIL+HVAJlrDCkwWuEeRklTX2v2xsIHGNjn01GqOP6IrIAnMudM9RiYJDFQ/tDVBcyQ lYrA== X-Forwarded-Encrypted: i=1; AJvYcCUVJuDtANP1a+DfBsmisvJX8SYJiawh76PwhX2NpSUrHlfpbi4cl/a18Lh0QTeD/0TLK4ND0azgGxiv@vger.kernel.org, AJvYcCVNM9VEvekwihi2t5xtA0na2Ygg1iFKVIkPxrJSyqcd0l3dNYkVVyW2VFEziYUYYFLw2sa76fhtW6ioq3Rh@vger.kernel.org, AJvYcCX9RTlvY4rQELX3l5Now/nsh3MQUN3Az9QwhgQldgSmbTRkG63+X13MwbzNFutZYk4yrhhBF1R+jiIkxU4D8eI=@vger.kernel.org, AJvYcCXqJn1OKtibHXMbMgK78l6leuDjlSdfyFUz11pXOUhIt34HZ2c7q2BJXQfW9jA14fsn8D7e8x7r@vger.kernel.org X-Gm-Message-State: AOJu0Yxc60fdSXnNRCdriAKa1UAGtJqpYUBIui6YBpvtovMbOwoOY5JC JOptcmC29m8W42JaoUC20fTJbKYbmZbUYLx0xcIcniCYr2Zrh4LC X-Gm-Gg: ASbGncsDTQDhVEFUo4mGeb+lCQSz4VpG615bUZPLZCne1lkNDGGKpaXN8cg4EyYZ+1M PGDwcg3Kc8s8cimgyzN+/G3RFCCdYeqNdNBFjWsytIH4g4wP4vG3Us1ymQzMA7iX78e2nY6B6yZ lxQFKqd+UAwT8AUrMlD76RgGauzUfwePR8s1lGUxXAyRW853zpktajLwAqIxJ9pAHw8Tt+AdEDB jqmoR/613iU5Ol0ldD3IClu/lt/3eaIJHUKZ6/NzWZSqQ37ljZOcJ7gqFw= 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13895619 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 862E521D588; Thu, 5 Dec 2024 15:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413389; cv=none; b=NaaT9hD6+C4vffHI9Sua8ZbksDa0+G50umC3C3aPVuSKCSz9U6Svdo87rxKWjV5eSI9YRdqAsn89scVtMnWrS3Cr0EsM8WlyX3hDBiwcAqkDrrA6M0GtnQ5Kumd1F0ZczPZ3VanjBf+Hr5Aqh41mX1XXzAjSRSLsAjV88cRCnfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733413389; c=relaxed/simple; bh=JLONeVzsZCBy3eSNw681X3ItRvbVGoCCoYm7SMR5mOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V9NCppen2CCznQrVDfngIuKeHZqrhvzK6wVkZO6eTTbn5VA3AjrBbrWU84e0K3UUXkftRXaDwWl3IRHdVLuA/mXlr5B8QU2cxrqWftyrG6PJg3ajjDH9b4AfLnt3Z+OHrpegVJLgGYKyVBqmP23YXL/4FS2WVFeaBUFIe1fPz0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lxjowGR6; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lxjowGR6" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4349cc45219so11071835e9.3; Thu, 05 Dec 2024 07:43:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733413386; x=1734018186; darn=vger.kernel.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=lxjowGR64rzsBDN6zab6RwPQyAgR849OXaTYtocgrU8drOfCtmTQkbAiv575SSE9bg 8iFu7C8x4O9SEFH8uAe+9GWep9mwWBVisPRfJkRSlwl5uYj1uTsCSD652DaIn1s/i9Hu YiwjlTY7tu/zTB8sallw7wHC4OTA694FIsIRhn0mViCEW05BLkyw8Z7UiORp6qglRxOo vFGoWGhXl5YK9X6jRD12OTqxL9hMg1cUl+vnBiY7fDcItQnW+Y5OTEBqwrnnrrIkViSI 0C47J+9x+nphGddfVannzaqNH6RKH0BiExTdkPAv/+1R5EOccDKtQ69bOpFR1HTe6te6 J7LQ== 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=Kj6mc+Y0CX2QzXB3PHkjBzNtjjGegqmi4kI1Q27f27V59IIMBChpfldXZzdqd6TVa1 iK6EvhI44oYxUCoqiRPr6NJVfXSC830rgUfqfEbpjtCuu4AND2kXlQBH/T0UH8oVaJqS dIq8+J3RC8VLRbaLxalxF/9jfXrD/X87wec6GSHpIOuYkYgtlipAilymR0Nw6vIr416n Mw/2F6sHzwQAXpiEhmcYJY3wN7cHhgi0M2LziaDltj9Py9zdFHn5QERAbGOnLARYMTV0 +fntFyKP/1H1f+nq+ZeYA17Akl1l8cLsic+m/1ZfhbG1lpa47kIpoo+ZmWdzC8QgwJe1 gkqg== X-Forwarded-Encrypted: i=1; AJvYcCUAt3bayb+WhQepWQHi0zF09b7+ecZe2iV7L4WKpgpB3yhZGiEpwaAdv3DEDpYQSRla77YiEXEb@vger.kernel.org, AJvYcCUp39vJux0c+Zwo3C6hYprjydNqmIo4QIP/X1NdaR033VtZvovlEn4woeUbmLlWSBjxK7Q7bVV0BY0Y@vger.kernel.org, AJvYcCVlie8ugT4SUVnTA/mfiSONRSfciMsJSINLKMfhByBn9QiJIk1X8+1DP68+WelA94qw6h98MDwP6pe1XC/6@vger.kernel.org, AJvYcCXqAGg7+g32ARsv+eXOoKhmOSg+mYFcUqgtUXbg7IW+8ccv8F7QkSRO8VlYR5fZJ4RyyUAj/asuV1aHULkGz6U=@vger.kernel.org X-Gm-Message-State: AOJu0YwK5mLL0E/SlRWw2AgPDDFZ1VXX/6OreOpB0ljZue/0bTaLRE3Y rSQtWp4GEm0HIU6oFbsYvACArQiS5dxYNfgmNMAcLhnmFcCoNESt X-Gm-Gg: ASbGnctX0dha/A0xJ+IpiK+DJ7t+ZpzNi+Zap5tni8YVtIZxd6apIKuxedV+dfWkgJP UKREJWwZz8btJxByTCXr5WQBFFtSCuPOD1Hnv6ZEdmjcSBijXqveQo4ZOI0hg+xr00zYudzf5Fu mDH5u0ofix+3rBkjajlgi7u8+ScyTM5lLCvh/vseuKJYNk1aI6jeBu7hieoA/CsbZYcsE0mAKvr X2VvTcDXdPZD3kpSrsldv4GFQOuheP4TskSGV2o5UjbB0rwck/zp2NFwdQ= 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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