From nobody Thu Nov 6 06:17:05 2025 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; dkim=fail; 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=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539388437063992.5896025925584; Fri, 12 Oct 2018 16:53:57 -0700 (PDT) Received: from localhost ([::1]:43097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7Fj-0003Aq-W1 for importer@patchew.org; Fri, 12 Oct 2018 19:53:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7Ax-0008C3-P2 for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gB7Aq-0006UD-70 for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:48:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47376) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gB7Ao-0006Rw-2Z for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:48:52 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9CNjM0p088839 for ; Fri, 12 Oct 2018 23:48:47 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2mxnprndsu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Oct 2018 23:48:47 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9CNmlrK031014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Oct 2018 23:48:47 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9CNmk4Y012021 for ; Fri, 12 Oct 2018 23:48:46 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Oct 2018 23:48:46 +0000 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-2018-07-02; bh=JnfpJ59ei4jKYPZ43F5pZQc9Y/NkMlcLODcrBwMTuRs=; b=f3TtgTqH1i3B1kzUdExEaXZMPLcq9GmbKT/Bb6wmgCYddZm03cGejh+bCfTUvVnYc7ht ZCFVg43FlIquuALaJD7EneKU+wchcbWvBhsznDdgNJPxEe3t8dOjpEV23LS+Dkjjk1Mc p+LkUpXvDfej8r5rgPmfzDMIgPxE3xfmT0Wdd7P0wVCBIkqBIfgMBbxMa+7BoQ1RUoVI LGmbdBDz8mzgfnx2CtweEO2ug5wTZBcmtbEbQ63x4nmmfzdKVqXb4XZbs+zja4WPbjEi UpkAeBeR48tm5Xtq04Ds78hJPrDU+Zh6P6q01a0lF8RYQzJGAHWPAQ30a/JTTvpmUvNv yw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2018 19:48:32 -0400 Message-Id: <25dd2b74a8ddc16da84a89adcfbeabf21aa89d2e.1539387238.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=5900 definitions=9044 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 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-1807170000 definitions=main-1810120235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v1 5/8] multi-process QEMU: setup memory manager for remote device 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: elena.ufimtseva@oracle.com, john.g.johnson@oracle.com, jag.raman@oracle.com, Kanth.Ghatraju@oracle.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" - sync_sysmem_msg_t message format is defined. It is used to send file descriptors of the RAM regions to remote device - RAM on the remote device is configured with a set of file descriptors. Old RAM regions are deleted and new regions, each with an fd, is added to the RAM. Signed-off-by: Jagannathan Raman --- include/io/proxy-link.h | 9 +++++ include/remote/memory.h | 34 ++++++++++++++++++ remote/Makefile.objs | 1 + remote/memory.c | 93 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 137 insertions(+) create mode 100644 include/remote/memory.h create mode 100644 remote/memory.c diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 6ce6c10..1eeabae 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -39,6 +39,8 @@ typedef struct ProxyLinkState ProxyLinkState; #define PROXY_LINK(obj) \ OBJECT_CHECK(ProxyLinkState, (obj), TYPE_PROXY_LINK) =20 +#include "exec/hwaddr.h" + #define MAX_FDS 8 =20 #define PROC_HDR_SIZE offsetof(ProcMsg, data1.u64) @@ -47,16 +49,23 @@ typedef enum { INIT =3D 0, CONF_READ, CONF_WRITE, + SYNC_SYSMEM, MAX, } proc_cmd_t; =20 typedef struct { + hwaddr gpas[MAX_FDS]; + uint64_t sizes[MAX_FDS]; +} sync_sysmem_msg_t; + +typedef struct { proc_cmd_t cmd; int bytestream; size_t size; =20 union { uint64_t u64; + sync_sysmem_msg_t sync_sysmem; } data1; =20 int fds[MAX_FDS]; diff --git a/include/remote/memory.h b/include/remote/memory.h new file mode 100644 index 0000000..4500192 --- /dev/null +++ b/include/remote/memory.h @@ -0,0 +1,34 @@ +/* + * Memory manager for remote device + * + * Copyright 2018, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * 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 OT= HER + * 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_MEMORY_H +#define REMOTE_MEMORY_H + +#include "qemu/osdep.h" +#include "exec/hwaddr.h" +#include "io/proxy-link.h" + +void remote_sysmem_reconfig(ProcMsg *msg, Error **errp); + +#endif diff --git a/remote/Makefile.objs b/remote/Makefile.objs index e90ae20..c52d500 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1,2 +1,3 @@ remote-obj-y +=3D pcihost.o remote-obj-y +=3D machine.o +remote-obj-y +=3D memory.o diff --git a/remote/memory.c b/remote/memory.c new file mode 100644 index 0000000..f4cf2d2 --- /dev/null +++ b/remote/memory.c @@ -0,0 +1,93 @@ +/* + * Memory manager for remote device + * + * Copyright 2018, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * 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 OT= HER + * 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 + +#include "qemu/osdep.h" +#include "qemu/queue.h" +#include "qemu-common.h" +#include "remote/memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" +#include "cpu.h" +#include "exec/ram_addr.h" +#include "io/proxy-link.h" +#include "qemu/main-loop.h" + +static void remote_ram_destructor(MemoryRegion *mr) +{ + qemu_ram_free(mr->ram_block); +} + +static void remote_ram_init_from_fd(MemoryRegion *mr, int fd, uint64_t siz= e, + Error **errp) +{ + char *name; + + name =3D g_malloc(sizeof(int) + 1); + snprintf(name, sizeof(int) + 1, "%x", fd); + + memory_region_init(mr, NULL, name, size); + mr->ram =3D true; + mr->terminates =3D true; + mr->destructor =3D remote_ram_destructor; + mr->align =3D 0; + mr->ram_block =3D qemu_ram_alloc_from_fd(size, mr, false, fd, errp); + mr->dirty_log_mask =3D tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; + + g_free(name); +} + +void remote_sysmem_reconfig(ProcMsg *msg, Error **errp) +{ + MemoryRegion *sysmem, *subregion, *next; + int region; + sync_sysmem_msg_t *sysmem_info =3D &msg->data1.sync_sysmem; + + sysmem =3D get_system_memory(); + + qemu_mutex_lock_iothread(); + + memory_region_transaction_begin(); + + QTAILQ_FOREACH_SAFE(subregion, &sysmem->subregions, subregions_link, n= ext) { + if (subregion->ram) { + memory_region_del_subregion(sysmem, subregion); + /* TODO: should subregion be finalized separately? */ + } + } + + for (region =3D 0; region < msg->num_fds; region++) { + subregion =3D g_new(MemoryRegion, 1); + remote_ram_init_from_fd(subregion, msg->fds[region], + sysmem_info->sizes[region], errp); + memory_region_add_subregion(sysmem, sysmem_info->gpas[region], + subregion); + } + + memory_region_transaction_commit(); + + qemu_mutex_unlock_iothread(); +} --=20 1.8.3.1