From patchwork Mon Dec 11 12:06:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 176640 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6993998vqy; Mon, 11 Dec 2023 04:06:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVImbNySFXk3gkkfZLRnRMVM5jPuAkCUe9CcVoZWEJyQoDd4D0swxG2qzzc3dM8EfPxIQN X-Received: by 2002:a05:6a00:4b0c:b0:6ce:2731:79f7 with SMTP id kq12-20020a056a004b0c00b006ce273179f7mr1449576pfb.45.1702296404904; Mon, 11 Dec 2023 04:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702296404; cv=none; d=google.com; s=arc-20160816; b=Ha7saQzubYGryUkYh1uLK8wPXi1TrYbAS9WHdSkzLOXUruUFT2pYOQ0QgZj6blKMhG 43NJgt2thEXxYT+AKol3K+8xVnRnb3C1uz0uEJbskljmd/ddtH/kHTmptKZ5fyveyJuV TOXlW+XvX3hI4K5I71+v7Wufo2LmROmnTbmYeZlTVGUUTFz5BQ4T/3fHIpPfDaYMA3+K Xy5/Putku8vmn2UEVV2jWyBtZVG49987e08FwYfZBFbHh34yKubNgce0e/FxIUm08uiN N/m7OMvZ4M+IRQ1AbEYVProf2sLkQn8BBIWTJHLyFqEcycMoKg1ds7rX3CQOi6MlorOq DvBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=G78RNOpLa8XVcxJfF2eZlwdtk/PkTnqU6DbxyMBE2lk=; fh=aMuEctUrpEjcm7+Z6FW9dcyBzbyQClfa+XesJRjdIVw=; b=qIWOwde/IC/1MdYP3td+zf2xj1mmPJGOOCPhJ5g7JMiDZ0RULOwQjQn7hNad9gSqCZ Wmvp14YHkBgS7XjcrehyFyARYGbAggatR8wP06kIvw+1pweiDj5sBhV6Mnew39qnrX9m dEBPiDcbbOFYxSFDkFaAiKxKn+vhpz4ssQ5ahOOOFAQtpvLYggcfKxysxjlzZ44x+v/O QSDIR+4dNwIZlUmOi1OjU3/HYY+Iw6yTwqvJBbHWiFQozt6GwWRDY8siD/m5+ReGIU+f /I/wBNYj5wc1k11rhM0A21DXlWbA0ovjSnVGO1XCUt6yI3bTVO6nGMFY2lv6tLzuYsF8 ziRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1xj0L7aS; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s9-20020a056a00194900b006ce11380ce4si6009833pfk.20.2023.12.11.04.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 04:06:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1xj0L7aS; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 7479E8069CB6; Mon, 11 Dec 2023 04:06:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234498AbjLKMGW (ORCPT + 99 others); Mon, 11 Dec 2023 07:06:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234333AbjLKMGP (ORCPT ); Mon, 11 Dec 2023 07:06:15 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A935D6; Mon, 11 Dec 2023 04:06:21 -0800 (PST) Date: Mon, 11 Dec 2023 12:06:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702296379; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G78RNOpLa8XVcxJfF2eZlwdtk/PkTnqU6DbxyMBE2lk=; b=1xj0L7aSqbmCin0bvL7p4dPt9uUnI6naXSgsEhQn47xEAYAhexN6ht0ukpTpmN/87x9klB 3IIcZKj1E/tx8JSbCK56AM6y+OCEjHsxjAyGGBJ8IIpe3R7Ue7/AB3nIQvIwW+GCgG8pRm IOd6+CI9O5IbUvp8J7oa700lQx1CdawGhIcnmCl+hBmTzqAYa2LoJqP9aD5rRFVGDr7gVR RFd/FRfbpoCmcHhdgi1xsrM0WqigvhCH2asoZuOtnXapM5tAc84Mfo9CoyBVzbm4TLv3rp 2YTg++dPq1fEAtW+AjDQWe0jgBHPcQL80q8M2BHV0jfZDDjZYi71kL///NNTug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702296379; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G78RNOpLa8XVcxJfF2eZlwdtk/PkTnqU6DbxyMBE2lk=; b=RoLuEaRlM6CCn8GLgGiIuYESz+pmcK9Qw8PFmpJEfqRPE2EH1ffNYc5dnNnlg3URpiTdfM S+SJT+CyNXubEDBg== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/percpu] x86/percpu: Fix "const_pcpu_hot" version generation failure Cc: Uros Bizjak , Ingo Molnar , Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231204210320.114429-1-ubizjak@gmail.com> References: <20231204210320.114429-1-ubizjak@gmail.com> MIME-Version: 1.0 Message-ID: <170229637904.398.12069378585426327897.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 howler.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 (howler.vger.email [0.0.0.0]); Mon, 11 Dec 2023 04:06:41 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784386756470127254 X-GMAIL-MSGID: 1784987154901377889 The following commit has been merged into the x86/percpu branch of tip: Commit-ID: 0e3703630bd3fead041a6bfb3a3f2a9891af6c34 Gitweb: https://git.kernel.org/tip/0e3703630bd3fead041a6bfb3a3f2a9891af6c34 Author: Uros Bizjak AuthorDate: Mon, 04 Dec 2023 22:02:29 +01:00 Committer: Ingo Molnar CommitterDate: Mon, 11 Dec 2023 11:47:14 +01:00 x86/percpu: Fix "const_pcpu_hot" version generation failure Version generation for "const_pcpu_hot" symbol failed because genksyms doesn't know the __seg_gs keyword. Effectively 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. Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Cc: Linus Torvalds Link: https://lore.kernel.org/r/20231204210320.114429-1-ubizjak@gmail.com --- 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 9fbd7cb..c8c5674 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 0f12b20..3859aba 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 f20e876..a94a857 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -519,7 +519,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); }