From patchwork Wed Jan 10 15:08:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 186926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp852637dyi; Wed, 10 Jan 2024 07:08:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvYjUsRctEVAExAdMI8gSLS+sLVKprNN9RMbD0ldhXjOxvIZ4nm6WX28RqEI41qy+55OKV X-Received: by 2002:a05:6512:510:b0:50e:ccc3:470b with SMTP id o16-20020a056512051000b0050eccc3470bmr373806lfb.30.1704899319888; Wed, 10 Jan 2024 07:08:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704899319; cv=none; d=google.com; s=arc-20160816; b=yTBxsRoy5Q10cS24QZvgAUcV9sk1RabuKWgcsXj6zSQh1XEBMACK7VAR90ClsimDhq Dwq2z949FPLpyLmlKMzeCU60DBd/wjqQ8STg6f0yzMiYeeLyzv55VN/O4THvqhs3PiZ1 FaFdwfP5h5/M4WWfmz63JgMOsuVCFLjrwWlvnVdefgoienm54Z3kFRrZwNfMwKHYYsrd R/0+SgqiYxDtyAGfr2OjiD4z2cM85uQb/hDiQKY+50OgQyu7PGYOMwtZJpfQl0eMvwxu 2ZbY1oinsg6LXTBMfutlKzleDjCqI0p+XRI32BWmlVQ3uLkKrPSCGA0uvo8+2CjzEQ1O ReAw== ARC-Message-Signature: i=1; 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=DOwKQHMBULrU7xwun5pw8IsNhO9Q+ezf9iCAhEPbTMA=; fh=+6KIiIQx7RlBEpiJo3aozMdAMX7u/fPcgwx32k1QFuY=; b=pxtNx2dvR8vInZ73b4yZpBPJ6PJ7kCCvcyEqspCLERZKlKLwFFRMOaHew2EUPXWfTy ColyukSdU5TjDfwgHy+PyQEXSTLW6JilflzoJ3gWFMnhzWegvkcZXf5sa5WTS6yaB9YT HFjma2S9rNlQQ+P7q03Zq3LURUTXQtO2cM66qjtwBDWyA/kRIHqHKs/0Un73r3RzEwbS cloHyCwKejnnFixqLrML2OKpMUkVmqleIejVaTvgOAdoHPwIFhMFhilK1qhvLFsdaxxX cTU2/b0OFhbH7yqnS6q/mRBTFYwoHD4Yx8s+aUyMU9Dy3ze1KJ68cRQn/ut7ibfG2SPg Fn5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Hk/G1Yyg"; spf=pass (google.com: domain of linux-kernel+bounces-22395-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22395-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 1-20020a170906058100b00a28e8e72e8dsi1845743ejn.997.2024.01.10.07.08.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 07:08:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22395-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Hk/G1Yyg"; spf=pass (google.com: domain of linux-kernel+bounces-22395-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22395-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6FA2D1F2286B for ; Wed, 10 Jan 2024 15:08:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C6AD4C3B0; Wed, 10 Jan 2024 15:08:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Hk/G1Yyg" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 348A94BA85 for ; Wed, 10 Jan 2024 15:08:16 +0000 (UTC) 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=1704899296; x=1736435296; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=sHwp7FLzZIlG5HFYdgHfqqle8SLGS8mrA0XxzJMtOUU=; b=Hk/G1YygGc3Lw1kYm84PJIaJNGJ2OJUSjaHeF/FP6Ba2r0B/8P2dU3WW NeJouDLUU52C2wYM9qxX01hWnvSnfoEB9Nt67K4JJpRuygLyw4OSWw2eR B7eHFQQzP4CAveEgLcyAmdPJXdYn39pWXUyDGUdlZXGeqj++2DMwUvgaM LdKqoApcXK6KU25v/VgGxj9XS0U+F2XvEPWwfYF9CFlV0+rgvgEIB+hTj AEKElmaN5Gv5HGntuL96JMrsv2p49WpKF6JyEi8LX4jb54vQ9z9hOL9/Z /+XBSNBBqPIXcbF2n01R+NpRoYMp8z6GaPzOV/7cxGfUHOTMWq+/ohE1h g==; X-IronPort-AV: E=McAfee;i="6600,9927,10948"; a="5904720" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="5904720" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 07:08:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10948"; a="872673036" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="872673036" Received: from tassilo.jf.intel.com ([10.54.38.190]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 07:08:14 -0800 From: Andi Kleen To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH v2] x86/mtrr: Check if fixed MTRRs exist before saving them Date: Wed, 10 Jan 2024 07:08:06 -0800 Message-ID: <20240110150806.22531-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787716509460989807 X-GMAIL-MSGID: 1787716509460989807 This one place forgot to check the fixed capability. Otherwise there will a harmless but ugly WARN_ON for the failed WRMSR when the MSR doesn't exist. Noticed when testing X86S support. Fixes: 2b1f6278d77c ("[PATCH] x86: Save the MTRRs of the BSP before") Signed-off-by: Andi Kleen --- v2: Add Fixes tag and 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);