From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 468A8CA9EAF for ; Thu, 24 Oct 2019 09:18:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 11D0E205F4 for ; Thu, 24 Oct 2019 09:18:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="POX867tI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11D0E205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNZGG-0000Py-G1 for qemu-devel@archiver.kernel.org; Thu, 24 Oct 2019 05:18:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43632) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNZ8R-0005mU-JU for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:10:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNZ8P-0003vt-Hh for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:10:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNZ8N-0003to-Fw for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:10:21 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9O94W41116471; Thu, 24 Oct 2019 09:10:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=corp-2019-08-05; bh=oTKvfV0Lq4NRImdyTqVejIX9eQAO5e1RcIUXCvxfH9M=; b=POX867tIERsIh8cR7NfU1fdhfINwuCqkcwZkXKd2vkEUr9Q5x2B/9JPE28BpEbXlIXSA ERVBYf8e0oI2SnKtnxPfWuUw4dALjU/vv2KTPzMmFJnNgTmo0uCVfsizFjAkavyrKeW5 Mt6RMdn3nZxC9XULG+2Tnh4Onu3dYEM1vSYe9lHrAcHuF0lHUkNNM/laihYhnBHOqElh bfz/fqLpMAxBkzrAJWLSiRtRNiW3zjUp2OR1dVjIv16aFsJ+0swQQru5FtVL31kBCGyz OtPFv1rKtse5KQctVHLNg4jYQ/AauWwjKh2jPEMRMyhFaViSgGk4iYdZt5alj3oXcDqb IA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2vqswttdx4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 09:10:13 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9O98ndQ076254; Thu, 24 Oct 2019 09:10:13 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2vtjkj2wdp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 09:10:13 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x9O9AAKP011533; Thu, 24 Oct 2019 09:10:10 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Oct 2019 02:10:09 -0700 From: Jagannathan Raman To: qemu-devel@nongnu.org Subject: [RFC v4 PATCH 09/49] multi-process: setup PCI host bridge for remote device Date: Thu, 24 Oct 2019 05:08:50 -0400 Message-Id: <21b8d0f06279f177f2daca8779ced48af14139ee.1571905346.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240089 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240089 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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: elena.ufimtseva@oracle.com, fam@euphon.net, john.g.johnson@oracle.com, kraxel@redhat.com, jag.raman@oracle.com, quintela@redhat.com, mst@redhat.com, armbru@redhat.com, kanth.ghatraju@oracle.com, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.com, rth@twiddle.net, kwolf@redhat.com, berrange@redhat.com, mreitz@redhat.com, ross.lagerwall@citrix.com, marcandre.lureau@gmail.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" PCI host bridge is setup for the remote device process. It is implemented using remote-pcihost object. It is an extension of the PCI host bridge setup by QEMU. Remote-pcihost configures a PCI bus which could be used by the remote PCI device to latch on to. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- hw/pci/Makefile.objs | 2 +- include/remote/pcihost.h | 59 +++++++++++++++++++++++++++++++++ remote/Makefile.objs | 1 + remote/pcihost.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 include/remote/pcihost.h create mode 100644 remote/pcihost.c diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs index 955be54..90693a7 100644 --- a/hw/pci/Makefile.objs +++ b/hw/pci/Makefile.objs @@ -13,6 +13,6 @@ common-obj-$(CONFIG_PCI_EXPRESS) += pcie_port.o pcie_host.o common-obj-$(call lnot,$(CONFIG_PCI)) += pci-stub.o common-obj-$(CONFIG_ALL) += pci-stub.o -remote-pci-obj-$(CONFIG_MPQEMU) += pci.o pci_bridge.o +remote-pci-obj-$(CONFIG_MPQEMU) += pci.o pci_bridge.o pci_host.o pcie_host.o remote-pci-obj-$(CONFIG_MPQEMU) += msi.o msix.o remote-pci-obj-$(CONFIG_MPQEMU) += pcie.o diff --git a/include/remote/pcihost.h b/include/remote/pcihost.h new file mode 100644 index 0000000..b3c711d --- /dev/null +++ b/include/remote/pcihost.h @@ -0,0 +1,59 @@ +/* + * PCI Host for remote device + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef REMOTE_PCIHOST_H +#define REMOTE_PCIHOST_H + +#include +#include + +#include "exec/memory.h" +#include "hw/pci/pcie_host.h" + +#define TYPE_REMOTE_HOST_DEVICE "remote-pcihost" +#define REMOTE_HOST_DEVICE(obj) \ + OBJECT_CHECK(RemPCIHost, (obj), TYPE_REMOTE_HOST_DEVICE) + +typedef struct RemPCIHost { + /*< private >*/ + PCIExpressHost parent_obj; + /*< public >*/ + + /* + * Memory Controller Hub (MCH) may not be necessary for the emulation + * program. The two important reasons for implementing a PCI host in the + * emulation program are: + * - Provide a PCI bus for IO devices + * - Enable translation of guest PA to the PCI bar regions + * + * For both the above mentioned purposes, it doesn't look like we would + * need the MCH + */ + + MemoryRegion *mr_pci_mem; + MemoryRegion *mr_sys_mem; + MemoryRegion *mr_sys_io; +} RemPCIHost; + +#endif diff --git a/remote/Makefile.objs b/remote/Makefile.objs index a9b2256..2757f5a 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1 +1,2 @@ remote-pci-obj-$(CONFIG_MPQEMU) += remote-main.o +remote-pci-obj-$(CONFIG_MPQEMU) += pcihost.o diff --git a/remote/pcihost.c b/remote/pcihost.c new file mode 100644 index 0000000..0f43057 --- /dev/null +++ b/remote/pcihost.c @@ -0,0 +1,85 @@ +/* + * Remote PCI host device + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_host.h" +#include "hw/pci/pcie_host.h" +#include "hw/qdev-properties.h" +#include "remote/pcihost.h" +#include "exec/memory.h" + +static const char *remote_host_root_bus_path(PCIHostState *host_bridge, + PCIBus *rootbus) +{ + return "0000:00"; +} + +static void remote_host_realize(DeviceState *dev, Error **errp) +{ + PCIHostState *pci = PCI_HOST_BRIDGE(dev); + RemPCIHost *s = REMOTE_HOST_DEVICE(dev); + + /* + * TODO: the name of the bus would be provided by QEMU. Use + * "pcie.0" for now. + */ + pci->bus = pci_root_bus_new(DEVICE(s), "pcie.0", + s->mr_pci_mem, s->mr_sys_io, + 0, TYPE_PCIE_BUS); +} + +static Property remote_host_props[] = { + DEFINE_PROP_END_OF_LIST(), +}; + +static void remote_host_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass); + + hc->root_bus_path = remote_host_root_bus_path; + dc->realize = remote_host_realize; + dc->props = remote_host_props; + + dc->user_creatable = false; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->fw_name = "pci"; +} + +static const TypeInfo remote_host_info = { + .name = TYPE_REMOTE_HOST_DEVICE, + .parent = TYPE_PCIE_HOST_BRIDGE, + .instance_size = sizeof(RemPCIHost), + .class_init = remote_host_class_init, +}; + +static void remote_machine_register(void) +{ + type_register_static(&remote_host_info); +} + +type_init(remote_machine_register) -- 1.8.3.1