Received: by 2002:a25:d80d:0:0:0:0:0 with SMTP id p13csp131659ybg; Sat, 23 May 2020 09:19:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI7XG6HhiTjjK1VYubVBfwzXkwQ1NvuIy6NfxlhSl3FLG5Q1nqXj4hBuAkiaqmKEqXwceQ X-Received: by 2002:a17:906:33c1:: with SMTP id w1mr13391011eja.313.1590250768965; Sat, 23 May 2020 09:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590250768; cv=none; d=google.com; s=arc-20160816; b=NIC5SszFYlnTpU9I+zO8CuHm65/MQU5icHZNt1yhh1qexBkGzwDlgNne6GOi856c1B MlR+J+LzPTUjCjzMXhaXuzm4JVng07WA4j5vwN+9p5TxE1EAeOdYb71f+tAgeIBj4Qq2 civq1iYgjAr6S/xR5sZCqP6Z/Goqhj6zn1hiSmrPana1gp3Y214uNKqGPZSUaBHiiZcW oDv0ZZAEE2U/kzpDmEMGTcurXGUMhFbZytfxyGW3ZoBnkSBtodWsTKVg0yruAhZd+vhw 6jFUe7bYGyH2ooJp9Q/aHlPVsXtj5oCPJORIP2RDIuYfU7jAFZ5VBXD4gg7ijfRlJokb m7wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ytf9W2kex3b56H4BEKOUukloGENtrEZz4KuH9AmMNpQ=; b=H06GH23bC4mpgChUzMMk11q0Ba9kyQems1h+TySCuUvqTIeOzZREYTpfU5aVkidFHV WHG+2lLpp+4uIgbetvug0oJc2OCM4ZZ8AcPUJz5NX+L/NomSGkeKf04DdRd7bxnPXapy a3i3SKTU/AmKEnSP7RmcOWHiMy/Euc/DZSNSvQuMb/e3+jahQ77Nuv4JJr+2toI6PBtt rxY3zNaFZ0ETR2lDJOlN79QqJs6mG2TfrOve1lszKGhLDK22NsXQZVCMSg7z5LfK+Gm7 V6CaSlaujsPpqvTgUlI8VrTSF9weU+OuBbFvE+TWutr+saLtq/e8V3D/DcPD55ZCxvCL dUkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UwTopeKn; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ny24si6667355ejb.445.2020.05.23.09.19.06; Sat, 23 May 2020 09:19:28 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=UwTopeKn; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728077AbgEWQPU (ORCPT + 99 others); Sat, 23 May 2020 12:15:20 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:48202 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728025AbgEWQPU (ORCPT ); Sat, 23 May 2020 12:15:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590250519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ytf9W2kex3b56H4BEKOUukloGENtrEZz4KuH9AmMNpQ=; b=UwTopeKnbUkabq7R4yzTEcU2bfYqmy5PBingBqsR+uqm1OGbOZeOSgfFoa5tzH+frYq6T7 6pM4AzSH8xA6Ig58Dfb/QLl+BXH2M/dRbiaqnnu2mld0i6Y+PWANiFh5ldaP2hdj5PDNSC A371EVFfbJvL58n4dHt2p5Y4fpp55ng= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-3rESmGjfPumnQqjegbACfQ-1; Sat, 23 May 2020 12:15:17 -0400 X-MC-Unique: 3rESmGjfPumnQqjegbACfQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EBCF107ACCA; Sat, 23 May 2020 16:15:15 +0000 (UTC) Received: from starship.f32vm (unknown [10.35.206.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DD6B600E5; Sat, 23 May 2020 16:15:01 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Paolo Bonzini , "H. Peter Anvin" , Tao Xu , Sean Christopherson , Jim Mattson , linux-kernel@vger.kernel.org, Joerg Roedel , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Wanpeng Li , Ingo Molnar , Thomas Gleixner , Borislav Petkov , Vitaly Kuznetsov , Jingqi Liu , Maxim Levitsky Subject: [PATCH 1/2] kvm/x86/vmx: enable X86_FEATURE_WAITPKG in KVM capabilities Date: Sat, 23 May 2020 19:14:54 +0300 Message-Id: <20200523161455.3940-2-mlevitsk@redhat.com> In-Reply-To: <20200523161455.3940-1-mlevitsk@redhat.com> References: <20200523161455.3940-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Even though we might not allow the guest to use WAITPKG's new instructions, we should tell KVM that the feature is supported by the host CPU. Note that vmx_waitpkg_supported checks that WAITPKG _can_ be set in secondary execution controls as specified by VMX capability MSR, rather that we actually enable it for a guest. Fixes: e69e72faa3a0 KVM: x86: Add support for user wait instructions Suggested-by: Paolo Bonzini Signed-off-by: Maxim Levitsky --- arch/x86/kvm/vmx/vmx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 55712dd86bafa..fca493d4517c5 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7298,6 +7298,9 @@ static __init void vmx_set_cpu_caps(void) /* CPUID 0x80000001 */ if (!cpu_has_vmx_rdtscp()) kvm_cpu_cap_clear(X86_FEATURE_RDTSCP); + + if (vmx_waitpkg_supported()) + kvm_cpu_cap_check_and_set(X86_FEATURE_WAITPKG); } static void vmx_request_immediate_exit(struct kvm_vcpu *vcpu) -- 2.26.2