From nobody Tue May 7 11:52:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636028605; cv=none; d=zohomail.com; s=zohoarc; b=mvraQRQqFqa5Yxdg6PKEK0nAbFgH/AeHYVClRtY3bCejTKrePTN3utmlN5F9aRQAQorbnBFgvWcXxB+7tY5M/xpjcNMR7V4PNUo0P9AEQsQhLATZ4qLWZ99D+2ADO1UUfuxAyLKVQ2norHqyuLcx5g1qIEy2kjYY2/u42DI8rjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636028605; h=Content-Type:Content-Transfer-Encoding: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=kv5v4Oiv+2DdjABDhMPmz+BJMtWbDqiYGmxiHRO3N3w=; b=Z5hwcO4zvmWTBMhJKtMlQRiW3PNv1pMKFNjnFTxDL5jMZINE3s6I0EEhLaakU1I2Hd692hN0M3dJYFqpwPLIjOFeax/Otad4y6WXLhF6p5IGxIHosiTe3ykr/g7Mb3NFAgpIfy+ltjn924qK9UfMJxhR+z+d+Pw5YaPxkL/iUWg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636028605274711.044715591776; Thu, 4 Nov 2021 05:23:25 -0700 (PDT) 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-564-vB43z5olPkessIjoIyd1Uw-1; Thu, 04 Nov 2021 08:23:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3A4E192296D; Thu, 4 Nov 2021 12:23:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5D1C5FC25; Thu, 4 Nov 2021 12:23:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6EFC457DC4; Thu, 4 Nov 2021 12:23:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A4CN6Ci003565 for ; Thu, 4 Nov 2021 08:23:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E02D57CD3; Thu, 4 Nov 2021 12:23:06 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AA6E2B060; Thu, 4 Nov 2021 12:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636028604; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kv5v4Oiv+2DdjABDhMPmz+BJMtWbDqiYGmxiHRO3N3w=; b=iUBlOT8OFjXlYJLjPFmwV6DEte+ZJ5NsBDVy+d7ifroZqyW+OGutlERPUxiDhpsIOGPlW1 zmGFsPpIEos7wSbuDv5/UJdhbWmIKort7tR29rHEbDui2s9PkrEe5xRks0QZQojt/zwwhx 9iZtYG4cDO1KZ+HbXSP9Tz3jlpI3PKQ= X-MC-Unique: vB43z5olPkessIjoIyd1Uw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] conf: Introduce TCG domain features Date: Thu, 4 Nov 2021 13:22:52 +0100 Message-Id: <442ecae5b08ac074b0649016a3f4fb5438e031a2.1636028443.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636028606075100001 Content-Type: text/plain; charset="utf-8" It may come handy to be able to tweak TCG options, in this specific case the size of translation block cache size (tb-size). Since we can expect more knobs to tweak let's put them under common element, like this: 128 Signed-off-by: Michal Privoznik Tested-by: Kashyap Chamarthy =20 --- docs/formatdomain.rst | 11 +++ docs/schemas/domaincommon.rng | 15 +++- src/conf/domain_conf.c | 90 +++++++++++++++++++ src/conf/domain_conf.h | 7 ++ src/qemu/qemu_validate.c | 11 +++ .../x86_64-default-cpu-tcg-features.xml | 67 ++++++++++++++ ...default-cpu-tcg-features.x86_64-latest.xml | 1 + tests/qemuxml2xmltest.c | 1 + 8 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.= xml create mode 120000 tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-feature= s.x86_64-latest.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 0651975c88..d7f4f093fb 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1864,6 +1864,9 @@ Hypervisors may allow certain CPU / machine features = to be toggled on/off. + + 128 + ... =20 @@ -2065,6 +2068,14 @@ are: ``fixed-na (fixed in hardware - no longer applicable)``. If t= he attribute is not defined, the hypervisor default will be used. :since:`= Since 6.3.0` (QEMU/KVM only) +``tcg`` + Various features to change the behavior of the TCG accelerator. + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + Feature Description Value = Since + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + tb-cache The size of translation block cache size an integer = :since:`7.10.0` + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 :anchor:`` =20 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 67df13d90d..73401e6b75 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -6062,7 +6062,7 @@ @@ -6202,6 +6202,9 @@ + + + @@ -6490,6 +6493,16 @@ =20 + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4644d18120..2db013cab4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -172,6 +172,7 @@ VIR_ENUM_IMPL(virDomainFeature, "cfpc", "sbbc", "ibs", + "tcg", ); =20 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, @@ -17650,6 +17651,30 @@ virDomainFeaturesCapabilitiesDefParse(virDomainDef= *def, } =20 =20 +static int +virDomainFeaturesTCGDefParse(virDomainDef *def, + xmlXPathContextPtr ctxt, + xmlNodePtr node) +{ + g_autofree virDomainFeatureTCG *tcg =3D NULL; + VIR_XPATH_NODE_AUTORESTORE(ctxt); + + tcg =3D g_new0(virDomainFeatureTCG, 1); + ctxt->node =3D node; + + if (virDomainParseMemory("./tb-cache", "./tb-cache/@unit", + ctxt, &tcg->tb_cache, false, false) < 0) + return -1; + + if (tcg->tb_cache =3D=3D 0) + return 0; + + def->features[VIR_DOMAIN_FEATURE_TCG] =3D VIR_TRISTATE_SWITCH_ON; + def->tcg_features =3D g_steal_pointer(&tcg); + return 0; +} + + static int virDomainFeaturesDefParse(virDomainDef *def, xmlXPathContextPtr ctxt) @@ -17858,6 +17883,11 @@ virDomainFeaturesDefParse(virDomainDef *def, break; } =20 + case VIR_DOMAIN_FEATURE_TCG: + if (virDomainFeaturesTCGDefParse(def, ctxt, nodes[i]) < 0) + return -1; + break; + case VIR_DOMAIN_FEATURE_LAST: break; } @@ -21526,6 +21556,39 @@ virDomainRedirFilterDefCheckABIStability(virDomain= RedirFilterDef *src, } =20 =20 +static bool +virDomainFeatureTCGCheckABIStability(const virDomainDef *src, + const virDomainDef *dst) +{ + const int srcF =3D src->features[VIR_DOMAIN_FEATURE_TCG]; + const int dstF =3D dst->features[VIR_DOMAIN_FEATURE_TCG]; + + if (srcF !=3D dstF || + !!src->tcg_features !=3D !!dst->tcg_features) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("State of feature '%s' differs: " + "source: '%s', destination: '%s'"), + virDomainFeatureTypeToString(VIR_DOMAIN_FEATURE_TCG= ), + virTristateSwitchTypeToString(srcF), + virTristateSwitchTypeToString(dstF)); + return false; + } + + if (!src->tcg_features && !dst->tcg_features) + return true; + + if (src->tcg_features->tb_cache !=3D dst->tcg_features->tb_cache) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("TCG tb-cache mismatch: source %llu, destination:= %llu"), + src->tcg_features->tb_cache, + dst->tcg_features->tb_cache); + return false; + } + + return true; +} + + static bool virDomainDefFeaturesCheckABIStability(virDomainDef *src, virDomainDef *dst) @@ -21676,6 +21739,11 @@ virDomainDefFeaturesCheckABIStability(virDomainDef= *src, case VIR_DOMAIN_FEATURE_MSRS: break; =20 + case VIR_DOMAIN_FEATURE_TCG: + if (!virDomainFeatureTCGCheckABIStability(src, dst)) + return false; + break; + case VIR_DOMAIN_FEATURE_LAST: break; } @@ -27645,6 +27713,24 @@ virDomainDefFormatBlkiotune(virBuffer *buf, } =20 =20 +static void +virDomainFeatureTCGFormat(virBuffer *buf, + const virDomainDef *def) +{ + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + + if (!def->tcg_features || + def->features[VIR_DOMAIN_FEATURE_TCG] !=3D VIR_TRISTATE_SWITCH_ON) + return; + + virBufferAsprintf(&childBuf, + "%lld\n", + def->tcg_features->tb_cache); + + virXMLFormatElement(buf, "tcg", NULL, &childBuf); +} + + static int virDomainDefFormatFeatures(virBuffer *buf, virDomainDef *def) @@ -27965,6 +28051,10 @@ virDomainDefFormatFeatures(virBuffer *buf, virDomainIBSTypeToString(def->features[i])); break; =20 + case VIR_DOMAIN_FEATURE_TCG: + virDomainFeatureTCGFormat(&childBuf, def); + break; + case VIR_DOMAIN_FEATURE_LAST: break; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index cb6d8975b8..e2287b3be1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2044,6 +2044,7 @@ typedef enum { VIR_DOMAIN_FEATURE_CFPC, VIR_DOMAIN_FEATURE_SBBC, VIR_DOMAIN_FEATURE_IBS, + VIR_DOMAIN_FEATURE_TCG, =20 VIR_DOMAIN_FEATURE_LAST } virDomainFeature; @@ -2252,6 +2253,11 @@ typedef enum { =20 VIR_ENUM_DECL(virDomainIBS); =20 +typedef struct _virDomainFeatureTCG virDomainFeatureTCG; +struct _virDomainFeatureTCG { + unsigned long long tb_cache; /* Stored in KiB */ +}; + /* Operating system configuration data & machine / arch */ struct _virDomainOSEnv { char *name; @@ -2814,6 +2820,7 @@ struct _virDomainDef { unsigned long long hpt_maxpagesize; /* Stored in KiB */ char *hyperv_vendor_id; virTristateSwitch apic_eoi; + virDomainFeatureTCG *tcg_features; =20 bool tseg_specified; unsigned long long tseg_size; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index c4384dbe8b..5ee4d3ffcb 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -294,6 +294,17 @@ qemuValidateDomainDefFeatures(const virDomainDef *def, } break; =20 + case VIR_DOMAIN_FEATURE_TCG: + if (def->features[i] =3D=3D VIR_TRISTATE_SWITCH_ON) { + if (def->virtType !=3D VIR_DOMAIN_VIRT_QEMU) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("TCG features are incompatible with d= omain type '%s'"), + virDomainVirtTypeToString(def->virtType= )); + return -1; + } + } + break; + case VIR_DOMAIN_FEATURE_SMM: case VIR_DOMAIN_FEATURE_KVM: case VIR_DOMAIN_FEATURE_XEN: diff --git a/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.xml b/t= ests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.xml new file mode 100644 index 0000000000..e2058487b2 --- /dev/null +++ b/tests/qemuxml2argvdata/x86_64-default-cpu-tcg-features.xml @@ -0,0 +1,67 @@ + + guest + 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 + 4194304 + 4194304 + 4 + + hvm + + + + + + + 102400 + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + +
+ + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + +