Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp245773lqt; Thu, 18 Apr 2024 13:54:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViXuNM3Mt9z1b0dcdjhd/d0FTykdwKrK2pODrZfqmTdvVoE5JfZ6kffCXp2+NzXOaLmhLjlH5gb+9hiBTVWHIoiTsDot6MeF8V/KDjGw== X-Google-Smtp-Source: AGHT+IH/McqEGJ8PqYxK0LobWmE4SJcPv5RTyktWkhWjZI61mMYDMmP+1+cTl8JNFxA0jfI/YRtA X-Received: by 2002:a05:6a20:d808:b0:1a9:4342:ac1b with SMTP id iv8-20020a056a20d80800b001a94342ac1bmr407104pzb.1.1713473690839; Thu, 18 Apr 2024 13:54:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713473690; cv=pass; d=google.com; s=arc-20160816; b=Ao54w2cf2AnmlMhsECJs+q4Xwg0F4pjGwmTtPJKly8eKdqQ9jWltt6BTH8KeLLW0e/ s2A4iF1Op6QuIwQv0TQQH6tJdac12ItMDmsziuAxLlHyQkN5k0D6C5cYalY+DcrtKgEZ 4/uOM3Bcgn4tqN2hl+CB3IIbFTXxDXq8Pd0x5TDn+Y7ncpp9lUtyg/FYua3mKne0tQ8K HM6Wu31gfa/cSI1Vn/EpJifDEviyTAfxdUW4xJ55bcf6bK+B2HvvhFvi4dNoPCyu+uY7 2kvjdhbhazAb4SXNUQmzZ7Bnd8g7Lxa1WJor8D4HfxycQ1n3b7XVBDA6aGXUnGI9n3Ov fyFw== 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=4ZmBRd6TQpcOrzV82ppPMAlsFWiAW828/xnVHYi9lh4=; fh=fTsvBGRCJ30wcbM+qukBwV1mBYwq/gxe2+STlSGXKvg=; b=Rin/VdqKnFU4yJLXONuQpS6CWeRYO+qFvxh91pa5FzSnWMHsyLQEwA7rFu4om525HM ZUWr7cWwuuFJoyTLloWo8ShDMEgJzmhx9PH/1m4zUnXGDR7qp2eKUNqWQfs2JOVei34E VtngKsmyVWWK5e23/S6p/P/lV7OWNZfQBxombgSbKMzjIpKrwSsWjCO31br+O7m1Rs3f dlZpzDYrl5Ryro7G+3wYgsDle9ga0IuZP4Qbrl9QwXw9Uejey5flwhfPcZ4YkfXueqbb Srur/M21DDDv24+2s03ql92SAJ5jTpqMKgiF8d8OhQA9XBxD7+56Y3JPUOf0zRwIk8GD 50Vw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=E8MKuAiE; 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-150776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f21-20020a635115000000b005dc7fe4a2a0si1958959pgb.584.2024.04.18.13.54.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150776-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=@xry111.site header.s=default header.b=E8MKuAiE; 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-150776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150776-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 943922821F5 for ; Thu, 18 Apr 2024 20:54:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B914B194C72; Thu, 18 Apr 2024 20:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="E8MKuAiE" 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 AABC7194C70 for ; Thu, 18 Apr 2024 20:54:37 +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=1713473679; cv=none; b=HbgtzSlsYu8Xm56pU5VuNnyK1RAdmxomD4rRKR6d56eQ9rgsYF7oi03DupHOfkEbf6OOaYtNOJW1pSfGLJYO1mp8l9dkJ4fuUiI7rxfgNv/a/oCBLDqKlUNoPyYWvJ+M2MYnRmJwiJjC1+VyMTJ7p0h4QXs9pEsJyh+hqFzyxAQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713473679; c=relaxed/simple; bh=jw7B6rN+W4EcAICNrjvS7o3xQ1r6kRpyDSmSpeRt/EM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DFzYM/PcKRtvLY8avQmbAONDJz7PPXUTUGFMAKZ9do4a1OAvF5RxZwhWCu2HzB7BJyANSbTadcx4EYPTIsj2fi7rkH0nuK0TyBcpMMqUtfwWNZddZpGjIQ2/6YXMfj/yhby6Hq5XansRmwlQZeU+PPOjoebUustB98SXWhn9Xo0= 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=E8MKuAiE; 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=1713473676; bh=jw7B6rN+W4EcAICNrjvS7o3xQ1r6kRpyDSmSpeRt/EM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8MKuAiEzkZyrBuQ6NASHrG/6+s4eK6Olk+yeKsBXEPWM+BA5iO19PHNMDFFmpKRM ZT+i+xnVAU6DqDYaqNl49VW3Idh88yJrKHUaNY0XFRNX365VapSNcArjkBrqSFrxod iY9tmDofrq/iz37esJveyV3sF/2uXBbwW7ANQk/0= Received: from stargazer.. (unknown [IPv6:240e:358:1129:f600:dc73:854d:832e:7]) (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 178101A4052; Thu, 18 Apr 2024 16:54:30 -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 v9 2/2] x86/mm: Don't disable PCID if the kernel is running on a hypervisor Date: Fri, 19 Apr 2024 04:54:14 +0800 Message-ID: <20240418205414.67735-2-xry111@xry111.site> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240418205414.67735-1-xry111@xry111.site> References: <20240418205414.67735-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 PCID. 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index c318cdc35467..b20e453c1217 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -286,7 +286,7 @@ static const struct x86_cpu_id invlpg_miss_ids[] = { static void setup_pcid(void) { - const struct x86_cpu_id *invlpg_miss_match; + const struct x86_cpu_id *invlpg_miss_match = NULL; if (!IS_ENABLED(CONFIG_X86_64)) return; @@ -294,7 +294,9 @@ static void setup_pcid(void) if (!boot_cpu_has(X86_FEATURE_PCID)) return; - invlpg_miss_match = x86_match_cpu(invlpg_miss_ids); + /* Only bare-metal is affected. PCIDs in guests are OK. */ + if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) + invlpg_miss_match = x86_match_cpu(invlpg_miss_ids); if (invlpg_miss_match && boot_cpu_data.microcode < invlpg_miss_match->driver_data) { -- 2.44.0