Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4277016imw; Tue, 12 Jul 2022 05:19:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uPOKTRpjyLJqOYYr4OwU64NwllFsAadX1sxmPRBSq67EPjCjeM3JkMzPpZq0e1rwae3QFI X-Received: by 2002:a05:6402:5245:b0:43a:a024:82cc with SMTP id t5-20020a056402524500b0043aa02482ccmr31870718edd.56.1657628357368; Tue, 12 Jul 2022 05:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657628357; cv=none; d=google.com; s=arc-20160816; b=dY6DMKHKvc+BnImYRmjqmjoNo1EuvmokP+ER8qnJzNhY19Vh6szYNCnrgDuehGs4hf crrnjvfmssRfZTsN1biLwnYg5C6iayBtVSiIWjfemxOpCJu0leieO0iq6qvxyTzKcMyD mX2TzfwmDIalbApZsToIS65LnGHv9w3o6+tmO3XTJFUOlw2QeQJyCvWZIWE0Wl/ohvOb ddslzluaVyHWHYeSB5sUhLUFdKG/tpV+QCqFZHuBNxT2MzIjKsaiTm6aZf6UFzyIaRyA icZYH5oZ6hPFb9I+F8AEHZNDhKFnG4ziWIeYq88Ho53Ks6VJe7Y7vwBEDs6amy+5xJ5i zzhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=WAxGI00yNn9GNFeh9dlU/4akmeOA8R+tofyDowtvI5A=; b=P4n4C3E6kiMOexqWmygXKm1nEkma0iY2FbOQivq76NwaxIEM/BAqygq78uVx/hxebb H1FYfifoCnQXe5LpEkFGY4aPgep+7OG43kdkllVMu4I32DjfGCH2idK4XfUe90VZlqpJ Dh7tD35E0tupsnLcHpIlUWVyo0JAAWt5KlED53QJidsdckJKWbXsY+DrE5nhpYBi3+mp Rt3bFy+cj2CUr7Glpv+sjIigoRZ58lwfpCO1STXCCGhPcoXCYF96AWMa+KR0TSwcdMYw ixDa934lKgiOxlZSParpFuFyUSigDNylsvWOKv1a0jtd/XYCEyc+ayKDiXWkuFyCBdi2 Tieg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dbNwqZpZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f13-20020a17090624cd00b0072af6d136a4si11470454ejb.805.2022.07.12.05.18.52; Tue, 12 Jul 2022 05:19:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dbNwqZpZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232317AbiGLMOS (ORCPT + 99 others); Tue, 12 Jul 2022 08:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbiGLMON (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 80BF045059 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-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-SAap4GI_M9uSoNJxwLwYHQ-1; Tue, 12 Jul 2022 08:14:10 -0400 X-MC-Unique: SAap4GI_M9uSoNJxwLwYHQ-1 Received: by mail-wm1-f71.google.com with SMTP id p21-20020a05600c1d9500b003a2d6c2b643so635957wms.1 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=Yco1UC+ew8Muj8VFCOcOOaJx8Tl35YEi6vk8t24VClEE8rnn974k0KNNxl0WEaEYMn vHDQzWabAylEKi2ncVegcgH7gjAhX71RKc3JO4PpiHZT84r0uH7Kf93quQ/vjX9lbJgX tMfuYMjUoxs+lBM2SSmoNQb+/QiVHsZZj6RpHIFBEWNvGLX75v+zrIz0dNb4sUGIILqR PPsFEozXLeBxalxkkiO/TWq6LOeQhyhuBaDAE7azqR5+leDP3b9tHsIO+MPS3YgCqWnq uvRQ0OuRzObvXbpfm4rgRfg2q5nV4D3eIROGEoQpRz9Wx1AwJ5Bp3J0VP0Fa9oBolkR1 4U7g== X-Gm-Message-State: AJIora84OZ3iE3TKEWDHjvK9TxIGVCgYBAMtsU0eJ71WWQ9o3RGjEeWa GDXzshuUQDd9uiKvUG2uFsNPA3R8Rbjwd8veyoXzNYYXWbWek62XCUQefe42u06st39OQ/KZQ3u cDFg7i2N/t3x19uoDk6NBaYe+ X-Received: by 2002:a05:600c:a02:b0:39c:97cc:82e3 with SMTP id z2-20020a05600c0a0200b0039c97cc82e3mr3631774wmp.97.1657628049102; Tue, 12 Jul 2022 05:14:09 -0700 (PDT) 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 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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