Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp448759lqg; Thu, 11 Apr 2024 07:45:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoo8T5bJ419ti5425VmsOronedYurY2dzKz/rsTgvww/rTuGA3HnlCTZeLfrx2n0tjPc+1p9HHnOHi2BTOCC92ENicP85L1C3py+Vj4w== X-Google-Smtp-Source: AGHT+IGAnjhix59S7HEtdFNWGW5b3Y31pcKMziVC39iHbX+f4MMf6eBa7nhx45IGVJKyDMrZRnaV X-Received: by 2002:a17:907:7e88:b0:a52:169c:3bc3 with SMTP id qb8-20020a1709077e8800b00a52169c3bc3mr2997398ejc.75.1712846730490; Thu, 11 Apr 2024 07:45:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712846730; cv=pass; d=google.com; s=arc-20160816; b=nTDWni254iCVYZqejni+gYb+wkOg4SlTgNp0/5otIYZTHu7Wnfh1A8b8oY7GonBxIz oWuaCNdz2EgEqlGUlFPvDW3X89EIC7hhRfTJUMWq3GHl4swbZpDjLPmlaxLV9MStrqqU 3k1rGPHgLRQyWvpOXSBBwbmEcM9yPl3uTXLIZ5DGB5K15YmAGdVlF6KOh5LMaWNRCnsc Y6t1B3iMeNjYkEvu21lqfHe2hTmOQ3eEo+rNJWsSB5/F7VOgBAQMJAJ/YGnoAAIMwjW9 RR5GbBjhM01+ZFR33l4QxCFp6NDjS+vnx/C28b3MIVGOsUoOTuEe5bsvDce0zz5yV9mx 3FtQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EQdRpts/7Zr0wdnR5AlW3DodriFrXscoOkAJXtSwHe4=; fh=fTsvBGRCJ30wcbM+qukBwV1mBYwq/gxe2+STlSGXKvg=; b=PtB+lSgw65UuHkdynZbJ8YiaWinvPCyG/595FT5OSJlU3k2Uv1Qkptk/bgditjzERe FoHt7VHpxfc1uD5q33KqgDkneHybvUyHdryF5vGszTIPKFgws9zl7vwpl+SvvWuNRByT dscFVWK0dNsZ7rNEv9zHrCIhkD3+8x9UyPz6kV3OFhnO+kxQTtLp3DPNi2E3Xo9ERheJ 4DgUi7bobqs5LQ1Z58lvCF+XwKg8ijuA3BOnttS705hV0TwRtbso1X76IPkNueAYueYv OjHO4SYz9+3mU3HiaEqGGzvKBzjKCSr/VzM/9WwWZ0bsq+dQ6U0aFLmvDrFMkRT8/heF 7GKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=OT0wS8Hw; 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-140685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140685-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j12-20020a170906254c00b00a521be3b5c6si788219ejb.664.2024.04.11.07.45.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:45:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=OT0wS8Hw; 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-140685-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140685-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 201821F2326B for ; Thu, 11 Apr 2024 14:45:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B48E2556E; Thu, 11 Apr 2024 14:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="OT0wS8Hw" 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 0A57D1865A for ; Thu, 11 Apr 2024 14:43:42 +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=1712846623; cv=none; b=YK98G5eyHfYKuLtW3r1dtjYJs8uOk5DmLKzalvcxoPSYsAu/lsFOGOXyFawBi/47bEYSBUjBOgAuf6EVOEx6R+QA6jROiV8pv0MZJR/vaA/L1yQFKNeNiNk9fw3EYaO8U/UWMLf9goA+mgt+QzQ8AfJbSj9QErU2kVqr2KAizK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712846623; c=relaxed/simple; bh=koOBQ3Z44ypR6NQitkysuOhab6CFAR8ivaxRCIRFuvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l4Y0qagJdtwUJnkQmCduVNoN6QrrrrWzUYlqeBov+y66ms5C7JI8u8+w9BUbQeZfG7sdJlceqvD/FTAXFdvzAOG/byM2Mtxsc0SwAgHu8uu5JkYmLAbc1CHr2/QYX3itkgelB21X3DgYHTQfZuTdco7S5ND23F1K90f3WvbgY8w= 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=OT0wS8Hw; 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=1712846621; bh=koOBQ3Z44ypR6NQitkysuOhab6CFAR8ivaxRCIRFuvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OT0wS8HwgqKnDxl2iTWdboUcgVCzlFides50BJvedp01vlHZ2PbkFP12wtzuKS8mL QiHkHQ0/WBot531WCUdlTpIzuUqdbZWKzOxj9jzjlGimreBlXl9CQCuFFxoV2FuT51 qgAtBvFaDf3q02SupK9zPFZP6bn7Qtg9Hc++TGVs= 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 CF08B66EAB; Thu, 11 Apr 2024 10:43:37 -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 2/2] x86/mm: Don't disable INVLPG if the kernel is running on a hypervisor Date: Thu, 11 Apr 2024 22:43:22 +0800 Message-ID: <20240411144322.14585-2-xry111@xry111.site> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240411144322.14585-1-xry111@xry111.site> References: <20240411144322.14585-1-xry111@xry111.site> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The Intel erratum for "incomplete Global INVLPG flushes" says: This erratum does not apply in VMX non-root operation. It applies only when PCIDs are enabled and either in VMX root operation or outside VMX operation. So if the kernel is running in a hypervisor, we are in VMX non-root operation and we should be safe to use INVLPG. 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://cdrdv2.intel.com/v1/dl/getContent/740518 # RPL042, rev. 13 Link: https://cdrdv2.intel.com/v1/dl/getContent/682436 # ADL063, rev. 24 Signed-off-by: Xi Ruoyao --- arch/x86/mm/init.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index c318cdc35467..e69d227ea123 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -296,7 +296,14 @@ static void setup_pcid(void) invlpg_miss_match = x86_match_cpu(invlpg_miss_ids); - if (invlpg_miss_match && + /* + * The Intel errata claims: "this erratum does not apply in VMX + * non-root operation. It applies only when PCIDs are enabled + * and either in VMX root operation or outside VMX operation." + * So we are safe if we are surely running in a hypervisor. + */ + if (!boot_cpu_has(X86_FEATURE_HYPERVISOR) && + 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); -- 2.44.0