Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp173842lqp; Thu, 4 Apr 2024 09:48:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVekkfi4MGy7OMahzDJsGTuwEiuvpKlYgbiugZrtsyWk2iecAxmuLJsqImx/W1GDWs2q/C43pHoWVayBZdVLFxuYjhruo7FVy2JVy13xQ== X-Google-Smtp-Source: AGHT+IEBpoH5Sv1IB7GKixalx4yZtyBMCJlLRueGKVgN+pLKiaAuC3FKjvqThq322BYKJOBldWDS X-Received: by 2002:a05:6218:2612:b0:184:c60:2bc6 with SMTP id oy18-20020a056218261200b001840c602bc6mr2290719rwc.26.1712249301988; Thu, 04 Apr 2024 09:48:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712249301; cv=pass; d=google.com; s=arc-20160816; b=g4qWoGIy4adsAcWxUWqgRhJOEu3ErnlzoOijyMy/A8XQvDaWfW0H7kpciVh2448huI 6GbGG1jBGuypWvjcysRfmEaRxH3sLQVD9Kj6tYnSzST6z3YNlbdPSe0ejmpl+K+lOcQ9 zF32WPkpEDfMCP6iye86KdP7t1IJlOAueUARDfouJUcC56NnTRwD99pG4SsOONjEgoG6 lyJOLNXqWZiRPIJdWTmZLZ8+lGm33fW2ySzt87ZkQTAHxlF1P2FVABcXUAaGwLfvIdD6 jj982Fq2iajxHcHq7sMUcXAO/4OwoHTbg5c3tW7NBZsGbm2Tjtc3eT73jQzlu4NCmpXN AOyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=iWPM39phGnWd3wtkybxStwEPc4WkoN2Lgf73jp2nIuY=; fh=m7S50lAoapZ5UQSHIwzBSwjhFUc0UJNbBuUoLflMwkQ=; b=tGENwtL9CKa/2brdrRVFS9yHlPcH7oTK2iYDtry/14nnje926Lov+W5jbDDUIFIHL7 er3NzQKHv0Uu+JC0zV5NfvlaZyb3slL6ibKhsYCwgd118vD8GmF7Sb40tj614NiRd7EZ mT7u6Hg7k91RKEcM9oxqWKOE2Bp/kng8TEDbVcT2r4r2hYFIq5Rzz/jKrjgZjYKaIbtT gnGSzaqWzuF/dGRb7AJ023b+SPvEMXFfp41V6Cwgae++G7F+YEU0zoojvW3ygbvsAXl6 uroibUqysInmPp1qF2YyqNK96MWovEeMhUUjqtjePV0BbxscvS1EFNzVn0aRZNGBo/Ym n0HA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=sapdhHG3; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-131848-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131848-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 84-20020a630057000000b005dc7ee3c62dsi15200721pga.236.2024.04.04.09.48.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 09:48:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131848-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=sapdhHG3; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-131848-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131848-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9F3A52879FA for ; Thu, 4 Apr 2024 16:48:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 614531F95A; Thu, 4 Apr 2024 16:48:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="sapdhHG3" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 658CA1F944 for ; Thu, 4 Apr 2024 16:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249290; cv=none; b=tEcR315GMCliYa+bf3ZEUxJWM2cApCU8fo6c9Ba3k+AKIYSNJ1hVeyjck+iVOWQuEUbdRuszLJayz44BcK0dnKwByrlD3xJ1VMknIYM9H6yMJsb7jegOAWtRF5acjQMhe5BMO9wXtndCIuzrQItcSnZ3bEPSvrwIsLM3yMbFAFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712249290; c=relaxed/simple; bh=7UZUpqrnZ2tB/8ABvVgavX6FGM5clbP8oDO5cQ9jQLM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Mpzf1ttWZuY8xCtuYF3rLaJvWPRAgslAPUngUfgvmUyIbSU5RuXhI1ElsgCk9vLGRsV/Ll7X7IrVUPymz6m926Xs+XOHb4oVcL6z1Wg+uwoRQPiwbWsKLZDhFt7BS47f2wYQ3nGqlzVaisrZRFyngySKGHF0lzVLv7SPrwvy52g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=sapdhHG3; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d715638540so16285201fa.3 for ; Thu, 04 Apr 2024 09:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1712249286; x=1712854086; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=iWPM39phGnWd3wtkybxStwEPc4WkoN2Lgf73jp2nIuY=; b=sapdhHG3CtfqN7biyc95AZyI/S2unBIWaifs52QktP7w7o9uu+zQfYIOo9+y0yEqer jHAuMYbH5YD7BaBk2K/QzjugMKoIb/RhQuCt9O9LXCHF1dAN39B1KUqbGmsH/QUJsj/x dnQQbrOB7+rNfxqaAhxB9TV4eu11Wvl2t1hkY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712249286; x=1712854086; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iWPM39phGnWd3wtkybxStwEPc4WkoN2Lgf73jp2nIuY=; b=DrLhpLdRMo/qlJlUUaIX3AsQkkYfAfd7zeVzqgzO3qKUCMXYNnXMe4kotmIhSdhV4w tJQVlrBLcUXbtLnYUxFXVqqWhKoEXeAXWGeuFrXQxSRnQcxLVtFb8n8QvhBKQ+Uz800+ b+cICidmRjBjjMGxlI/mA6A9a2yQMxGwJ41BjyUe39dbpVYxCZI1n7tr/MkDeWyUduAW 0g5dpL9kPqol76jA6+MRWpkkBRMWn51xutAYtsP9lZcY2IEB5b5lYQoZs2R0Ez4wTN3D vSfM3RA/6mNwx2EGNKz2qztcRP5m5rWxv2w8j6qnKtHUj/JxJaIdj052J/ikX1mTqEOj hg6Q== X-Forwarded-Encrypted: i=1; AJvYcCU/LWUwu18d6KrezoRGrNlJGKKJc3jxkQJBkstPRmJ5St6enU9Rmc6vat/RoHIpqTrPuzkiDjCenNpjqJxu4cZTXmFuGHJT4uFPCvt/ X-Gm-Message-State: AOJu0Ywj2QeYAc6tY4a/1w7DrFrYngIl86kt/4czWG8dffc71HdgseYt KVGTjreix30gOvAO1w4PmeT6gR7LSsiYCOobHJmLvl/AFeALOk/ZhWIpudLKSXk= X-Received: by 2002:a2e:a376:0:b0:2d8:4295:da45 with SMTP id i22-20020a2ea376000000b002d84295da45mr1960367ljn.5.1712249286489; Thu, 04 Apr 2024 09:48:06 -0700 (PDT) Received: from [192.168.1.10] (host-92-3-248-192.as13285.net. [92.3.248.192]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c230300b0041497707746sm4114646wmo.0.2024.04.04.09.48.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Apr 2024 09:48:06 -0700 (PDT) Message-ID: Date: Thu, 4 Apr 2024 17:48:05 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] x86/mm: Don't disable INVLPG if "incomplete Global INVLPG flushes" is fixed by microcode To: Sean Christopherson , Michael Kelley Cc: Xi Ruoyao , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , Dexuan Cui References: <20240324190503.116160-1-xry111@xry111.site> Content-Language: en-GB From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPsLBegQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k6fKl+RFiFpyAhvO 59ttDFI7nIA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kmkmc0+XCHmj5WhwNNYjgbbmML7y0fsJT5RgvefAIFfHBg7fTY/i kBEimoUsTEQz+N4hbKwo1hULfVxDJStE4sbPhjbsPCrlXf6W9CxSyQ0qmZ2bXsLQYRj2xqd1 bpA+1o1j2N4/au1R/uSiUFjewJdT/LX1EklKDcQwpk06Af/N7VZtSfEJeRV04unbsKVXWZAk uAJyDDKN99ziC0Wz5kcPyVD1HNf8bgaqGDzrv3TfYjwqayRFcMf7xJaL9xXedMcAEQEAAcLB XwQYAQgACQUCUuE2fwIbDAAKCRBlw/kGpdefoG4XEACD1Qf/er8EA7g23HMxYWd3FXHThrVQ HgiGdk5Yh632vjOm9L4sd/GCEACVQKjsu98e8o3ysitFlznEns5EAAXEbITrgKWXDDUWGYxd pnjj2u+GkVdsOAGk0kxczX6s+VRBhpbBI2PWnOsRJgU2n10PZ3mZD4Xu9kU2IXYmuW+e5KCA vTArRUdCrAtIa1k01sPipPPw6dfxx2e5asy21YOytzxuWFfJTGnVxZZSCyLUO83sh6OZhJkk b9rxL9wPmpN/t2IPaEKoAc0FTQZS36wAMOXkBh24PQ9gaLJvfPKpNzGD8XWR5HHF0NLIJhgg 4ZlEXQ2fVp3XrtocHqhu4UZR4koCijgB8sB7Tb0GCpwK+C4UePdFLfhKyRdSXuvY3AHJd4CP 4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 04/04/2024 5:18 pm, Sean Christopherson wrote: > On Mon, Mar 25, 2024, Michael Kelley wrote: >>> 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 && >>> + invlpg_miss_match->driver_data > boot_cpu_data.microcode) { >>> pr_info("Incomplete global flushes, disabling PCID"); >>> setup_clear_cpu_cap(X86_FEATURE_PCID); >>> return; >> As noted in similar places where microcode versions are >> checked, hypervisors often lie to guests about microcode versions. >> For example, see comments in bad_spectre_microcode(). I >> know Hyper-V guests always see the microcode version as >> 0xFFFFFFFF (max u32 value). So in a Hyper-V guest the above >> code will always leave PCID enabled. > Enumerating broken PCID support to a guest is very arguably a hypervisor bug. > Hypervisors also lie to guest about FMS. As KVM *user* with affected hardware > (home box), I would want the kernel to assume PCID works if X86_FEATURE_HYPERVISOR > is present. I have very mixed feelings about all of this. The Gracemont INVLPG vs PCID bug was found in the field, so PCID will have been enumerated to guests at that point.  You can't blindly drop PCID until the VM next reboots. A related example.  I wrote the patch to hide XSAVES to work around an AMD erratum where XSAVEC sufficed, and the consequences were so dire for some versions of Windows that there was a suggestion to simply revert the workaround to make VMs run again.  Windows intentionally asserts sanity (== expectations) in what it can see; I have no idea whether it would object in this case but hiding PCID is definitely playing with fire. I am frequently dismayed at how many FMS abuses there are in Linux, and I'm this >< close to talking a leaf out of HyperV's book and poisoning FMS to 0 or ~0 just like the microcode revision.   Any use of FMS for anything other than diagnostic purposes under virt is live migration bug waiting to happen. Xen's current TLB algorithms ensure never to have both PCID and PGE active together, so we managed to dodge this particular mess.  But as a consequence, we've got no logic to spot it, or to consider changing PCID visibility.  That said, for better or worse, the ucode revision is visible (for now), and a guest which polls the revision will even spot the hypervisor doing a late ucode load. Sorry I don't have any better suggestions.  The only nice(ish) of fixing this for the guest kernel is for Intel to allocate a $FOO_NO bit, and it's horrible in every other way. ~Andrew