Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp914509imu; Tue, 11 Dec 2018 09:29:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/VLQWCtvoTIOvvVdQP+QyjguzYCHZh/ZDYCFPCdI3wZPFrY3VI1mEGsvWcMmOoaameJjP9k X-Received: by 2002:a62:4641:: with SMTP id t62mr16858763pfa.141.1544549340375; Tue, 11 Dec 2018 09:29:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544549340; cv=none; d=google.com; s=arc-20160816; b=x3nOJQz2YnVemMsZXXFNg+FtT/u/B+S9oLGr1OyNS+kEvbBsz1qNqnJgXSyGVdNCBG kybVtEYv4Wv6+hS4WgcZzxFesV8D6OCwiirZzQIR3qiiGXGuSHt6IWnd/iwvLziqAya+ ftzY6Pg5kKQZmaChfRWXPDiZAyiHYZJcvC2BOT5AVyfkjljDUdnNRvIc1LDHNRyUPOH3 dcZCa9QZhKNBLmPlKqG2bZU55X896P+kVQHmkPXqYfK83PkasHHuhV1DosotHNWt5bUV aXP4BOVOmIMNc3C/v7C59L3DA/JJ8OSuBK4suJWxifsgKeq9o98wOQsvYGM3vGTZR1w+ UANg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=Y+FCO5+Upo9dECBYDQNqV8Tkpdduuk3c1wNCYN1hCSA=; b=EKTv/qF6aYhPmtGa1mzyvkStbSZjnrD8CQKv9xRKLcZczZngGXf2pwnEXcS9q8fRvB USYOmu7ZdVxpgSHJumTaCo7xmFx0in+7nd4AZHWNzjZj++X+vG+RnPdgPzL61pgP4eRi N8r8gLQ+NPCXyXzP+bGGMuUI3/ly6jssqEyQVb3DvCUpbbQd3oNCuvyboKKy5evA/rfV l756aMkAeprzTy4QXK/8ViYiTzfcxhVlPmqDr5TGkuqgmiReXJnzymwZApdY0JxkygY7 AUkxT5ouIj5mmP1ykFIWHsvpOjSj49jOx4ZUzsOBrASzG9k/UAhu0ltRN3LyXPwCrJUy ezIQ== 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 m20si12072174pgk.323.2018.12.11.09.28.23; Tue, 11 Dec 2018 09:29:00 -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 S1726551AbeLKPEG (ORCPT + 99 others); Tue, 11 Dec 2018 10:04:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58158 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbeLKPEG (ORCPT ); Tue, 11 Dec 2018 10:04:06 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DF24307D846; Tue, 11 Dec 2018 15:04:05 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.34.244.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CE1425D717; Tue, 11 Dec 2018 15:04:02 +0000 (UTC) From: Vitaly Kuznetsov To: Roman Kagan Cc: "kvm\@vger.kernel.org" , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , "linux-kernel\@vger.kernel.org" , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "x86\@kernel.org" , "Michael Kelley \(EOSG\)" , Eduardo Habkost Subject: Re: [PATCH v2 4/7] x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID In-Reply-To: <20181211140247.GC2378@rkaganb.sw.ru> References: <20181210172159.410-1-vkuznets@redhat.com> <20181210172159.410-5-vkuznets@redhat.com> <20181211124956.GA2378@rkaganb.sw.ru> <87bm5sp501.fsf@vitty.brq.redhat.com> <20181211140247.GC2378@rkaganb.sw.ru> Date: Tue, 11 Dec 2018 16:04:01 +0100 Message-ID: <87woognlzy.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 11 Dec 2018 15:04:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Roman Kagan writes: > On Tue, Dec 11, 2018 at 02:28:14PM +0100, Vitaly Kuznetsov wrote: >> Roman Kagan writes: >> >> > On Mon, Dec 10, 2018 at 06:21:56PM +0100, Vitaly Kuznetsov wrote: >> >> >> + >> >> +Currently, the following list of CPUID leaves are returned: >> >> + HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS >> >> + HYPERV_CPUID_INTERFACE >> >> + HYPERV_CPUID_VERSION >> >> + HYPERV_CPUID_FEATURES >> >> + HYPERV_CPUID_ENLIGHTMENT_INFO >> >> + HYPERV_CPUID_IMPLEMENT_LIMITS >> >> + HYPERV_CPUID_NESTED_FEATURES >> >> + >> >> +HYPERV_CPUID_NESTED_FEATURES leaf is only exposed when Enlightened VMCS was >> >> +enabled on the corresponding vCPU (KVM_CAP_HYPERV_ENLIGHTENED_VMCS). >> > >> > IOW the output of ioctl(KVM_GET_SUPPORTED_HV_CPUID) depends on >> > whether ioctl(KVM_ENABLE_CAP, KVM_CAP_HYPERV_ENLIGHTENED_VMCS) has >> > already been called on that vcpu? I wonder if this fits the intended >> > usage? >> >> I added HYPERV_CPUID_NESTED_FEATURES in the list (and made the new ioctl >> per-cpu and not per-vm) for consistency. *In theory* >> KVM_CAP_HYPERV_ENLIGHTENED_VMCS is also enabled per-vcpu so some >> hypothetical userspace can later check enabled eVMCS versions (which can >> differ across vCPUs!) with KVM_GET_SUPPORTED_HV_CPUID. We will also have >> direct tlb flush and other nested features there so to avoid addning new >> KVM_CAP_* for them we need the CPUID. > > This is different from how KVM_GET_SUPPORTED_CPUID is used: QEMU assumes > that its output doesn't change between calls, and even caches the result > calling the ioctl only once. > Yes, I'm not sure if we have to have full consistency between KVM_GET_SUPPORTED_CPUID and KVM_GET_SUPPORTED_HV_CPUID. >> Another thing I'm thinking about is something like 'hv_all' cpu flag for >> Qemu which would enable everything by setting guest CPUIDs to what >> KVM_GET_SUPPORTED_HV_CPUID returns. In that case it would also be >> convenient to have HYPERV_CPUID_NESTED_FEATURES properly filled (or not >> filled when eVMCS was not enabled). > > I think this is orthogonal to the way you obtain capability info from > the kernel. Not necessarily. If very dumb userspace does 'host passthrough' for Hyper-V features without doing anything (e.g. not enabling Enlightened VMCS) it will just put the result of KVM_GET_SUPPORTED_HV_CPUID in guest facing CPUIDs and it will all work. In case eVMCS was previously enabled it again just copies everything and this still works. We don't probably need this for Qemu though. If you think it would be better to have HYPERV_CPUID_NESTED_FEATURES returned regardless of eVMCS enablement I'm ready to budge) -- Vitaly