From nobody Sat May 18 16:46:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1603875745; cv=none; d=zohomail.com; s=zohoarc; b=SII6Z69Srn4wcQmNSbbLRaFTRdRMpLKuCS3RHgu8fHXtsF6q2Z/67KA3DQbLx83Z/2xIRZ/5wf3L730ZVZ637sG0+oiqny0CFq43Ywu/hhyvt6Jdp5FRS5r9aHDUjGrTkRoxNIWHfoN10Z6KwGBgH1f1f7Vx3EEwMp9EEOFT5/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603875745; h=Content-Type: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=9KzxZphh5qorAZCm7OOtB/tI3KN6E0kQQ+xEwkJpWxM=; b=Oy6o4mzr/x1xBftryxKPSSOFnj3b0uRP5ce0F1rR9qzSu778HT7mXRPnTqHJcCV3uDdYhJnHqSJ217uzG+K1gVfCKmKbVWiDPrz2nyBEKl19p0PyYgl68sFWjoSlS8S/KhWiwfZFMOuF2S90N5X2uvWo+4X93VJ+YQWupbFeTc4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603875745253975.5799315500165; Wed, 28 Oct 2020 02:02:25 -0700 (PDT) Received: from localhost ([::1]:60052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXhLb-0008Lq-Ik for importer@patchew.org; Wed, 28 Oct 2020 05:02:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXhJ1-0007Nz-Ul for qemu-devel@nongnu.org; Wed, 28 Oct 2020 04:59:43 -0400 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]:46431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kXhIz-0008Ml-Te for qemu-devel@nongnu.org; Wed, 28 Oct 2020 04:59:43 -0400 Received: by mail-lj1-x242.google.com with SMTP id 2so5127413ljj.13 for ; Wed, 28 Oct 2020 01:59:40 -0700 (PDT) Received: from localhost.localdomain (37-145-124-43.broadband.corbina.ru. [37.145.124.43]) by smtp.gmail.com with ESMTPSA id l3sm521719lji.36.2020.10.28.01.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 01:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9KzxZphh5qorAZCm7OOtB/tI3KN6E0kQQ+xEwkJpWxM=; b=CAsGSljuJw3uvCLpvtA92Xycjxof9qcDxt2mv6LrlQ5QWNxzi0rwe7GoLD7Z9RQeoI ge2CRd518VBBe704wYLGYwW/VvnbQqh+Pknt/sFcL7Mf8iSQVpTfindehsgJK98i4Cf5 9l3uUNMMTBbAyy91UbDGTLo2rviLZE8P7ZmnLL9/p4aMxBOf+kfHKKCU9PvGulYGA6z/ wII+T1b5U/LdlCXwzZAS5DevaIoThhTpI+6GbLTu0Dx/4p68NeAFaupCWUFLWQKJM6yz htamPTcxkhAhDHqnpiy5akCEdfo8hpl5yGiM2FVz/ZMkRLfB7wkVSUB1AUcahA7BcW7e 205A== 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=9KzxZphh5qorAZCm7OOtB/tI3KN6E0kQQ+xEwkJpWxM=; b=bO9Y96hoqhuWej5GN3/H4VtZnECrSMB2db9UImSXRpD6z5Lp8oqDmVbiy2nkU+kDPv JsMnprYG3RRDJWPpHtrYDwIkQtAxSrKZhW3wGAuwcZ2gCphV+P43t5DP+9Sq1ppuwpVE kXR80m33K3q8QFwTYBaQOH/Skj6x2RyvF8SIkGDB49cX4mwiZR4cF0CUj1c1kj31mxhL Z4TaHBYjYGll3Le27pjciI7sFvDIF6FzAkSRKZj115dClRvrCXoRXH8DPbC16BS98s42 41r6Pw/OZRoKrOaFZyxenuRGo1xKNAXOlZpWOhzLdrnXokOZ81RH8EsrCnAWO/f8B62A liWg== X-Gm-Message-State: AOAM532hyukduvbPYqYourAdNX4Qt9kY+LVqQEjV3+2JSYtZ2RtvRrQC KV/1ho1M80OZYRv6apyJVE+HZw== X-Google-Smtp-Source: ABdhPJzWJrosHWaikvLP3KEh9e3UgnNGGsB3BhffeaUV0l4ZFay1uHHlUhy0/+IDIr9YQcIBzF2kdg== X-Received: by 2002:a2e:884d:: with SMTP id z13mr597254ljj.413.1603875578430; Wed, 28 Oct 2020 01:59:38 -0700 (PDT) From: Maxim Uvarov To: qemu-arm@nongnu.org Subject: [RFC PATCH] hw/arm/virt: use sbsa-ec for reboot and poweroff in secure mode Date: Wed, 28 Oct 2020 11:59:18 +0300 Message-Id: <20201028085918.14580-1-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::242; envelope-from=maxim.uvarov@linaro.org; helo=mail-lj1-x242.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: peter.maydell@linaro.org, francois.ozog@linaro.org, qemu-devel@nongnu.org, Maxim Uvarov , tf-a@lists.trustedfirmware.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) If we're emulating EL3 then the EL3 guest firmware is responsible for providing the PSCI ABI, including reboot, core power down, etc. sbsa-ref machine has an embedded controller to do reboot, poweroff. Machine virt,secure=3Don can reuse this code to do reboot inside ATF. Signed-off-by: Maxim Uvarov --- Hello, This patch implements reboot for the secure machine inside ATF firmware. I= .e. current qemu =C2=A0patch should be used with [1] ATF patch. It looks like that Embedded = Controller qemu =C2=A0driver (sbsa-ec) can be common and widely used for other emulated mac= hines. While if =C2=A0there are plans to extend sbsa-ec then we might find some other solut= ion. =C2=A0So for the long term it looks like machine virt was used as an initia= l playground for secure firmware.=C2=A0=C2=A0While the original intent was a runner for kvm guests= . Relation between kvm guest and firmware=C2=A0=C2=A0is not very clear now. If everyone agree it might = be good solution to move secure firmware things=C2=A0from virt machine to bsa-ref and make this machine re= ference for secure boot, firmware updates=C2=A0=C2=A0etc. [1] https://github.com/muvarov/arm-trusted-firmware/commit/6d3339a0081f6f2= b45d99bd7e1b67bcbce8f4e0e Best regards, Maxim. hw/arm/virt.c | 9 +++++++++ include/hw/arm/virt.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index e465a988d6..6b77912f02 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -152,6 +152,7 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_ACPI_GED] =3D { 0x09080000, ACPI_GED_EVT_SEL_LEN }, [VIRT_NVDIMM_ACPI] =3D { 0x09090000, NVDIMM_ACPI_IO_LEN}, [VIRT_PVTIME] =3D { 0x090a0000, 0x00010000 }, + [VIRT_EC] =3D { 0x090c0000, 0x00001000 }, [VIRT_MMIO] =3D { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that siz= e */ [VIRT_PLATFORM_BUS] =3D { 0x0c000000, 0x02000000 }, @@ -1729,6 +1730,13 @@ static void virt_cpu_post_init(VirtMachineState *vms= , int max_cpus, } } =20 +static void init_ec_controller(VirtMachineState *vms) +{ + vms->ec =3D qdev_new("sbsa-ec"); + + sysbus_mmio_map(SYS_BUS_DEVICE(vms->ec), 0, vms->memmap[VIRT_EC].base); +} + static void machvirt_init(MachineState *machine) { VirtMachineState *vms =3D VIRT_MACHINE(machine); @@ -1797,6 +1805,7 @@ static void machvirt_init(MachineState *machine) */ if (vms->secure && firmware_loaded) { vms->psci_conduit =3D QEMU_PSCI_CONDUIT_DISABLED; + init_ec_controller(vms); } else if (vms->virt) { vms->psci_conduit =3D QEMU_PSCI_CONDUIT_SMC; } else { diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index aad6d69841..6f2ce4e4ff 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -85,6 +85,7 @@ enum { VIRT_ACPI_GED, VIRT_NVDIMM_ACPI, VIRT_PVTIME, + VIRT_EC, VIRT_LOWMEMMAP_LAST, }; =20 @@ -163,6 +164,7 @@ struct VirtMachineState { DeviceState *gic; DeviceState *acpi_dev; Notifier powerdown_notifier; + DeviceState *ec; }; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.17.1