Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2982193rdb; Mon, 4 Dec 2023 13:03:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgLT4EE3cKm3/FH/ySp8DNG9VCojbQkGmihgOo2n8YQGmYANc8iy2IYfMEmIHuobWVLvX6 X-Received: by 2002:a05:6a20:1483:b0:186:e53:b64b with SMTP id o3-20020a056a20148300b001860e53b64bmr1809183pzi.47.1701723826717; Mon, 04 Dec 2023 13:03:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701723826; cv=none; d=google.com; s=arc-20160816; b=y0JVIqV2vMNruINecJkhZQ6xG7nepdHSJcyx1q1rLHzDS6VcyKmgylodB3t69d3mMz Ta8yEVlzWxsmSvAIqcgmeyldNLNFjstDQYIaKI2thbwnn3GPWaYPAkAkHZKq/cj18Gx6 xGUlrEMdZxMQ+vIXlvo0VTK2LnNsFqRd+L7DZh4EeYfvey79kX6Nan86dFbwGvFFvFV+ uOmRtGJW8/oijprIq+qkWYFeKZbdGHnPgAYLUGr6ZR81GbVIEHJ1n1aOfMYrijY00xn6 feUoo+opwUdFO9/MuyZAqjzgFtKIScqGf7/yRc6Y8XjI0wA8I6uBrZMULrYfq8ZAiIO6 zVEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=U/WOpD6r5y0Ok3tYpWvI/WXVRtBKW+2PA57aZ1Qk9dM=; fh=RG81z/Hx5yQPYynbH2fyLvJdTMRM0l6VgTlyKjMN48M=; b=y6MuR+FHeEycUYS02RVQBkLRvLPXPIVZMiZJbf1+Qaw8WYgINra7h+ZKPReV3wE8QD M1qJYIrG/JgVmfHz0P3aKXPIy9HZ9XWOJl7/Ot5GDT4OL9DXaaHr6EsYiRFYMoQa2WIm XLMapaEOHrRV7h95utx8fbO5JIcJoXs10sWW9qXrzL9LzUJU22XUv6zVcRCJ5b4GUhXR 280IkZAmISyhzVAfV4xoBaiT/u96l3NKAmFwynh4tGo/B3ERDOhIIxzDysbaJExGgvGn B4DtYL51e2eRALxzk2ENTJgu7+1DY3Z3pPzHi2oSFMlJvY0CLlRX8CK4vtzFHmsV2QB5 ipXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eISlS4nc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s66-20020a632c45000000b005c200b11ba3si523288pgs.888.2023.12.04.13.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 13:03:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eISlS4nc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3FB2E80560C9; Mon, 4 Dec 2023 13:03:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233723AbjLDVDZ (ORCPT + 99 others); Mon, 4 Dec 2023 16:03:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbjLDVDY (ORCPT ); Mon, 4 Dec 2023 16:03:24 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FD4BAA for ; Mon, 4 Dec 2023 13:03:30 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3333074512bso2029080f8f.1 for ; Mon, 04 Dec 2023 13:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701723809; x=1702328609; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=U/WOpD6r5y0Ok3tYpWvI/WXVRtBKW+2PA57aZ1Qk9dM=; b=eISlS4nc6Ls4YF409KOga3qngwtTYbPNvk0NJEi1wGAqFij9pH90cnR3jMyVFTkCO7 VUtgDM7rOhOsmH64zJMoABAwH1iPEfoQj4DW0SCmZrNPcNV6OeymamR9gwcq7WcSSAL5 I5KzHpMd51JIkV9eDEmqLt7Za6y6tmyGKOBtaVM5vYhZvl5XL227ohhgf4sSVJ7muEzS jQwFqX6rljtDhK3pyrJQAUhsSeeCjCe9dFSBNiWNvPu/2jthyfC/aF1maKecUHgV8HKe mpk+eDAXQAmcuNsjDCm/LqctfZgIwkb8/us6311B81QLCTG7Zs8tLdeb0lGhheH5bC/v wsrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701723809; x=1702328609; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U/WOpD6r5y0Ok3tYpWvI/WXVRtBKW+2PA57aZ1Qk9dM=; b=Obhv0MYqwnKgBwjP7YMOcHKat0AFFiEgHOLF+fRrYHxD24vTSueF64V0efQ5Q2vcKf LBWUyYPDrXlqKdCxsNynqjFA4D9hbBD99ja7f6TPIhUIUmlLrlOxFvyXVXsjSKnsRcoX Ak5QJcO/1xZkMTUgLjDGpNfS9re6OeCICGVtFtPq3IqbuvhP7ZZr5WhEKYIeVfJAYYY2 FeQ5fyUy6nF8kaexTZ4FmgA0BiYxeH4gKopJGQLYfNqKbrlRT1nBHsZ3m0+iW8/KR5WS bgXqmuurBZXuO2hP/7TNcZ870zTNfSDhXl3qcfyfCB8INh6UBX7GVRSnP8PR6bDP/yTl 3TJg== X-Gm-Message-State: AOJu0YxSLcORU2OArH3/Io2r/auL6A2Krck//9l4F0mkTAUAK74UZK0M N6XkslwwP2vXrR3VrtUkNNhS94tFPNWpGgvE X-Received: by 2002:a05:600c:19d2:b0:40b:5e4a:235e with SMTP id u18-20020a05600c19d200b0040b5e4a235emr3218429wmq.96.1701723808650; Mon, 04 Dec 2023 13:03:28 -0800 (PST) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id b18-20020a05600c4e1200b0040c08567bbfsm7414815wmq.17.2023.12.04.13.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 13:03:28 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Andy Lutomirski , Brian Gerst , Denys Vlasenko , Ingo Molnar , "H . Peter Anvin" , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf Subject: [PATCH -tip v3 1/3] x86/percpu: Fix "const_pcpu_hot" version generation failure Date: Mon, 4 Dec 2023 22:02:29 +0100 Message-ID: <20231204210320.114429-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 04 Dec 2023 13:03:44 -0800 (PST) Version generation for "const_pcpu_hot" symbol failed because genksyms doesn't know the __seg_gs keyword. Revert commit 4604c052b84d "x86/percpu: Declare const_pcpu_hot as extern const variable" and use this_cpu_read_const instead to avoid "sparse: dereference of noderef expression" warning when reading const_pcpu_hot. Cc: Andy Lutomirski Cc: Brian Gerst Cc: Denys Vlasenko Cc: Ingo Molnar Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Josh Poimboeuf Signed-off-by: Uros Bizjak --- v2: Use BUILD_BUG() instead of BUG(). --- arch/x86/include/asm/current.h | 5 +++-- arch/x86/include/asm/percpu.h | 7 +++++++ arch/x86/include/asm/processor.h | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/current.h b/arch/x86/include/asm/current.h index 9fbd7cb2dc86..c8c5674d69f6 100644 --- a/arch/x86/include/asm/current.h +++ b/arch/x86/include/asm/current.h @@ -37,12 +37,13 @@ static_assert(sizeof(struct pcpu_hot) == 64); DECLARE_PER_CPU_ALIGNED(struct pcpu_hot, pcpu_hot); /* const-qualified alias to pcpu_hot, aliased by linker. */ -extern const struct pcpu_hot __percpu_seg_override const_pcpu_hot; +DECLARE_PER_CPU_ALIGNED(const struct pcpu_hot __percpu_seg_override, + const_pcpu_hot); static __always_inline struct task_struct *get_current(void) { if (IS_ENABLED(CONFIG_USE_X86_SEG_SUPPORT)) - return const_pcpu_hot.current_task; + return this_cpu_read_const(const_pcpu_hot.current_task); return this_cpu_read_stable(pcpu_hot.current_task); } diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 0f12b2004b94..3859abad19ec 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -28,6 +28,7 @@ #else /* ...!ASSEMBLY */ +#include #include #include @@ -462,6 +463,7 @@ do { \ #define this_cpu_write_8(pcp, val) __raw_cpu_write(volatile, pcp, val) #endif +#define this_cpu_read_const(pcp) __raw_cpu_read(, pcp) #else /* CONFIG_USE_X86_SEG_SUPPORT */ #define raw_cpu_read_1(pcp) percpu_from_op(1, , "mov", pcp) @@ -486,6 +488,11 @@ do { \ #define this_cpu_write_8(pcp, val) percpu_to_op(8, volatile, "mov", (pcp), val) #endif +/* + * 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 raw_cpu_add_1(pcp, val) percpu_add_op(1, , (pcp), val) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 061aa86b4662..1188e8bf76a2 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -534,7 +534,7 @@ static __always_inline unsigned long current_top_of_stack(void) * entry trampoline. */ if (IS_ENABLED(CONFIG_USE_X86_SEG_SUPPORT)) - return const_pcpu_hot.top_of_stack; + return this_cpu_read_const(const_pcpu_hot.top_of_stack); return this_cpu_read_stable(pcpu_hot.top_of_stack); } -- 2.42.0