From nobody Tue Feb 10 02:48:49 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612979732; cv=none; d=zohomail.com; s=zohoarc; b=g935u47GgX9uQC1VI0E1aVMIj/aFCJ5+2yOLhIVnUbCzjQTYhsZY+lyzXs36PiOU33/jT6ddjR0hikt8VnBPRqI9RdbME7lt33eaDjWnvdH0jceX/MAbnjj7relGt9825ZHW1GYuiZEpRhGk+ZYG6WFq2Zpk7TFWGs0HoLGyXh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612979732; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gCzFwz5A2M5u86vlKhF3IJuBm7ZN0Qaa9eC8NVbtT9g=; b=WWp3YiuvgdGUDNR63zmjY3BOn2m7zkl9Yn7vfEWX7+yJYPgD/TF2dvDQfw68GSz3mpW7tpJEnDlcMpxl+W0O/0gAV2Qfs0fdWuOuwA5JdzgVb8TKw6JOCaGIM9AbeSm+vgXDQKZcFkdlT8XI3KA/k0Sa9/f7m1IKUeSUuHBSYos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612979731976581.0718397467549; Wed, 10 Feb 2021 09:55:31 -0800 (PST) Received: from localhost ([::1]:37444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9sve-0007VW-QH for importer@patchew.org; Wed, 10 Feb 2021 12:05:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9sYW-0007LE-BE for qemu-devel@nongnu.org; Wed, 10 Feb 2021 11:41:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:32689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9sYO-0008VE-53 for qemu-devel@nongnu.org; Wed, 10 Feb 2021 11:41:32 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-MgYUTyygOf2GHhTmjWx3Ng-1; Wed, 10 Feb 2021 11:41:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 448699127C for ; Wed, 10 Feb 2021 16:41:18 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.195.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF2BD5D9D0; Wed, 10 Feb 2021 16:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612975280; 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=gCzFwz5A2M5u86vlKhF3IJuBm7ZN0Qaa9eC8NVbtT9g=; b=P2QjyiGZlZlYkI4NIFa6iYp5xVlFzBY5xG2GIzuxfwCAaWAlS+kqviKsge5wlaBtW7Trkg A1NiDEJzSnbCBeeZuRutKuQx9xsrrZ+DI2fkxpCedtfouiJBn9QYTipK0YHQopuHo4AusX 3YmfNJTDqfAaxH4UvpXXjA2eU7ynW7M= X-MC-Unique: MgYUTyygOf2GHhTmjWx3Ng-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org, Eduardo Habkost Subject: [PATCH v4 17/21] i386: support 'hv-passthrough, hv-feature=off' on the command line Date: Wed, 10 Feb 2021 17:40:29 +0100 Message-Id: <20210210164033.607612-18-vkuznets@redhat.com> In-Reply-To: <20210210164033.607612-1-vkuznets@redhat.com> References: <20210210164033.607612-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.568, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Marcelo Tosatti , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Currently, we support 'hv-passthrough,hv-feature=3Don' enablement, this is supposed to mean "hv-feature is mandatory, don't start without it". Add support for 'hv-passthrough,hv-feature=3Doff' meaning "enable everything supported by the host except for hv-feature". While on it, make 'hv-passthrough' parse semantics in-line with other options in qemu: when specified, it overrides what was previously set with what's supported by the host. This can later be modified with 'hv-feature= =3Don'/ 'hv-feature=3Doff'. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 28 +++++++++++++++++++++++++++- target/i386/kvm/kvm.c | 4 ++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e8a004c39d04..f8df2caed779 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4725,6 +4725,29 @@ static void x86_hv_stimer_direct_set(Object *obj, bo= ol value, Error **errp) x86_hv_feature_set(obj, value, HYPERV_FEAT_STIMER_DIRECT); } =20 +static bool x86_hv_passthrough_get(Object *obj, Error **errp) +{ + X86CPU *cpu =3D X86_CPU(obj); + + return cpu->hyperv_passthrough; +} + +static void x86_hv_passthrough_set(Object *obj, bool value, Error **errp) +{ + X86CPU *cpu =3D X86_CPU(obj); + + cpu->hyperv_passthrough =3D value; + + /* hv-passthrough overrides everything with what's supported by the ho= st */ + if (value) { + cpu->hyperv_features =3D 0; + cpu->hyperv_features_on =3D 0; + cpu->hyperv_features_off =3D 0; + } + + return; +} + /* Generic getter for "feature-words" and "filtered-features" properties */ static void x86_cpu_get_feature_words(Object *obj, Visitor *v, const char *name, void *opaque, @@ -7281,7 +7304,6 @@ static Property x86_cpu_properties[] =3D { HYPERV_SPINLOCK_NEVER_NOTIFY), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), - DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), =20 DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), @@ -7460,6 +7482,10 @@ static void x86_cpu_common_class_init(ObjectClass *o= c, void *data) x86_hv_stimer_direct_get, x86_hv_stimer_direct_set); =20 + object_class_property_add_bool(oc, "hv-passthrough", + x86_hv_passthrough_get, + x86_hv_passthrough_set); + for (w =3D 0; w < FEATURE_WORDS; w++) { int bitnr; for (bitnr =3D 0; bitnr < 64; bitnr++) { diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 30013f0d7cee..fca088d4d3b5 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1153,6 +1153,10 @@ static int hv_cpuid_check_and_set(CPUState *cs, int = feature, Error **errp) return 0; } =20 + if (cpu->hyperv_passthrough && (cpu->hyperv_features_off & BIT(feature= ))) { + return 0; + } + deps =3D kvm_hyperv_properties[feature].dependencies; while (deps) { dep_feat =3D ctz64(deps); --=20 2.29.2