From patchwork Tue Nov 26 17:21:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13886263 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 3BE921DAC90; Tue, 26 Nov 2024 17:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641838; cv=none; b=MM9Dk1bvWTKCKLsKkaJyCiSyGDt7qKsAYsz1olPLmRSFj0AVKI+8vCiNO1rgrEoZjebiHECN5u1m1nmwL14P6wK/VA5WR3kuzFnIniFdVEnBeO9DZPnfXEzOUkcyWOZGSiv664owSZbccOO+2m7RS3YpB82Uab44Xe5JPJzwdxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641838; c=relaxed/simple; bh=iEt60t+44TZTZTJPgClb2mTSiitDuQ4tBir6K4CL7PQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pP53xeL0mAwS5csxN+Gdh8euOqvpxyZAuhx6OFrRc29TqFWdbNGfDgUVNaIw0zJ/OT3AT4LsCIxX3VePvsLHkf4lw/iLnBiSJ5vCayDTRamOgmnFlIAgq+Gs+OS89XLBK65clKKHs0uoa8Jsd+Hyd/+VvMXSBsVukkYGczNpTPY= 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=Qpr+o188; arc=none smtp.client-ip=209.85.167.50 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="Qpr+o188" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-53dee064f00so1089237e87.3; Tue, 26 Nov 2024 09:23:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732641834; x=1733246634; 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=n5NofcZHiN/mPTufbVMAYbTQYvMqATiuy7cs+7+mqOw=; b=Qpr+o1881aKO8nsDqOD//3NCeRNCf/vgj2y1jsdgHzkxF0VBhOEwX7GXwfJeZGeXSZ n6CkEYd6WZLRmkQTJCDTXB6EvjvH3Kg1H4K40tixAjZxfeK2L1osJMSgAgfJAZdpZcG+ 1Y8mqfH17LUcMAiJAsyHhjlr/swKEPXhGRbyE4KQQKbodnZzJYt5+Q0h2g+NXl3qdLqC JtslcTYFIbWKoXipcCccwOVxU/TLbZXjmuMz1W8/wnIivYZSsQ5R89b9llXHYuc5vv2g d/RG0P1T/uVmu4bglg3h0+k7OhHd4nYqwldPnIN+6owcA/jYuSPHaISC0Jm3yGKbaJ6t 05qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732641834; x=1733246634; 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=n5NofcZHiN/mPTufbVMAYbTQYvMqATiuy7cs+7+mqOw=; b=na/lG/iy55aqgKIzbj05zpgT7PjC32cnDsVFB7DRN0GZKMNA+PV/ju9pYCXvCvakKi 3F257kKm0BA6ufjLB4Em9lZ4F9rmDhAY2BggZi1gqbP/0iB2BpkqQ4bzae40cJNpsAP1 7cvoeqPvXTD2CEsidW+4bD9CWklWMsT9sRlnE6/wwlNFgBZxERhPg+d7VpmF4GLJ/5dC op8LlLTQ3/7cORdrat4SpkXT96tREsoqEXm9tzMsyb7n/fH0CXBVgKvkKdEyAVKM6YSf ePfR8swaD2AM1x/krH8kUbX9la+szoRRJ1z5fzPVGqmtH2M9hx/N2bAGr/HgZhY8D9ZP BVDQ== X-Forwarded-Encrypted: i=1; AJvYcCU02yndtHQ8DonEywqXuzT+bWdcq0tFjPXsgV9Hmk6C8sOmzAq23nclIyxY2uz43NHMFMAI9rCC@vger.kernel.org, AJvYcCUdDeFDh4QMMFoITOaxc+JtUdTfWXrYaNVLXgaiPT2oPWUlQQ5jBIDS45KK4qMOEm2GzkWeuWuR2ckpFrPN@vger.kernel.org, AJvYcCVslzznk44jEnicaZZhlMLHz1wKCo04ojMAjafHJ6UsOVuG3dlsq+VvAbXn8YgjsAXpXOl+HsyZ7MS2DCVNMTk=@vger.kernel.org, AJvYcCWzKrvV+p19ybX3xrOiCYO6mtPH2aRHVux72ibs8KXglNjxykqvmHh0d+RloECHu3nHntQj4p2A7r3W@vger.kernel.org, AJvYcCXfT308PTSlz+8B03+8+AvSZavnYp7UouFnVtwBavZePJaZBs2OZtGNCktLxcF0asUad5kqPd2hcCY4Ew0X@vger.kernel.org X-Gm-Message-State: AOJu0YxYz85qwUZj1HPyQb/PBgbkUz7RaIgljIEdlrouWU9qF5RF1GT+ JGqmH5uoi3iZsX1EuM3Rw2CfJ9tVgsefa56SReVrKj81d7FjkDyH X-Gm-Gg: ASbGnctHlqZrGst/lGVw8DZrKzBT/1pzZhUuvJv+YRFZRKV/kbNcHKXexPY46lphbpD gvwE4Mm68boe9y/6KehFM5MVKZvJYHjl/4FbO3uWiMcMuXi2ygBfHLRQeZ3ziymr3AxDuooouTo Objp0Mg1H6z+RlevWbAq/lV70obw+V7RVirVdzW2e5hoyoYyLalJ0KtjrcRFVQoqDXCEMMXImc7 xmTtxmOsazyToLGFfz5UEe3xOHvquAHs2gwSrCT+ZTmy3BaqjtnNNCordI= X-Google-Smtp-Source: AGHT+IFIkpku7uKl9KKAwOvhvPeOWflgDevT092ovp6tlkSzp8pl+CUkXBrRACuxkb0yqjHw9Xdg0g== X-Received: by 2002:a05:6512:3ba2:b0:53d:a012:efe3 with SMTP id 2adb3069b0e04-53dd35a4ccemr9018215e87.11.1732641834066; Tue, 26 Nov 2024 09:23:54 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa534232086sm473832866b.42.2024.11.26.09.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 09:23:53 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-sparse@vger.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 , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Luc Van Oostenryck , Nadav Amit , Brian Gerst , Peter Zijlstra Subject: [PATCH 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Date: Tue, 26 Nov 2024 18:21:18 +0100 Message-ID: <20241126172332.112212-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241126172332.112212-1-ubizjak@gmail.com> References: <20241126172332.112212-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 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: Luc Van Oostenryck Cc: Nadav Amit 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 Tue Nov 26 17:21:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13886264 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.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 6609A1DD894; Tue, 26 Nov 2024 17:23:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641839; cv=none; b=itKSidX8luTIg9N6j+muFV+b0uBHY6jQq4w2o9BBCorOxrVGMu3hB4nKX2whErDrRR6i8ox+NunZzebVimhXQgTd+V0iNz9J3bAQnoa34kmKfXyrgBiSr68vvqkLar4ORQk3AOL8AQr3EJ0aVjAU7HCutJF6LP7nbngaYDb8GAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641839; c=relaxed/simple; bh=VvmlP5AH+fUUSyvPi8wqWT4LAcAAvQBDSvVszq80Jb4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uFpt1ZD+zRBbHm56iKPBI6RZb+Q1JKhIENYOiitJYO/uO4TFV6ei54wvV5GPm5o5TOQ8nujWH9UZlvOVWamtvoXhnE613KSzVETyZ8H9KlGt9eICPC0C4HmV9tMsA5pYRfnE3nWWeX4nONDeHI9jM5YB1X+mmvFEayU0GMW3U9o= 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=PasuyTDP; arc=none smtp.client-ip=209.85.218.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="PasuyTDP" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-aa549f2f9d2so357243466b.3; Tue, 26 Nov 2024 09:23:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732641835; x=1733246635; 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=scK7sUlNwfpZu+VLLnedXLuF+xaa2OfJ8eCpocRXk/o=; b=PasuyTDPIk+o30QbnbRZ9C/o5ajDIAxXS9t9r6TDH1csdPiywxtBIkL+z2PSImqoqI 0M4E2YVOI/Q345nbId3Q4KXJmLAWaLFvfmdYZlXuIuRi2H1pNIHu6gJfcC9CHxM/jSg0 CS8yjlbQ4KNvLFAEhGIx6uR9xl7X2G/Qekve27tSAmlOmid8E8kJ64RHnXJSGwHTVQlI zxxV+Wl0yfccnYKu6XUtbXfxXw/DVSJBSTKPyPLbi4RIf5Xr2TpckZfwy+kW+XDhGG4p DfLc54eglsxNp2gzdl5MRAW1bDvrSL1eU0dQlsQUaUqzYW0NtyYzinCXtA4X0WnxtLei 9+mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732641835; x=1733246635; 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=scK7sUlNwfpZu+VLLnedXLuF+xaa2OfJ8eCpocRXk/o=; b=sLX+anlf57r8e3f7v9BVC8waDSLChRywlsMR24k+kIbJs14N9RjLFYqXX0DksQnHoT Yab4kEhmTJ7TUt5s7iXnoyIuRGHzJKALOGYVs+4Uc9sDKBNDi6EYPyKPiRRtZ6hqxcr2 zpbSW1Zn0iDRIqqDT1eAWEn9omszb8uvSIZZduSScHRHc/hYxdQVcMeKzT/UYgLEIs3n 0nV/EldJPsaC+WSTku/6SAq8kM0uUJGFBvpKHRcBuFO2FzQ9LxzSd82psQ6TjYJkmpDV e549UtdWdw+GZT946AiScAg4m9+I05qbteUqIpJJGnfHOToVL6gHp7W+CHR1kR0vQCaC R+5Q== X-Forwarded-Encrypted: i=1; AJvYcCU06t6cUSSKuC6YxloIGulxr+g3Uk8In5d64H0VmhsnhxHMYtVnQA9CyCMoFqN2kDKPgidD7O+n@vger.kernel.org, AJvYcCU43YYm0UelqpVDDl2rFLCctfllCWEL6W3QmCB3ral+COdqSPMEEzCVCA5XHFBp2Sp7xB83Th4qBNOiBgOh@vger.kernel.org, AJvYcCVkwuOFHtBem1gKZ50dXyYnFk+VREDaYlRqfDolg7KalSm9aGYhq88stifNr7ofdPw2Qorf18gaE3QH@vger.kernel.org, AJvYcCWXwwEDwrxnxWhvyY1X05QcjFTGP2dQrmBlmPBIwCxoP36yaIvgZH8XEkR5o8LNyhc157HPmEZn31z+poV7@vger.kernel.org, AJvYcCWYJX0XCOuLAlf1yXOCpJcDVdDcKjEIUsLKhhSXeZHsDoKG/KVSgHepKm3mjL8HPKP1CwkPx+eV2DGEo0hD6uA=@vger.kernel.org X-Gm-Message-State: AOJu0YyFe/DPxLZsOcibMlS+NS2//0DTiOCDdm1mDXRBmJ8DPltrXdpB 90gzp39lj9ZZJOKoOVvhhK5mQoTjgIqIfa48pqdJWcx37E+gu8+EYzBtHp3H7yk= X-Gm-Gg: ASbGnctzco8PwIGw85XzpKKPy4lCzmRXBkH6bp4miLAm5kgSgMlE1GSrLZa8EXhGJ0f AbHeHh6YUMxzjdvURQYW66rAUPxeA8v63tE+c7/A8YGdD/0rZ8k+JM/mDf3dFLAMEp+QZfgoq+G GFuSmwFBkJIgz+2CX6lwEGqapB3bxyxHtwiiF/Bavd+7ZVfsAUdqVqiaDT1wOlNQhsb1BN80HST /wSax31qh6OSUYh4iZPgesZMKOKcGrtbJmIJnkKbhAi7qib1cQ5s2Qxs8c= X-Google-Smtp-Source: AGHT+IFUI0YUp1+RBJSqcGYBOc1FhgIJEm5xni8unk9E56g4XY//7qbTg95Zcg5DcOFquH1FM+TtEQ== X-Received: by 2002:a17:906:1daa:b0:aa5:3748:2ee3 with SMTP id a640c23a62f3a-aa537483463mr1076090466b.50.1732641835429; Tue, 26 Nov 2024 09:23:55 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa534232086sm473832866b.42.2024.11.26.09.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 09:23:55 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-sparse@vger.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 , Luc Van Oostenryck , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Nadav Amit , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" Subject: [PATCH 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Date: Tue, 26 Nov 2024 18:21:19 +0100 Message-ID: <20241126172332.112212-3-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241126172332.112212-1-ubizjak@gmail.com> References: <20241126172332.112212-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: Luc Van Oostenryck Cc: Thomas Gleixner Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Linus Torvalds Cc: Andy Lutomirski Cc: Ingo Molnar Cc: Nadav Amit 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 Tue Nov 26 17:21:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13886265 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 539DF1DE2D0; Tue, 26 Nov 2024 17:23:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641841; cv=none; b=ekNqU0sOB0NZ5oltWOhD/x0+/ltY0t7XPyefO9ZsTYVPAep1TeeavVnCB4j7g3C2kmGjqJ0DImrIXP66CCb1WgxG2J7/8vnbYAD5H+ZHddek9s9rNqoghcRA17rGoxbRN0D+C7yjJaLltRxF4HAbJH0qe1u3H0I3EfLnq4ma+7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641841; c=relaxed/simple; bh=erxvZaRBgrJH3EI5/GzeGdZJBfM0yz+9F9NpPtDuo9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rB5K8BpCT+gruSC3jS3fD2aTbHeUnGSUYAWH2pYruFeCF7KU625NgWwgkcg+jsgafqNi3bE1MC2EOTYfQnzkAH5Ube7xP3uh8NAzjNrMP4UyEK1ToB1wL/Y9ew4gwQ3SfI6oM8bmgXVOWb3dvHMvdCb8By16V0y3WU7BOXXuV68= 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=ZH4occY/; arc=none smtp.client-ip=209.85.167.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="ZH4occY/" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-53dde5262fdso3832984e87.2; Tue, 26 Nov 2024 09:23:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732641837; x=1733246637; 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=kox9z7JfiY9O2bkBijsUQnV/alELjzcn+LlxGXFiSRo=; b=ZH4occY/fQMg/OGz9FCn6SDsvQMeeaq8GB+W2IlavW66pfamwjNDfUUHxA7srUbx59 208/AW0idfcf2qf4VNYkNLZxwyepPPwFMGnbLSyB2qo1Iy3dbV1GSWQNlXbx51hO8vEc ddSFZDafH/H/8oH077rKJVROlSCSJsDW2RVSjHw+dXV5vuPzmq2KiyOPgZ5qIS4URQxk RUIzGopJ0HBQIqGVMh/vB305wu5OzzNtTh2lEjZrQN0v5G6ZwbDPRR6TGQmU334aA5Bw 3YazThxJS/S4x4NnihA/+P6rIEsqa2ds08jdxtmWKrjvmLw2U3hkv8Zz5AfbEypEuYxT Kgcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732641837; x=1733246637; 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=kox9z7JfiY9O2bkBijsUQnV/alELjzcn+LlxGXFiSRo=; b=jvjMo3KY/TXM3Od1URTAW/MzzDlmGNPtuSJT2NxjQNJKhqlgijYCheyvsqauoEYBNy EJez65O6lZwv7a7ujwl6NnT9gtH6JA/VG6YDlsFrgqAHt3Ht88BmIP7SNZomFQTdaOOq KL1fpKQnxHhBtD7lT9BXosoKadp6MhJIrqIGdJJGwWd0P0c9MRZiAekcNAIpsXSeqseh dWs0iQJ/GW6RKVnGD6I0BueeSp5GNpbmFW40og164UKdOvIgZ34JadrhrIlslnPKhSIj wnAgCx1SRo3S7smIAV0V2G4LUfhqdc67/Iohtgx0KPDi1hF1w3ZyTc48a9E2JPdm3p5N jtVA== X-Forwarded-Encrypted: i=1; AJvYcCU7W+9Vqj5rrYFNEfseQGpjKCyyz44IRA+Mdnlb+JLgvPd49v1K++DZoLs6lDChImfjo3HBLlL2EyNq@vger.kernel.org, AJvYcCUfqn140hpE8eRv/Zrs+UeSfqFVsFQP6dVwpHej7cPyAqTw27H/rxhdkGRM/x08tKSa2y6OwbCt@vger.kernel.org, AJvYcCUm6DDk1QMKoDORNDygRwBuYXiP43kuyrm+jrPov3tIXQo4gwvYmy2QUcr0DLneOf9BnVChEfhmOTZHqS3P@vger.kernel.org, AJvYcCVVEQIKLR+HgckvQHpB8N2+jNMlCoGrhmTPcLC2IfYkrIApa6Et7lXTF8fF7yrx2eem6DBf5+F3tBJ8UBRn@vger.kernel.org, AJvYcCVtj8WWdykubCVOXWqNmMpYg+rqkQ6md7yy1FKlF3jUHRh42yZ0TBQBapYBUg7m+u0ofpBeLvf9qQVR7nwNTC8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx2W7jPASvur6+BkB6hOR5/KC+p5pXdi6sJLX6WhuVVQmoChmXj UFWGOUoEocMXAk0mjRwstyQgkhuyvPO0x/MgrMMt+agmAlae1yrG X-Gm-Gg: ASbGncsJE3NAP9UK0oEdYQ2KcfnLdvRETaENxw7A7BNIjWjsaBvaiJDkK8U/yitUyU/ 1VrJXeqZWmWTYj9zWkA27X6PYmdd6ienLUhwi21vkZcQGDN9ObXc9kbvExW7Gqmx7vPhr3I2Fxn R0Tb0Ia7tX+SatJG+4NN6FqDtM5zk71L4CerqnI0posiGUsWmH7Fanfg+r0qQL+RQGdg1jwr6M6 +H3lFqsXvVa3T+MD6wpV+aISTeMICfTn4aaD9dZa77Z/Q2REdmrXD6M+RM= X-Google-Smtp-Source: AGHT+IFafhTeOcM4tAMdv0K7GsnHQKDv0NLujRtaLdpUu+P/n+6xxinduNCThfHYJZO8CNUezGgibw== X-Received: by 2002:a05:6512:3d88:b0:53d:ecf2:332c with SMTP id 2adb3069b0e04-53decf233a6mr1552836e87.19.1732641837149; Tue, 26 Nov 2024 09:23:57 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa534232086sm473832866b.42.2024.11.26.09.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 09:23:56 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-sparse@vger.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 , 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 , Luc Van Oostenryck , Nadav Amit , Brian Gerst Subject: [PATCH 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Date: Tue, 26 Nov 2024 18:21:20 +0100 Message-ID: <20241126172332.112212-4-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241126172332.112212-1-ubizjak@gmail.com> References: <20241126172332.112212-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 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: Luc Van Oostenryck Cc: Nadav Amit 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 Tue Nov 26 17:21:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13886266 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 895F51DF972; Tue, 26 Nov 2024 17:24:00 +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=1732641842; cv=none; b=eclcRR78fAlkP7SUJX7coIo8KDNcydH/9hnJr/JnEPFX4eUEtmP3ZAV5IiRfS5UaoaaqSptB/4oMSIgzY0GX2xus9eAv1BGziA+qtM9VEgGY82Cy8DYdrpifJYZkqeSbsYgDD12VDkrcTNeSQmvdSOmW/m/V1FYQJlIRig2fAP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641842; c=relaxed/simple; bh=UP+TeyFWhapXWWZjm7znhWw8IPamZQWNemWDE3MZkrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MRJjB0WgZ5h/yZz7l5KiwYl4/j7b/3i+Qv0qygQV/IOrGOj/wwUOYEf65QWdtYtCSGYKrnsGESTHiGh2QdG3oRCS2g02eU8fdoerVn1y/5jBxvZREUnXa1NYJORFBGBZeKW0x9X9W6W/JG7VZr9SVPYng4ZAdOBk7jlHCCCET3g= 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=VZVbAqtA; 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="VZVbAqtA" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-aa545dc7105so450296566b.3; Tue, 26 Nov 2024 09:24:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732641839; x=1733246639; 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=e67gnDX037AzEtGr2TTuiC3i0rrMYCYbsdiQSpuFMPc=; b=VZVbAqtATMGXVp6f/tdvQDr4Elu31/CEWZIN1LilyE74vMKXcafgXkWHUsoeF0LHjM bTxjkzUUJ3XswmjwIqF8v8ECQCejyedbFPqw6FIHaAnIH62cs/PXRZTGWxeiBty/b5rD BnoFho+O1fKKxB7MZm+ggGDnpcm8x6nmBXbF9S6Yxi7kG/BcaZdLNl/KQTCmGFDPGHMe d5TN3RjH7iWdyIq0cjuQK5U3YAcEyUi2efQqfUdotfLjOgH0D9083EwfJIsJTwyqY/91 wNa5JazqRBEZKnc5dAUmfUqRUZPpzEibNFoltnbWkURWp6tvSJoZ3T3H4v5s6FqEWW/E 2lfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732641839; x=1733246639; 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=e67gnDX037AzEtGr2TTuiC3i0rrMYCYbsdiQSpuFMPc=; b=B2ZCt47rhcwd7VhQVTjnI2/iXykvOcdeDymVqaRudXhZ3RwVHnyu1iQWPKn8Qi1fkt yy0x5EwhXNFxfRdcXq/gW3+61w9UsyKFi5X9nEB0NSZU+Qg3tNT3GX/bLBHRs5YTOHwb O8vCXL+Wk7Ib9Tcal0WA5xXIN2xRK2zPcLh2xsbA0UU79R8lF3QDX+Pjnrajs69hUYT9 iABnUjDbmDr7i3MNjQEPHwycTTWtBX0fSKrSuPQkL5B34GshHxhkdrKt+fQHV8dTwy+4 bV/uia1bQVeeEuYIyHtUGm9TkXWNKYj+6tHAf7M9d9hIlmc66XNE/+PMHnXt424kY7R0 4FkA== X-Forwarded-Encrypted: i=1; AJvYcCU3IvcRrhIc9eO1coFKgRtOcSBhgyDfPIQah2dcW/MsIgnMmC13XYOq4gWPI1VakquRhiJcFTbO@vger.kernel.org, AJvYcCUhulyHblnh6OUUsayZy3DWBESyl+IepM5Ya9rdfB8MwkmrU52VoTWfsp/KaDWv6s+UvkrCDp3yQmTo@vger.kernel.org, AJvYcCVswgmBB5E+9++DPfFnFl4QwyBQSYjUPV4LUxFBs3HA993ijH9vCspxH3fDm5jSAfGSG4EfRTDh1HTy98YG@vger.kernel.org, AJvYcCWh1qpWHgtyJ8xDKpqjYiTt88tT8dZe4l8yeQK6djiBxpKBsp74PjmWFJrWpWxOiV95kAOBRxyHn6RFyNQv2mU=@vger.kernel.org, AJvYcCXrO7pgjNZ00WjqdGF4FEFWDDsQGceFlioU4QCDV9CE4AGhboICTkS8SnDTCbTIVuFD7XVacjnu6KOV7QEO@vger.kernel.org X-Gm-Message-State: AOJu0YwADh2r7GPl6gNXsFwiHugngUnjNIuT18OaaD/iYou97S6LK9qX 848DQlOpY8UEDXI8Ztm2J1cRoFdyGvYqumY2G6WAkPF8kws66FqE X-Gm-Gg: ASbGncuCUuYlOdsLwH1gUc5EzGDPw4jI3eWALxpEA/XUjGRbnKcsk+vXOD2s3kL5rLI aY5194hP+mA485Xi700WgDQKAxI66ZyvwmO3hj9xbYFM3K+ToeZbrYtnH3BuXzQ3dBHy246XZVX wTf2wEBDYrf/IP6NI36Vvu5fFFxjKwfH518kdWFner5AL1p1uHht/zVjVFVuDXRNzYTT1vuFfBb BxN7DvoYD3NDd3Y3T6uaLRlhzZZiCoYyRLOyjxH8uvVl1k+fjLOuXDJ9ZU= X-Google-Smtp-Source: AGHT+IGSX3RDD4Mjs5KZqKxckix0gq8OkR9npjFRRCctDVzzyNWShDqRqCQCbZlVg9RCDHh4i4SbvQ== X-Received: by 2002:a17:906:1baa:b0:aa5:274b:60e9 with SMTP id a640c23a62f3a-aa5274b69ecmr1175231566b.33.1732641838563; Tue, 26 Nov 2024 09:23:58 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa534232086sm473832866b.42.2024.11.26.09.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 09:23:58 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-sparse@vger.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 , Dennis Zhou , Tejun Heo , Christoph Lameter , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Luc Van Oostenryck , Nadav Amit , Brian Gerst , Peter Zijlstra Subject: [PATCH 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Date: Tue, 26 Nov 2024 18:21:21 +0100 Message-ID: <20241126172332.112212-5-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241126172332.112212-1-ubizjak@gmail.com> References: <20241126172332.112212-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 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: Luc Van Oostenryck Cc: Nadav Amit 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 Tue Nov 26 17:21:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13886267 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 034C51DFD98; Tue, 26 Nov 2024 17:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641843; cv=none; b=ABvtvt31GGpWruvDvKclfD7zxf5AepqVaL3Eri3P9AZICkFKq9Mk0HKMg4lGvT4IwWaRF0qWteZvUMa1TvSR1yQ1+x9IDgGngKGYeXmUXzFsK/DcGMFfSZ259uBCWvo66llHjVvcXAH7NEnJ0xLK7zNJGHdVHCV7D2ZR3FAYBT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641843; c=relaxed/simple; bh=eC25SyhqUQGBuichpm/2M12L5lE0TLdJk2x0WWN6EXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fTdc5/rK0zY5w90lDO5ugInMSUXW07XvAFId7YB3tmP7Rt/1EMzwX51kP+oVor9dHXUcPxolYrHJWcffhqg1eigtigAddI6g/J7uhEpeM6pZHFO0B5KdBcYlKwPcfz6K6nl3Jb0crQQLiYRHQncsWhSlC7lpiK/vwUcNQxSl2LM= 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=e9uZy5WL; arc=none smtp.client-ip=209.85.218.54 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="e9uZy5WL" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-aa54adcb894so334377166b.0; Tue, 26 Nov 2024 09:24:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732641840; x=1733246640; 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=ky+OlLkDMElBCNtIUb2edtqmSrtx7L7/4FrYNlOF0QA=; b=e9uZy5WLP0/V+640qEBXyxSmB16ueWiwFChxZ7BOW/vXyV/kV9HoTjniEF9H6dGaaQ c7Bv+1drknNdKMTNA+YyflkLYvYSpfhvbHpvxOPO2J9LixAKnJXx1L9BBRbTD/piz2Rh Z+3ObOE06kaIcMIHy7j9quqoe6+ULaxziOehQ4GmZ3U76q9zHKlcoOQAO6uPrBmk/wAm SpjFSuWFoWeZp84ew8F8o4x0ilokxr761xeCVDkGplGG26S7BpzrydUr9yrjGa3sgDb2 en0gxiDfAOdQmiOBiuqdjNz52DQrsnWfbHUPMIntOdkdyGHKUP2CKIgkdq1/KwJk243Q ejog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732641840; x=1733246640; 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=ky+OlLkDMElBCNtIUb2edtqmSrtx7L7/4FrYNlOF0QA=; b=P5BLd+8lqm3RrLE8gKNcjNqZodOb1twFcJhWTZEg9THg/gab+Yq7YK/aIsKJqAP3nR ZSug0YTJCLxqHZ8p1xL1TnKiho05O+QQXSGUoCwaTgGuTkr0iKTT46IolT1YcmjrT+9f kgwGPviBBmE73EnARP4deblORiMC6+0b1Qs31L8z7XgqGN2IVFd1JO4qK2XJCRrBRqo0 x84IW0yC3tu5XiMQ9cQ6d1Oo5UmxG3/N+rUs/lSoYE41Xr5EAinq+cYPzt7f3KG0GyNM e7R8WLyZG2zxcPTJM39+ZiTWs1rlhNuIhM4bUILSPsiVJiO9quOP0qTpxhkd3Ub9abZr RYyw== X-Forwarded-Encrypted: i=1; AJvYcCUowTzMvyy1nDbT7aNPEQbS6kB1DKFqMZYYwm/WGdI3U5M3b/G11RGWG0s0m3qma3j6kl+Bc5Z1@vger.kernel.org, AJvYcCVzLDqMV3rIl7Y8bPHEbA/bR4hgoiIWvPaaY1PfJFxTBGwjgMz76aY2jjUlj0zRCeu62tSC4Fgw3e6QTzyT@vger.kernel.org, AJvYcCWG8J00yQ9SLjDERxD1yVYhRBaf1LDEtaBWSuPLKdseEA4oS4FMl0eWH5U/82HDqzT4RfPc0EwpQlG7/4NAVlE=@vger.kernel.org, AJvYcCXDH53Zv7m/mBWxjhw/1ouCq3xoyYIm+18jXok+nHCZplBVmqmsJhteI2ao0WfFKgOtcHPIUYon0w7SiJ/3@vger.kernel.org, AJvYcCXVZY9izTuS7GPtHD9RvubjxS1Xtg7ifvoGiXvc9i/QG1OdX/u3SfFdd+kw53obK6xNGBrTzSn95D1G@vger.kernel.org X-Gm-Message-State: AOJu0Yw6qmPwRW4l+Zw3WxhnBPMmjEudaWxHpBK6F4UvD/nYrCd++Y/n +tdrw8azJglvVgL79zjqjR/7mqSxc9d8Ad+63QcGUgaajjrqSS91 X-Gm-Gg: ASbGncu/6//1edAZlJbKGZyJHaG4/HmTmh/dG8SYIOSyNM1ZrNJWpikjdv2YSOjt7fE KvaROQ56sWUhDyBnq3oekRG1kZhOl7xQv1oTLL/rxuOpot0cVQUZONWMJYbmP+Sv7IH2AsnCQCn +i1cP8y+I/qjOf2DZC2RucM3pri4Z0Is3lwmB67UNzU/wTdlAw0+YE4HF8vRsUjSmI7QqXpD8TS Zum5bQH32NxzcdbvO0m8CpWiVTznGtVIn2tyyP/u3G4SNd2NAQWXZ71uDs= X-Google-Smtp-Source: AGHT+IFf/RvtHifh9xfGRhKVpgriIMG2kypuYoc32969CCQP2/adNO/7HRTialB1HvpO1MqhLIyC7Q== X-Received: by 2002:a17:907:784b:b0:aa5:15ab:a5d4 with SMTP id a640c23a62f3a-aa515ababeemr1070027166b.22.1732641840123; Tue, 26 Nov 2024 09:24:00 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa534232086sm473832866b.42.2024.11.26.09.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 09:23:59 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-sparse@vger.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 , Arnd Bergmann , Thomas Gleixner , Dennis Zhou , Tejun Heo , Christoph Lameter , Linus Torvalds , Andy Lutomirski , Ingo Molnar , Luc Van Oostenryck , Nadav Amit , Brian Gerst , "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Date: Tue, 26 Nov 2024 18:21:22 +0100 Message-ID: <20241126172332.112212-6-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241126172332.112212-1-ubizjak@gmail.com> References: <20241126172332.112212-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 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: Luc Van Oostenryck Cc: Nadav Amit 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 Tue Nov 26 17:21:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13886268 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.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 5F8C21DE880; Tue, 26 Nov 2024 17:24:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641845; cv=none; b=q2vqdQHfypL1+vf3G/rPAmofHn1j3RZBF8y65UypKbEnZ57gkqmcWV66qYmBToo51NMqFyy7C0vPYC6UGJhRbe3+Ibb4AITRRyjyYkaBaB2BpA5UDoDP5GXV7I5rUDDj434BZWBTDsQBYEUPYZ634puZzV5prporOWYrKrG/D2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732641845; c=relaxed/simple; bh=4OHFcqeT2AuYq8OOGzyp2EVumvns8aqChYzt49dh7GI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FM3Fhpcy2+FP0U4ojPkCepnm7Qi/I9mrbt/9SPV6PnOsYhPHj0lUcOvGohHh6z71ZISAbIHNzI4okZXQP396/yqpggs6sJFgq1j5qy1bOoaMP0917yNo5tyop4tEPZjIEtRMsZ4uM8NQEs0Va6cdvxXaxR3HMy4QCGKBi/6S9Go= 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=DxJ5Kt3T; arc=none smtp.client-ip=209.85.218.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="DxJ5Kt3T" Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-aa52edbcb63so607612466b.1; Tue, 26 Nov 2024 09:24:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732641841; x=1733246641; 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=vYQhfY8XS5QoJJ9ROocmWAxArKh2nECE5yY90QqkfaM=; b=DxJ5Kt3TjyZCKe4FdtR+FlKe+nypTY20rap7N+7ElE9SJ2jwWDI/4OZls/pnafXGxw A1VeeBx2+sPjNvSwftPac77KHG+nsWFnumIdIW1heQ4jWZpf1kc7YPmtgF3/TQuwXCgt YZG5j38j5BFCS9o9ehoRkXAlQv7ie0QJJgIXQqAfOACdDOGzDLc3Zs618dl7uarR2yC1 flYQE69f887Ic9526A9xdpt3Jfd2jH5ZscWZtmmIHCXFB4lkAzyOOrx+yNAN+eI241ef NiiaxEjpuH8AwlQlCO93SQB1uUbb1NlAPByCdMyGeEpHXOLTHLh6U3L4xpFetk7LwwMF ydWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732641841; x=1733246641; 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=vYQhfY8XS5QoJJ9ROocmWAxArKh2nECE5yY90QqkfaM=; b=FryF+cxf7oez3yrh+qpRJ3vq85HJbRaJYZWChtSvlGHAjHj+0QVbRdzAspyXnQ1h16 nPvfEqxN8quu+NqMHbN3HJTJHRlDqQZ4wcGh3uf7oEBoLXuyNvziiv061o4W+FKLqUGW QUjBOJyScEbcrqoCOiEeIIWqGmyRj8/SIF0eWj3tGd6LjpBL9zszrAhqjBqc3Co/BxuD hXF7cxuFYGHJBVXQR/D930GN1d4PpEJQ9dBaq/aVqZvyu6uUeOGISpuQ622OHfIRlEJC crYCcWqDC/FEhPaTokcakkDjuFzXir1DyI/xvlH/jhLgw0pOjnb1u2kudBalCKyIdN8a NmjQ== X-Forwarded-Encrypted: i=1; AJvYcCU5LzB9ZS06BLdO4lVxTsGzkGnPVHcGhgkhQKewGTgUO5BgG4Lho+X7Xi787WfGg0RLejSs937gpHMCdx67@vger.kernel.org, AJvYcCVBZ993GV2K8b0iycgDp+o4GG7BLV9WW2/vAnfNnPDcU6384eQiuSWrigBkl+VlLdlMNXe0t7we@vger.kernel.org, AJvYcCWL7P7J0di343GjVNVNnqT78XXhRbnoOVSA3yHJ0b69dmVswMIV/q7HQl2H6hStwS+4LbrvO2nIc9B4Zn2i@vger.kernel.org, AJvYcCXIRtOaQyuQwX+hOkpBt/tG0yfllpsvjABB+y61h5mTVwOpc34DAf4Tds1ngTwH+jVZqq0Va6Ggy8R81ee5wVI=@vger.kernel.org, AJvYcCXLguZcCsJroTTRzXoC63WRgmlrj63fdk724ejyxbYD7FhHSoLOnjhjZtmXBH3rtwMfLFBtjkNQ7Cw5@vger.kernel.org X-Gm-Message-State: AOJu0YxZXwa6cxyqN9H7J+f03R5kag6CqdSicrqAVR7+6wBVhyrhHrs7 EZNYdHwovsA1SjcPVbi+WjQU2FVnn8EPaYS/eC7Z5UmucJCo4J9F X-Gm-Gg: ASbGnct5eNeAz39VYC6K+PS26/TScZtq7H7JqLVeVBD2nvsCL3E71tDOk3DA5d+z9Np 9P7HE57A0TfK8IPCbuJ5B3SF3o6hyagbkx3nz+s5h231VpenALxflhWkNTmvK2I0Kc4qh2CRTce PCFp529JfphlVMFp5USdOdGs93uQOTUm1N2h9V0bBLBeHBO5fG+s8cTOIecb3W9I/p8UrXlWjRw ew/mu3vY01NwLWbGO22R4rNqpzPTyDZDivUB2ccIihbJXHBS1NpEf8gsCg= X-Google-Smtp-Source: AGHT+IGyDslpGnIuA7EaGQJjOGzUF02XOkLJcH+fA/4c2TgsR6qaqxDya98ILXBrNs7h8xnzOadyXQ== X-Received: by 2002:a17:906:3d22:b0:aa5:26ac:18e2 with SMTP id a640c23a62f3a-aa57fbba709mr3970966b.23.1732641841517; Tue, 26 Nov 2024 09:24:01 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa534232086sm473832866b.42.2024.11.26.09.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 09:24:01 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-sparse@vger.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 , Dennis Zhou , Tejun Heo , Christoph Lameter , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Luc Van Oostenryck , Nadav Amit , Brian Gerst , Peter Zijlstra Subject: [PATCH 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Date: Tue, 26 Nov 2024 18:21:23 +0100 Message-ID: <20241126172332.112212-7-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20241126172332.112212-1-ubizjak@gmail.com> References: <20241126172332.112212-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 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: Luc Van Oostenryck Cc: Nadav Amit Cc: Brian Gerst Cc: Peter Zijlstra --- arch/x86/include/asm/percpu.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 27f668660abe..61b875243ea3 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -95,9 +95,19 @@ #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(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