Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp448544lqg; Thu, 11 Apr 2024 07:45:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWM2+boD3HIANX+M8OhFbS+xvAS51fNTyfnuvCASMCvjdI3ijdjLD9pW7cJr+gnK9x08wML/XS0Adn/QfcAUIOmRsRFcQ7mKna76TSK+g== X-Google-Smtp-Source: AGHT+IF6AOXAUWgdal9yFX1BE78e5BlmQ0YUWJwgOnh8MXqeYXQ5dsYVtLaav7IZF9DYWlijIo0y X-Received: by 2002:a17:906:240e:b0:a52:2231:f005 with SMTP id z14-20020a170906240e00b00a522231f005mr1137625eja.49.1712846709239; Thu, 11 Apr 2024 07:45:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712846709; cv=pass; d=google.com; s=arc-20160816; b=R7PjjRiR4+GvJ4dlmaXjQ/7OYfVwm1vn9DVfBEa0YouHIxqACU+hZTLKJhBTwvEwik Ialt2izVyMns+1EJlmATZ06h0h2ORgyt/i8txZcluoYWiNsZJGQSfUX8Yy91V513zfBY it4ykV0w+meAzBVaIj9xj7TKov6XxBAfOaCJSorggBage9m4GUnVxTBrKIFUZuQCmwsS EoooXIYBgN9HL7k8e9QuDwbixAeRodsHTOelE1cz5Vnp2W8U1XhAdAgKvS8JfwD6NrkB sEz2H2PoEY55cPmjv5ziL0GZE95or0sHELyLhSGbTbyOBg2upO5j5kqy2gTNFXe2rXAH gFkg== 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=LWr+r3u1/fMYVtUTj9W9H3amZQ6iGfvNayCC7KzGL88=; fh=fTsvBGRCJ30wcbM+qukBwV1mBYwq/gxe2+STlSGXKvg=; b=MCUHRdsoI7wIHbKZVW4pKrcMTtywzq6DwV0qnmhn/4umTcXzX3F6fAtyUS5zK6A0XH dJwiaSNsEWHIlvhOwA0tkT/j7lBass35EQ9zepBrIdKLwaqU0Rc0YFvS5Fri5r5q1wNn h+qYR7B3u/2EyXub71O3/EUBSmiI3yl/IdAEYO/o+HjKjBagw0jeFai3eAISzj19CsLC 1d7w8gm5tqg0sR3rvZ6re5VoYN76Njw3Nz7uyYx/qPE6rHfS2bf4IF9+dGK4hReetC2o 9VX9cfwAyN5M19fGSs9/MMYouebw8xDRvn3R11gR3i5ab4aXHulWPPjn4KteU4RLuSge j9iA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b="QRXz7/pD"; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-140683-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140683-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y23-20020a1709063a9700b00a51b4e36229si796435ejd.501.2024.04.11.07.45.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140683-linux.lists.archive=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=@xry111.site header.s=default header.b="QRXz7/pD"; arc=pass (i=1 spf=pass spfdomain=xry111.site dkim=pass dkdomain=xry111.site dmarc=pass fromdomain=xry111.site); spf=pass (google.com: domain of linux-kernel+bounces-140683-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140683-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site 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 F1E5E1F21DF0 for ; Thu, 11 Apr 2024 14:45:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74CAB1802B; Thu, 11 Apr 2024 14:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="QRXz7/pD" Received: from xry111.site (xry111.site [89.208.246.23]) (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 0EFBF17C61 for ; Thu, 11 Apr 2024 14:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.208.246.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712846620; cv=none; b=ufGraQMkjWBspWDSJwCZ0pPKpuiT++N1y077mH+T84fiU1onNcVjmt9jtztI+D5aPWxwCSBvEoZIx5a9U1SJicN1IV7GbKWz1SuaSbav3uhdSfNexdowGLgwXuTRY0KnrZqe3fj6DPmnA4UIvzUznEJnn5hQZ2B+tp0bdzrP13c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712846620; c=relaxed/simple; bh=5dwBI9khdYJeiWpel/yUUnsS8SPNZ9Fqg7qfToEvfZY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fAzqq4W8tIhCccDHB1m9WDtn7CVDo2Koq+9+pzjxN0wMYhc7ZMbRMONiJJg2hLHVTGbBvzs++mYa7l2tY63BzJw2XrgOHtPSAi+P2+6BzMvY+0Ne4a+n/NV4T85NR4Qggi1HuI9BWNtaUSneV3Pq7r5bmirWgoay8XQTH3UxURk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site; spf=pass smtp.mailfrom=xry111.site; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b=QRXz7/pD; arc=none smtp.client-ip=89.208.246.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1712846615; bh=5dwBI9khdYJeiWpel/yUUnsS8SPNZ9Fqg7qfToEvfZY=; h=From:To:Cc:Subject:Date:From; b=QRXz7/pDt/jVzuDcjihSy6iw0ML9j0uiHYjKbmGJq9JXtHn2NYOSBi2MnKsCASoya uxcIWQvnh6Bet0wMOs8zc0vVoKlnrjcUuT4BEJzeE4Y7z0nBOQTXoB98ugqcpU+Kmp QE/5myHeUWrEQS0pV7PTDYmgLnq/5rRLIDd7w/Dk= Received: from stargazer.. (unknown [113.200.174.104]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 1E7D266EA9; Thu, 11 Apr 2024 10:43:31 -0400 (EDT) From: Xi Ruoyao To: Dave Hansen , Michael Kelley , Pawan Gupta Cc: Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Xi Ruoyao , Sean Christopherson , Andrew Cooper Subject: [PATCH v7 1/2] x86/mm: Don't disable INVLPG if "incomplete Global INVLPG flushes" is fixed by microcode Date: Thu, 11 Apr 2024 22:43:21 +0800 Message-ID: <20240411144322.14585-1-xry111@xry111.site> 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 Per the "Processor Specification Update" documentations referred by the intel-microcode-20240312 release note, this microcode release has fixed the issue for all affected models. So don't disable INVLPG if the microcode is new enough. The precise minimum microcode revision fixing the issue is provided by engineer from Intel. Cc: Dave Hansen Cc: Michael Kelley Cc: Pawan Gupta Cc: Sean Christopherson Cc: Andrew Cooper Link: https://lore.kernel.org/all/168436059559.404.13934972543631851306.tip-bot2@tip-bot2/ Link: https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/releases/tag/microcode-20240312 Link: https://cdrdv2.intel.com/v1/dl/getContent/740518 # RPL042, rev. 13 Link: https://cdrdv2.intel.com/v1/dl/getContent/682436 # ADL063, rev. 24 Link: https://lore.kernel.org/all/20240325231300.qrltbzf6twm43ftb@desk/ Signed-off-by: Xi Ruoyao --- arch/x86/mm/init.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 679893ea5e68..c318cdc35467 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -261,33 +261,43 @@ static void __init probe_page_size_mask(void) } } -#define INTEL_MATCH(_model) { .vendor = X86_VENDOR_INTEL, \ - .family = 6, \ - .model = _model, \ - } +#define INTEL_MATCH(_model, _fixed_microcode) \ + { \ + .vendor = X86_VENDOR_INTEL, \ + .family = 6, \ + .model = _model, \ + .driver_data = _fixed_microcode, \ + } + /* * INVLPG may not properly flush Global entries - * on these CPUs when PCIDs are enabled. + * on these CPUs when PCIDs are enabled and the + * microcode is not updated to fix the issue. */ static const struct x86_cpu_id invlpg_miss_ids[] = { - INTEL_MATCH(INTEL_FAM6_ALDERLAKE ), - INTEL_MATCH(INTEL_FAM6_ALDERLAKE_L ), - INTEL_MATCH(INTEL_FAM6_ATOM_GRACEMONT ), - INTEL_MATCH(INTEL_FAM6_RAPTORLAKE ), - INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_P), - INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_S), + INTEL_MATCH(INTEL_FAM6_ALDERLAKE, 0x2e), + INTEL_MATCH(INTEL_FAM6_ALDERLAKE_L, 0x42c), + INTEL_MATCH(INTEL_FAM6_ATOM_GRACEMONT, 0x11), + INTEL_MATCH(INTEL_FAM6_RAPTORLAKE, 0x118), + INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_P, 0x4117), + INTEL_MATCH(INTEL_FAM6_RAPTORLAKE_S, 0x2e), {} }; static void setup_pcid(void) { + const struct x86_cpu_id *invlpg_miss_match; + if (!IS_ENABLED(CONFIG_X86_64)) return; if (!boot_cpu_has(X86_FEATURE_PCID)) return; - if (x86_match_cpu(invlpg_miss_ids)) { + invlpg_miss_match = x86_match_cpu(invlpg_miss_ids); + + if (invlpg_miss_match && + boot_cpu_data.microcode < invlpg_miss_match->driver_data) { pr_info("Incomplete global flushes, disabling PCID"); setup_clear_cpu_cap(X86_FEATURE_PCID); return; -- 2.44.0