From nobody Tue Sep 9 19:10:17 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail header.i=@fujitsu.com; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=aa.jp.fujitsu.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1735899968683781.5319306519993; Fri, 3 Jan 2025 02:26:08 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 671C29AD; Fri, 3 Jan 2025 05:26:07 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3F83F994; Fri, 3 Jan 2025 05:24:21 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4BA8510F6; Wed, 25 Dec 2024 04:02:48 -0500 (EST) Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 014E2CD2 for ; Wed, 25 Dec 2024 04:02:42 -0500 (EST) Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Dec 2024 18:01:39 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id F2E7DD4C48 for ; Wed, 25 Dec 2024 18:01:35 +0900 (JST) Received: from oym-om1.fujitsu.com (oym-om1.o.css.fujitsu.com [10.85.58.161]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id C3D81BF3C3 for ; Wed, 25 Dec 2024 18:01:35 +0900 (JST) Received: from sm-x86-mem01.ssoft.mng.com (sm-x86-stp01.soft.fujitsu.com [10.124.178.20]) by oym-om1.fujitsu.com (Postfix) with ESMTP id A7B3E4007A440; Wed, 25 Dec 2024 18:01:35 +0900 (JST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 62 seconds by postgrey-1.37 at lists.libvirt.org; Wed, 25 Dec 2024 04:02:42 EST DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1735117364; x=1766653364; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MuVS92Wech9K69233gIVTm1kfA8qZGV5S6Q1/Gxur7s=; b=NUMiBUE2Z0aUrR2euN+KN9EC0gaoAHHc85JBnOhxBhc7gCJ4dsi3f2vg c6poxU0aKVyp7/WqHluvH7sDsKiSVuehGIRZSdWaWhibVGgp/c5r1zVFN e2KSQFZ2K66WjXnrBkjKiiQjigKIOIuw3NisLWG85afwiQwmehe00PhWI Uh/NQeyDuVCvQjlLSkHGGzkQjvjCW2+y2HtYuxDsPNLWTeuABF3MxpYOm S2PKPabh9jibynN/b5XYcW+Sps+PMIV53RHc1fj6c/L5zU964Lw+6ORJI SYNQUJt4Z8prArUPLUfsDrGHkn6lomc3ojkT/vKgB0vthYjYMTg3kCMuj w==; X-CSE-ConnectionGUID: Nn3nsuKRRiajweYbETLwtg== X-CSE-MsgGUID: cRJhs0ZaSDOshcMMKINb5g== X-IronPort-AV: E=McAfee;i="6700,10204,11296"; a="184868966" X-IronPort-AV: E=Sophos;i="6.12,262,1728918000"; d="scan'208";a="184868966" From: Akio Kakuno To: devel@lists.libvirt.org Subject: [PATCH 1/1] RFC: Add Arm CCA support for getting capability information and running Realm VM Date: Wed, 25 Dec 2024 09:01:32 +0000 Message-Id: <20241225090132.1991250-2-fj3333bs@aa.jp.fujitsu.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241225090132.1991250-1-fj3333bs@aa.jp.fujitsu.com> References: <20241225090132.1991250-1-fj3333bs@aa.jp.fujitsu.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MailFrom: fj3333bs@aa.jp.fujitsu.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 Message-ID-Hash: NXTDHH25HEHAZ3MEG5B76PJJ4VFD3LPG X-Message-ID-Hash: NXTDHH25HEHAZ3MEG5B76PJJ4VFD3LPG X-Mailman-Approved-At: Fri, 03 Jan 2025 10:24:18 -0500 CC: Taketani Ryo , Akio Kakuno X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1735899971195116600 Content-Type: text/plain; charset="utf-8" - This patch adds Arm CCA support to qemu driver for aarch64 system. CCA is an abbreviation for Arm Confidential Compute Architecture feature, it enhances the virtualization capabilities of the platform by separating the management of resources from access to those resources. [summary] - At this stage, all you can do is getting the CCA capability with the virsh domcapabilities command and start the CCA VM with the virsh create comman= d. [Capability example] - Execution results of 'virsh domcapability" on qemu ... ... sha256 sha512 ... [XML example] ... sha256 ... Signed-off-by: Akio Kakuno --- docs/formatdomain.rst | 28 ++++++ docs/formatdomaincaps.rst | 26 ++++- src/conf/domain_capabilities.c | 41 ++++++++ src/conf/domain_capabilities.h | 12 +++ src/conf/domain_conf.c | 13 +++ src/conf/domain_conf.h | 7 ++ src/conf/schemas/domaincaps.rng | 14 +++ src/conf/schemas/domaincommon.rng | 14 +++ src/conf/virconftypes.h | 2 + src/libvirt_private.syms | 1 + src/qemu/qemu_capabilities.c | 156 ++++++++++++++++++++++++++++++ src/qemu/qemu_capabilities.h | 4 + src/qemu/qemu_cgroup.c | 2 + src/qemu/qemu_command.c | 32 ++++++ src/qemu/qemu_driver.c | 2 + src/qemu/qemu_monitor.c | 10 ++ src/qemu/qemu_monitor.h | 3 + src/qemu/qemu_monitor_json.c | 104 ++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 + src/qemu/qemu_namespace.c | 2 + src/qemu/qemu_process.c | 4 + src/qemu/qemu_validate.c | 7 ++ 22 files changed, 487 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 3253a28e5a..08e0abf0f3 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -9040,6 +9040,34 @@ The ```` element then accepts the f= ollowing child elements: the SNP_LAUNCH_FINISH command in the SEV-SNP firmware ABI. =20 =20 +The contents of the ```` element is used to c= reate +RealmVM using the Arm CCA feature (Confidential Compute Architecture). +CCA :since:`Since 10.9.0` enhances the virtualization capabilities of the +platform by separating the management of resources from access to those re= sources. +This is achieved by extending the TrustZone of Cortex-A's Normal and Secure +world concepts and adding the Realm world and the underlying Root world. +The Secure Monitor runs in the root world and manages the transition betwe= en +these security states. For more information see the Learn the architecture= - +Arm Confidential Compute Architecture software stack: +``__ + +:: + + + ... + + sha256 + + ... + + +The ```` element accepts the following attributes: + +``measurement-algo`` + The optional ``measurement-algo`` element determines algorithm used to + describe blob hashes. + + Example configs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/docs/formatdomaincaps.rst b/docs/formatdomaincaps.rst index 5309c6c251..7457c3ac98 100644 --- a/docs/formatdomaincaps.rst +++ b/docs/formatdomaincaps.rst @@ -708,6 +708,12 @@ capabilities. All features occur as children of the ma= in ``features`` element.
+ + + sha256 + sha512 + + relaxed @@ -835,6 +841,23 @@ document store. In order to use SGX with libvirt have = a look at `SGX in domain X ``sections`` The sections of the SGX enclave page cache (called EPC). =20 +CCA capabilities +^^^^^^^^^^^^^^^^ + +Arm Confidential Compute Architecture (CCA) capabilities are exposed under= the +``cca`` element. + +Arm CCA is a system solution comprised of hardware and software components= that +maximizes the security of data on devices and in the cloud. +CCA enhances the virtualization capabilities of the platform by separating= the +management of resources from access to those resources. + +For more details on the CCA feature, please follow resources in the CCA de= veloper's +document store. In order to use CCA with libvirt have a look at `CCA in do= main +XML `__ + +``measurement-algo`` + Options for the ``measurement-algo`` used to describe blob hashes. =20 Hyper-V Enlightenments ^^^^^^^^^^^^^^^^^^^^^^ @@ -856,4 +879,5 @@ The ``sectype`` enum corresponds to ``type`` attribute = of ```` element as documented in `Launch Security `__. :since:`(Since 10.5.0)` For addit= ional information on individual types, see sections above: `s390-pv capability`_= for -S390 PV, `SEV capabilities`_ for AMD SEV and/or AMD SEV-SNP. +S390 PV, `SEV capabilities`_ for AMD SEV and/or AMD SEV-SNP, `CCA capabili= ties`_ +for Arm CCA. diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index cf40d798e5..0a79fc0279 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -90,6 +90,19 @@ virSGXCapabilitiesFree(virSGXCapability *cap) } =20 =20 +void +virCCACapabilitiesFree(virCCACapability *cap) +{ + if (!cap) + return; + + if (cap->ccaMeasurementAlgo) + g_free(cap->ccaMeasurementAlgo); + + g_free(cap); +} + + static void virDomainCapsDispose(void *obj) { @@ -755,6 +768,33 @@ virDomainCapsFeatureSGXFormat(virBuffer *buf, virBufferAddLit(buf, "\n"); } =20 +static void +virDomainCapsFeatureCCAFormat(virBuffer *buf, + const virCCACapability *cca) +{ + size_t i; + + if (!cca) { + virBufferAddLit(buf, "\n"); + return; + } + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + for (i =3D 0; i < cca->nCcaMeasurementAlgo; i++) { + virBufferAsprintf(buf, "%s\n", + cca->ccaMeasurementAlgo[i]); + } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n\n"); +} + static void virDomainCapsFeatureHypervFormat(virBuffer *buf, const virDomainCapsFeatureHyperv *hyperv) @@ -802,6 +842,7 @@ virDomainCapsFormatFeatures(const virDomainCaps *caps, =20 virDomainCapsFeatureSEVFormat(&childBuf, caps->sev); virDomainCapsFeatureSGXFormat(&childBuf, caps->sgx); + virDomainCapsFeatureCCAFormat(&childBuf, caps->cca); virDomainCapsFeatureHypervFormat(&childBuf, caps->hyperv); virDomainCapsLaunchSecurityFormat(&childBuf, &caps->launchSecurity); =20 diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index a706ab337e..ef925fda0a 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -239,6 +239,12 @@ struct _virSGXCapability { virSGXSection *sgxSections; }; =20 +typedef struct _virCCACapability virCCACapability; +struct _virCCACapability { + size_t nCcaMeasurementAlgo; + char **ccaMeasurementAlgo; +}; + STATIC_ASSERT_ENUM(VIR_DOMAIN_CRYPTO_MODEL_LAST); STATIC_ASSERT_ENUM(VIR_DOMAIN_CRYPTO_TYPE_LAST); STATIC_ASSERT_ENUM(VIR_DOMAIN_CRYPTO_BACKEND_LAST); @@ -300,6 +306,7 @@ struct _virDomainCaps { virDomainCapsFeatureGIC gic; virSEVCapability *sev; virSGXCapability *sgx; + virCCACapability *cca; virDomainCapsFeatureHyperv *hyperv; virDomainCapsLaunchSecurity launchSecurity; /* add new domain features here */ @@ -359,3 +366,8 @@ void virSGXCapabilitiesFree(virSGXCapability *capabilities); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSGXCapability, virSGXCapabilitiesFree); + +void +virCCACapabilitiesFree(virCCACapability *capabilities); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCCACapability, virCCACapabilitiesFree); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6d7dee7956..62debe9eaa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1515,6 +1515,7 @@ VIR_ENUM_IMPL(virDomainLaunchSecurity, "sev", "sev-snp", "s390-pv", + "cca", ); =20 VIR_ENUM_IMPL(virDomainPstoreBackend, @@ -13775,6 +13776,15 @@ virDomainSEVSNPDefParseXML(virDomainSEVSNPDef *def, } =20 =20 +static int +virDomainCCADefParseXML(virDomainCCADef *def, + xmlXPathContextPtr ctxt) +{ + def->measurement_algo =3D virXPathString("string(./measurement-algo)",= ctxt); + return 0; +} + + static virDomainSecDef * virDomainSecDefParseXML(xmlNodePtr lsecNode, xmlXPathContextPtr ctxt) @@ -13800,6 +13810,9 @@ virDomainSecDefParseXML(xmlNodePtr lsecNode, break; case VIR_DOMAIN_LAUNCH_SECURITY_PV: break; + case VIR_DOMAIN_LAUNCH_SECURITY_CCA: + virDomainCCADefParseXML(&sec->data.cca, ctxt); + break; case VIR_DOMAIN_LAUNCH_SECURITY_NONE: case VIR_DOMAIN_LAUNCH_SECURITY_LAST: default: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a15af4fae3..c13b7995d3 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2870,6 +2870,7 @@ typedef enum { VIR_DOMAIN_LAUNCH_SECURITY_SEV, VIR_DOMAIN_LAUNCH_SECURITY_SEV_SNP, VIR_DOMAIN_LAUNCH_SECURITY_PV, + VIR_DOMAIN_LAUNCH_SECURITY_CCA, =20 VIR_DOMAIN_LAUNCH_SECURITY_LAST, } virDomainLaunchSecurity; @@ -2904,11 +2905,17 @@ struct _virDomainSEVSNPDef { }; =20 =20 +struct _virDomainCCADef { + char *measurement_algo; +}; + + struct _virDomainSecDef { virDomainLaunchSecurity sectype; union { virDomainSEVDef sev; virDomainSEVSNPDef sev_snp; + virDomainCCADef cca; } data; }; =20 diff --git a/src/conf/schemas/domaincaps.rng b/src/conf/schemas/domaincaps.= rng index f9b87c8a59..5379bfb45c 100644 --- a/src/conf/schemas/domaincaps.rng +++ b/src/conf/schemas/domaincaps.rng @@ -334,6 +334,9 @@ + + + @@ -452,6 +455,17 @@ =20 + + + + + + + + + + + diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index efb5f00d77..7cea83cc01 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -523,6 +523,9 @@ s390-pv + + + @@ -618,6 +621,17 @@ + + + + cca + + + + + + +