From nobody Mon Feb 9 04:37:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1620648574; cv=none; d=zohomail.com; s=zohoarc; b=nZSYqZPm2IVmN68MVoymD0siL5pkrEBKGxHzrd/yzj2w17hI1SBFb7COd8ruyu/g9oKDbR/GykIRdIMUyJ/Aswzv1r8m09eCkEAxwZka9+ouWHabNJPsd91heBOiDg0NpUZmaUUMOSWneWmSdVSv6nFiJvzYz/kkSpoqv+O+3y8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620648574; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=EZjBTCjfLjuw+fMtZby49poKJKIsVUn8rmA8SEDnUfc=; b=LWTetC2LydurQeoxyNf7sIhNwnH+ZrnLtNYCn9BR5hBtSJ6D/hholuBnXZIXnPZUmgRyLoKALhazL9PfADc0WWonzoCcnkqsbwuG2xWRinKtEnR3MJJVDwR0A+mJO20g5pJrg4gtx69BWL5d+ZLhJV9HpZ37VcnRMF/xfuFhsfE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620648574425931.2670552936273; Mon, 10 May 2021 05:09:34 -0700 (PDT) Received: from localhost ([::1]:36532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lg4j7-0000st-IZ for importer@patchew.org; Mon, 10 May 2021 08:09:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg4h1-0007fm-Ag for qemu-devel@nongnu.org; Mon, 10 May 2021 08:07:23 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:35487) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lg4gz-0000eB-6f for qemu-devel@nongnu.org; Mon, 10 May 2021 08:07:23 -0400 Received: by mail-pf1-x430.google.com with SMTP id i13so13577677pfu.2 for ; Mon, 10 May 2021 05:07:19 -0700 (PDT) Received: from localhost ([120.18.209.143]) by smtp.gmail.com with ESMTPSA id 1sm10866501pfv.159.2021.05.10.05.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 May 2021 05:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EZjBTCjfLjuw+fMtZby49poKJKIsVUn8rmA8SEDnUfc=; b=YgC8uMIiU4nV3mshNswsTcHHNLAMytLLva8RoIiQJqWUSRtsO+AunFnlFD0+HEeQWC Uq4Zfx/GVkJ0lBBn22a56sGzOBuLkcvzVxvYlRvodE5KjIPy7ReK1vdHmHs1Fiyp6oi2 8PFP8TTRJEhdcv4z6WR2Tr4pITeiG8y2mTZRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EZjBTCjfLjuw+fMtZby49poKJKIsVUn8rmA8SEDnUfc=; b=pOxQ45Ikf+qCUPFfrKKjOFbf4yiqZguFSFlm7oUEHIxSpyQrk/iAHHzgNp+trM+FAw nzZNN8Wd1DSsgdZyCfAD6TJHadaoCQlI+Rq85mbpt+kvxLBXQcgigSq4sI8NkTMBLWj7 nRIoWVFFxp//9zr01rM6NxVQJErOC9wxtBCO6lYQc0lTUdHJaowEIC6MbKV8K1w4gRf2 iBL3qgb6PWBrnZF+5Daaa5C8SF9w5Fb18PEVDxGEnxesC+Gn+LSkrP3pz1JLitS0pQU3 eE0Ys7erHzksVilkR9xYyVBRd1waZ3G6Qc0D+tE6u7LuEGVkqsuLmKyjvjZ6blrmz8XV h0tw== X-Gm-Message-State: AOAM531IkQ4Y7rMrDJZNnG/b6lApT1RDYp1Sp86apcbBrtwZTy6XIQZB aLrH+f03wambftw5fIHLtpHhGQ== X-Google-Smtp-Source: ABdhPJzICCcB19A+6zdbe6pTjxw8Ds9LTGfoTk5pRvs2Hyesv8yxXG5NPFjKT/N5XQQ5IBGHCvmduw== X-Received: by 2002:a63:338b:: with SMTP id z133mr24379977pgz.442.1620648438464; Mon, 10 May 2021 05:07:18 -0700 (PDT) From: Daniel Axtens To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Subject: [PATCH] ppc/spapr: advertise secure boot in the guest device tree Date: Mon, 10 May 2021 22:07:13 +1000 Message-Id: <20210510120713.90053-1-dja@axtens.net> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 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=2607:f8b0:4864:20::430; envelope-from=dja@axtens.net; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: qemu-devel@nongnu.org, Daniel Axtens Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @axtens.net) Content-Type: text/plain; charset="utf-8" The ibm,secure-boot property of the / node determines how firmware and the operating system should enforce secure boot. The meaning of the various values are: 0 - secure boot is disabled 1 - secure boot in log-only mode 2 - secure boot enabled and enforced 3-9 - secure boot enabled and enforced; requirements at the discretion of the operating system We expose this as two properties: - secure-boot: determines whether the property is advertised in the guest device tree. The default is false. - secure-boot-level: what value is advertised if enabled? The default is 2. This doesn't make the firmware or OS actually _do_ any verification, it just advises them that they should. Signed-off-by: Daniel Axtens --- Linux already reads this property. Versions of SLOF and grub that do verification are available on my GitHub: - github.com/daxtens/SLOF branch ibm,secure-boot (not production ready!) - github.com/daxtens/grub branch appendedsig-2.06 --- hw/ppc/spapr.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 4 ++++ 2 files changed, 46 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3b1a5ed86518..544a412c3d18 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1157,6 +1157,20 @@ static void spapr_dt_hypervisor(SpaprMachineState *s= papr, void *fdt) } } =20 +static void spapr_dt_stb(SpaprMachineState *spapr, void *fdt) +{ + /* + * PowerVM may provide fw-secure-boot, which purports to tell a partit= ion + * if the underlying firmware was booted securely. It's not meaningful + * for KVM as there are no agreed semantics for what it would mean (ho= st + * secure boot only gives you integrity for the host kernel, not host + * qemu). So we omit the property for now. + */ + if (spapr->secure_boot) + _FDT(fdt_setprop_cell(fdt, 0, "ibm,secure-boot", + spapr->secure_boot_level)); +} + void *spapr_build_fdt(SpaprMachineState *spapr, bool reset, size_t space) { MachineState *machine =3D MACHINE(spapr); @@ -1263,6 +1277,9 @@ void *spapr_build_fdt(SpaprMachineState *spapr, bool = reset, size_t space) spapr_dt_hypervisor(spapr, fdt); } =20 + /* /ibm,secureboot */ + spapr_dt_stb(spapr, fdt); + /* Build memory reserve map */ if (reset) { if (spapr->kernel_size) { @@ -3298,6 +3315,20 @@ static void spapr_set_host_serial(Object *obj, const= char *value, Error **errp) spapr->host_serial =3D g_strdup(value); } =20 +static bool spapr_get_secure_boot(Object *obj, Error **errp) +{ + SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); + + return spapr->secure_boot; +} + +static void spapr_set_secure_boot(Object *obj, bool value, Error **errp) +{ + SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); + + spapr->secure_boot =3D value; +} + static void spapr_instance_init(Object *obj) { SpaprMachineState *spapr =3D SPAPR_MACHINE(obj); @@ -3353,6 +3384,17 @@ static void spapr_instance_init(Object *obj) spapr_get_host_serial, spapr_set_host_serial); object_property_set_description(obj, "host-serial", "Host serial number to advertise in guest device tree"); + + /* If we have secure boot, the default level is 2: enable and enforce = */ + spapr->secure_boot_level =3D 2; + object_property_add_bool(obj, "secure-boot", + spapr_get_secure_boot, spapr_set_secure_boot); + object_property_set_description(obj, "secure-boot", + "Advertise secure boot in the guest device tree"); + object_property_add_uint8_ptr(obj, "secure-boot-level", + &spapr->secure_boot_level, OBJ_PROP_FLAG_READWRITE); + object_property_set_description(obj, "secure-boot-level", + "Level of secure boot advertised in the guest device tree"); } =20 static void spapr_machine_finalizefn(Object *obj) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index c421410e3fb8..d829d0c27011 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -210,6 +210,10 @@ struct SpaprMachineState { int fwnmi_machine_check_interlock; QemuCond fwnmi_machine_check_interlock_cond; =20 + /* Secure Boot */ + bool secure_boot; + uint8_t secure_boot_level; + /*< public >*/ char *kvm_type; char *host_model; --=20 2.27.0