Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp170787rbe; Wed, 28 Feb 2024 16:24:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWru8I1EpLEjR1zIijpcn6DtNQ9XqFkZP16TGzd2jmG7DGGMCaR9G70BX8et4We9Su/h54eDxcLmjo+rum1EbLa2uVvKyFJsUEHTNAQuw== X-Google-Smtp-Source: AGHT+IFqUWvivO/2N1H6LCoVbaP3GzkEq3iTgD5jA5MrzrwVqjmfNMG7GMAfIJFP05HEl7k9tjeN X-Received: by 2002:a17:902:d306:b0:1dc:41a1:9ece with SMTP id b6-20020a170902d30600b001dc41a19ecemr523179plc.19.1709166286072; Wed, 28 Feb 2024 16:24:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709166286; cv=pass; d=google.com; s=arc-20160816; b=Ap6jtMFYnwv6dDN6FCcW9VSsZhr/cZGmcDflSg2DHH5yNhVRm7b08Ey6V5kFbTrgHP jvrEqgGi9De7qE92hc/bZrdYOB+kVOYtQVcmewWDHaH3/Y3eej0MoKIsYQaUVqAyx4Ec LxpB0mEZ11YMmt8ikDSl2Zvd5lbpQbjX1vGqpV+Z5nZjbzbe9bknuNw3JeMM+RQKVZGS JA3Tp03yPucTqfnXbVD+B5QqXo+V85pSClGhg/VLvV19kE9UmtNdqNgIv2yAmfHj5spg WyT5sCrmePfDqV5drF2nlvUKs6IePJ8jPln0I2ex0+E5ixjMWElVI9Hgt4sC4rnT7FsG hz5w== 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=RnBLtuB2b648Rh4Bbl7xtWAZwHz8024rDkxnu3D5mL0=; fh=+6KIiIQx7RlBEpiJo3aozMdAMX7u/fPcgwx32k1QFuY=; b=iY8lPGNaG96lPgtfDQvNo90E7w5HVxPfuUFsvRBQtT0/fvQg4fPHGaobLHG9lhxSIP SaSlBuRRZTHtSaGr1SSIoslmD/iVUuu7bAriczlzynGMcBba34QF70Vrv92rJGSwlMvQ 95r3o3zjaTQA95Otl23FbgLmo00J/UsnhkfqjCXnlznGpHjjG4vX5JoqHiUqaPnNb117 LWcjfIJWIAVtCdBCgufe86v5PoF5NkMeoU9dYmNfScfDnmPC3OybChuNcI36eQ5xSnKC fYt3dNYDlPnpgIBGS40aN26gUJND0v191gk6i41ar3uwh3Ye+D/PBzxQUQjhobsEhNOj UnKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nsa10gvd; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85914-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85914-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. [139.178.88.99]) by mx.google.com with ESMTPS id i14-20020a170902cf0e00b001db6043dd97si117957plg.246.2024.02.28.16.24.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85914-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nsa10gvd; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85914-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85914-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 C024E28678E for ; Thu, 29 Feb 2024 00:24:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC924107B2; Thu, 29 Feb 2024 00:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nsa10gvd" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 9123C7FE for ; Thu, 29 Feb 2024 00:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709166007; cv=none; b=d4d7KMXFtNAM1CWqMXyjp4O+kfP0InOAQeDU1hsk1UIPlDqDIa0fttY2c3aSNk6P9X+Hh/p/Wjx0w2VqpBZK5R+qefVVZC0z2VnF89Z6QZrW/D512E40cwsvf5fDI5dqhdqImlb4nvCTf51P0asuHsihDSjR04eMO9R8/yKlc8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709166007; c=relaxed/simple; bh=WP9vvbV2njaVQ8t02r3r/YNcGX7SRKU79ihqdWRNDkM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=i6ci/PfTrviFVtKKgNMUULvCvGDrWriZj9I+qA+I3DqW5XrEhJuVOPH8y+OCP4Jb2JWkTMCnxx7Y+e5DiVDFlRkHeUZDvcPOb8j31X5o8LYpl9PdooyG8q++d12knwkL7VazoSKBD7rhw8uIn1wCO0P272JBOWdbkkRPtURC8Vs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nsa10gvd; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709166005; x=1740702005; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=WP9vvbV2njaVQ8t02r3r/YNcGX7SRKU79ihqdWRNDkM=; b=nsa10gvdVvnxt8tj8NKhW+QJSqYy0EtqpkOF38hRhm+h3XgEIPvETLV9 WUyKaJU6kKPliZer7oI6fJqHFfpo9ESIL2ZN+EiGn1m7Hi2AlgnCldVmC KAnmttBgG1Si0l+kUyE2RlxLDXtFQwKDH/we4AbPLvOpiuSfalmx0Fj+m ZCk7eA/St614gg7yW23xP8l9zPeGVq+VavbayvsHmkoQtRdTA7W2o2xhi FAnPUyTOyLtRgSjgMtUFesoOPQUnk+Xcy9oqQbuFjMZt+y0NIjuofsm3n S1fmE/lZ1pDsRhzFO1Q2yKmohTzmOTfcY36WwNNciEwiySIRiKCHbkkTz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14245922" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="14245922" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 16:20:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="12275188" Received: from tassilo.jf.intel.com ([10.54.38.190]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 16:20:05 -0800 From: Andi Kleen To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH v3] x86/mtrr: Check if fixed MTRRs exist before saving them Date: Wed, 28 Feb 2024 16:19:52 -0800 Message-ID: <20240229001952.325275-1-ak@linux.intel.com> X-Mailer: git-send-email 2.43.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 MTRRs have a obsolete fixed variant for fine grained caching control of the 640K-1MB region. This fixed variant has a separate capability bit in the MTRR capability MSR. The MTRR code checks this capability bit before trying to access the fixed MTRR MSRs, except in one place. This patch fixes this place to also check the capability. Otherwise there will be a WARN_ON when the respective MSRS don't exist. Fixes: 2b1f6278d77c ("[PATCH] x86: Save the MTRRs of the BSP before booting an AP") Signed-off-by: Andi Kleen --- v2: Add Fixes tag and expand description. v3: Expand description --- arch/x86/kernel/cpu/mtrr/mtrr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 767bf1c71aad..2a2fc14955cd 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -609,7 +609,7 @@ void mtrr_save_state(void) { int first_cpu; - if (!mtrr_enabled()) + if (!mtrr_enabled() || !mtrr_state.have_fixed) return; first_cpu = cpumask_first(cpu_online_mask); -- 2.43.0