From nobody Fri Dec 19 15:58:15 2025 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1657197469; cv=none; d=zohomail.com; s=zohoarc; b=hN09fZv+Pms8ZUmmjwWyKm31idEaA21Trh83w11pijTohANmPGMweZhchiyorASDgaOsPxbT4Ube9XCx0wKiDPIRIN8M3cde1rEfRZr/gCLTVEzM99RtFNVFimj4Rx9CxkYmmtx/yopBPs+WYk3hcmRFeVtRbD8EhL/Ru1s37y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657197469; h=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=A1Q2JKEPW4FUywVz3aNzReARCY9uYbuNteUss9UEJ04=; b=SHoOM0LpidwzeGruitK447gqpXIo9Tsdb4juI6zf0lp2r1SJGTTcRdGfjudc/OLnabtsu9yMn9yx9wapqP9yWnU37TelO2QLih7gG8Zd8c1uASSvL06YkFewUrn5aLexdCAlz1tcw/qR/gKts/TNjWwCdRyMr5RQdsni5VeQRbE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657197469472737.9402677335007; Thu, 7 Jul 2022 05:37:49 -0700 (PDT) Received: from localhost ([::1]:48606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9QlQ-0001sg-C3 for importer@patchew.org; Thu, 07 Jul 2022 08:37:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9Qbd-0007h1-Ve for qemu-devel@nongnu.org; Thu, 07 Jul 2022 08:27:41 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:40466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9Qbb-0006vC-2D for qemu-devel@nongnu.org; Thu, 07 Jul 2022 08:27:40 -0400 Received: by mail-wr1-x42e.google.com with SMTP id z12so16480529wrq.7 for ; Thu, 07 Jul 2022 05:27:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id r16-20020a05600c35d000b003a0375c4f73sm29177618wmq.44.2022.07.07.05.27.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 05:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=A1Q2JKEPW4FUywVz3aNzReARCY9uYbuNteUss9UEJ04=; b=sxzhwwaA261wS5wkrMUGNdhLz7Vg2quRnngFC8nSLDRs/VNKvy9SrN/hKP6igCE9HL 9n7N5X0jRjQgR2Ps6cMyfY9ZBwKE+2Hj5oGqburRhCSACRsfT4e24JjVt/fPRQNrn1Eb LNRcxKDrRPpoNTXv7sIqp0ffO+U/QOktZctLC7g7gaV7OoClBg/m4HmtV5CzoNokajq+ vuM0Xc8QpCZWMPsPQR/3meslA9J3YIMoBiWE/bvc4B1MAI7J3orWJyrGH3NRJcttkiHj gcYlWTA/xQW74Ps1fGtOTkqQtg8RNpIUCnbfLKVrW1Tyit3gAZ52tfakJHKYVD71y5iL M+0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A1Q2JKEPW4FUywVz3aNzReARCY9uYbuNteUss9UEJ04=; b=V/5OB8vVdsfEj6IropmQSOE1cJ/4EttJqp1mO/NsgOknIqY5V8XeGrfr6PrDWihSMD hqXpYk1DIxxe2cAEjfdm8UW6sTs+GdgtMoAUuP69rWqun9C5BRSkZh9QGXRqj8UE+lmS 3MkBQRZCnz1f62uiFWJ9kI8UA5Dpr7t6Bby1IRrket3t9XZSXil4T5KQ5qprwcTjp1ta JVHf9W4Inewfi7aQuerjqlwtNJZzAiEeJ5gQuHe4uoJ0fMf9aFONsfd59UImkhR0z1W9 ze0fLtW+7ntBKkawvzLbtHotEYVGDVHFflqE8JmyuSv94vBSAdtEl4UYmN1dLDNmu2Wd mwbQ== X-Gm-Message-State: AJIora/5qMVmx7HDJMfN7YthLbdHETeoq47aM6u92T8MNGyZ9LRBeKQK PWD94BmtZxZHo5JNP5rmiXqKpETgERBXWQ== X-Google-Smtp-Source: AGRyM1sLXwf+bFW4lsDSGhClIGFD4Cus8qeg1kXJgYBZ2wgh1pTCMeRq/DDq6M3uGGCXRPApbkk2aQ== X-Received: by 2002:adf:f345:0:b0:21d:6927:ec8f with SMTP id e5-20020adff345000000b0021d6927ec8fmr21580522wrp.490.1657196857225; Thu, 07 Jul 2022 05:27:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/9] hw/arm/virt: dt: add rng-seed property Date: Thu, 7 Jul 2022 13:27:26 +0100 Message-Id: <20220707122734.288929-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707122734.288929-1-peter.maydell@linaro.org> References: <20220707122734.288929-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.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, T_SCC_BODY_TEXT_LINE=-0.01, WEIRD_QUOTING=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1657197471750100001 Content-Type: text/plain; charset="utf-8" From: "Jason A. Donenfeld" In 60592cfed2 ("hw/arm/virt: dt: add kaslr-seed property"), the kaslr-seed property was added, but the equally as important rng-seed property was forgotten about, which has identical semantics for a similar purpose. This commit implements it in exactly the same way as kaslr-seed. It then changes the name of the disabling option to reflect that this has more to do with randomness vs determinism, rather than something particular about kaslr. Cc: Peter Maydell Signed-off-by: Jason A. Donenfeld [PMM: added deprecated.rst section for the deprecation] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- docs/about/deprecated.rst | 8 +++++++ docs/system/arm/virt.rst | 17 +++++++++------ include/hw/arm/virt.h | 2 +- hw/arm/virt.c | 44 ++++++++++++++++++++++++--------------- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 19a91b575fb..7ee26626d5c 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -225,6 +225,14 @@ Use the more generic event ``DEVICE_UNPLUG_GUEST_ERROR= `` instead. System emulator machines ------------------------ =20 +Arm ``virt`` machine ``dtb-kaslr-seed`` property +'''''''''''''''''''''''''''''''''''''''''''''''' + +The ``dtb-kaslr-seed`` property on the ``virt`` board has been +deprecated; use the new name ``dtb-randomness`` instead. The new name +better reflects the way this property affects all random data within +the device tree blob, not just the ``kaslr-seed`` node. + PPC 405 ``taihu`` machine (since 7.0) ''''''''''''''''''''''''''''''''''''' =20 diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst index 3d1058a80c0..3b6ba69a9a9 100644 --- a/docs/system/arm/virt.rst +++ b/docs/system/arm/virt.rst @@ -126,13 +126,18 @@ ras Set ``on``/``off`` to enable/disable reporting host memory errors to a g= uest using ACPI and guest external abort exceptions. The default is off. =20 +dtb-randomness + Set ``on``/``off`` to pass random seeds via the guest DTB + rng-seed and kaslr-seed nodes (in both "/chosen" and + "/secure-chosen") to use for features like the random number + generator and address space randomisation. The default is + ``on``. You will want to disable it if your trusted boot chain + will verify the DTB it is passed, since this option causes the + DTB to be non-deterministic. It would be the responsibility of + the firmware to come up with a seed and pass it on if it wants to. + dtb-kaslr-seed - Set ``on``/``off`` to pass a random seed via the guest dtb - kaslr-seed node (in both "/chosen" and /secure-chosen) to use - for features like address space randomisation. The default is - ``on``. You will want to disable it if your trusted boot chain will - verify the DTB it is passed. It would be the responsibility of the - firmware to come up with a seed and pass it on if it wants to. + A deprecated synonym for dtb-randomness. =20 Linux guest kernel configuration """""""""""""""""""""""""""""""" diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 15feabac63d..6ec479ca2b7 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -152,7 +152,7 @@ struct VirtMachineState { bool virt; bool ras; bool mte; - bool dtb_kaslr_seed; + bool dtb_randomness; OnOffAuto acpi; VirtGICType gic_version; VirtIOMMUType iommu; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 5502aa60c83..9633f822f36 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -221,14 +221,18 @@ static bool cpu_type_valid(const char *cpu) return false; } =20 -static void create_kaslr_seed(MachineState *ms, const char *node) +static void create_randomness(MachineState *ms, const char *node) { - uint64_t seed; + struct { + uint64_t kaslr; + uint8_t rng[32]; + } seed; =20 if (qemu_guest_getrandom(&seed, sizeof(seed), NULL)) { return; } - qemu_fdt_setprop_u64(ms->fdt, node, "kaslr-seed", seed); + qemu_fdt_setprop_u64(ms->fdt, node, "kaslr-seed", seed.kaslr); + qemu_fdt_setprop(ms->fdt, node, "rng-seed", seed.rng, sizeof(seed.rng)= ); } =20 static void create_fdt(VirtMachineState *vms) @@ -251,14 +255,14 @@ static void create_fdt(VirtMachineState *vms) =20 /* /chosen must exist for load_dtb to fill in necessary properties lat= er */ qemu_fdt_add_subnode(fdt, "/chosen"); - if (vms->dtb_kaslr_seed) { - create_kaslr_seed(ms, "/chosen"); + if (vms->dtb_randomness) { + create_randomness(ms, "/chosen"); } =20 if (vms->secure) { qemu_fdt_add_subnode(fdt, "/secure-chosen"); - if (vms->dtb_kaslr_seed) { - create_kaslr_seed(ms, "/secure-chosen"); + if (vms->dtb_randomness) { + create_randomness(ms, "/secure-chosen"); } } =20 @@ -2340,18 +2344,18 @@ static void virt_set_its(Object *obj, bool value, E= rror **errp) vms->its =3D value; } =20 -static bool virt_get_dtb_kaslr_seed(Object *obj, Error **errp) +static bool virt_get_dtb_randomness(Object *obj, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - return vms->dtb_kaslr_seed; + return vms->dtb_randomness; } =20 -static void virt_set_dtb_kaslr_seed(Object *obj, bool value, Error **errp) +static void virt_set_dtb_randomness(Object *obj, bool value, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - vms->dtb_kaslr_seed =3D value; + vms->dtb_randomness =3D value; } =20 static char *virt_get_oem_id(Object *obj, Error **errp) @@ -2980,12 +2984,18 @@ static void virt_machine_class_init(ObjectClass *oc= , void *data) "Set on/off to enable/disable " "ITS instantiation"); =20 + object_class_property_add_bool(oc, "dtb-randomness", + virt_get_dtb_randomness, + virt_set_dtb_randomness); + object_class_property_set_description(oc, "dtb-randomness", + "Set off to disable passing rand= om or " + "non-deterministic dtb nodes to = guest"); + object_class_property_add_bool(oc, "dtb-kaslr-seed", - virt_get_dtb_kaslr_seed, - virt_set_dtb_kaslr_seed); + virt_get_dtb_randomness, + virt_set_dtb_randomness); object_class_property_set_description(oc, "dtb-kaslr-seed", - "Set off to disable passing of k= aslr-seed " - "dtb node to guest"); + "Deprecated synonym of dtb-rando= mness"); =20 object_class_property_add_str(oc, "x-oem-id", virt_get_oem_id, @@ -3053,8 +3063,8 @@ static void virt_instance_init(Object *obj) /* MTE is disabled by default. */ vms->mte =3D false; =20 - /* Supply a kaslr-seed by default */ - vms->dtb_kaslr_seed =3D true; + /* Supply kaslr-seed and rng-seed by default */ + vms->dtb_randomness =3D true; =20 vms->irqmap =3D a15irqmap; =20 --=20 2.25.1