From patchwork Mon Jan 27 16:05:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951596 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 0C3A9433CB; Mon, 27 Jan 2025 16:07:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994045; cv=none; b=tqWQjAmK7TQcdMu+587RPXGB2P8RrCKPC7jIf3QM+gdS1Wx0MKoRNth03GUstXTc48l7psASBMXVgj8Qph5dOcbszxdrej2n/4JrqZSF6bG8NYpAQuZCrH5RYENVNwi/lQVm944wMKgdQ4AiWn6uUFYZJUMcG4l0KpMTOab8jm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994045; c=relaxed/simple; bh=ogmAtJgEaFLWhDuyZKKcCqZcT06MJkx7e0moOOTVcLo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JOx5bl4YyUGzfmyru+yhBGZnenIDU7/3PhNUhiv60wkxUSWMe4O/sFRiBIWGVf1d/+xq9eYFE65GUIxni4+6dLbndGKXvdT7iDNyB/XFAddJf0T2Lb+GoJDnMCbXbWaYjtO+RJUhH/LRO5iRzhZ6MfkpTWGPuctQoEDmtSUKRck= 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=B1NAwXsv; arc=none smtp.client-ip=209.85.218.53 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="B1NAwXsv" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aaec61d0f65so1010201366b.1; Mon, 27 Jan 2025 08:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994042; x=1738598842; darn=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=B1NAwXsvMciORuJURVCZ8WUkCjZ1Em7U9BI1FjEHxco3vImD2VYWn/VfnHauy9yAfo uec8j+P206TP0kx2a2OeSBrGHyJIb/zy+pYWS9RIQ4KjZiToXvZNb27Y+yeuZnV3L9Ot 8Ahc9uGZZUFduXPZbgcxOxdAwj+TFJqjVCiU5Qb0hQBpR2SJyL2NjzTZ3HPlBkv2liIr hfHdw9Aey2FDN83olHh0G5iqeWEePb129gFcqLMReF979ZmRsgcKq6pw+8+2VkfNBPVj 05Sd2hsuplFuBka8xXs0z4ucr+YaQsrII+5Uk5VMerS+w1VyAOaizZQqc3SNPxRvtVvX dCEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994042; x=1738598842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3PpdJnIt0LB5LuubDznUPiNtcUhO58iUpeI8CzsV/cw=; b=PAPUFwLPz/xGh9EJ9Aa7A5Xuf5GZESf4Gwc1jFzOnzgwNuHUXWSfiGxtDDUR3Qf3vu hTghqQfvldf5zh0/GBS/BnA9TWAnB6++Pj+hFYe4UJTsAUEdq67qR3IJm3K13a333Qnp Be+GlaD/WWPagDHd2xEsyWJMEBeqK9te9mzHbqEPnpRr2Kt0BrMAMFLXxilksg8iNwQY KU9ifjEfk3vdM29KGfZSGWH4qkwcGioW1WXGYtjaEozAeYU1S6MnJdUHhvsmCQpg48if Ik/xwC5l2hj6tlKbjEbGUJDv/QCVk5LcEii4wu5ZtfU+S+IJWY/dIqP9j6zNzdgjqsjH cUVQ== X-Forwarded-Encrypted: i=1; AJvYcCWA07g3SnLDQt+q02Vysho2xYAaaoeyCH+nDy/lISqhExoAVqznS0C+ADTarFZ0aQ6i0HPfJJM9HB0t@vger.kernel.org, AJvYcCWBJB6NO5e6P2T9Ji1n6ykt3Evk9+ooIjoQkdQoTqIw1wYR9eEFfEnQ7GFdJpjwF7aS5PMguCS8@vger.kernel.org, AJvYcCX/Ci3EkPzmQuoEERbhA25yR/6yGlzPaX7wPE7UFq4QfhMHgw2Q1CpbNtig4mstK/Xtp3lex2qZHdtOR4Zc@vger.kernel.org, AJvYcCXtqod+qzhd8zG50p2Po48iCGWOAetklhhudnrHkoe8sIx3JEk9OzsS1dJHuoGfYugZJL+XqzDbGfKaco5ljPQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyZdXXG+sgJ7R32wqOo6sa7Hp2dZ6aVnQnIi/ME/mB0KfMQ4vMN 1RLRWpclU22aNMfbwHKz+Aggri4rS1vUc52QkixCgs4Xbz9xSnQ1 X-Gm-Gg: ASbGncu8PrWYURQqBhCrlzUAIbY+0gbhwdvbm1EjFFYWvzd30kEyWcmnI6UXe7rPi1n 0zjMVkRCvpp2U+PzJKpr4uv7d+kjbdskXraNJUbku2CxQnmIWr6HAuePKUHR2DayAYnhOvgsQCC llyEg0vf6fJJEaq8Uj1iSxwQmNrv7frkNrgSZLf7AcLE2+THa5BMyUJrBt2J9DmC8Qdpzfbm5SF zjHm1xFiOlGveGndTGeiHYiZqfp5T9yAopCkM2CiMjmbYrGvvTRreY/gBSK/M1iHZ5yVyvcGHLt P+JFaRNCSfF0ig== X-Google-Smtp-Source: AGHT+IGxHekg6wyKtSsIHlBYr5ZZfkRZgv/1+kkXgRb8vYd9lhSt2dayN8UQWL8xHzS8S9+szifYTg== X-Received: by 2002:a17:907:930c:b0:aa6:557a:c36f with SMTP id a640c23a62f3a-ab38b378436mr3836172866b.46.1737994041908; Mon, 27 Jan 2025 08:07:21 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:21 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v4 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Date: Mon, 27 Jan 2025 17:05:05 +0100 Message-ID: <20250127160709.80604-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> 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 Mon Jan 27 16:05:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951597 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 68B911607A4; Mon, 27 Jan 2025 16:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994047; cv=none; b=sSqLm+fiONv5t87/T1eXxfsdqIx2ZsVULfki9B5NFcvZif27LzCmjN/AdxPCmL7Ynd3RiZW//WjNJuM/yL8rWoPVhYNUrYL1Ff4ci1vUhFaC9ocy3mFpLPCRwx8M9dPg+5+2YDM32uHxr+3EcmQVCbpWWMBnJhh2dkZr0H1/TMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994047; c=relaxed/simple; bh=vvltvsqkhSZ4zV6BYemVWLxTvnMXnejfNrK4rPX+kmM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jIm0zXQ0W+jjfhLP6sZmCoNS1TeVB0DsOMko+0rTGr4yvnC4mJ9U10ZaJ9OJmd/w+IIXfqzAenPflwHSc1cNftdQqbtJXNl2Nms012A8a5qFONUSwllRdw9a/zUuksIh4Kq8yPzQTGqnretZnLettk4tirImJXK+3xy/FSVfbpI= 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=ae8BIFbg; arc=none smtp.client-ip=209.85.218.48 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="ae8BIFbg" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-ab68d900c01so369963566b.0; Mon, 27 Jan 2025 08:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994044; x=1738598844; 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=kq9/i3Ta5l2MI1vOWLuY/2sULLk+AJ5LvhrOAI9bZzU=; b=ae8BIFbgpWURN2jnqWDKWTeLkjIvOLUeZ7Su0s4ZHiUCge9oHxYZ8FC36c1mdmBpKz WtmMJOTdCZh/YM1uknIKPkpA2WVEbRDcroOATeBFRg9OWplL4yNzLvfP68Q3wI/89dOk FrzHLTYWNcIFrymWKCuotGCD8APD7QDJg9fseCFn/KuyXbg6jsUMlna81UcOYj5yr9uL bHmUVNresiJJAH9N7fSl2EMwBYR6FK8gef0V08QlJeOGUqx/pT1aeqsEG78dClbauv8O xXqY/OyKgFkZ3iIfFSYk9VPfDMAWItE03qS3NrypA5I4xgaebhu+Rfz+hHrUsjBruISd I51w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994044; x=1738598844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kq9/i3Ta5l2MI1vOWLuY/2sULLk+AJ5LvhrOAI9bZzU=; b=DoRr7ie5YGu5HGW1B0ksoUYCcTlHnCeEF6Wv0oFcxW9AwuuMGuP3EAacTeczpLfGpM fFjqtpWTmRBu6j5CzrwaXnOQKd5ZgwcwUKActUkOvyWxIPVrlNOkJDnDYKaV/lVQKomU PQO6K2IXpEIotRROmxktaHWbY9cYeIIjNmc4k7ujoJfcThvMgrrIpnBh9LujiSbxi3hD 3U01zj2OEuCU6IVW288bDRecaWuAaPwSr9D3upOTyrSF9MVDxXSlJx5Zfyzg9viqqquJ Z/u6DzbIxDd5uixA6uFXM56cLt+SJetLAhAIJb4UdVYGKBs6w4JReSrY9j9yymBzFkGF EA/g== X-Forwarded-Encrypted: i=1; AJvYcCUCXPodH7hMO1+mIHmwbwbEwvUBO7kRDcmg3RyCe0xmMwuc9LxVRF7htW21RSuX+mgIQrZlImov2qqSOlRD6QY=@vger.kernel.org, AJvYcCUngWLDu8ZpaUMTYPJ9rsjIvWM4rrwwEWx3V9pB3V+eqkaAs9cAX/F3xS84XXjpTRgfXc//qpNnmMGD@vger.kernel.org, AJvYcCUzVFBX6EDRuDw9PjfYAhafEkPhN1QvN0qY1INpACVVubR1UaqsHmBTidAD1htSna1vIjFpCBl9b7rjD0pZ@vger.kernel.org, AJvYcCVwOJK4y8EnnFQtrO4pSvTvUmi34PZNzSC+Ujdz7q/s/hNPJ722MlI3LRx3+zlkz7AtwFjdB8Ez@vger.kernel.org X-Gm-Message-State: AOJu0Yz/JaQxyyTai6QJoThmuBf1mUsAbji+RyGbD4aF+EJ05EfEyQEY /3zcTq5HNNkB+ZCUAyTWjg5QpDwOcFiMF1mkL3xhImR6AWj1R6XVOMvRJ3jS X-Gm-Gg: ASbGncuP/kCng+v/FzohZwXMxgOgV1PJ1DxwlRQH6yq84UAxWIxqXrU3ItMgtGi/Xel WxwM3dE+WbyG7w1Qx3wy/UDBtu7PyeZIbKYdWf7VZn+KWVnSp3jBf4Qh4MAQUuk7AkZcuM1f029 +T+SGAZMy6PBOl5kyMPdnzAwaFb+HfW3U7Yj0AmJ7Lhgx5+SbwC9M3eNgVo7TAE5qQjPWzXvAjl pVakcCyRWkvqdlEXWHth5ny4XXinPg0XnKzSPZgRaM44/vTRPk46wjUovvz2zDvRhacvtiZgmTp JiKBdG0Eju5UbQ== X-Google-Smtp-Source: AGHT+IGps2FOyGZFh29HU88UQXaUARQyvefInzqR9JwB8VX2QVMTmcMPtTLVQtl0rzI1dpYkZKybuQ== X-Received: by 2002:a17:907:72d6:b0:ab3:4d1e:4606 with SMTP id a640c23a62f3a-ab662910720mr1670846366b.3.1737994043332; Mon, 27 Jan 2025 08:07:23 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:22 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH v4 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Date: Mon, 27 Jan 2025 17:05:06 +0100 Message-ID: <20250127160709.80604-3-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> 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 Cc: Thomas Gleixner Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Brian Gerst Cc: Denys Vlasenko Cc: "H. Peter Anvin" Cc: Peter Zijlstra --- v2: - Add comment to remove test for __CHECKER__ once sparse learns about __typeof_unqual__. v4: - Do not auto-detect compiler support for __typeof_unqual__() --- include/linux/compiler-clang.h | 8 ++++++++ include/linux/compiler-gcc.h | 8 ++++++++ include/linux/compiler.h | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index 2e7c2c282f3a..4fc8e26914ad 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -128,3 +128,11 @@ */ #define ASM_INPUT_G "ir" #define ASM_INPUT_RM "r" + +/* + * Declare compiler support for __typeof_unqual__() operator. + * + * Bindgen uses LLVM even if our C compiler is GCC, so we cannot + * rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL. + */ +#define CC_HAS_TYPEOF_UNQUAL (__clang_major__ >= 19) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index c9b58188ec61..32048052c64a 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -137,3 +137,11 @@ #if GCC_VERSION < 90100 #undef __alloc_size__ #endif + +/* + * Declare compiler support for __typeof_unqual__() operator. + * + * Bindgen uses LLVM even if our C compiler is GCC, so we cannot + * rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL. + */ +#define CC_HAS_TYPEOF_UNQUAL (__GNUC__ >= 14) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index b087de2f3e94..a892c89ac28a 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -191,6 +191,26 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, __v; \ }) +/* + * Use __typeof_unqual__() when available. + * + * XXX: Remove test for __CHECKER__ once + * sparse learns about __typeof_unqual__(). + */ +#if CC_HAS_TYPEOF_UNQUAL && !defined(__CHECKER__) +# define USE_TYPEOF_UNQUAL 1 +#endif + +/* + * Define TYPEOF_UNQUAL() to use __typeof_unqual__() as typeof + * operator when available, to return an unqualified type of the exp. + */ +#if defined(USE_TYPEOF_UNQUAL) +# define TYPEOF_UNQUAL(exp) __typeof_unqual__(exp) +#else +# define TYPEOF_UNQUAL(exp) __typeof__(exp) +#endif + #endif /* __KERNEL__ */ /** From patchwork Mon Jan 27 16:05:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951598 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 58ACF17C20F; Mon, 27 Jan 2025 16:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994049; cv=none; b=abqfNPi1LrYJLMvw10iIzJL4kDPhiOyD3UXFdesnbokKsVdRGdivFeRmFOL6g2t161hq9PufEmT8PDTitMypy09EPzyoYwDimLwPyKkGr1wy3YqQRwX3OG/ebR4ycDJDr3ZeL3gUHlwJXTcVbQp9gU5Ycz70qNDGUwOoKh5MNM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994049; c=relaxed/simple; bh=+OxcuWyTmpuvVZrJy438ZPLoZDH7E8GuHxtnwkkCxWM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W+JYpR44kbvr66S6A6nZkQSdaRgtyG2E4qLt6AH0C1LcvXnokB5Lpq5vIpjECI3zo00hlD+GrHLn4zM0Hx1q0PdnlO8URZCu4mnYgqarrbLFo0O7hO1ug9B1gYQ/AVgTAeNyanA6eDJJmeHiE/6aLrJTzrYyJbhBGbTK+9m/Egk= 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=aXLDTB2l; arc=none smtp.client-ip=209.85.218.47 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="aXLDTB2l" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-ab68d900c01so369969766b.0; Mon, 27 Jan 2025 08:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994045; x=1738598845; darn=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=SuZxe+AfFouuIU0wQHkXEH3/7ewa5etNqEUu9GIF73k=; b=aXLDTB2lk6O6zVBh7ADoKQlxm4UveK3OvoMyavu3ymqtGnSwDFYohFUT+vsQvcYnXZ 4Gn2tv36F/xzgJmG6DZHOGB2k3kUkN2qJLCARiYNSMjCZCDC8fU80H1n5vCSA58z6uiy JwxHQZVbEria5GZrihTQivncia53V9mbOLDeqML9F8arJnFVhQr1H9gyF5dUEKMffx/H XQuZjLz8DzYGN+wnb51eqPIHh0tQDmvoE1bkCz0zgDArnUN25KGR0f/hg7OV+6vDisQv rYAj6lKB5i+egADZAV3unDxe1tRZqxl7hQSIctRKo7LXaTRgrkeuYL6z+IjuQMY4GId+ 6g9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994045; x=1738598845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SuZxe+AfFouuIU0wQHkXEH3/7ewa5etNqEUu9GIF73k=; b=p+Qd7C0A9jDvVJdByVf+K3uOy62mAiRif+V14nQB4CoK1v0132bQsiIcKwNyRHJOM6 Q+lJQx0WlxYzk5jigUg/vdRIMqz9n8jiPTJdcYnU6fvGrfqEiFoZ54shqMj2PlHs7cDD wN0Ur2pdmGtu/rMscSu2/sDF4YXfBu+Van5QEDwb8Qy28b4OjIi47UWEUVTKE/8ZOLVS UGIQkI02UBR7/cwfCORRCWc+EJpG1xw+Fe1lG/HZBBXd9JHGa7bL3Lw02Am6L31Ye5QN /Gh/aK2gKZ+pnitpWl9yiuacPN0LoBRhzf9sVHjZqL70WkqXjKbN1v/7drfV+8HH0MX1 py4w== X-Forwarded-Encrypted: i=1; AJvYcCUEgFfCu5e4r4ORPq/513Wtna7AB9KBwFvY3bH/zPpu1DTuvVT3iVv6WKFEIC2c0qGYKyfGns+iVdqMXVvK5xk=@vger.kernel.org, AJvYcCViWIe/SA70T3ZlGBv74FjUnYHtf9Z10mX1m5dZ+nUZd0eeFdbWVrP0zby793KThyjIHhGxnbAL@vger.kernel.org, AJvYcCWzC4gm7ZQD+Xp2k5viFCghGz/r6ncBhjHKeWcdjaugXIhWjBU5Ays9HUw85UyE27oSNDIozl1AnMqZ@vger.kernel.org, AJvYcCXTLHAYGtsProesjkjTolRMr8ce011xJMsHyiBbuUz+Ua1akZi3/bLd4dMQhU3Fu88Qw4GAHrKHWtF6Y9q+@vger.kernel.org X-Gm-Message-State: AOJu0Yw6oyyDcyfbt1/Ya9dlRfyy6L3QjpLmdPH+mDziFeeeK7iLejwe PNWSt8DClbWI/CTLijXRSZzn/mPlhE6K+KUg4ZrdF42GgGnQV4nL X-Gm-Gg: ASbGncsKrjwyZDeHtxI+gmKaQuf7ZFn8R1dBuYnjugkTYgBR8jLqMLHIpISqympIODN UOvftpryQ7WqpFpQn4qEdec7t/8gQzCjm6HUCHrUPvXvElBYYhmU5BKgUvLA2im66Ix1HAqhHVH jhH0cZEnjPuhtyKkgJOosZDNGmwZReu+P6LBB67mzIFdZOw/3Nh3Ozbwxhs8UvJ/icrMnXIla43 s8f+ZlV6qyB4TT6rkI4hz4qyTDhAV+JuqPXH/vwRhDPGEbvr8h7kg0uxwIzlfCBvKn/X19nzU0H KFVvAOPbAd3v2g== X-Google-Smtp-Source: AGHT+IEhkb1QlpKpjEVh9Qlf5cg4BvflbRVDsJrlA2oE2R2yIM44Ae2Zi5eaJQiOnUdYAJplTRaD5w== X-Received: by 2002:a17:907:7e85:b0:ab6:59e0:b756 with SMTP id a640c23a62f3a-ab6629cce1dmr1786130466b.14.1737994045166; Mon, 27 Jan 2025 08:07:25 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:24 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Christoph Lameter , Dennis Zhou , Tejun Heo , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Kent Overstreet , Arnd Bergmann , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Will Deacon , Waiman Long , Boqun Feng , Linus Torvalds , Brian Gerst Subject: [PATCH v4 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Date: Mon, 27 Jan 2025 17:05:07 +0100 Message-ID: <20250127160709.80604-4-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> 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 Acked-by: Christoph Lameter Cc: Dennis Zhou Cc: Tejun Heo Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Kent Overstreet Cc: Arnd Bergmann Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Peter Zijlstra Cc: Will Deacon Cc: Waiman Long Cc: Boqun Feng Cc: Linus Torvalds Cc: Brian Gerst --- arch/x86/include/asm/percpu.h | 10 +++++----- fs/bcachefs/util.h | 2 +- include/asm-generic/percpu.h | 26 +++++++++++++------------- include/linux/part_stat.h | 2 +- include/linux/percpu-defs.h | 4 ++-- include/net/snmp.h | 5 ++--- kernel/locking/percpu-rwsem.c | 2 +- net/mpls/internal.h | 4 ++-- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index e525cd85f999..666e4137b09f 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -180,7 +180,7 @@ do { \ __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val); \ \ if (0) { \ - typeof(_var) pto_tmp__; \ + TYPEOF_UNQUAL(_var) pto_tmp__; \ pto_tmp__ = (_val); \ (void)pto_tmp__; \ } \ @@ -219,7 +219,7 @@ do { \ __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val); \ \ if (0) { \ - typeof(_var) pto_tmp__; \ + TYPEOF_UNQUAL(_var) pto_tmp__; \ pto_tmp__ = (_val); \ (void)pto_tmp__; \ } \ @@ -240,7 +240,7 @@ do { \ (val) == (typeof(val))-1)) ? (int)(val) : 0; \ \ if (0) { \ - typeof(var) pao_tmp__; \ + TYPEOF_UNQUAL(var) pao_tmp__; \ pao_tmp__ = (val); \ (void)pao_tmp__; \ } \ @@ -273,7 +273,7 @@ do { \ */ #define raw_percpu_xchg_op(_var, _nval) \ ({ \ - typeof(_var) pxo_old__ = raw_cpu_read(_var); \ + TYPEOF_UNQUAL(_var) pxo_old__ = raw_cpu_read(_var); \ \ raw_cpu_write(_var, _nval); \ \ @@ -287,7 +287,7 @@ do { \ */ #define this_percpu_xchg_op(_var, _nval) \ ({ \ - typeof(_var) pxo_old__ = this_cpu_read(_var); \ + TYPEOF_UNQUAL(_var) pxo_old__ = this_cpu_read(_var); \ \ do { } while (!this_cpu_try_cmpxchg(_var, &pxo_old__, _nval)); \ \ diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index 1a1720116071..e430a32050c2 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -609,7 +609,7 @@ do { \ #define per_cpu_sum(_p) \ ({ \ - typeof(*_p) _ret = 0; \ + TYPEOF_UNQUAL(*_p) _ret = 0; \ \ int cpu; \ for_each_possible_cpu(cpu) \ diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 94cbd50cc870..50597b975a49 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -74,7 +74,7 @@ do { \ #define raw_cpu_generic_add_return(pcp, val) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ \ *__p += val; \ *__p; \ @@ -82,8 +82,8 @@ do { \ #define raw_cpu_generic_xchg(pcp, nval) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) __ret; \ __ret = *__p; \ *__p = nval; \ __ret; \ @@ -91,7 +91,7 @@ do { \ #define __cpu_fallback_try_cmpxchg(pcp, ovalp, nval, _cmpxchg) \ ({ \ - typeof(pcp) __val, __old = *(ovalp); \ + TYPEOF_UNQUAL(pcp) __val, __old = *(ovalp); \ __val = _cmpxchg(pcp, __old, nval); \ if (__val != __old) \ *(ovalp) = __val; \ @@ -100,8 +100,8 @@ do { \ #define raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \ ({ \ - typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __val = *__p, ___old = *(ovalp); \ + TYPEOF_UNQUAL(pcp) *__p = raw_cpu_ptr(&(pcp)); \ + TYPEOF_UNQUAL(pcp) __val = *__p, ___old = *(ovalp); \ bool __ret; \ if (__val == ___old) { \ *__p = nval; \ @@ -115,14 +115,14 @@ do { \ #define raw_cpu_generic_cmpxchg(pcp, oval, nval) \ ({ \ - typeof(pcp) __old = (oval); \ + TYPEOF_UNQUAL(pcp) __old = (oval); \ raw_cpu_generic_try_cmpxchg(pcp, &__old, nval); \ __old; \ }) #define __this_cpu_generic_read_nopreempt(pcp) \ ({ \ - typeof(pcp) ___ret; \ + TYPEOF_UNQUAL(pcp) ___ret; \ preempt_disable_notrace(); \ ___ret = READ_ONCE(*raw_cpu_ptr(&(pcp))); \ preempt_enable_notrace(); \ @@ -131,7 +131,7 @@ do { \ #define __this_cpu_generic_read_noirq(pcp) \ ({ \ - typeof(pcp) ___ret; \ + TYPEOF_UNQUAL(pcp) ___ret; \ unsigned long ___flags; \ raw_local_irq_save(___flags); \ ___ret = raw_cpu_generic_read(pcp); \ @@ -141,7 +141,7 @@ do { \ #define this_cpu_generic_read(pcp) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ if (__native_word(pcp)) \ __ret = __this_cpu_generic_read_nopreempt(pcp); \ else \ @@ -160,7 +160,7 @@ do { \ #define this_cpu_generic_add_return(pcp, val) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_add_return(pcp, val); \ @@ -170,7 +170,7 @@ do { \ #define this_cpu_generic_xchg(pcp, nval) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_xchg(pcp, nval); \ @@ -190,7 +190,7 @@ do { \ #define this_cpu_generic_cmpxchg(pcp, oval, nval) \ ({ \ - typeof(pcp) __ret; \ + TYPEOF_UNQUAL(pcp) __ret; \ unsigned long __flags; \ raw_local_irq_save(__flags); \ __ret = raw_cpu_generic_cmpxchg(pcp, oval, nval); \ diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h index ac8c44dd8237..c5e9cac0575e 100644 --- a/include/linux/part_stat.h +++ b/include/linux/part_stat.h @@ -33,7 +33,7 @@ struct disk_stats { #define part_stat_read(part, field) \ ({ \ - typeof((part)->bd_stats->field) res = 0; \ + TYPEOF_UNQUAL((part)->bd_stats->field) res = 0; \ unsigned int _cpu; \ for_each_possible_cpu(_cpu) \ res += per_cpu_ptr((part)->bd_stats, _cpu)->field; \ diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 5b520fe86b60..79b9402404f1 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -317,7 +317,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { } #define __pcpu_size_call_return(stem, variable) \ ({ \ - typeof(variable) pscr_ret__; \ + TYPEOF_UNQUAL(variable) pscr_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr_ret__ = stem##1(variable); break; \ @@ -332,7 +332,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { } #define __pcpu_size_call_return2(stem, variable, ...) \ ({ \ - typeof(variable) pscr2_ret__; \ + TYPEOF_UNQUAL(variable) pscr2_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr2_ret__ = stem##1(variable, __VA_ARGS__); break; \ diff --git a/include/net/snmp.h b/include/net/snmp.h index 468a67836e2f..4cb4326dfebe 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h @@ -159,7 +159,7 @@ struct linux_tls_mib { #define __SNMP_ADD_STATS64(mib, field, addend) \ do { \ - __typeof__(*mib) *ptr = raw_cpu_ptr(mib); \ + TYPEOF_UNQUAL(*mib) *ptr = raw_cpu_ptr(mib); \ u64_stats_update_begin(&ptr->syncp); \ ptr->mibs[field] += addend; \ u64_stats_update_end(&ptr->syncp); \ @@ -176,8 +176,7 @@ struct linux_tls_mib { #define SNMP_INC_STATS64(mib, field) SNMP_ADD_STATS64(mib, field, 1) #define __SNMP_UPD_PO_STATS64(mib, basefield, addend) \ do { \ - __typeof__(*mib) *ptr; \ - ptr = raw_cpu_ptr((mib)); \ + TYPEOF_UNQUAL(*mib) *ptr = raw_cpu_ptr(mib); \ u64_stats_update_begin(&ptr->syncp); \ ptr->mibs[basefield##PKTS]++; \ ptr->mibs[basefield##OCTETS] += addend; \ diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index 6083883c4fe0..d6964fc29f51 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -184,7 +184,7 @@ EXPORT_SYMBOL_GPL(__percpu_down_read); #define per_cpu_sum(var) \ ({ \ - typeof(var) __sum = 0; \ + TYPEOF_UNQUAL(var) __sum = 0; \ int cpu; \ compiletime_assert_atomic_type(__sum); \ for_each_possible_cpu(cpu) \ diff --git a/net/mpls/internal.h b/net/mpls/internal.h index b9f492ddf93b..83c629529b57 100644 --- a/net/mpls/internal.h +++ b/net/mpls/internal.h @@ -33,7 +33,7 @@ struct mpls_dev { #define MPLS_INC_STATS_LEN(mdev, len, pkts_field, bytes_field) \ do { \ - __typeof__(*(mdev)->stats) *ptr = \ + TYPEOF_UNQUAL(*(mdev)->stats) *ptr = \ raw_cpu_ptr((mdev)->stats); \ local_bh_disable(); \ u64_stats_update_begin(&ptr->syncp); \ @@ -45,7 +45,7 @@ struct mpls_dev { #define MPLS_INC_STATS(mdev, field) \ do { \ - __typeof__(*(mdev)->stats) *ptr = \ + TYPEOF_UNQUAL(*(mdev)->stats) *ptr = \ raw_cpu_ptr((mdev)->stats); \ local_bh_disable(); \ u64_stats_update_begin(&ptr->syncp); \ From patchwork Mon Jan 27 16:05:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951599 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.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 ACBA8152196; Mon, 27 Jan 2025 16:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994050; cv=none; b=FF++BuJQv7gJPz9FMcwjvCO1w0KOcDeWQFj78B47wtekxQZ9jenToUpHDIcGlNzDHEOwtWCV2xdE1sRzR6dWBnshjF8FS4tNjtGD5GCGeF/MjZvdg1dewlCkFH9Adeu80nK69t3R9lf8lWWnp1HmD+vyYPvzKQTJQ/JxmZ93oZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994050; c=relaxed/simple; bh=+VGH5bX+jj74i1xSHIJiswrHg7DNc9rM+fwUyXLk4tk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rzi4HkFJEPGF46t129CNdsBqx8/ohJlkVrwtgSLL0Jqri1bqOl3FrCKvxLg56moA4/UqEv3imyqDiLnHbgw6QzRpMZvgm17PJaA+uTTwBA2a0Y9oUDPPcUKQYqdiQqTdijasWSGLv8T4+4VZC4zGBAZ6dqLa47RjgHKuWhE7N8g= 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=lM1bHG28; arc=none smtp.client-ip=209.85.218.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="lM1bHG28" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-aaee0b309adso643346566b.3; Mon, 27 Jan 2025 08:07:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994047; x=1738598847; darn=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=eOGOr4s5yiF+IlrjEXheryEMyHp3uedGamtyEKhbkyY=; b=lM1bHG28xi/xMZ+yrBWOGEHfNZ240yiyLeWvEvq1WCkmLBO3PAbEh7nibp770oeqlX TFyLqW3izveOVT9scfBhWeccJdRmH+9E55tkYasPaReVqTxf/NsZbi9JEYhpv6a9890U e5hphrvo7oKf2FkI3pLBsWdRkKv52nR6kKLH2TbBeiZE59NLVOsw4wOg9xDQv5nQcYG+ INBh8q3Uq/5DhdKOoXPT4kzVLvryNDQ4oEsIA1Sbghc0ThTkEZ+o4dVdK9r3UZoP6+xv zWwvR106LW5GY0LCYpslm5ktF1P42TDdmhZ2OYFG2uBU2tQDU6p4zd2lJkdzpFFfOeua Sgtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994047; x=1738598847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eOGOr4s5yiF+IlrjEXheryEMyHp3uedGamtyEKhbkyY=; b=xFSmdbxDIg6IsAqXsEF2C9CUM+WIm5rat3mIZf6HPANPaLU+uwuZB0oCqlsNdA5iZk ZdBakXcc11xTVCL8ZyudHSNb8MTdM2RgwPqYl3gsd+Ul0+H3B+CFQ+C8AHPTfkQ6Gklk Cw0RNLJF9eFaO9ax4PUWriCDWdntiFo2ULqx6j26qMEvjN6jE92xzagYIO5wI5YuwqQB tdoStQlYtGaW5VsNK4hvHilkdPzDO+O7pXE0rPgFYeNG+Ekx8FZsS3cESC6xxED107EM 6fyZowMqeJORE9l3a5zjzfl0IOw0/0+CMr2aNBo7dbF6Y/xWjLUAS5DmwvJWD3apyzV3 P1fQ== X-Forwarded-Encrypted: i=1; AJvYcCU8DZ50G7JA4LfIJq4fkFohaGGa+0T0c3GvoxvIVO+sCuoNdnJifJQlAyWO9zamgfBNJW35bg0G@vger.kernel.org, AJvYcCUp3TxbyNnGldj/ZXg1qgrzADqolDm68xv6lQ9L0ENAdIc8JefQCncLJGQvxDRNww1DC/hCNL+NbP1FeQFJGEY=@vger.kernel.org, AJvYcCVBgMUVu5qxGX4f/73B+740NggSvu04MZdrcZ9F/1vt8e0VEDn0QM0NFyUaJU65MGDylNDPiNWXDrb9c3+E@vger.kernel.org, AJvYcCXF7KfX2A0dDr/7n+xnjp/GgLU19eJPrBTj6J9FxyFpGu//Cgskug/MT2bBhr9bZ3pyEczwPsKhYTHo@vger.kernel.org X-Gm-Message-State: AOJu0Yw5eoIyADNlbXBV+n0L8/WwDJREPuVro8Vw/Xxvr8in2cASkIZY r3xPVKGlWCv61FnZVQWuj9ioOFMOmIUi3YQ0XJsjEDO2YQ6b5hSc X-Gm-Gg: ASbGnctc1HQ27ZBL80SH8jWsjlVb5XIcq+oSbNUDQ5c2SnZG70aTo7VE+NkTCQ4Y2mV NK5FYx/U8hmptesZAJybxl+Ch6t1ScFXi5RjBB+HOiG2RU2wZ7jGYZeiRKFynuoFHUgBCBFaA7m i5zepBikqd9bZeBb+nYUAwZMhIG0J2YSPAf6GrLHqMpMJFdxjjCugSZCXzt9R2KsDYb6qoP4WmY yE2yQeyO4RBSe+/ePNoSRvz8smEwAQ640IsSAhjCq9jhj1FCXYM9o4Csq9rNwfg863HXGGJy1Px j0I/O7HKI9vs1A== X-Google-Smtp-Source: AGHT+IERCLQXnCU+YIaBBJp+oaHBkoRX9ZwnjjcfabyvezHHAG9ec22+X9u8D1546w+n0uGxAoPHpg== X-Received: by 2002:a17:906:2cc4:b0:ab3:a3b4:f91c with SMTP id a640c23a62f3a-ab3a3b4f9b3mr3132086166b.34.1737994046774; Mon, 27 Jan 2025 08:07:26 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:26 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Christoph Lameter , Dennis Zhou , Tejun Heo , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v4 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Date: Mon, 27 Jan 2025 17:05:08 +0100 Message-ID: <20250127160709.80604-5-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> 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 Acked-by: Christoph Lameter Cc: Dennis Zhou Cc: Tejun Heo Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Brian Gerst Cc: Peter Zijlstra --- arch/x86/include/asm/percpu.h | 8 ++++++-- include/linux/percpu-defs.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 666e4137b09f..27f668660abe 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -73,10 +73,14 @@ unsigned long tcp_ptr__ = raw_cpu_read_long(this_cpu_off); \ \ tcp_ptr__ += (__force unsigned long)(_ptr); \ - (typeof(*(_ptr)) __kernel __force *)tcp_ptr__; \ + (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)tcp_ptr__; \ }) #else -#define arch_raw_cpu_ptr(_ptr) ({ BUILD_BUG(); (typeof(_ptr))0; }) +#define arch_raw_cpu_ptr(_ptr) \ +({ \ + BUILD_BUG(); \ + (TYPEOF_UNQUAL(*(_ptr)) __force __kernel *)0; \ +}) #endif #define PER_CPU_VAR(var) %__percpu_seg:(var)__percpu_rel diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 79b9402404f1..a7cf954ea99d 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -221,7 +221,7 @@ do { \ } while (0) #define PERCPU_PTR(__p) \ - (typeof(*(__p)) __force __kernel *)((__force unsigned long)(__p)) + (TYPEOF_UNQUAL(*(__p)) __force __kernel *)((__force unsigned long)(__p)) #ifdef CONFIG_SMP From patchwork Mon Jan 27 16:05:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951600 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.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 46DA11898E9; Mon, 27 Jan 2025 16:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994052; cv=none; b=p7ugDCAqCMV34HrBKZSyPcj56bBt8D8dZw2F5pppQcObrRenXVF985D/ROCn4leq9BwByJMxBjMPniSE8uQYpq4Y/Bz5+8asjmxEUDRHsL5e+wSO05fL3pHk/RLW99E/Fhwv2VpblNY96cWxwTGiG+kRAy79QXqvCSaz4Kq6Ip0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994052; c=relaxed/simple; bh=VD2esfG+2A7H5xnu8x5ip6Z+n1iO/sQ6fWXzAj+5R9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q9uzn+zRJog3wOq9c6seGjhV2eDf6EvjP9d0VYg3SUziRnO3Gtl+eh/EB6KL+gLo4pQEWn/tiwCcQEvboFB5MvTFZeC53GtsJGfILvUE6DE63U08CB8BosQ/ibZizXX4HRXh3m+gcNDDw39+iuEyvuoLUmcsDlgb1ZxV7fo2FkI= 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=cTLkKca2; arc=none smtp.client-ip=209.85.208.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="cTLkKca2" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5dc052246e3so9419645a12.2; Mon, 27 Jan 2025 08:07:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994048; x=1738598848; darn=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=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=cTLkKca2U04HWXPM43X8JQRw+cJrzyWhQiVLMhjjNzQY45zDA99Zqboa/mbFfPCVfF 6+7mnuMh+ppxQiQ7EMKTW05y7hlc4mgXcjHBTkCp43IxZJF2pW4hU+3/HpAbxwdVzWU1 0mUUvcZW2wITnTkPUTny8HoZrYsXfgFcKx6iROghMIRt0AI5JIMOabzLBwCqAIDNXbdq 0X1rkqSpX/MkgHkEzv8J8+jdaBL038ylexRzifTVm6UCiag6it8iY/lshTeAMSLvDdUE coaTrIjCyqfDN3houcKj5w/yZwzblN8HMJylrOyu22CVDJ31MU4dYX81oZg0phj9JUqE CCNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994048; x=1738598848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FQICK2kFPsfEELpT4bODj3LxfYome5g697HLvcS8DLE=; b=rrXTTgHsAk1wz6fkMzhA3K6ckvtdh7EERPOSZI7LIOwmiRsCFE/+cSn9p6aLO4qbjS 1tdsQh8hXNB8WXsQq2DDt2qW6lyJz1Wk1euYj1ehbsnhR/EwllGrxVETT8vLLIC8lOWZ 2oKo+iOp9fWRbEJBVUJ4vDPV/lrJAAw8A8gbMTKL5v0FaDoFGqqDZX8s6gomDlxQ5dIx wNeSwrVoh485T8H/zr6nJUfXz/wSAhmU47D8rJb0CGxCy7bnEehZ3T7tFlqfeiBu8SvL PL2pnRejLOgfzel2db4kkUKRXqMcXukElEKkK+qA1PciKsu2olz+v0c+3lLeZGU0F8Sp vVcw== X-Forwarded-Encrypted: i=1; AJvYcCUx5V4W90M4OJssH2D3xyViqD9WlmXd717xvzaGQd04FkdLQem6Di/YLdOCuBKYcKlGg+Co2lColffk@vger.kernel.org, AJvYcCWRu1DBA0YCLZiyHljfpl/ESwDqTRkXoGNiUK59YVd7yDbi/nvWaIb2csIhpAHjZyfBw2zZB9B0@vger.kernel.org, AJvYcCWZI7mepDyS8z9c9TruCIG/bQrdY1wPVgIaIyIU1w7gqwJBrzDYW+t55buN2ar4eGrELZS3B5luv+R52soq@vger.kernel.org, AJvYcCXSSrIWjpCvuhOB3oZ/RS6xaa4vOu8C/b2EIe8m4ZNa0RG1ofy6zxuB5fjwQpYBI1wJJmp/7FDx/CL6DzMF3Dw=@vger.kernel.org X-Gm-Message-State: AOJu0YziZuV2rsHLw/Ymctr5qZgjlZmTHWQUuyuYTSDsHAzkCYhPAH/j Vaeo0TpXiOWMYxPL3WakSc6p6ypzcN2jaJOFIIQiC1CQmJh0laaB X-Gm-Gg: ASbGncuvOhTljAUXAyqaudm87SzyZqlclTp3/LPMVHc8BKx6qp+5joK2Y3jB+VZcxzD rMrXaFNbrdAZEP9f/UNe9wm8rHIg8232k2QAIW5YnEH5eNHU3xHLpyCnYnx8he5QbtAD5AFrAQl 4m4PFwX+6iu7gKMtwWyVYbBYl8+cNasEUHyQRW+kk4B1AMkM1hDii788w7el13PzRcJtXahym8k YUUboyeGBtVDJWtbB5Nge1+K8aJ/waN9HVdHP7zHkWPxJ56RUj2UQEItS5IC7nZBR2AutUnJxyN vIj/FT/gZTAlqA== X-Google-Smtp-Source: AGHT+IFAuvcto44xbfJbzToMqvasWkjx8mJOE7NNj1gZKmPQ5KI6lBKJIGSybMmZDHGSQog3h29n+w== X-Received: by 2002:a17:907:1c19:b0:aa6:acd6:b30d with SMTP id a640c23a62f3a-ab38b4c63f2mr3942830466b.48.1737994048224; Mon, 27 Jan 2025 08:07:28 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:27 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Arnd Bergmann , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Brian Gerst , "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH v4 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Date: Mon, 27 Jan 2025 17:05:09 +0100 Message-ID: <20250127160709.80604-6-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The patch introduces __percpu_qual define and repurposes __percpu tag as a named address space qualifier using the new define. Arches can now conditionally define __percpu_qual as their named address space qualifier for percpu variables. Signed-off-by: Uros Bizjak Acked-by: Nadav Amit Cc: Arnd Bergmann Cc: Thomas Gleixner Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Brian Gerst Cc: "H. Peter Anvin" Cc: Peter Zijlstra --- v3: - Rename __per_cpu_qual to __percpu_qual. --- include/asm-generic/percpu.h | 13 +++++++++++++ include/linux/compiler_types.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 50597b975a49..02aeca21479a 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -6,6 +6,19 @@ #include #include +/* + * __percpu_qual is the qualifier for the percpu named address space. + * + * Most arches use generic named address space for percpu variables but + * some arches define percpu variables in different named address space + * (on the x86 arch, percpu variable may be declared as being relative + * to the %fs or %gs segments using __seg_fs or __seg_gs named address + * space qualifier). + */ +#ifndef __percpu_qual +# define __percpu_qual +#endif + #ifdef CONFIG_SMP /* diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 981cc3d7e3aa..5d6544545658 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -57,7 +57,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } # define __user BTF_TYPE_TAG(user) # endif # define __iomem -# define __percpu BTF_TYPE_TAG(percpu) +# define __percpu __percpu_qual BTF_TYPE_TAG(percpu) # define __rcu BTF_TYPE_TAG(rcu) # define __chk_user_ptr(x) (void)0 From patchwork Mon Jan 27 16:05:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13951601 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.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 9ECCD18BBBB; Mon, 27 Jan 2025 16:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994054; cv=none; b=D6w0BSvdTfjMi1fL2lKQlR1RROjAowKG5qO/ET2XrN9Nec4wsHDBsTtYkr9VSvYYxrwJdWA2yHYSSm92pKXMJpMlW/C9KeqhG3xVmrzjn5ouEatQ5DISuG6wiopsecRnEofUNBP4AgSOxS8ernYlgpEYNVty6dc41DP7DtWXNho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737994054; c=relaxed/simple; bh=akMqODiqeN8wWk3NHvjbNPcxc03Zh5d0pwf+U9K424c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tc42QmAbc54rC2sCtK/BF4m9o8di/vpuFbnENsaUiyI3o3hjCapFdNOlzaOlYiybAasBLcWRcMa8VdWotvBuW5MYbXO0fwQ++zcR+tIRhyXCspYaDfopVWJWiAyqO50+gDU7PCNMfCM8QzrlUZfTLAVb9Q2S6TGYVkt3TJBDBAY= 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=Rrk+SjZC; arc=none smtp.client-ip=209.85.218.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="Rrk+SjZC" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-aaeef97ff02so767671966b.1; Mon, 27 Jan 2025 08:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737994050; x=1738598850; darn=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=lrZpQikn3aM6B3Iqd/Ucnjx7jHzSyajd3QTmq9Vwrvo=; b=Rrk+SjZCZFuKVTuU3ZxE/CBmDV4khDaEmpCki1+V4khao0clWNGCKzVpyyMhrwXHoI l6W9VAuzEfaC2+D2sD9ZqksrYh7muCEAqkzOQlYZnfk6nrGQghEBXvAMNISdlX81f2Rh 4b9c8lShMDohWV4cBWwW9MqREfaFkB5PtvCpKTx7sE4TQB/6N1dIvjykHxklz3h/aYqL ZSoBlRkTdovCuI0tluFuwZLdZn9TnutUyeF09Y7dw9Ef+SalRBseUe4cS0r9AP9/OYvs 8itmFrturJnBsLsT6Iw4KHzVQyRSfpmfxjQXEZ0zGzwVwMPnNWtjEig4Ow6J8XM8qpEr M3ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737994050; x=1738598850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lrZpQikn3aM6B3Iqd/Ucnjx7jHzSyajd3QTmq9Vwrvo=; b=YPvSfUPbCSGdupb9a/2S0ScrdPvhQgn+1otXGLXA8drKHgVw+BWqg2Ui8Q0Bz7R/MQ iR4Tmqn10P9ZIjnE0WVB4rUClP9hb+wdZtRTqxrVldvwUTP2lnduKB4AqHcFnswAhGdz f5x7HGh3btUgcL47siWCrvAGjwko0Hyu/041I6YV+cqBnX0IC53Vab20UiA4B8dFr2kv 2tMe0+KKBTu/shinmqtdY2qOflkhyd70jGVn+OiVjr317ICR85r91eyI7fS9g690hzHT 07bdlcIOUbkSOd8ORHN/Dv7p4aoFWqlvcxRL/JdDYWyQUhQD1HyMeUqrV5GIvQjDxe1C PSmA== X-Forwarded-Encrypted: i=1; AJvYcCVgKaUo90mNJaO0ttHKhKAukRv+C8oVofWSEd9QWo2frPRsmUQ1Ipuf4K8IOttgSIuf1fJnSkqO@vger.kernel.org, AJvYcCVuK4YUK43BT3KDrj5K9F9+RUNV47Eg6c/QQFaFTuN1gJzB1VfxhNG3MgTmzTatoWxolAUwTeWROZj+RhBT@vger.kernel.org, AJvYcCW32n+7KYF8HKsRiwbPRmQD9PM4bfsgppE6ON43gyo2xf9F4wTwm4xf873FFKT44dpDyW7Abs1ErKU5@vger.kernel.org, AJvYcCWAgqeVujaSXfD1ToXY5p96dh0iWSuLi00BLOAgPHSdu5a2ujSXA0bxyQtgVRdcaI3/Vnc/OgPqTO6k136PaiA=@vger.kernel.org X-Gm-Message-State: AOJu0YyaRq8k+gsnE4dEtO4JySGdyJ8WEkuKzDrSRGS00a1aJjCguatc Utf0IPIlVkb9wPQsWS+jL9AhHxwpeWze+4js8JtHDmG8JcUzIecy X-Gm-Gg: ASbGncsB0GL0SQLkQhvrxgG7O8FBb43FY+UoqYlQH1oGiBDSGkIbSfY20LV7Q/6ho8p 6zo1xQukrCx5fcznPUq0Ji3tTbAe0E0V4rwlU9dmsGP+wMGJ2y+15gnaAJumfHcfCQlyQi0yGDo mCvDN36xU3wKrVyat7upIM77ULJR5OMuLO9dh2f0b7drSfKoZpYFqcZNe5x8Ul/aXO04KkWvXFF c3Mo6xofPxWtN/t/mSI+zZXBNcuJ/IRZvHUOMP2hSgpRAVXay2LQWejweS9BdncakRRjBa0id+o CXJqPi461Z3tgw== X-Google-Smtp-Source: AGHT+IHVilwWp86cIXuCPcSCEjAlKAPSZRo0H0MsLWLvAzoRKeZuFBp6uVwp/VtMeJUTjVHCLgUcfw== X-Received: by 2002:a17:906:4f8c:b0:ab6:362c:a8ab with SMTP id a640c23a62f3a-ab6362caa41mr2246025266b.29.1737994049651; Mon, 27 Jan 2025 08:07:29 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab675e8b01asm592643866b.84.2025.01.27.08.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2025 08:07:29 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org Cc: Uros Bizjak , Nadav Amit , Dennis Zhou , Tejun Heo , Christoph Lameter , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Brian Gerst , Peter Zijlstra Subject: [PATCH v4 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Date: Mon, 27 Jan 2025 17:05:10 +0100 Message-ID: <20250127160709.80604-7-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250127160709.80604-1-ubizjak@gmail.com> References: <20250127160709.80604-1-ubizjak@gmail.com> 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 --- arch/x86/include/asm/percpu.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 27f668660abe..474d648bca9a 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -95,9 +95,18 @@ #endif /* CONFIG_SMP */ -#define __my_cpu_type(var) typeof(var) __percpu_seg_override -#define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) -#define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +#if defined(CONFIG_USE_X86_SEG_SUPPORT) && defined(USE_TYPEOF_UNQUAL) +# define __my_cpu_type(var) typeof(var) +# define __my_cpu_ptr(ptr) (ptr) +# define __my_cpu_var(var) (var) + +# define __percpu_qual __percpu_seg_override +#else +# define __my_cpu_type(var) typeof(var) __percpu_seg_override +# define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) +# define __my_cpu_var(var) (*__my_cpu_ptr(&(var))) +#endif + #define __percpu_arg(x) __percpu_prefix "%" #x #define __force_percpu_arg(x) __force_percpu_prefix "%" #x