Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2578030pxb; Thu, 11 Feb 2021 16:45:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJycgRxJ/8avbNcu1u0wr6MbzjGP1eyaBDhSQXjDEQ3H5iofUgnj2xumMV8Gjgsfnf6EAjkm X-Received: by 2002:a05:6402:35ca:: with SMTP id z10mr826988edc.174.1613090714748; Thu, 11 Feb 2021 16:45:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613090714; cv=none; d=google.com; s=arc-20160816; b=ayZY/0MbWdnPlerJRbdky59GJQVXoobfV76tSwWsab83gvhcJuPAxjBAxykclm0ztV SpbxCKnxKmd9uiTUGMIk6416rH2Pgo8NeaCp8iHlw7KJz2dYnq1bWnycZuffv0tnXiqI 6RdKf2PE5j6EmkqoDKKrUbIqST04T+KXpXHn2HOqh8LRognAgRk4jkYR9l72EuhUm/2N UBAL5pkeVHEMspaCOo6E3IDGdtSVlXQw4F2/0Ed9wIA6wLdvJVthUt5sSkNlun6WzDVK Mo+ArNfdip4QniRCis1fjYmy8v7ozzpNzujl9GuLm5Bkwx3MvGRjQrjNi1O89C23FA3U ZMow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:sender:dkim-signature; bh=HiLuaEqgR2Zld6XmaaPoO5KvEAReZ5PkM63iqGTwhYE=; b=D+71SVDjukaJ3diYelOFSTEvUEHJkbf+HSz8fxh/afilcLDjnu5aOFes6DPI41V7AV EtUy8lB3424U3MV4aCjGPLyL4Ksw6dWjKJuEEuOZSa7bj8820oXH/kbdscaVcxS74NYg NUC81boLLFx9hgeSSUKJJ8trcR9GscnMMm8mNJxa4C9EAC4F/AnOJrSYaeQlRPTuZ30z w0tC2jYRswC/sww6PBm28Ry4pyq4ISMVxhSiBKxyE2u+YC4Z7IuAFWAAgXXmwmvo1bB9 dbzdiykVnM+ap5C98sQ1kCnMBxntijXOkC0NpzB9Zer8JNFdNOeG2qTM2yCSY6dm9eUm xWQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZsKNp492; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si5442231edi.81.2021.02.11.16.44.51; Thu, 11 Feb 2021 16:45:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZsKNp492; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbhBLAgJ (ORCPT + 99 others); Thu, 11 Feb 2021 19:36:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230413AbhBLAfn (ORCPT ); Thu, 11 Feb 2021 19:35:43 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C269EC06178C for ; Thu, 11 Feb 2021 16:34:22 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id l10so8013861ybt.6 for ; Thu, 11 Feb 2021 16:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=HiLuaEqgR2Zld6XmaaPoO5KvEAReZ5PkM63iqGTwhYE=; b=ZsKNp492o99jcgPOmAK9In2KwTkldmofXtwhobMCDR54LWHgw43V6No73zBR1S5ALi fx0ZOcy7c+r+wQrPsBDFdugM41Dh5lpn+VNZBgLOrMleScPRqb/tNiwzoQEGm1TjJOJn l6ddgrgyUwK+TTDdcv4E7MbMabLrG7drll821snERsbcjmnYKhU0aUH43h6RtpGdwqnB knsdzOM7TU1C3dnTEYqN5h2jgfqnz2XsBEKmg6ilFTnpFXqd3G9rgQgf67CBWpiFuBoi j7NOGRDhbQvawgpRsBEZv+khpTk17mhPdzoAxXC/hwRTaRNDZQ5x7qNQfCPvan7I61nq TeDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=HiLuaEqgR2Zld6XmaaPoO5KvEAReZ5PkM63iqGTwhYE=; b=jZWBpXc/q6pyUkx7MBRmn05hTehX2Ibo4EGrnWsKwvpTlghcUguWyKndISSCvKsYRm oSUe1xrjGuuZ+mnUZwJ28NqO4RrBkFHXR3kECTQRefi7VwcenY8tShmhVC8Bddd7e+re dQvtWHjafgELT/FiILx5WgfwS2XZ2yqeNupQTUk6+QlGE8xNeTzGQRu9OfQC0rojhHcY FycPG3VlhnBVwD6VaYQXD+LgclMZ0Cbxn0Eec29XSim9Yn8cSSecyF5e+X3ASH8c1LW3 wBxLkaSKJF6eYfXlMXQdiO7/A8SX3w/pM2zfmhw1bm7gCBVPkQXTIPCCi57xNHQYH1Ph 9bkA== X-Gm-Message-State: AOAM531VYzqAKv9Xj/OAJiHff5vMpBDuaeEx8jmD6t1wwJc41dnc75ih WLUTz/DW15tmK+AE01kEdUrFYe5ERoI= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:f588:a708:f347:3ebb]) (user=seanjc job=sendgmr) by 2002:a25:2b04:: with SMTP id r4mr699264ybr.219.1613090062011; Thu, 11 Feb 2021 16:34:22 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 11 Feb 2021 16:34:11 -0800 In-Reply-To: <20210212003411.1102677-1-seanjc@google.com> Message-Id: <20210212003411.1102677-4-seanjc@google.com> Mime-Version: 1.0 References: <20210212003411.1102677-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog Subject: [PATCH 3/3] KVM: VMX: Allow INVPCID in guest without PCID From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Babu Moger Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the restriction that prevents VMX from exposing INVPCID to the guest without PCID also being exposed to the guest. The justification of the restriction is that INVPCID will #UD if it's disabled in the VMCS. While that is a true statement, it's also true that RDTSCP will #UD if it's disabled in the VMCS. Neither of those things has any dependency whatsoever on the guest being able to set CR4.PCIDE=1, which is what is effectively allowed by exposing PCID to the guest. Removing the bogus restriction aligns VMX with SVM, and also allows for an interesting configuration. INVPCID is that fastest way to do a global TLB flush, e.g. see native_flush_tlb_global(). Allowing INVPCID without PCID would let a guest use the expedited flush while also limiting the number of ASIDs consumed by the guest. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 6d265b2523f8..e1b84008a05d 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4295,18 +4295,8 @@ static void vmx_compute_secondary_exec_control(struct vcpu_vmx *vmx) } vmx_adjust_sec_exec_feature(vmx, &exec_control, rdtscp, RDTSCP); - - /* - * Expose INVPCID if and only if PCID is also exposed to the guest. - * INVPCID takes a #UD when it's disabled in the VMCS, but a #GP or #PF - * if CR4.PCIDE=0. Enumerating CPUID.INVPCID=1 would lead to incorrect - * behavior from the guest perspective (it would expect #GP or #PF). - */ - if (!guest_cpuid_has(vcpu, X86_FEATURE_PCID)) - guest_cpuid_clear(vcpu, X86_FEATURE_INVPCID); vmx_adjust_sec_exec_feature(vmx, &exec_control, invpcid, INVPCID); - vmx_adjust_sec_exec_exiting(vmx, &exec_control, rdrand, RDRAND); vmx_adjust_sec_exec_exiting(vmx, &exec_control, rdseed, RDSEED); -- 2.30.0.478.g8a0d178c01-goog