From nobody Mon Feb 9 02:51:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1639087487933573.7086060156796; Thu, 9 Dec 2021 14:04:47 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-vOzY6WTFO1O3w96D1yvaMg-1; Thu, 09 Dec 2021 17:04:44 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF739190B2AF; Thu, 9 Dec 2021 22:04:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A7A85BE16; Thu, 9 Dec 2021 22:04:36 +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 2E0C01809CB8; Thu, 9 Dec 2021 22:04:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B9M4S9V012937 for ; Thu, 9 Dec 2021 17:04:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1C70A40CFD07; Thu, 9 Dec 2021 22:04:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16A574010FDD for ; Thu, 9 Dec 2021 22:04:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED2CB800B28 for ; Thu, 9 Dec 2021 22:04:27 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.111.102]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-bWHbr0zZP9mspXJhgbkgow-1; Thu, 09 Dec 2021 17:04:25 -0500 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2059.outbound.protection.outlook.com [104.47.0.59]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-6-ajVb_8ObNi-IFlGu7azDJA-1; Thu, 09 Dec 2021 23:04:23 +0100 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) by AM0PR04MB4897.eurprd04.prod.outlook.com (2603:10a6:208:c8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.12; Thu, 9 Dec 2021 22:04:22 +0000 Received: from AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3]) by AM0PR04MB4899.eurprd04.prod.outlook.com ([fe80::2491:2b2f:154a:acf3%5]) with mapi id 15.20.4755.025; Thu, 9 Dec 2021 22:04:22 +0000 Received: from localhost (75.169.28.116) by AM6P194CA0079.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.16 via Frontend Transport; Thu, 9 Dec 2021 22:04:21 +0000 X-MC-Unique: vOzY6WTFO1O3w96D1yvaMg-1 X-MC-Unique: bWHbr0zZP9mspXJhgbkgow-1 X-MC-Unique: ajVb_8ObNi-IFlGu7azDJA-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH V2 1/3] libvirt: Introduce virDomainSetLaunchSecurityState public API Date: Thu, 9 Dec 2021 15:04:13 -0700 Message-ID: <20211209220415.22039-2-jfehlig@suse.com> In-Reply-To: <20211209220415.22039-1-jfehlig@suse.com> References: <20211209220415.22039-1-jfehlig@suse.com> X-ClientProxiedBy: AM6P194CA0079.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::20) To AM0PR04MB4899.eurprd04.prod.outlook.com (2603:10a6:208:c5::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 53fdf0c5-075c-4915-8461-08d9bb5fdb0e X-MS-TrafficTypeDiagnostic: AM0PR04MB4897:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: WhheNLtx3HNjkIbE4We721jdxkvM8Mdpl7AHfizdAENpd/Dhpb27OhQzTTxC52dNnm9KfD5tWRNnLIxQ5u+70Yq9ZbKAT75O/DfvHuUgCQrE/Vhmeq7Oi9GUNnGIu+dGmRdD2qDzMiONmBKvUJ0A2SC1fWKspJcBP2FUz4LrNh0EsGQcWq1o+nV/dh+MSVKbmmmvv5t3e2GV9fikPAfWdFINf9C+7d1o1kVSn9VYrEEmrY58RvjLlteM6HkLa6GbEuIbGamSYlHMdqhl4hsHvj5tjehXpeCfSj3oEY400JgSg/DBaVPkSFG0pT+m7Zy2k93lyLMEMuUEhuYbrJwewy6roBoTHvJcZJVh4jgdsqxOw4DyvGQFqxh9QCyrr4+7+0IzSARgbFSZqCdkc0RvnMHT4PrqcrbLRJ/FXu83gFBe/74Wwkksnz/w5GHjfhzMVTY4I8mQuxyxoKH8VHZ3xd5WFOgvJS2LYt6WvyB5wHJtLVadfatR3ZJk/5KzFhjzU5stABC94yUL968WafUnNnM9miYlYR0l6D2RCmHaStHkYKR1BfKsIGwki667vJ187tasQwy3iave7lZLetahQgGupLRWjJ3tMEDlOKpEG0fCfRFhDsxdoXnFSRkLBltUPWaJaIQUbvM6jnX6gRvVjUcF+BqpK0mn4ybEwB5YyVc/K1pkTzMhRS0uVBEyhlpRLfduHY+bUqpDTqvPa/urzgekML6+KrdQ8havRGNusT0brlIORTEmbx574Xlp0xSnciYgjW2uLRExqsG/p+mCtStQ5bMtgLxAAt+Jc0D7DU1ws7LRR57jRq+sEuWZ+uSY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB4899.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6666004)(6916009)(83380400001)(186003)(956004)(2616005)(6496006)(26005)(66946007)(66476007)(66556008)(8936002)(36756003)(6486002)(966005)(316002)(1076003)(38100700002)(2906002)(508600001)(8676002)(86362001)(5660300002)(145543001)(213903007); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?MybC143CV2A0brCb8flJN8zZ7KTKLhWBAuok5BV8i3p6VXNS6o4mR5/j9EzE?= =?us-ascii?Q?ysc6bopqmXJjpiJcSI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-ascii?Q?mZrX8YX7csGoKJdPifPFRBhseQv6Xjs3iFA1FB3xkFDnsMpFABLa972clzpv?= =?us-ascii?Q?Lxrcfx+0Y3m2lbSlIurShJMjYRoEH9ZDoN8V9NSwiVOiJY6kDcywSknujIuz?= =?us-ascii?Q?xLu4RBm8a19tMxMVaLHxB6N0fi5c9+fkT04GxjupKpSVSagXCxN02hMwmaVF?= =?us-ascii?Q?l86OlyL08wCMmITWTCPX4/VhlHxus4P09EKW3GbvpnxDMYa8kYyQq7MHdsBN?= =?us-ascii?Q?uln7pXRrpn+xxvsvE1I0u2Kukeg+RI6DZ1VUHu4U5rg8hqihF6S9lerwcBWT?= =?us-ascii?Q?drtISTXrzB1qjscYMrhPaITSsAmq9dx3xFUg7DG1ZOi8TnAGrlyODjZr7BWd?= =?us-ascii?Q?+M5xf2FferxnPPfTihSQAjMzPl1wq9Lzb4mx3l3ErfkvmgMdWs91cCRH3dfy?= =?us-ascii?Q?jC1GZyd8XgXwO7LY25Ajj0zZMG5pJjFaMrnZenz2e3RMrogSNanwJB58t66c?= =?us-ascii?Q?NsPGdGo4sQMFQUtM2TL+tZXlIZr0ZBkPwT3CtcDTJIvVbHBImGTGuwg7LDC/?= =?us-ascii?Q?EGm8O2UDFomxg6f+unYlL7GybnncuhopBKgVvJc3LyxxJ6hxecxhrvG7AVWg?= =?us-ascii?Q?7x7gXXnLTLnjh+W/lAYiWLIXIwHkKK7iilnDTtOzZv83rvi1fN8TaPgfVSW/?= =?us-ascii?Q?qqJMgbrD8Z7KBxjVibhbSuY=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53fdf0c5-075c-4915-8461-08d9bb5fdb0e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB4899.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2021 22:04:22.3740 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TvCo86fjI7PAIgdPbALdqJucJXEQev/bIe9jxcj8yK9MACY1Pwb7LCZtcf2lisihlGR+guVwZ7Uz8UDjE7a54g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4897 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 1B9M4S9V012937 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.15 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-ZM-MESSAGEID: 1639087489061100001 Content-Type: text/plain; charset="utf-8" This API allows setting a launch secret within a guests's memory. The launch secret is created by the guest owner after retrieving and verifying the launch measurement with virDomainGetLaunchSecurityInfo. The API uses virTypedParameter for input, allowing it to be expanded to support other confidential computing technologies. In the case of SEV, a basic guest launch workflow is described in the SEV API spec in section "1.3.1 Launch" https://www.amd.com/system/files/TechDocs/55766_SEV-KM_API_Specification.pdf Signed-off-by: Jim Fehlig Reviewed-by: Daniel P. Berrang=C3=A9 --- include/libvirt/libvirt-domain.h | 35 ++++++++++++++++++ src/driver-hypervisor.h | 7 ++++ src/libvirt-domain.c | 62 ++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ 4 files changed, 109 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index d0dd11ab01..9e7f72e214 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -5101,11 +5101,46 @@ int virDomainSetLifecycleAction(virDomainPtr domain, */ # define VIR_DOMAIN_LAUNCH_SECURITY_SEV_MEASUREMENT "sev-measurement" =20 +/** + * VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEADER: + * + * A macro used to represent the SEV launch secret header. The secret head= er + * is a base64-encoded VIR_TYPED_PARAM_STRING containing artifacts needed = by + * the SEV firmware to recover the plain text of the launch secret. See + * section "6.6 LAUNCH_SECRET" in the SEV API specification for a detailed + * description of the secret header. + */ +# define VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_HEADER "sev-secret-header" + +/** + * VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET: + * + * A macro used to represent the SEV launch secret. The secret is a + * base64-encoded VIR_TYPED_PARAM_STRING containing an encrypted launch + * secret. The secret is created by the domain owner after the SEV launch + * measurement is retrieved and verified. + */ +# define VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET "sev-secret" + +/** + * VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_ADDRESS: + * + * A macro used to represent the physical address within the guest's memory + * where the secret will be set, as VIR_TYPED_PARAM_ULLONG. If not specifi= ed, + * the address will be determined by the hypervisor. + */ +# define VIR_DOMAIN_LAUNCH_SECURITY_SEV_SECRET_SET_ADDRESS "sev-secret-set= -address" + int virDomainGetLaunchSecurityInfo(virDomainPtr domain, virTypedParameterPtr *params, int *nparams, unsigned int flags); =20 +int virDomainSetLaunchSecurityState(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags); + typedef enum { VIR_DOMAIN_GUEST_INFO_USERS =3D (1 << 0), /* return active users */ VIR_DOMAIN_GUEST_INFO_OS =3D (1 << 1), /* return OS information */ diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index d642af8a37..c83fb648a2 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1333,6 +1333,12 @@ typedef int int *nparams, unsigned int flags); =20 +typedef int +(*virDrvDomainSetLaunchSecurityState)(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags); + typedef virDomainCheckpointPtr (*virDrvDomainCheckpointCreateXML)(virDomainPtr domain, const char *xmlDesc, @@ -1661,6 +1667,7 @@ struct _virHypervisorDriver { virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU; virDrvNodeGetSEVInfo nodeGetSEVInfo; virDrvDomainGetLaunchSecurityInfo domainGetLaunchSecurityInfo; + virDrvDomainSetLaunchSecurityState domainSetLaunchSecurityState; virDrvDomainCheckpointCreateXML domainCheckpointCreateXML; virDrvDomainCheckpointGetXMLDesc domainCheckpointGetXMLDesc; virDrvDomainListAllCheckpoints domainListAllCheckpoints; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5708ff839b..82b0822d12 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12844,6 +12844,68 @@ int virDomainGetLaunchSecurityInfo(virDomainPtr do= main, } =20 =20 +/** + * virDomainSetLaunchSecurityState: + * @domain: a domain object + * @params: pointer to launch security parameter objects + * @nparams: number of launch security parameters + * @flags: currently used, set to 0. + * + * Set a launch security secret in the guest's memory. The guest must be + * in a paused state, e.g. in state VIR_DOMIAN_PAUSED as reported by + * virDomainGetState. On success, the guest can be transitioned to a + * running state. On failure, the guest should be destroyed. + * + * A basic guest attestation process can be achieved by: + * - Start a secure guest in the paused state by passing VIR_DOMAIN_START_= PAUSED + * to one of the virDomainCreate APIs + * - Retrieve the guest launch measurement with virDomainGetLaunchSecurity= Info + * - Verify launch measurement and generate a secret for the guest + * - Set the secret in the guest's memory with virDomainSetLaunchSecurityS= tate + * - Start running the guest with virDomainResume + * + * See VIR_DOMAIN_LAUNCH_SECURITY_* for a detailed description of accepted + * launch security parameters. + * + * Returns -1 in case of failure, 0 in case of success. + */ +int virDomainSetLaunchSecurityState(virDomainPtr domain, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ + virConnectPtr conn =3D domain->conn; + + VIR_DOMAIN_DEBUG(domain, "params=3D%p, nparams=3D%d flags=3D0x%x", + params, nparams, flags); + VIR_TYPED_PARAMS_DEBUG(params, nparams); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + virCheckNonNullArgGoto(params, error); + virCheckPositiveArgGoto(nparams, error); + virCheckReadOnlyGoto(domain->conn->flags, error); + + if (virTypedParameterValidateSet(conn, params, nparams) < 0) + goto error; + + if (conn->driver->domainSetLaunchSecurityState) { + int ret; + ret =3D conn->driver->domainSetLaunchSecurityState(domain, params, + nparams, flags); + if (ret < 0) + goto error; + return ret; + } + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} + + /** * virDomainAgentSetResponseTimeout: * @domain: a domain object diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 788a967df7..f93692c427 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -911,4 +911,9 @@ LIBVIRT_7.8.0 { virNetworkCreateXMLFlags; } LIBVIRT_7.7.0; =20 +LIBVIRT_8.0.0 { + global: + virDomainSetLaunchSecurityState; +} LIBVIRT_7.8.0; + # .... define new API here using predicted next version number .... --=20 2.34.1