Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp407113lqo; Thu, 16 May 2024 09:29:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWb6YifNnDH6dOKG5haOY+YIPqi5GckNGJ+FP2h2H4rKFbmI+sTQe2T3n7QzuEEDkqQYbmje7xZHXknuYKXBin6UhaiZru8+177nCI1vg== X-Google-Smtp-Source: AGHT+IHzJT5OJsTILQhU48EXJXk3Oa+jt3yPqcRcqOSR1LXYuyalj5aV+kEw+oVH2N6GNAcydOI7 X-Received: by 2002:a17:90a:c241:b0:2b1:74ad:e252 with SMTP id 98e67ed59e1d1-2b6cc780684mr15580169a91.28.1715876983417; Thu, 16 May 2024 09:29:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715876983; cv=pass; d=google.com; s=arc-20160816; b=R7TZlqLDoT+RlQ1F6CovfmzwYTzC6/DUAlhxbW77tiW/49DEdtFJpjaLFh+7GxCwCD V6o1/6TmSLvPDnDEnr5SCJlVxw1uhCn4RFYt/+bh1xuv3vdlYonTe7FhNoQIDxb42Fnm I7Q7pghOm/nT+YhwBa+dLBIh4uLDTjYyskp/6/EABinRax946hunIWeQvTc5R32hRC2p scmLdZ9m9EUFk4FqdmmMD8WN/e7jpAUE7xiHe5VOR13XZs2T5gYr3pzqNnHbXfxo7nvg ywxrZqF4vEZBzfBcm1/lgtHHqJfbYP1eH9v6mdxlE+q0k7kySbGaYB1RCnKXXmFMwPcD 2ctg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=0oxo6S31Pb5KIU+yeXGruyY4PTNgOQ3P31JYzTeVEiw=; fh=opYnIx4LlFV2dWoSw9otQBA2NkdVIrY42BLac6KZU/8=; b=v9cIuD1c1Jhh7hHRNhV8VM4FyeEZnmGJRUzptWQ7rb7sBg1HkfkGGCMIAH1LyJlgDv U/IVN6LWPA/xCJp0lAk74h9/fyBLyqjH4vsYww0uXM0FLboVDql2XXpiFJv/svULiTvI 6xtvk3zs27YEms0UsJtk5XqRvQ1zJdgVDOPzG2SqPJSZuhKWywCo6Z2tZK38c6htwPwH XQKDj371st+ZOsSDq5maw2px1h9imH71O401BGZADkA/uqgE68SHpRCzUUtSFPcBYPqQ Zq/zJAQbsKpkCIjvASFwDoU0pBPlXXrlmdyCwW3QZStltHqLxZKXGlxVENN2qB431nIe bBdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NAqCT0JW; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-181316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b67168a3dasi13461191a91.180.2024.05.16.09.29.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 09:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NAqCT0JW; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-181316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DB5032811E5 for ; Thu, 16 May 2024 16:29:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1656515099C; Thu, 16 May 2024 16:29:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NAqCT0JW" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AAD7150991 for ; Thu, 16 May 2024 16:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715876976; cv=none; b=T2rkn1BaqUqtPISlJ0sgfc6nKTAyl0ra7Dub8i3tFW2zx7lFjR9vSaRj61rU0gzTW+t/pPt3Y7SGJncGb47aSEv+J48zsRWJF5yFv7qYCOBgFDd5BCYBw95Nt7Iwp5U6AfCX4UeX8JqV22Z06zjQMRir8VDWJj+xPH2kTmDJZxA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715876976; c=relaxed/simple; bh=oH7jW/qEeaQFMv1KiZOCshAmxrfYFU2lxVVW+EBHAs8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OLKsX6RvFeXM62qxxfwZnxIiCvX9L5ZtbEEv8NjG+qd8f/EYJbdBTPYsIBdUz2Whh4MPx4ShHfzxZ1iXlG6gXVHN2r3Z0xsC7b6rn2nSCTpu9cw4KvUpC/vXPya94Y0I8WVxG5aHo4hBn25CzW/CoYJVjBwBzVk84oZj2mcSmjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NAqCT0JW; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715876973; x=1747412973; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=oH7jW/qEeaQFMv1KiZOCshAmxrfYFU2lxVVW+EBHAs8=; b=NAqCT0JWkZwri7cOcYbDN2aYnmHf9zw1mG88gdLbO1c9HlqQ4YmaPndc eDW21SUjkoGc66yd1WbFxrwfo09qH83SYRXrF9stsELscpem2/R/nOHQW 6c92kL70PLcdUcpb0oDT79Dbu8tODLcPdBIcTc4zVsQ0SCIU8THqAliXR clKYMc+ZtuezG7lSrsSUuI66IE5fnSAxv30Z/vWzgYdDRCPJh1Iz9GqUq xpxVWdGI2nCANuIZSXaRap/na6C6flEB4cuNAm4SFX5APti0uX4kHaouv +YIsOiotrfpl1wMYdPT4qpAs1g5V5ldWzXBt293iFzSi8EyUYCe6bAKqm w==; X-CSE-ConnectionGUID: +eVv7Z6DTx+nsB8A3V5YJw== X-CSE-MsgGUID: mTnztSj9RAahzj+WUYyzng== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="11871766" X-IronPort-AV: E=Sophos;i="6.08,165,1712646000"; d="scan'208";a="11871766" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2024 09:29:32 -0700 X-CSE-ConnectionGUID: SyNlay/xSGi25eLc74TvzA== X-CSE-MsgGUID: 0rTHOyvpRi+TlH5j1E31vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,165,1712646000"; d="scan'208";a="68936483" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2024 09:29:32 -0700 From: Tony Luck To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H. Peter Anvin" , "Peter Zijlstra (Intel)" , Uros Bizjak , Rick Edgecombe , Arnd Bergmann , Tony Luck , Mateusz Guzik , Thomas Renninger , Greg Kroah-Hartman , Andi Kleen , linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v2] x86/cpu: Fix x86_match_cpu() to match just X86_VENDOR_INTEL Date: Thu, 16 May 2024 09:29:25 -0700 Message-ID: <20240516162925.79245-1-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Code in v.9 arch/x86/kernel/smpboot.c was changed by commit 4db64279bc2b ("x86/cpu: Switch to new Intel CPU model defines") from old code: 440 static const struct x86_cpu_id intel_cod_cpu[] = { 441 X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, 0), /* COD */ 442 X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, 0), /* COD */ 443 X86_MATCH_INTEL_FAM6_MODEL(ANY, 1), /* SNC */ 444 {} 445 }; 446 447 static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) 448 { 449 const struct x86_cpu_id *id = x86_match_cpu(intel_cod_cpu); new code: 440 static const struct x86_cpu_id intel_cod_cpu[] = { 441 X86_MATCH_VFM(INTEL_HASWELL_X, 0), /* COD */ 442 X86_MATCH_VFM(INTEL_BROADWELL_X, 0), /* COD */ 443 X86_MATCH_VFM(INTEL_ANY, 1), /* SNC */ 444 {} 445 }; 446 447 static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o) 448 { 449 const struct x86_cpu_id *id = x86_match_cpu(intel_cod_cpu); On an Intel CPU with SNC enabled this code previously matched the rule on line 443 to avoid printing messages about insane cache configuration. The new code did not match any rules. Expanding the macros for the intel_cod_cpu[] array shows that the old is equivalent to: static const struct x86_cpu_id intel_cod_cpu[] = { [0] = { .vendor = 0, .family = 6, .model = 0x3F, .steppings = 0, .feature = 0, .driver_data = 0 }, [1] = { .vendor = 0, .family = 6, .model = 0x4F, .steppings = 0, .feature = 0, .driver_data = 0 }, [2] = { .vendor = 0, .family = 6, .model = 0x00, .steppings = 0, .feature = 0, .driver_data = 0 }, [3] = { .vendor = 0, .family = 0, .model = 0x00, .steppings = 0, .feature = 0, .driver_data = 0 } } while the new code expands to: static const struct x86_cpu_id intel_cod_cpu[] = { [0] = { .vendor = 0, .family = 6, .model = 0x3F, .steppings = 0, .feature = 0, .driver_data = 0 }, [1] = { .vendor = 0, .family = 6, .model = 0x4F, .steppings = 0, .feature = 0, .driver_data = 0 }, [2] = { .vendor = 0, .family = 0, .model = 0x00, .steppings = 0, .feature = 0, .driver_data = 0 }, [3] = { .vendor = 0, .family = 0, .model = 0x00, .steppings = 0, .feature = 0, .driver_data = 0 } } Looking at the code for x86_match_cpu(): 36 const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match) 37 { 38 const struct x86_cpu_id *m; 39 struct cpuinfo_x86 *c = &boot_cpu_data; 40 41 for (m = match; 42 m->vendor | m->family | m->model | m->steppings | m->feature; 43 m++) { ... 56 } 57 return NULL; 58 } 59 EXPORT_SYMBOL(x86_match_cpu); it is clear that there was no match because the ANY entry in the table (array index 2) is now the loop termination condition (all of vendor, family, model, steppings, and feature are zero). So this code was working before because the "ANY" check was looking for any Intel CPU in family 6. But fails now because the family is a wild card. So the root cause is that x86_match_cpu() has never been able to match on a rule with just X86_VENDOR_INTEL and all other fields set to wildcards. Fix by changing X86_VENDOR_INTEL to a non-zero value (4 was lowest unused value, so I picked that). Fixes: 644e9cbbe3fc ("Add driver auto probing for x86 features v4") Signed-off-by: Tony Luck --- Changes since v1: 1) More detailed commit description. 2) Changed "Fixes" tag. Commit 4db64279bc2b merely revealed a twelve year old gap in the implementation of x86_match_cpu(). arch/x86/include/asm/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index cb4f6c513c48..271c4c95bc37 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -175,10 +175,10 @@ struct cpuinfo_x86 { unsigned initialized : 1; } __randomize_layout; -#define X86_VENDOR_INTEL 0 #define X86_VENDOR_CYRIX 1 #define X86_VENDOR_AMD 2 #define X86_VENDOR_UMC 3 +#define X86_VENDOR_INTEL 4 #define X86_VENDOR_CENTAUR 5 #define X86_VENDOR_TRANSMETA 7 #define X86_VENDOR_NSC 8 -- 2.44.0