Received: by 10.223.185.116 with SMTP id b49csp6533051wrg; Thu, 8 Mar 2018 08:58:53 -0800 (PST) X-Google-Smtp-Source: AG47ELtNEkkeR+AZJ2pEKJzeToqeJ4Dp4HQl13dw2EfXYTA6zAc1he+nz0n33UR9EYq0PC5QX5Zl X-Received: by 2002:a17:902:42e:: with SMTP id 43-v6mr25245918ple.186.1520528333851; Thu, 08 Mar 2018 08:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520528333; cv=none; d=google.com; s=arc-20160816; b=MgbrUw3WNBW9H6M53LP9j8ufVY5cAkLOA7P60+blvaWMtEqCsz6IvHkRwud1pkSFmr gLttkKNWtgrHzk+c9mSA6VfNVoldyz+Qv0Serq7yCwIoWwEdderRYX32XOidXDL3aRKM 7tD2qq1JC1y+CziPkqjQsROIktUoc2LCI1BgMWFrl34IOdze7OuInA/iAYcAcvUCWWO/ wu+8erPn6Nsamv8rlTVqhwRr5KHjQnqjIyGE6nNC1FS69hKsnOugPyHlc2797Qc1pE7e gLJoWUcS/v37IGl3/C4i2ec2L3OHUDo+H0CP10FLj/jh+JZEjBJdBaXURXHiwc3G+bx9 Ejvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=GsvLyel+UxcEJGPR++vm/Ni/stz5HRDfbPS3RCK84Ik=; b=LBE5gOtOpkdpVtBYI6JDrnRR6HsUdVGHbOrEq7KmGbkE25VkqjmhLTIGJ3UtXulPVs zN/7nLBj12vJQbRQYnj6PQiWTSGuJ7+bWFF3ZehoCfWK3DmB3N/84uCvX0qHq1BnqD7U btGjcsq0In4xkkPfy7yA9Ik0h2bALN2tno66fv+6KAZsWsBFPFVzsqUd2DN7cUi8fj29 hOMZfWhSDEFh2dg9GmN7i/CrWaj5B6u88IZqJu3sAu8zfNn9hMowzAvn+M4ajmPjFWSC DbdJna3e+cMEO+uwKjOPiRIcg98c1IyvzG6xUtYJ8NKo0AYPfpnRQQxBKiewp7zpmCrt FvCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f33-v6si13614743plf.650.2018.03.08.08.58.39; Thu, 08 Mar 2018 08:58:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936040AbeCHQ4y (ORCPT + 99 others); Thu, 8 Mar 2018 11:56:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48546 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932100AbeCHQ4w (ORCPT ); Thu, 8 Mar 2018 11:56:52 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D7E38182D0C; Thu, 8 Mar 2018 16:56:52 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 83FA52024CA1; Thu, 8 Mar 2018 16:56:49 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Thu, 08 Mar 2018 17:56:10 +0100 Date: Thu, 8 Mar 2018 17:56:10 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Vitaly Kuznetsov Cc: kvm@vger.kernel.org, x86@kernel.org, Paolo Bonzini , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , Bandan Das , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/5] x86/kvm: use Enlightened VMCS when running on Hyper-V Message-ID: <20180308165610.GI12290@flask> References: <20180226171121.18974-1-vkuznets@redhat.com> <20180226171121.18974-6-vkuznets@redhat.com> <20180307175611.GF12290@flask> <87h8pqyif4.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87h8pqyif4.fsf@vitty.brq.redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Mar 2018 16:56:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Mar 2018 16:56:52 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rkrcmar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-03-08 11:23+0100, Vitaly Kuznetsov: > Radim Krčmář writes: > > 2018-02-26 18:11+0100, Vitaly Kuznetsov: > >> @@ -3828,7 +4302,12 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf) > >> vmcs_conf->size = vmx_msr_high & 0x1fff; > >> vmcs_conf->order = get_order(vmcs_conf->size); > >> vmcs_conf->basic_cap = vmx_msr_high & ~0x1fff; > >> - vmcs_conf->revision_id = vmx_msr_low; > >> + > >> + /* KVM supports Enlightened VMCS v1 only */ > >> + if (static_branch_unlikely(&enable_evmcs)) > >> + vmcs_conf->revision_id = 1; > > > > I think we have to put the bottom bits from ms_hyperv.nested_features > > here. 16.5.1 Enlightened VMCS Versioning: > > > > Each enlightened VMCS structure contains a version field, which is > > reported by the L0 hypervisor (see 2.4.11) > > see below > > > > >> + else > >> + vmcs_conf->revision_id = vmx_msr_low; > >> > >> vmcs_conf->pin_based_exec_ctrl = _pin_based_exec_control; > >> vmcs_conf->cpu_based_exec_ctrl = _cpu_based_exec_control; > >> @@ -12414,7 +12908,35 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { > >> > >> static int __init vmx_init(void) > >> { > >> - int r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), > >> + int r; > >> + > >> +#if IS_ENABLED(CONFIG_HYPERV) > >> + /* > >> + * Enlightened VMCS usage should be recommended and the host needs > >> + * to support eVMCS v1 or above. We can also disable eVMCS support > >> + * with module parameter. > >> + */ > >> + if (enlightened_vmcs && > >> + ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED && > >> + (ms_hyperv.nested_features & 0xff) >= 1) { > > > I think we should not proceed with version other than 1 for now -- there > > is no mention of backward compatibility in the spec. > > I think the check is correct. eVMCS version represents the format of the > structure in memory. New versions may have nothing in common but at the > same time Ver1 support can't be dropped from future Hyper-V versions > without regressing L1s which don't support new version. I am concerned because Intel doesn't and eVMCS is based on VMCS, so maybe they are going to use the live migration notifier to disable eVMCS on incompatible versions. TLFS points that they plan to handle eVMCS versions the same as Intel, but the spec might just be misleading. > So currently we check that L0 supports at least ver1 (or some newer > version which implies all previously released versions are supported > too) and we declare that KVM supports ver1 exactly (this is the format > of the structure we put to memory and share with L0). We can't declare > support for any other version. Yes, I'm saying that we don't proceed with any other version than 1. > Currently, it is only Ver1 on WS2016. Right. It should be an easy bug to spot, so I'm ok with the current version.