Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1895525lqa; Tue, 30 Apr 2024 02:25:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVj3qDJpcVDuZSAjQAaDTviH+EjlupMmkM8heo8KDlMvWdxWuyG/UtpeT+R7/VkhZBQoUOSp1HjDNNNcv+xkbCoZGs06ToIODvhcwlvdg== X-Google-Smtp-Source: AGHT+IG592Rifpn1RW1D7I0g581pHY+JH79BkLq7qV61+N346aIv6I8HsiU+vySByFF807o6u8v/ X-Received: by 2002:a17:90b:4f85:b0:2a3:48a8:cf7b with SMTP id qe5-20020a17090b4f8500b002a348a8cf7bmr12783558pjb.18.1714469150888; Tue, 30 Apr 2024 02:25:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714469150; cv=pass; d=google.com; s=arc-20160816; b=lNVUpiN2Cif7LjL+zFK9tyq+mQBsRsVEk/cKJILanIPZ6VZ7AtXIknTE5Qwzu2lwlI EPnsxdMstfycBlh/PHOe9wqgS3Qvpo7zR4RSjqRLkslyivDGZyxLinLsldDLp6dE+j0/ 7KOb9MlS72rV1SbI0z7GFNPtcrPMUEOwZYMOuXSlkfRz5xfRnDKV3hhkRoqlT43M5exv a82j+ZBiz2SPQdQ6A6CbbxNWA7OniMEySBQoOtELRRoud0o2ghfuvb/u1KvlTHsorJ+h 6n/bXlvp7a7SZBVjMi0Qmqd2/hnIxVUz7MqobagBmBRxWWRxzPLop3gtC8+EN92eITfk /iYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ccImkqCG6/R3elWT5YA+XOLGgQwwcOOmKHy66GQ0wX4=; fh=I/X9n3+OVlLrnTOL7Gh4Q0y1oDAf4zE3wK4eZRnLjr8=; b=e2VwlHQNTLCY1LPluwpWb6xLY8r3FZShXqhxEX/ffqZplnYGwVoMRvOYiIEpCt24Nc ORVxLLyENI7gPgxO+aT5i4gEuAYiNLSNU5FCg4Na7yfO+AADS+Lj6Ckz72e1DxhB+I3N DiqTpFjz0pNoZHgF9RCKTexJZzifupiqwjBXpUVM0nvPTYh40n6TCTkqnbxA6E9BzSvp j8pfNx+bYK00l20K3rOB31qM0ImSmGsMWTJQVkEFw3jqwKkuVIdUvoVQfz5UI/tnmlZU LFzccV91c4qsvE1DSpFhUYUayr0pvgWvqXfARiEEVTvum7yfwF5rnWQAsm7HY7oY59EC oPyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gTDuMjfW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n13-20020a17090a394d00b002afd46ecbe3si9573083pjf.76.2024.04.30.02.25.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 02:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gTDuMjfW; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-163655-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C3FC1B22FA7 for ; Tue, 30 Apr 2024 09:21:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F382E1BED73; Tue, 30 Apr 2024 09:18:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gTDuMjfW" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 4D5541A0AF9 for ; Tue, 30 Apr 2024 09:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714468733; cv=none; b=PmSFhhuRFypeaXLIL2HUDkkyjIuiqfD3rpcxEJqmBMRQA2FWyAfnBOOG4UMdbVPILnqcSL7gPWO+Y4IotorBqLg5xnqI4IdW2F20rFnnwP2/WRAhTgx9hL4zJnKOf2u8nxePuO70vxuCxYiGVBVTbJgCAfuexTjthbw+Lf8vw4o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714468733; c=relaxed/simple; bh=yzAOc6IgPr0Vk1N6O1Mc2R9ZBQ7o1IAvTNs87xxba+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DtciNgoQ9vrqp2eekew4efhIZOLxGv/K2YWtKFJdoThDluKMkXzb7HY0f0871gJo9/sCbu2SIMMhVszK/pCPcUcw5fhvN5nZgFosFRMVyEuwHn5QefM4tOC/gNDFgWNeR5GrfFq5D0x7yR0YsP0DyvQ8KD8KT5ieHWfHQA6Gi8Y= 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=gTDuMjfW; arc=none smtp.client-ip=209.85.128.43 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 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-41b4ff362a8so50040815e9.0 for ; Tue, 30 Apr 2024 02:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714468729; x=1715073529; 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=ccImkqCG6/R3elWT5YA+XOLGgQwwcOOmKHy66GQ0wX4=; b=gTDuMjfWYPOV5bpMADnXMKPtiCgl2JiMdTS9prhqSzIpD5hPDK7WyJG+PkeZ9YiV6l WSKqGRH1TzrrgSi+EV7SQ0dNunn8TQrPrCkexPtVwyh3/SqkmRLyVcrQH/u+XfeQMiZH pJQfLw43/9odJEuL8MFNQN8oWyConmZMJVD8WjKKCA0BQGAlv60YPwK2Bkd+hsmsVMSy ULRr+erqIdPPEpikPVlOpZ6TNeAHmeomKZyxi8a5xlunuRZ8o1f6oGpdF7pOxHttfIbH uQqdyuUeHDlqVh3bAZBoYkdCOriAMlDivvgxxZD2U9xhkOwLTlDAPG3gi+xUCPzdzUfC 9QJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714468729; x=1715073529; 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=ccImkqCG6/R3elWT5YA+XOLGgQwwcOOmKHy66GQ0wX4=; b=gR3hmqxb4vDSSOkB7VAIQnRJ8Cc6n6c9No56SfJQnZ60X24TPxLAA5q9Rc2sWdOD5L NmAeOJywfRzSLkrskLmydGdUYMZQrv7LEVY6Q+0JLfYjxZmeJTTy1F3ftP2Zvo3T6rPn vff7h/Pc+tiqgpq7y430j/dKB0qNRKEA1CoyXnUb46tAVsRVxtmjtAWgn+Tn1MTQPFcF hWM80p+I8qXaVXHCXGpyE7kjZJ+GHqLYoDqRa7T0Z26avi4HD0MpUFrl+c8YW1TvtmnZ AyzSJjk+ARW2Z0JwgzPFL76gn4ymHi815Mtl24MMNqktFaiL6HlxU1vwwO5lAsdnoiN8 k4lQ== X-Forwarded-Encrypted: i=1; AJvYcCXv4x9Ias6JBHuooljUNsR1WE0HCQk0Jar0SEbfydCl82ZvWEoaVvY2SJ3Nfah6RMU00QfecJydPTnE/8tPyj0rEIyHZiW/N1G9AsXr X-Gm-Message-State: AOJu0Yxbhu8E09YPkddcxUUOwe0aJOPmCxP/Q/EVr7LJtcQUFUirRIX4 VbxfsRteuBwQc8f63A1V/LXilzKLvSGlnBYs3eX22uHbebfnclck4JO2l7J5 X-Received: by 2002:a05:600c:3546:b0:419:a3f:f4f6 with SMTP id i6-20020a05600c354600b004190a3ff4f6mr12713041wmq.8.1714468729361; Tue, 30 Apr 2024 02:18:49 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id h3-20020a05600c314300b0041abdaf8c6asm26324458wmo.13.2024.04.30.02.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 02:18:48 -0700 (PDT) From: Uros Bizjak To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH -tip 4/5] x86/percpu: Introduce __raw_cpu_read_const() macro Date: Tue, 30 Apr 2024 11:17:23 +0200 Message-ID: <20240430091833.196482-4-ubizjak@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430091833.196482-1-ubizjak@gmail.com> References: <20240430091833.196482-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Introduce __raw_cpu_read_const() macro to further reduce ifdeffery and differences between configs w/ and w/o USE_X86_SEG_SUPPORT. No functional change intended. Signed-off-by: Uros Bizjak Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" --- arch/x86/include/asm/percpu.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index f360ac5fccde..d20255138426 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -156,6 +156,8 @@ do { \ *(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val); \ } while (0) +#define __raw_cpu_read_const(pcp) __raw_cpu_read(, , pcp) + #else /* CONFIG_USE_X86_SEG_SUPPORT */ #define __raw_cpu_read(size, qual, _var) \ @@ -180,6 +182,12 @@ do { \ : [val] __pcpu_reg_imm_##size(pto_val__)); \ } while (0) +/* + * The generic per-cpu infrastrucutre is not suitable for + * reading const-qualified variables. + */ +#define __raw_cpu_read_const(pcp) ({ BUILD_BUG(); (typeof(pcp))0; }) + #endif /* CONFIG_USE_X86_SEG_SUPPORT */ #define percpu_stable_op(size, op, _var) \ @@ -470,16 +478,7 @@ do { \ #define this_cpu_write_8(pcp, val) __raw_cpu_write(8, volatile, pcp, val) #endif -#ifdef CONFIG_USE_X86_SEG_SUPPORT -#define this_cpu_read_const(pcp) __raw_cpu_read(, , pcp) -#else /* CONFIG_USE_X86_SEG_SUPPORT */ - -/* - * The generic per-cpu infrastrucutre is not suitable for - * reading const-qualified variables. - */ -#define this_cpu_read_const(pcp) ({ BUILD_BUG(); (typeof(pcp))0; }) -#endif /* CONFIG_USE_X86_SEG_SUPPORT */ +#define this_cpu_read_const(pcp) __raw_cpu_read_const(pcp) #define this_cpu_read_stable_1(pcp) percpu_stable_op(1, "mov", pcp) #define this_cpu_read_stable_2(pcp) percpu_stable_op(2, "mov", pcp) -- 2.44.0