Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2490000rwb; Fri, 20 Jan 2023 03:45:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXu/Rnm9na49Z8YRW69pXtJL4pveRvTt0vdJ6lSt8YpOxXn0otrGw9+RMVtuBlYoanhU5KyE X-Received: by 2002:a05:6a21:1646:b0:ad:6305:a4 with SMTP id no6-20020a056a21164600b000ad630500a4mr15933210pzb.48.1674215151945; Fri, 20 Jan 2023 03:45:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674215151; cv=none; d=google.com; s=arc-20160816; b=RTwx932FP/qLnuoXUWwwRC5FVyOvCoHST+uefAhdufarbc9Gduw/6T2wXO8i5fevG0 G+grEVNPYayEj8vwYL10b813rwh+JI4WSNZ7G6mqhNo1fOlN8EVFk1JwEKKnLMIE1F7w HoofwIhA5C93oQUEbBhxvdr/98lrbebg4eQaPP5lV6ftWpnCrud6FHltKn/jkbj5qbtz RRDsdlRSwdgrbzDHW/H+5ZFFIj1mSs9bw8aHqMJCxxG/Bzm1KQAv3+KXtWWujhrNOobA 1V/A2yOTqJzFu0QOVLvRYCaNPfZOSbw+hzL8H0CfVJEaBOiJswphmFXCDXtvNZry1xhW sUCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Qyjdb+QGL3giQ8e4/81uR6HIF4H9CMXCkYb1kYtUlnM=; b=XLHe/jZc3yT420LfbRyzKip/Nz90XCwIsmnkHkcRW3BzOXfZVHgCesZGAMX2Yc9XGn bNjf4uOO8ESFiw6yOCo6ox2X3iRN49QdF9ONkucOeqTGHH8xUEKcQ1AImqDjC+/ckvTH RGceFyW3KIbL1SFjwsQb3eJ8O/IaOwf0rF3JyMRZlkSmZgrL0KMeOUw13vYoZfb9Czi3 Z0hshg1HzS6IgejB2FuZaw9MzS8I0s2g8gfPLpzEDgt+ordKop7AcHnDmixcoJiKlhlv R2aPulsCRbvvy0/1ZgVBcwcdXu0K1lpRhkwTTsTmoWfqRckdKOmFKKbBXcAyl9SSXndT nZZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YwvfcJdw; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a631355000000b0049ea2bf101fsi41168084pgt.877.2023.01.20.03.45.45; Fri, 20 Jan 2023 03:45:51 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=YwvfcJdw; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbjATL1c (ORCPT + 49 others); Fri, 20 Jan 2023 06:27:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjATL1b (ORCPT ); Fri, 20 Jan 2023 06:27:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 567C345F75 for ; Fri, 20 Jan 2023 03:27:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9040E61F22 for ; Fri, 20 Jan 2023 11:27:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A80D4C433D2; Fri, 20 Jan 2023 11:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1674214049; bh=rfM9XoEsJ3fxixGBFYlNuvWTsDntB4jiWzzWwt4TgPA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YwvfcJdwevZ+aASmlryPCVwN+yyKPDFI7isQ9VtTUc1nRq0Ca4LyE9GQLAGQUNLeO 4dNYSz7ym833D6GvCQNzz/WS649ynrYw8/CABb4fTxXN1+9wuvW0BA0m1D7rpswnB1 nF1qAdm4DbjHu3/G3IAe0j3r2lKEj63fER5WkN6g= Date: Fri, 20 Jan 2023 12:27:26 +0100 From: Greg Kroah-Hartman To: Pierre Gondois Cc: Yong-Xuan Wang , Sudeep Holla , Vincent Chen , Greentime Hu , linux-kernel@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH v2 1/1] drivers: base: cacheinfo: fix shared_cpu_map Message-ID: References: <20221219105132.27690-1-yongxuan.wang@sifive.com> <20221219105132.27690-2-yongxuan.wang@sifive.com> <9cfb3356-3e3b-e9f3-1e16-ff02790e5829@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9cfb3356-3e3b-e9f3-1e16-ff02790e5829@arm.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Wed, Dec 21, 2022 at 10:00:39AM +0100, Pierre Gondois wrote: > Hello Yong-Xuan, > Except for the nit below, I tried the patch and everything seemed ok, so > with that: > Reviewed-by: Pierre Gondois > > Regards, > Pierre > > On 12/19/22 11:51, Yong-Xuan Wang wrote: > > The cacheinfo sets up the shared_cpu_map by checking whether the caches > > with the same index are shared between CPUs. However, this will trigger > > slab-out-of-bounds access if the CPUs do not have the same cache hierarchy. > > Another problem is the mismatched shared_cpu_map when the shared cache does > > not have the same index between CPUs. > > > > CPU0 I D L3 > > index 0 1 2 x > > ^ ^ ^ ^ > > index 0 1 2 3 > > CPU1 I D L2 L3 > > > > This patch checks each cache is shared with all caches on other CPUs. > > > > Signed-off-by: Yong-Xuan Wang > > --- > > drivers/base/cacheinfo.c | 25 +++++++++++++++---------- > > 1 file changed, 15 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c > > index 950b22cdb5f7..d38f80f6fff1 100644 > > --- a/drivers/base/cacheinfo.c > > +++ b/drivers/base/cacheinfo.c > > @@ -256,7 +256,7 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) > > { > > struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); > > struct cacheinfo *this_leaf, *sib_leaf; > > - unsigned int index; > > + unsigned int index, sib_index; > > int ret = 0; > > if (this_cpu_ci->cpu_map_populated) > > @@ -284,11 +284,12 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) > > if (i == cpu || !sib_cpu_ci->info_list) > > continue;/* skip if itself or no cacheinfo */ > > - > > - sib_leaf = per_cpu_cacheinfo_idx(i, index); > > - if (cache_leaves_are_shared(this_leaf, sib_leaf)) { > > - cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map); > > - cpumask_set_cpu(i, &this_leaf->shared_cpu_map); > > + for (sib_index = 0; sib_index < cache_leaves(i); sib_index++) { > > + sib_leaf = per_cpu_cacheinfo_idx(i, sib_index);; > > It seems there are 2 ';' above (same in the block below). Yes, the kernel test robot complains about this as well. It needs to be fixed before this change can be accepted. thanks, greg k-h