Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp140964lqo; Wed, 27 Mar 2024 09:00:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVY/0QzLuQ3eBU5D6WOpRI1i4zKODF/j3gUSEwkiG4bQWwy/c9AMZC1dXV4ded//HQ7wLVzHRUW4sffot88hfiYA70RMnZ/8xPxo7PZtg== X-Google-Smtp-Source: AGHT+IEhEwcie/5xO1EAqJJv9rUsRUn8vmTglkNqE+maunp+EZO1OcMLo4nqXM469XdxmB/58VCo X-Received: by 2002:a25:bf86:0:b0:dc6:23ac:9ef2 with SMTP id l6-20020a25bf86000000b00dc623ac9ef2mr219919ybk.19.1711555229088; Wed, 27 Mar 2024 09:00:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711555229; cv=pass; d=google.com; s=arc-20160816; b=lvu+Ac0OcAy5W4ZoZtY10uWkKvLmCqzERx6r2MvqkofN1mNajXi0nI1W5mtLfsHO+2 qRBVLZAnIUxK8yNvHVIxsqDKbt1FazCuURGapMyTbWrau6ioPmgxdYUD2oQEqx4+71sF 2/uLOjzle7O9dbTw89lGLClpZKvMwSF/zfvLb09ezxxfE0IK5TLXP8dDQFYq87i2lW0S SQ1KwDpNbJnmoGp6aDH7m6lo6d5Y/EeBq/X9VDgErYIXAUX8Ibk1LjADT7T6BhiE9PUU 4pGF/N2ZKrttiGpINp8YmDag5EhtlkwBf3p8LOY5Nv+RmFpLdWU5AoELxXYLJVFF4JoO 6Fgg== 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=tRG9RJT9CDq4Raw2U5hv3nky6TFnMph+hLyko/h3ytM=; fh=/m3HqCFed2bxB38yAcPdKmCeyYC/ZHJVBDseUdUB4Vo=; b=Xd74BXVzzRc9mHFEMQkEHQEJEqstEDNlUfcRl9Oi7Ff/b/2oYKKtxRb4isb1t2eLjC nAO5TAQH3KOEVBVkTXnp+WFrUB8bgzLSBfbIMv/D4lu0y1RBuxmy/Nk/fPXjp/bpuTIP TjkJs5vQTPRjj6ALbl9DzkV3nJ+AaOGk1YEqG18HfHdUgmT9pR4TpqWXLdYd2jOZ2H0l 7tMmm6/jA2SwznA80bFYVZxYmsruJYQZMxWQ6xcoHLdijU/Qf1BIz2X20K9e91Qe60hL xrxN5CG++ur+3482R5Dbj9IvHXVRCoKmtuCtUXIaWFIDmvt+BNwYq0kHbKSrSdD8tUap DmGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b="U881pNV/"; 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-121582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u99-20020a25ab6c000000b00dd0bc3caca1si3013758ybi.567.2024.03.27.09.00.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 09:00:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b="U881pNV/"; 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-121582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121582-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B3BF61C31576 for ; Wed, 27 Mar 2024 16:00:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D4FE12F58C; Wed, 27 Mar 2024 16:00:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="U881pNV/" 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 32D8112E1EE for ; Wed, 27 Mar 2024 16:00:18 +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=1711555221; cv=none; b=tf/4YNjpRslAuMEKd30L65kVOFBuiF6A/r1WDhowor37gwszKfGalrbsyc7BtOKB6RzocAFjGDXZWp8fuM/Jw/NxVHl6V3uPA6qxMPtjMuciYlGy8T3tSXwu+HIz8EImG3shHtoQ8ppFxPsG0X6o865eY2cMZhom9S3BOBGZaqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711555221; c=relaxed/simple; bh=ULF32yPW5VnzXst8UpUYLUXbeHy7gDOzCHLEwUn1sWo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tCOTbT+pkXNOEW1KPwKAU8hHVMOmzTielhei1GXzCGDFKyZbcTAK/7UpntBiFd6RaMlQBDyJ/BALeiXOldHD2Fmwbic0xnwMigjoTg37+gfhTTNaCeG7Xb8QMiJdbcKv31CVOcUPApQK39YxTamgTmbBW2T0kqiiOx8jYZ2Bvrw= 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=U881pNV/; 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=1711555209; bh=ULF32yPW5VnzXst8UpUYLUXbeHy7gDOzCHLEwUn1sWo=; h=From:To:Cc:Subject:Date:From; b=U881pNV/w+uDEY6kIYq5vU47bg01Pi/X3tOGuDGXmJ5aUo0nDPKA+pTkHxAMUzJVC M37nvyyGkmbqKRWPfSNke8BPfswVhSh2dCWIaqdELgzVb/rGnbF5i6P5hpmlf7c/Vz tTaQH9sGwuMJk3XVksWVFbmyO4nusIsuQ3Mibdhg= Received: from stargazer.. (unknown [IPv6:240e:358:111f:6100:dc73:854d:832e:8]) (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 6C0571A4005; Wed, 27 Mar 2024 12:00:01 -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 Subject: [PATCH v5] x86/mm: Don't disable INVLPG if "incomplete Global INVLPG flushes" is fixed by microcode Date: Wed, 27 Mar 2024 23:59:20 +0800 Message-ID: <20240327155920.7026-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 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/ Reviewed-by: Michael Kelley Reviewed-by: Pawan Gupta Signed-off-by: Xi Ruoyao --- arch/x86/mm/init.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 679893ea5e68..476eb39db09a 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -261,33 +261,48 @@ 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); + + /* + * The hypervisor may lie about the microcode revision, conservatively + * consider the microcode not updated. + */ + if (invlpg_miss_match && + (boot_cpu_has(X86_FEATURE_HYPERVISOR) || + 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