From nobody Sat Apr 27 18:17:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538648582140985.6624560643039; Thu, 4 Oct 2018 03:23:02 -0700 (PDT) Received: from localhost ([::1]:54927 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g80ma-0007Em-SZ for importer@patchew.org; Thu, 04 Oct 2018 06:23:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g80kj-0005vX-NC for qemu-devel@nongnu.org; Thu, 04 Oct 2018 06:21:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g80XH-0002x4-9U for qemu-devel@nongnu.org; Thu, 04 Oct 2018 06:07:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38132) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g80XF-0002tT-Ab; Thu, 04 Oct 2018 06:07:11 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65D23C0587EE; Thu, 4 Oct 2018 10:07:06 +0000 (UTC) Received: from thuth.com (dhcp-200-199.str.redhat.com [10.33.200.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9267E1001F5D; Thu, 4 Oct 2018 10:07:05 +0000 (UTC) From: Thomas Huth To: David Gibson , qemu-ppc@nongnu.org Date: Thu, 4 Oct 2018 12:07:01 +0200 Message-Id: <1538647621-9376-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 04 Oct 2018 10:07:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] hw/ppc/spapr_rng: Introduce CONFIG_SPAPR_RNG switch for spapr_rng.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The spapr-rng device is suboptimal when compared to virtio-rng, so users might want to disable it in their builds. Thus let's introduce a proper CONFIG switch to allow us to compile QEMU without this device. Signed-off-by: Thomas Huth --- default-configs/ppc64-softmmu.mak | 1 + hw/ppc/Makefile.objs | 3 ++- hw/ppc/spapr.c | 3 ++- hw/ppc/spapr_rng.c | 24 +------------------- hw/ppc/spapr_rng.h | 48 +++++++++++++++++++++++++++++++++++= ++++ include/hw/ppc/spapr.h | 4 ---- 6 files changed, 54 insertions(+), 29 deletions(-) create mode 100644 hw/ppc/spapr_rng.h diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-soft= mmu.mak index b94af6c..24d4717 100644 --- a/default-configs/ppc64-softmmu.mak +++ b/default-configs/ppc64-softmmu.mak @@ -17,3 +17,4 @@ CONFIG_XICS=3D$(CONFIG_PSERIES) CONFIG_XICS_SPAPR=3D$(CONFIG_PSERIES) CONFIG_XICS_KVM=3D$(call land,$(CONFIG_PSERIES),$(CONFIG_KVM)) CONFIG_MEM_HOTPLUG=3Dy +CONFIG_SPAPR_RNG=3Dy diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs index 4ab5564..4e0c1c0 100644 --- a/hw/ppc/Makefile.objs +++ b/hw/ppc/Makefile.objs @@ -3,8 +3,9 @@ obj-y +=3D ppc.o ppc_booke.o fdt.o # IBM pSeries (sPAPR) obj-$(CONFIG_PSERIES) +=3D spapr.o spapr_caps.o spapr_vio.o spapr_events.o obj-$(CONFIG_PSERIES) +=3D spapr_hcall.o spapr_iommu.o spapr_rtas.o -obj-$(CONFIG_PSERIES) +=3D spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o +obj-$(CONFIG_PSERIES) +=3D spapr_pci.o spapr_rtc.o spapr_drc.o obj-$(CONFIG_PSERIES) +=3D spapr_cpu_core.o spapr_ovec.o spapr_irq.o +obj-$(CONFIG_SPAPR_RNG) +=3D spapr_rng.o # IBM PowerNV obj-$(CONFIG_POWERNV) +=3D pnv.o pnv_xscom.o pnv_core.o pnv_lpc.o pnv_psi.= o pnv_occ.o pnv_bmc.o ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 98868d8..ba40c85 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -53,9 +53,10 @@ #include "hw/ppc/fdt.h" #include "hw/ppc/spapr.h" #include "hw/ppc/spapr_vio.h" +#include "spapr_rng.h" + #include "hw/pci-host/spapr.h" #include "hw/pci/msi.h" - #include "hw/pci/pci.h" #include "hw/scsi/scsi.h" #include "hw/virtio/virtio-scsi.h" diff --git a/hw/ppc/spapr_rng.c b/hw/ppc/spapr_rng.c index d2acd61..dec8434 100644 --- a/hw/ppc/spapr_rng.c +++ b/hw/ppc/spapr_rng.c @@ -27,6 +27,7 @@ #include "sysemu/rng.h" #include "hw/ppc/spapr.h" #include "kvm_ppc.h" +#include "spapr_rng.h" =20 #define SPAPR_RNG(obj) \ OBJECT_CHECK(sPAPRRngState, (obj), TYPE_SPAPR_RNG) @@ -132,29 +133,6 @@ static void spapr_rng_realize(DeviceState *dev, Error = **errp) } } =20 -int spapr_rng_populate_dt(void *fdt) -{ - int node; - int ret; - - node =3D qemu_fdt_add_subnode(fdt, "/ibm,platform-facilities"); - if (node <=3D 0) { - return -1; - } - ret =3D fdt_setprop_string(fdt, node, "device_type", - "ibm,platform-facilities"); - ret |=3D fdt_setprop_cell(fdt, node, "#address-cells", 0x1); - ret |=3D fdt_setprop_cell(fdt, node, "#size-cells", 0x0); - - node =3D fdt_add_subnode(fdt, node, "ibm,random-v1"); - if (node <=3D 0) { - return -1; - } - ret |=3D fdt_setprop_string(fdt, node, "compatible", "ibm,random"); - - return ret ? -1 : 0; -} - static Property spapr_rng_properties[] =3D { DEFINE_PROP_BOOL("use-kvm", sPAPRRngState, use_kvm, false), DEFINE_PROP_LINK("rng", sPAPRRngState, backend, TYPE_RNG_BACKEND, diff --git a/hw/ppc/spapr_rng.h b/hw/ppc/spapr_rng.h new file mode 100644 index 0000000..1d5fdcb --- /dev/null +++ b/hw/ppc/spapr_rng.h @@ -0,0 +1,48 @@ +/* + * QEMU sPAPR random number generator "device" for H_RANDOM hypercall + * + * Copyright 2015 Thomas Huth, Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef SPAPR_RNG_H +#define SPAPR_RNG_H + +#define TYPE_SPAPR_RNG "spapr-rng" + +static inline int spapr_rng_populate_dt(void *fdt) +{ + int node; + int ret; + + node =3D qemu_fdt_add_subnode(fdt, "/ibm,platform-facilities"); + if (node <=3D 0) { + return -1; + } + ret =3D fdt_setprop_string(fdt, node, "device_type", + "ibm,platform-facilities"); + ret |=3D fdt_setprop_cell(fdt, node, "#address-cells", 0x1); + ret |=3D fdt_setprop_cell(fdt, node, "#size-cells", 0x0); + + node =3D fdt_add_subnode(fdt, node, "ibm,random-v1"); + if (node <=3D 0) { + return -1; + } + ret |=3D fdt_setprop_string(fdt, node, "compatible", "ibm,random"); + + return ret ? -1 : 0; +} + +#endif diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index ad4d7cf..9460c46 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -743,10 +743,6 @@ void spapr_lmb_release(DeviceState *dev); void spapr_rtc_read(sPAPRRTCState *rtc, struct tm *tm, uint32_t *ns); int spapr_rtc_import_offset(sPAPRRTCState *rtc, int64_t legacy_offset); =20 -#define TYPE_SPAPR_RNG "spapr-rng" - -int spapr_rng_populate_dt(void *fdt); - #define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */ =20 /* --=20 1.8.3.1