Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3512703imw; Thu, 7 Jul 2022 03:06:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sth71BoPYhNkV3n/BHowQSB4V3HmI1VTyKs0rNr/rZjYoDw5iR+vpHq9+UjJjCfdh0lLxu X-Received: by 2002:a17:90b:3b43:b0:1ef:d89b:3454 with SMTP id ot3-20020a17090b3b4300b001efd89b3454mr1521490pjb.87.1657188402426; Thu, 07 Jul 2022 03:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657188402; cv=none; d=google.com; s=arc-20160816; b=IsBJB4dKAVtv9P6Me+lqZwQzVcd1x9z83v/E9LOOK09SXOYn0kXnLlqlprEqE09wfn nmngsI0cFVoSVVGM21avvbKevGtwdq52IjWBbV7bwHL4TLJKtfZrkdmsJE0Ev/bT44/7 lTcExm69OICV3MEACBeZo0YyFZcVy2REAbme7BREfaukrumWE0yWuwfu/yUkmfv5JZLX QXCP8H3fAJBSGCRj+voOtA/PoODW4Qhj2Wio6OGkC8MbEXf4ZtfwqErdFqVQmGz4BCcK Mic5nreQWp32PpMyqj1L3OO9HVTJGPeuq5r2gsP72EmzWHshP+WX1UhU/Q+YqB4uL/8Z 6K5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=cHwrl27E0EeeOGu38G3zOF3hR+C+aXkp6gH0jh13XhA=; b=JSlKckAYFxBE5VV4yTNoZnDwUPtSzdAojJWvSollIS83v5g5sEp8vlIuVkKgAn43fN JFmvb6qWq1n3wbz9mBl7mnvHC9P5cWUrw2M3Sz75lyhOg2h8KRf2Yv7ZYGygyiVe7fh1 fuUFDi5yPVse8jh14Y1MYaQTB5h45L4Xxn6UbEatJk388mnhiRFmSPPZBi3ut0sBD9dl Ieekw9h81ov3aqeO67rtG/bOqSXg38leXYbxrn5qkuHtmVHqLDhbAhnhlZoGJv15Wf7w p7WbJyr5AWuHRUsMpSZKhOM3IniI0eIJxhotPcAJSufsaidVN19FvX3ek/huHogHXrko qobw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V5gK9hXB; 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 mi6-20020a17090b4b4600b001ec2b1a6e56si2079729pjb.93.2022.07.07.03.06.29; Thu, 07 Jul 2022 03:06:42 -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=V5gK9hXB; 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 S235211AbiGGJ6s (ORCPT + 99 others); Thu, 7 Jul 2022 05:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232927AbiGGJ6p (ORCPT ); Thu, 7 Jul 2022 05:58:45 -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 129D34D4FE for ; Thu, 7 Jul 2022 02:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657187922; 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: in-reply-to:in-reply-to:references:references; bh=cHwrl27E0EeeOGu38G3zOF3hR+C+aXkp6gH0jh13XhA=; b=V5gK9hXBTBSNtSad98p9y92PFF2QuMdltWBFQsFv/EHOorhmEEbOGCoZadHSI07jadxVpp TOzH9bT+FotQQgZZbuNVaFtWsoDi/uDwzckt7fPAoSy74ST4E0BmHOheBZzeWiU6/j6zHI WxAOKBVvQ6clpb5Fxave9oG4S57y42o= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-XeiQ-sS7Or61lcnybey0-A-1; Thu, 07 Jul 2022 05:58:41 -0400 X-MC-Unique: XeiQ-sS7Or61lcnybey0-A-1 Received: by mail-ed1-f71.google.com with SMTP id f13-20020a0564021e8d00b00437a2acb543so13513833edf.7 for ; Thu, 07 Jul 2022 02:58:41 -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; bh=cHwrl27E0EeeOGu38G3zOF3hR+C+aXkp6gH0jh13XhA=; b=NkfGfqpl7dvUuIxCU3G3OCRnuXylA3yFiljGEek0BiNz/1tMUkllDE6t7mMOraVwHY FEF2Q3lBqbA+VeHgawVpuptVOpOMWE+nzF3sxlnHwzDIp/snPHpdUzkYkmBVpP3u2PVv 92ggg5eG/Yo4eCGYLDuGNqJuVmRI3Uky5ae3/45jNg4pAWewztXWGb5CbTiPr/QJMizd THi+kgzU1nxV+I8usly8zO4uc7Z0s+iSMkEgfdoK1A1jtItQe9gdcJ3BNQlSnjvmQkxP Nk92bkxKpmfaBxdUJMnvJgiTB2SpNCmz1LlGYv8XWKS7VTGGVMfgO9mm+eNuLBvAEXrv dinw== X-Gm-Message-State: AJIora8ILn8c4AnGY/Gb2LKpImwFD95HVmf8w1Ho87rTiGWrYHJWlLHl bkLoqWt1CTKbKTsXAN3IeHSmc5E0iPW+VErQAhNaVUfKsOSOrWSNHH+0PR45CgAE+IpjIEmk8Q+ ZwX5rNaGEDT3dY5PuRNlI1Su9Hh6HcBUAKBzRb/djP6X4+U/4I02q9P5gqsHN+UduesLLLfIyms Sn X-Received: by 2002:a17:907:a07c:b0:72a:b390:ee8a with SMTP id ia28-20020a170907a07c00b0072ab390ee8amr24435282ejc.96.1657187920490; Thu, 07 Jul 2022 02:58:40 -0700 (PDT) X-Received: by 2002:a17:907:a07c:b0:72a:b390:ee8a with SMTP id ia28-20020a170907a07c00b0072ab390ee8amr24435259ejc.96.1657187920243; Thu, 07 Jul 2022 02:58:40 -0700 (PDT) Received: from fedora (nat-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id u5-20020a170906068500b00703671ebe65sm18516064ejb.198.2022.07.07.02.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 02:58:39 -0700 (PDT) From: Vitaly Kuznetsov To: Sean Christopherson Cc: kvm@vger.kernel.org, Paolo Bonzini , Anirudh Rayabharam , Wanpeng Li , Jim Mattson , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 06/28] KVM: nVMX: Introduce KVM_CAP_HYPERV_ENLIGHTENED_VMCS2 In-Reply-To: References: <20220629150625.238286-1-vkuznets@redhat.com> <20220629150625.238286-7-vkuznets@redhat.com> Date: Thu, 07 Jul 2022 11:58:38 +0200 Message-ID: <87o7y1qm5t.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.5 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=ham 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 Sean Christopherson writes: > On Wed, Jun 29, 2022, Vitaly Kuznetsov wrote: >> Turns out Enlightened VMCS can gain new fields without version change >> and KVM_CAP_HYPERV_ENLIGHTENED_VMCS which KVM currently has cant's >> handle this reliably. In particular, just updating the current definition >> of eVMCSv1 with the new fields and adjusting the VMX MSR filtering will >> inevitably break live migration to older KVMs. Note: enabling eVMCS and >> setting VMX feature MSR can happen in any order. >> >> Introduce a notion of KVM internal "Enlightened VMCS revision" and add >> a new capability allowing to add fields to Enlightened VMCS while keeping >> its version. > > Bumping a "minor" version number in KVM is going to be a nightmare. KVM is going > to be stuck "supporting" old revisions in perpetuity, and userspace will be forced > to keep track of which features are available with which arbitrary revision (is > that information even communicated to userspace?). My brain is certainly tainted with how we enable this in QEMU but why would userspace be interested in which features are actually filtered out? Currently (again, by QEMU), eVMCS is treated as a purely software feature. When enabled, certain controls are filtered out "under the hood" as VMX MSRs reported to VMM remain unfiltered (see '!msr_info->host_initiated' in vmx_get_msr()). Same stays true with any new revision: VMM's job is just to check that a) all hardware features are supported on both source and destination and b) the requested 'eVMCS revision' is supported by both. No need to know what's filtered out and what isn't. > > I think a more maintainable approach would be to expose the "filtered" VMX MSRs to > userspace, e.g. add KVM_GET_EVMCS_VMX_MSRS. Then KVM just needs to document what > the "filters" are for KVM versions that don't support KVM_GET_EVMCS_VMX_MSRS. > KVM itself doesn't need to maintain version information because it's userspace's > responsibility to ensure that userspace doesn't try to migrate to a KVM that doesn't > support the desired feature set. That would be a reasonable (but complex for VMM) approach too but I don't think we need this (and this patch introducing 'eVMCS revisions' to this matter): luckily, Microsoft added a new PV CPUID feature bit inidicating the support for the new features in eVMCSv1 so KVM can just observe whether the bit was set by VMM or not and filter accordingly. > > That also avoids messes like unnecessarily blocking migration from "incompatible" > revisions when running on hardware that doesn't even support the control. Well yea, in case the difference between 'eVMCS revisions' is void because the hardware doesn't support these, it would still be possible to migrate to an older KVM which doesn't support the new revision but I'd stay strict: if a newer revision was requested it must be supported, no matter the hardware. -- Vitaly