Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3921190imw; Thu, 7 Jul 2022 09:37:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u0NqOnYTLWAS9Cn5wFlN9R/nlAbowp03tRV55twSaOPDul6tOQ6TxV9bvjSCyHAAG1QJ0g X-Received: by 2002:a05:6402:3311:b0:43a:8714:d486 with SMTP id e17-20020a056402331100b0043a8714d486mr14540761eda.136.1657211842786; Thu, 07 Jul 2022 09:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657211842; cv=none; d=google.com; s=arc-20160816; b=Frd6v8jbKK00uPxhi2cTmow2EnK1Alfx6w2NG+hmtV+CovxDKYA6PYtXYeElPZVNQb wgkXCo9BDjo37t4L0gS695mzjw0iK7A3etv8pTRrJaNf1aqX7TiD+vBWYxSXZz1fg9fB cjuZyHGloqCI43HNTgRB5rTJP1fhKUmHese8E0e5R8xUsQRWg9UhpvPzbX6PHn4knAnh Tg/IYkFYSnxyXXG/QN07/VNZwbhITtmMAtaX5qItVNzUPWLHRZsyCMsm8SrngqcVRn/c 36T3ySFXwp3vS3FyJ2T2c9+nWlZo7QhtvXn8X0gdps+qe3z2XEevoI875fwCSPKUFkK2 uA1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=g4b8V9nVein02SaaRGxSEkwK4bSbPWw2wYDtDzzfHkA=; b=Hwf8ZPcjhs8wLihKOstCNnES60/5Xb7WSeKka1+2dvCNwDTfOjiPanhqpgr9I00cE5 mKEIQAETos/zNd/O5mRbafWWOHv0zfpodMGH+iC4Xx4swKiQeM4kdQBR6dE0UOY3Q93W Yt/s+0zIQamGqspb8Mlg106CEkuz/p9LDb6oO1JUxBB7ITpLHg0HkH/9z3a0aSA2fK8T EbZU8M908whceJlOy24E45BRujTgkSB3/Zo8Jxjpm42WSN9qT8vwuBodI/H3rwH+tzQK ydvvieLxKWdsJJR76LGcLxEIdjhgCEyGpKvPVhNJ+FcDvcQNwFt+7J/r32LrenmuwaAs wMxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="S1wqm/1J"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020a170906054b00b0072affa39083si495813eja.23.2022.07.07.09.36.58; Thu, 07 Jul 2022 09:37:22 -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=@google.com header.s=20210112 header.b="S1wqm/1J"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236285AbiGGQSG (ORCPT + 99 others); Thu, 7 Jul 2022 12:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235768AbiGGQSE (ORCPT ); Thu, 7 Jul 2022 12:18:04 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA363140F1 for ; Thu, 7 Jul 2022 09:18:03 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id o12so6815080pfp.5 for ; Thu, 07 Jul 2022 09:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=g4b8V9nVein02SaaRGxSEkwK4bSbPWw2wYDtDzzfHkA=; b=S1wqm/1JGuzFumHfm8KgkZ/ZmuKwtDo7fOVy8TDe4S/6DZZF3DOLf/U+gCQWD7X5dW mOlMPSMknLjb/VmC2bG7nJf/9Oyzf7DWQ5dfsGmm0+816UKihjMTzDE4R7trWFTzTZeR NWvkfug0M9MD2cvqAjyz2cOMPYl1YxrQSj9H5UTOUFTo3AddFXwj+fk6Cw58HSbuADVc rmx1tsUG28aI4sdXBlAgR9llS9ESRbYQcIbH3zOCC8h+hIP1vOJGTApjsKon1xSF0J0/ 5MAOO5uFIvqcZ61Yybujt6Q0k/6WH1YWdQIbTnVc2y7815JWlP4Uk2siX41L4Xknj8uj ZsdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=g4b8V9nVein02SaaRGxSEkwK4bSbPWw2wYDtDzzfHkA=; b=DOktYIgQ221qoLUjLjnLFjmNz4a9pX61IMRLSnRcx83TSpQ52VoRIUAZ2V1RUxru/n reER0k8zXuT1GCYRFXGdrw1TOashQ7ZRSBsnoi8vXx+nygOMSyWNS6O/mMkshJItULS2 +LfL7pvo+8F3AV5MvAbC2UxHpAeV86Kr4QRokaN8cLpW2HjtoC8Ub0ztHCslWKjAmsxC 9+Yw1KiPk9jKk7VREavSecJ1aORZ650Y670spcBbr/u/mDieEgTAWh0Ml26hZT4RfrQj YbPX6rWClROc52cmOT5qVbYMoeKyaGCdh8OGKwhpc5/672bLSC1lkXcXBQvV3nbbTKpf tbbw== X-Gm-Message-State: AJIora88lgaHc9AVk2hE3nysOGI9zfmbdtzQybDrC5rptry+GwsJGI8S 6NlgoamPfBFIdGW5PYERbOcXAQ== X-Received: by 2002:a17:90a:db96:b0:1ef:8c86:eb09 with SMTP id h22-20020a17090adb9600b001ef8c86eb09mr6043973pjv.22.1657210683045; Thu, 07 Jul 2022 09:18:03 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id cq13-20020a056a00330d00b005255489187fsm27060777pfb.135.2022.07.07.09.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 09:18:02 -0700 (PDT) Date: Thu, 7 Jul 2022 16:17:58 +0000 From: Sean Christopherson To: Vitaly Kuznetsov 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 Message-ID: References: <20220629150625.238286-1-vkuznets@redhat.com> <20220629150625.238286-7-vkuznets@redhat.com> <87o7y1qm5t.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o7y1qm5t.fsf@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Thu, Jul 07, 2022, Vitaly Kuznetsov wrote: > 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? For all the same reasons userspace wants to know what hardware features are supported by hardware and KVM. > 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. But users will inevitably want to know exactly what features a platform supports for a given configuration. E.g. if KVM only supported pre-configured CPU models, KVM would need to document what features are supported by each model, and userspace would have very little flexibility in terms of what features are exposed to the guest. That's an exaggerated example as there are far more CPUID features than eVMCS features, but it's the same underlying concept. > > 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): But userspace already has to deal with that complexity in raw VMX MSRs. The filtered values will always be a subset of the unfiltered values, so if eVMCS will be exposed to the guest, userspace can simply treat the filtered set as the baseline supported set, i.e. the userspace logic could simply be: if (expose_evmcs) get_evmcs_vmx_msrs(&msrs); else get_vmx_msrs(&msrs); Userspace will need to take on more complexity if userspace wants to expose features that are supported in hardware but not with eVMCS active, but I don't see the point in doing so because AFAICT KVM will just override and filter the VMX MSRs anyways when eVMCS is enabled, i.e. userspace _can't_ expose the unfiltered VMX MSRs to the guest when eVMCS is enabled. > 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. If there's a CPUID feature bit, why does KVM need to invent its own revision scheme? > > 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.