From nobody Mon Feb 9 00:01:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1639498073; cv=none; d=zohomail.com; s=zohoarc; b=JU551VFEgmOya0bLSlbbJXIWu0E347OfdAm0qNcULVygRzW6AmJrNHx8xdMZZUp6jPvBQ9fbGopXcBTwfdREB/0yFcmerhHlIdSatC4hr52F5nwdObdXp96GjX26Rhq9E4YZEV50VlgxH8UlxFzBQgC+RVxOB4OjvDC9MGIf3Uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639498073; 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=v8SP8QTG6jBJ8t8sn82sEjI4E7eFqkhzLBr6Cq549Po=; b=mn+jOOewC/g1PJvsQlkCXXQfiYlMK8/c55VyvdI1uhbC0S9kWtLOGISJ6SOp0ISczbrKauGzY1+kpsiUpbUFhp9LHTG63HGdVZ7zPvRK+ETiYdy3P7On+K1YvaOfX7xA0RiCL0Wh3ACbNagOzeKLpxgVlkJnjMInURMe3hdRGI4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1639498073888421.13347180976587; Tue, 14 Dec 2021 08:07:53 -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-225-5W4Ds-ebP1alC3i5ojrpuQ-1; Tue, 14 Dec 2021 11:07:48 -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 B6B9B34834; Tue, 14 Dec 2021 16:07:42 +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 4672E74E8D; Tue, 14 Dec 2021 16:07:42 +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 917104BB7B; Tue, 14 Dec 2021 16:07:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BEG7eLZ017363 for ; Tue, 14 Dec 2021 11:07:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5CDF674E9B; Tue, 14 Dec 2021 16:07:40 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.194.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A13677C9E; Tue, 14 Dec 2021 16:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639498072; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=v8SP8QTG6jBJ8t8sn82sEjI4E7eFqkhzLBr6Cq549Po=; b=fjRzPqwWrwieB06PD5OiolqyaXjcyxWxIdjGAXA/q452pGIo5nAar09N0gEzvk1oXosPN0 TLMfB3xg3YiijWYijYXUQGbq9fbl8xiboHFMcthB/l+uOz+erGs7IE15wpxJnUqgPE8+bQ 2gjSKLWywYugM/yw5YlPlkW0c93N+Fo= X-MC-Unique: 5W4Ds-ebP1alC3i5ojrpuQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v4 1/3] conf: add support for setting SEV kernel hashes Date: Tue, 14 Dec 2021 16:07:04 +0000 Message-Id: <20211214160706.3392451-2-berrange@redhat.com> In-Reply-To: <20211214160706.3392451-1-berrange@redhat.com> References: <20211214160706.3392451-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639498074941100001 Normally the SEV measurement only covers the firmware loader contents. When doing a direct kernel boot, however, with new enough OVMF it is possible to ask for the measurement to cover the kernel, ramdisk and command line. It can't be done automatically as that would break existing guests using direct kernel boot with old firmware, so there is a new XML setting allowing this behaviour to be toggled. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/formatdomain.rst | 7 ++++++- docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 8 ++++++++ src/conf/domain_conf.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 0c5e33c78f..9d064a4af2 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -8215,7 +8215,7 @@ spec `__ =20 ... - + 0x0001 47 1 @@ -8225,6 +8225,11 @@ spec `__ ... =20 +``kernelHashes`` + The optional ``kernelHashes`` attribute indicates whether the + hashes of the kernel, ramdisk and command line should be included + in the measurement done by the firmware. This is only valid if + using direct kernel boot. :since:`Since 8.0.0` ``cbitpos`` The required ``cbitpos`` element provides the C-bit (aka encryption bit) location in guest page table entry. The value of ``cbitpos`` is hypervi= sor diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ce5018f798..7fa5c2b8b5 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -499,6 +499,11 @@ sev + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9a21ac10ce..bd372190df 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14804,6 +14804,10 @@ virDomainSEVDefParseXML(virDomainSEVDef *def, unsigned long policy; int rc; =20 + if (virXMLPropTristateBool(ctxt->node, "kernelHashes", VIR_XML_PROP_NO= NE, + &def->kernel_hashes) < 0) + return -1; + if (virXPathULongHex("string(./policy)", ctxt, &policy) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("failed to get launch security policy")); @@ -27133,6 +27137,10 @@ virDomainSecDefFormat(virBuffer *buf, virDomainSec= Def *sec) case VIR_DOMAIN_LAUNCH_SECURITY_SEV: { virDomainSEVDef *sev =3D &sec->data.sev; =20 + if (sev->kernel_hashes !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(&attrBuf, " kernelHashes=3D'%s'", + virTristateBoolTypeToString(sev->kernel_hash= es)); + if (sev->haveCbitpos) virBufferAsprintf(&childBuf, "%d\n", sev->c= bitpos); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index afabcd1b4d..144ba4dd12 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2714,6 +2714,7 @@ struct _virDomainSEVDef { unsigned int cbitpos; bool haveReducedPhysBits; unsigned int reduced_phys_bits; + virTristateBool kernel_hashes; }; =20 struct _virDomainSecDef { --=20 2.33.1