Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1894563rwb; Fri, 19 Aug 2022 11:12:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Ipnk8aVsJHCSRNG2rX8ofqe394n2lRf79itbz1yvvAToCzhW3/JWT6l2Vt/dr2QY7mzfj X-Received: by 2002:a17:906:8465:b0:73d:60b9:19e3 with SMTP id hx5-20020a170906846500b0073d60b919e3mr460540ejc.168.1660932759454; Fri, 19 Aug 2022 11:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660932759; cv=none; d=google.com; s=arc-20160816; b=J8yHkUM+pFudQRAR/DLzlwhO7dtys2bWTIjDB8tfIrAxuq1MwA4m4ar4uVqiKWPG1X EVkn6RtlZ9kF0/KAPyWl7Bp9rhllGDsV6+a0jJo4SBk4bbJcriDbSgj/epsqvVHH9Y2c Xh+VDZElG+ZGz/zdo4s5CgE1DWROiiqxSyVXouTyIb1nZX4eb45LaRk2W/5dT1mGp/MI ODeILxpTsJL9pL4kaYaoYp80qmjvh8dFRgkj0h5j0g1vihLiWVTBBm7MbLpJull5aXkm yYljm7GWgwi/R/GyPb51xrZlD63V+wXIGIgshZSr9dqSjE5O6yZn4pe61yY4fdLPlZsw Ghqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=CXjLZTzWLgHm11JMQkD6Kgs5OR1kO/Wx2RQqlqJYj5M=; b=pDzPEPv7zBw+6P1m+y16huFuywpPY1SkJGtb1Qm8TpBm7YmfTfbaV6Ioy91KIwGlf2 GU+AuhCY/0aISgXBDbyIaR1wYuqITWL0i9D4gF6lgly9QKAJv+ysVuQ90bo5A5ESRMJP 1aQwro6mGZP3H+SYGT2gy8TVW6uaIBBDX+E22mRl32k8Lw9hLVS7m7BLFU7eN6UrM1Qs 9SDbHmA3eU4pw1pcZjYUWEc2DASK6nrORH7ZcAlLjKyPD+gi1x6RC0vepwsxDgWm/J05 X7QOJ8VRfWMMOn/9uDZIYcNwzDKpRqFZ90Wky1Et5y7RthR593KmwriUF0t0uKVz0PYf QdwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="qs/3Hsue"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a170907914300b007313c16ec8fsi2505952ejs.114.2022.08.19.11.12.11; Fri, 19 Aug 2022 11:12:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="qs/3Hsue"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350237AbiHSSB3 (ORCPT + 99 others); Fri, 19 Aug 2022 14:01:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350188AbiHSSAQ (ORCPT ); Fri, 19 Aug 2022 14:00:16 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B517C105F00 for ; Fri, 19 Aug 2022 10:46:59 -0700 (PDT) Received: by linux.microsoft.com (Postfix, from userid 1127) id 352B92304141; Fri, 19 Aug 2022 10:46:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 352B92304141 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1660931219; bh=CXjLZTzWLgHm11JMQkD6Kgs5OR1kO/Wx2RQqlqJYj5M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qs/3Hsue/QdOEIhR6OrSSHNFMYBVXoIzO0wNwCTvRjqT6l4taop7Gx+ypITa11sU9 xqXuelwYgK5SWo1XfZHW+aVE1o2pRpQWhudFmP+DdEJ2VjoUFyCQLiRn7DB4k9sb7J Wov2N7HpYzVfF+Q1JYVAwl8gykCsdYhlZf/ctUgM= Date: Fri, 19 Aug 2022 10:46:59 -0700 From: Saurabh Singh Sengar To: Borislav Petkov Cc: ssengar@microsoft.com, mikelley@microsoft.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, peterz@infradead.org, tim.c.chen@linux.intel.com, will@kernel.org, song.bao.hua@hisilicon.com, suravee.suthikulpanit@amd.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/cacheinfo: Don't use cpu_llc_shared_map for !CONFIG_SMP Message-ID: <20220819174659.GA16818@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1660148115-302-1-git-send-email-ssengar@linux.microsoft.com> <20220818045225.GA9054@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <20220818122925.GA8507@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 19, 2022 at 07:16:13PM +0200, Borislav Petkov wrote: > On Thu, Aug 18, 2022 at 05:29:25AM -0700, Saurabh Singh Sengar wrote: > > Boot latest linux kernel on AMD CPU, having CONGIG_SMP=n. Once booted > > execute lscpu (just lscpu without any argument ), this will cause > > segfault. Please make a note issue is observed with 2.34 version > > (default lscpu version with Ubuntu 20.04.4) of lscpu. > > Does that fix it? Yes, this patch fixes this segfault. - Saurabh > > --- > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index 81a0211a372d..a73bced40e24 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -21,16 +21,6 @@ DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id); > DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_l2c_id); > DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number); > > -static inline struct cpumask *cpu_llc_shared_mask(int cpu) > -{ > - return per_cpu(cpu_llc_shared_map, cpu); > -} > - > -static inline struct cpumask *cpu_l2c_shared_mask(int cpu) > -{ > - return per_cpu(cpu_l2c_shared_map, cpu); > -} > - > DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid); > DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid); > DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid); > @@ -172,6 +162,16 @@ extern int safe_smp_processor_id(void); > # define safe_smp_processor_id() smp_processor_id() > #endif > > +static inline struct cpumask *cpu_llc_shared_mask(int cpu) > +{ > + return per_cpu(cpu_llc_shared_map, cpu); > +} > + > +static inline struct cpumask *cpu_l2c_shared_mask(int cpu) > +{ > + return per_cpu(cpu_l2c_shared_map, cpu); > +} > + > #else /* !CONFIG_SMP */ > #define wbinvd_on_cpu(cpu) wbinvd() > static inline int wbinvd_on_all_cpus(void) > @@ -179,6 +179,11 @@ static inline int wbinvd_on_all_cpus(void) > wbinvd(); > return 0; > } > + > +static inline struct cpumask *cpu_llc_shared_mask(int cpu) > +{ > + return (struct cpumask *)cpumask_of(0); > +} > #endif /* CONFIG_SMP */ > > extern unsigned disabled_cpus; > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette