From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF1CAC433EF for ; Tue, 12 Jul 2022 12:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbiGLMOR (ORCPT ); Tue, 12 Jul 2022 08:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232479AbiGLMON (ORCPT ); Tue, 12 Jul 2022 08:14:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F14745056 for ; Tue, 12 Jul 2022 05:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657628051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WAxGI00yNn9GNFeh9dlU/4akmeOA8R+tofyDowtvI5A=; b=dbNwqZpZrFlT1bP01S+mzLK5MbEs5D9UP64vjQaPVXzd8+3Fbn4w/dNSyN7NWavMWG2equ t8r2VRhynq0Nq/B+XaRfTRrdXNC8T71MMmHC6vkmqwsDQxl+a+g16fkPXriCchaPlpz46e 4AA/OYb8cphUOzw9aWMOhi6R5X1KGWI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-19-PhkR83CxO3Cw6w8DVrRK5Q-1; Tue, 12 Jul 2022 08:14:10 -0400 X-MC-Unique: PhkR83CxO3Cw6w8DVrRK5Q-1 Received: by mail-wm1-f70.google.com with SMTP id y14-20020a7bcd8e000000b003a2ea282944so755636wmj.0 for ; Tue, 12 Jul 2022 05:14:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=WAxGI00yNn9GNFeh9dlU/4akmeOA8R+tofyDowtvI5A=; b=bwXqOCDD63qDKzby+EXUw97VSvIs4OoyZS/ubidhDCi77/vGniqXTLpM5Rqv/XU2vN x99/4PzK+StxSh+c0QR4cl3IKApQl5l5yZdYAy5MWu2qFrIUxrkGdm2eQgzeWiLxcJFn N/xNPhK2Io6MoIir7jgFK2Mal+pjZOzJlUnlwQgvIrBdMksRNRHR0mKEc0Q2c3pulLuX SupvkTb7PofADiy/TiV4EjES13qehMO68lF01pxxeJL1OqaLE3ubJgZT7PJWnN7EBeXT ySq3Tn7VpZfo6iwDUxnELBVvWd/2XtbvxaWnsPkcSm6exa62T6isYQyQ3nBu7QANmgX3 jFag== X-Gm-Message-State: AJIora9eCjlQwKjHro9rWXO1zSdYh+MocC0a4+h2UIJxkeGBXcAM37EY XI4zMMeJWa3ss1DDfrH+h376N6Q571LgOwA1Ul9xnq4NRE/DahGSphz4PSdNOf8+PBiBfjYvcFa zfT4sf/k52Tx9AtEDdz4fjk2G X-Received: by 2002:a05:600c:a02:b0:39c:97cc:82e3 with SMTP id z2-20020a05600c0a0200b0039c97cc82e3mr3631770wmp.97.1657628049102; Tue, 12 Jul 2022 05:14:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vJr7AKZGM9mihE37deXYF43Gq0ysHz0r6eaHk1Fd0fSvJKJonKBW6zwaLCeWi3o7tRipBdtg== X-Received: by 2002:a05:600c:a02:b0:39c:97cc:82e3 with SMTP id z2-20020a05600c0a0200b0039c97cc82e3mr3631744wmp.97.1657628048818; Tue, 12 Jul 2022 05:14:08 -0700 (PDT) Received: from fedora (nat-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id bg32-20020a05600c3ca000b003a04d19dab3sm2256602wmb.3.2022.07.12.05.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 05:14:07 -0700 (PDT) From: Vitaly Kuznetsov To: Maxim Levitsky , kvm@vger.kernel.org Cc: Anirudh Rayabharam , Wanpeng Li , Jim Mattson , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Sean Christopherson Subject: Re: [PATCH v3 11/25] KVM: VMX: Get rid of eVMCS specific VMX controls sanitization In-Reply-To: References: <20220708144223.610080-1-vkuznets@redhat.com> <20220708144223.610080-12-vkuznets@redhat.com> Date: Tue, 12 Jul 2022 14:14:06 +0200 Message-ID: <877d4iplyp.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-hyperv@vger.kernel.org Maxim Levitsky writes: > On Fri, 2022-07-08 at 16:42 +0200, Vitaly Kuznetsov wrote: >> With the updated eVMCSv1 definition, there's no known 'problematic' >> controls which are exposed in VMX control MSRs but are not present in >> eVMCSv1. Get rid of VMX control MSRs filtering for KVM on Hyper-V. > > If I understand correctly we are taking about running KVM as a nested gue= st of Hyper-V here: > > Don't we need to check the new CPUID bit and only then use the new fields= of eVMCS, > aka check that the 'cpu' supports the updated eVMCS version? > I've checked various Hyper-V versions available around and it seems there's no need for that: these new features are exposed in VMX control MSRs only when the updated eVMCS is supported. We can, in theory, preserve the filtering for non-updated eVMCS verison but I'd vote for putting a WARN_ON() or something around: we can eventually get rid of it in case we don't get any reports. > Best regards, > Maxim Levitsky > > > >>=20 >> Note: VMX control MSRs filtering for Hyper-V on KVM >> (nested_evmcs_filter_control_msr()) stays as even the updated eVMCSv1 >> definition doesn't have all the features implemented by KVM and some >> fields are still missing. Moreover, nested_evmcs_filter_control_msr() >> has to support the original eVMCSv1 version when VMM wishes so. >>=20 >> Signed-off-by: Vitaly Kuznetsov >> --- >> =C2=A0arch/x86/kvm/vmx/evmcs.c | 13 ------------- >> =C2=A0arch/x86/kvm/vmx/evmcs.h |=C2=A0 1 - >> =C2=A0arch/x86/kvm/vmx/vmx.c=C2=A0=C2=A0 |=C2=A0 5 ----- >> =C2=A03 files changed, 19 deletions(-) >>=20 >> diff --git a/arch/x86/kvm/vmx/evmcs.c b/arch/x86/kvm/vmx/evmcs.c >> index 52a53debd806..b5cfbf7d487b 100644 >> --- a/arch/x86/kvm/vmx/evmcs.c >> +++ b/arch/x86/kvm/vmx/evmcs.c >> @@ -320,19 +320,6 @@ const struct evmcs_field vmcs_field_to_evmcs_1[] = =3D { >> =C2=A0}; >> =C2=A0const unsigned int nr_evmcs_1_fields =3D ARRAY_SIZE(vmcs_field_to_= evmcs_1); >> =C2=A0 >> -#if IS_ENABLED(CONFIG_HYPERV) >> -__init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf) >> -{ >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->cpu_based_exec_ctr= l &=3D ~EVMCS1_UNSUPPORTED_EXEC_CTRL; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->pin_based_exec_ctr= l &=3D ~EVMCS1_UNSUPPORTED_PINCTRL; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->cpu_based_2nd_exec= _ctrl &=3D ~EVMCS1_UNSUPPORTED_2NDEXEC; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->cpu_based_3rd_exec= _ctrl =3D 0; >> - >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->vmexit_ctrl &=3D ~= EVMCS1_UNSUPPORTED_VMEXIT_CTRL; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->vmentry_ctrl &=3D = ~EVMCS1_UNSUPPORTED_VMENTRY_CTRL; >> -} >> -#endif >> - >> =C2=A0bool nested_enlightened_vmentry(struct kvm_vcpu *vcpu, u64 *evmcs_= gpa) >> =C2=A0{ >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct hv_vp_assist_page= assist_page; >> diff --git a/arch/x86/kvm/vmx/evmcs.h b/arch/x86/kvm/vmx/evmcs.h >> index 4b809c79ae63..0feac101cce4 100644 >> --- a/arch/x86/kvm/vmx/evmcs.h >> +++ b/arch/x86/kvm/vmx/evmcs.h >> @@ -203,7 +203,6 @@ static inline void evmcs_load(u64 phys_addr) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vp_ap->enlighten_vmentry= =3D 1; >> =C2=A0} >> =C2=A0 >> -__init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf); >> =C2=A0#else /* !IS_ENABLED(CONFIG_HYPERV) */ >> =C2=A0static __always_inline void evmcs_write64(unsigned long field, u64= value) {} >> =C2=A0static inline void evmcs_write32(unsigned long field, u32 value) {} >> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c >> index b4915d841357..dd905ad72637 100644 >> --- a/arch/x86/kvm/vmx/vmx.c >> +++ b/arch/x86/kvm/vmx/vmx.c >> @@ -2689,11 +2689,6 @@ static __init int setup_vmcs_config(struct vmcs_c= onfig *vmcs_conf, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->vmexit_ctrl= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D _vmexit_control; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vmcs_conf->vmentry_ctrl= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D _vmentry_control; >> =C2=A0 >> -#if IS_ENABLED(CONFIG_HYPERV) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (enlightened_vmcs) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0evmcs_sanitize_exec_ctrls(vmcs_conf); >> -#endif >> - >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return 0; >> =C2=A0} >> =C2=A0 > > --=20 Vitaly