Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp333855rwi; Fri, 14 Oct 2022 02:42:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YrH4vE5kDf4jqt6K8N88diR6hvj5YhHswwrLe8Ua90KYwDNxZklavJD0Wo1lumNkGGAm9 X-Received: by 2002:a05:6402:35cc:b0:45d:442:1765 with SMTP id z12-20020a05640235cc00b0045d04421765mr3542244edc.51.1665740557737; Fri, 14 Oct 2022 02:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665740557; cv=none; d=google.com; s=arc-20160816; b=DBQgGuWtacGvTarFY04OVT91kDKN0rKG+16Yz84yitvVGQQ3YRAsqBDKwerOV2ntnu PWxudLp1yLyvA6YrhvnBqXe81eA0mD0tVczGAqdrDAVxh31ZuuSeBxtLqz9tIwKOev9K 31d+hS7GIczcWADWA8VO8lBn+HfJo7tE1vYd7705KbMFvr3lXRKaGPFgovE5g/UZ5CEN gUKPBePDh641G4188Gy4QRFtJw5yIGV0zYGD3zoI6XIM34ta7haCYN0tiEQRxJYWy2hd sKsUTy5i9NFxbJdrVK60WjwKU7+LFanfb2IF0vke+JWddVgqQp14DrzShoWYhSiyAErw 7KBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=dRyYXEmc1wGjbTFgMzdK1xMsQi4IjpnWpFr+cY6Wchc=; b=wNqEKGLVyOU+kQ9GZK7O2U+ZG/xnwZVrB5nKeY+EwYJCwqurlGQRZkqvoE9Rij6Rcv xvlm2dmXtMO1XlL/3AQLrBKz7Q3eFKWXhszIRlZ4meQvVVUCLmZNe7tDKOLIYn8velYD //kjfKIZClaPQP/c5touKQzJdqfEUQWREAGuwX1uvyDfxBmUhHYx2CzHMU1+rn9QwiiT o1gb2jjSGO0ezTYHu+rnMLdqq6nQadGPh9EHlZklm6oBz0MwqU1CuWEJfgWtevDJ3Nn+ +YG3y0PegGA25lc4Tci5CO+06FAUycmLbZLTCXnLq0TsXhAY4YlvjT2IJiBBwtweq/jD e/wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nQrb5nbk; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a056402274500b0045c13366de4si2173742edd.572.2022.10.14.02.42.11; Fri, 14 Oct 2022 02:42:37 -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=@intel.com header.s=Intel header.b=nQrb5nbk; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbiJNI7f (ORCPT + 99 others); Fri, 14 Oct 2022 04:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230125AbiJNI7a (ORCPT ); Fri, 14 Oct 2022 04:59:30 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A4B1C6BF5; Fri, 14 Oct 2022 01:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665737960; x=1697273960; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=K5xG36ypnLnEJBbjHMbm2yY0zZe4wUyw2jNVWuOtSRQ=; b=nQrb5nbkRRpo01T8XBUp60uOrEBYgIKAqShvUQU3TSGYkDVskpgJXwGX GdwLTpJrNZrEBWPh0zmOQf43jUDda1HaQpNzMfGxQ4x6efFVdfW9u/MfH J8Qh560vXWtbBDMPZB17i7LrGnGQLXGGDdv9IhAqvNJvV6Q/Uc4Kn9bFY EbXXh2jmMzIArY0Ls6q2wvVXOc0C2bBIvvkVLivj0v1Bzd4QegtLct76q SzPyJRneSEfwo7dDWvSY+MUKHvnsqLN1zOxFPT0X5vqjMZoTwAE9X0yJq 80LpbRfwuEUAnAi8EOvzv0sp1iALiRgk3rz3cEf+0q5rImZbdgC5imebb A==; X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="391635396" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="391635396" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2022 01:59:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10499"; a="696234549" X-IronPort-AV: E=Sophos;i="5.95,182,1661842800"; d="scan'208";a="696234549" Received: from power-sh.sh.intel.com ([10.239.183.122]) by fmsmga004.fm.intel.com with ESMTP; 14 Oct 2022 01:59:17 -0700 From: Zhang Rui To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-hwmon@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, peterz@infradead.org, jdelvare@suse.com, linux@roeck-us.net, len.brown@intel.com, rui.zhang@intel.com Subject: [PATCH V4 4/4] x86/topology: Fix duplicated core ID within a package Date: Fri, 14 Oct 2022 17:01:47 +0800 Message-Id: <20221014090147.1836-5-rui.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221014090147.1836-1-rui.zhang@intel.com> References: <20221014090147.1836-1-rui.zhang@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 Today, core ID is assumed to be unique within each package. But an AlderLake-N platform adds a Module level between core and package, Linux excludes the unknown modules bits from the core ID, resulting in duplicate core ID's. To keep core ID unique within a package, Linux must include all APIC-ID bits for known or un-known levels above the core and below the package in the core ID. It is important to understand that core ID's have always come directly from the APIC-ID encoding, which comes from the BIOS. Thus there is no guarantee that they start at 0, or that they are contiguous. As such, naively using them for array indexes can be problematic. Fixes: 7745f03eb395 ("x86/topology: Add CPUID.1F multi-die/package support") Cc: stable@vger.kernel.org Suggested-by: Len Brown Signed-off-by: Zhang Rui Reviewed-by: Len Brown --- arch/x86/kernel/cpu/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/topology.c b/arch/x86/kernel/cpu/topology.c index f7592814e5d5..5e868b62a7c4 100644 --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -141,7 +141,7 @@ int detect_extended_topology(struct cpuinfo_x86 *c) sub_index++; } - core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width; + core_select_mask = (~(-1 << pkg_mask_width)) >> ht_mask_width; die_select_mask = (~(-1 << die_plus_mask_width)) >> core_plus_mask_width; -- 2.25.1