[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 20/36] multi-process: Forward PCI config space acceses to the
From: |
elena . ufimtseva |
Subject: |
[PATCH v6 20/36] multi-process: Forward PCI config space acceses to the remote process |
Date: |
Mon, 6 Apr 2020 02:41:10 -0700 |
From: Elena Ufimtseva <address@hidden>
The Proxy Object sends the PCI config space accesses as messages
to the remote process over the communication channel
Signed-off-by: Elena Ufimtseva <address@hidden>
Signed-off-by: Jagannathan Raman <address@hidden>
Signed-off-by: John G Johnson <address@hidden>
---
hw/proxy/qemu-proxy.c | 61 ++++++++++++++++++++++++++++++++++++++++
include/io/mpqemu-link.h | 8 ++++++
io/mpqemu-link.c | 6 ++++
remote/remote-main.c | 32 +++++++++++++++++++++
4 files changed, 107 insertions(+)
diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c
index 9b5e429a88..87cf39c672 100644
--- a/hw/proxy/qemu-proxy.c
+++ b/hw/proxy/qemu-proxy.c
@@ -14,6 +14,65 @@
#include "hw/proxy/qemu-proxy.h"
#include "hw/pci/pci.h"
+static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, int
l,
+ unsigned int op)
+{
+ MPQemuMsg msg;
+ struct conf_data_msg conf_data;
+ int wait;
+
+ memset(&msg, 0, sizeof(MPQemuMsg));
+ conf_data.addr = addr;
+ conf_data.val = (op == PCI_CONFIG_WRITE) ? *val : 0;
+ conf_data.l = l;
+
+ msg.data2 = (uint8_t *)&conf_data;
+ if (!msg.data2) {
+ return -ENOMEM;
+ }
+
+ msg.size = sizeof(conf_data);
+ msg.cmd = op;
+ msg.bytestream = 1;
+
+ if (op == PCI_CONFIG_WRITE) {
+ msg.num_fds = 0;
+ } else {
+ /* TODO: Dont create fd each time for send. */
+ wait = GET_REMOTE_WAIT;
+ msg.num_fds = 1;
+ msg.fds[0] = wait;
+ }
+
+ mpqemu_msg_send(&msg, dev->mpqemu_link->dev);
+
+ if (op == PCI_CONFIG_READ) {
+ *val = (uint32_t)wait_for_remote(wait);
+ PUT_REMOTE_WAIT(wait);
+ }
+
+ return 0;
+}
+
+static uint32_t pci_proxy_read_config(PCIDevice *d, uint32_t addr, int len)
+{
+ uint32_t val;
+
+ (void)pci_default_read_config(d, addr, len);
+
+ config_op_send(PCI_PROXY_DEV(d), addr, &val, len, PCI_CONFIG_READ);
+
+ return val;
+}
+
+static void pci_proxy_write_config(PCIDevice *d, uint32_t addr, uint32_t val,
+ int l)
+{
+ pci_default_write_config(d, addr, val, l);
+
+ config_op_send(PCI_PROXY_DEV(d), addr, &val, l, PCI_CONFIG_WRITE);
+}
+
static void proxy_set_socket(Object *obj, const char *str, Error **errp)
{
PCIProxyDev *pdev = PCI_PROXY_DEV(obj);
@@ -86,6 +145,8 @@ static void pci_proxy_dev_class_init(ObjectClass *klass,
void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->realize = pci_proxy_dev_realize;
+ k->config_read = pci_proxy_read_config;
+ k->config_write = pci_proxy_write_config;
}
static const TypeInfo pci_proxy_dev_type_info = {
diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h
index ebae9afc45..7228a1915e 100644
--- a/include/io/mpqemu-link.h
+++ b/include/io/mpqemu-link.h
@@ -39,9 +39,17 @@ typedef enum {
INIT = 0,
SYNC_SYSMEM,
CONNECT_DEV,
+ PCI_CONFIG_WRITE,
+ PCI_CONFIG_READ,
MAX,
} mpqemu_cmd_t;
+struct conf_data_msg {
+ uint32_t addr;
+ uint32_t val;
+ int l;
+};
+
typedef struct {
hwaddr gpas[REMOTE_MAX_FDS];
uint64_t sizes[REMOTE_MAX_FDS];
diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c
index b395869a22..643c0588ce 100644
--- a/io/mpqemu-link.c
+++ b/io/mpqemu-link.c
@@ -361,6 +361,12 @@ bool mpqemu_msg_valid(MPQemuMsg *msg)
return false;
}
break;
+ case PCI_CONFIG_WRITE:
+ case PCI_CONFIG_READ:
+ if (msg->size != sizeof(struct conf_data_msg)) {
+ return false;
+ }
+ break;
default:
break;
}
diff --git a/remote/remote-main.c b/remote/remote-main.c
index 22319cb5ea..b5ed31f63b 100644
--- a/remote/remote-main.c
+++ b/remote/remote-main.c
@@ -41,6 +41,32 @@ static MPQemuLinkState *mpqemu_link;
#define LINK_TO_DEV(link) ((PCIDevice *)link->opaque)
+static void process_config_write(PCIDevice *dev, MPQemuMsg *msg)
+{
+ struct conf_data_msg *conf = (struct conf_data_msg *)msg->data2;
+
+ qemu_mutex_lock_iothread();
+ pci_default_write_config(dev, conf->addr, conf->val, conf->l);
+ qemu_mutex_unlock_iothread();
+}
+
+static void process_config_read(PCIDevice *dev, MPQemuMsg *msg)
+{
+ struct conf_data_msg *conf = (struct conf_data_msg *)msg->data2;
+ uint32_t val;
+ int wait;
+
+ wait = msg->fds[0];
+
+ qemu_mutex_lock_iothread();
+ val = pci_default_read_config(dev, conf->addr, conf->l);
+ qemu_mutex_unlock_iothread();
+
+ notify_proxy(wait, val);
+
+ PUT_REMOTE_WAIT(wait);
+}
+
static gpointer dev_thread(gpointer data)
{
MPQemuLinkState *link = data;
@@ -99,6 +125,12 @@ static void process_msg(GIOCondition cond, MPQemuLinkState
*link,
case CONNECT_DEV:
process_connect_dev_msg(msg);
break;
+ case PCI_CONFIG_WRITE:
+ process_config_write(LINK_TO_DEV(link), msg);
+ break;
+ case PCI_CONFIG_READ:
+ process_config_read(LINK_TO_DEV(link), msg);
+ break;
default:
error_setg(&err, "Unknown command");
goto finalize_loop;
--
2.25.GIT
- Re: [PATCH v6 16/36] multi-process: remote process initialization, (continued)
- [PATCH v6 14/36] multi-process: setup a machine object for remote device process, elena . ufimtseva, 2020/04/06
- [PATCH v6 21/36] multi-process: PCI BAR read/write handling for proxy & remote endpoints, elena . ufimtseva, 2020/04/06
- [PATCH v6 18/36] multi-process: Initialize Proxy Object's communication channel, elena . ufimtseva, 2020/04/06
- [PATCH v6 13/36] multi-process: setup PCI host bridge for remote device, elena . ufimtseva, 2020/04/06
- [PATCH v6 19/36] multi-process: Connect Proxy Object with device in the remote process, elena . ufimtseva, 2020/04/06
- [PATCH v6 22/36] multi-process: Synchronize remote memory, elena . ufimtseva, 2020/04/06
- [PATCH v6 26/36] multi-process: add parse_cmdline in remote process, elena . ufimtseva, 2020/04/06
- [PATCH v6 20/36] multi-process: Forward PCI config space acceses to the remote process,
elena . ufimtseva <=
- [PATCH v6 25/36] multi-process: Introduce build flags to separate remote process code, elena . ufimtseva, 2020/04/06
- [PATCH v6 28/36] multi-process: send heartbeat messages to remote, elena . ufimtseva, 2020/04/06
- [PATCH v6 29/36] multi-process: handle heartbeat messages in remote process, elena . ufimtseva, 2020/04/06
- [PATCH v6 31/36] multi-process/mon: choose HMP commands based on target, elena . ufimtseva, 2020/04/06
- [PATCH v6 23/36] multi-process: create IOHUB object to handle irq, elena . ufimtseva, 2020/04/06
- [PATCH v6 33/36] multi-process/mon: enable QMP module support in the remote process, elena . ufimtseva, 2020/04/06
- [PATCH v6 36/36] multi-process: add configure and usage information, elena . ufimtseva, 2020/04/06
- [PATCH v6 32/36] multi-process/mon: stub functions to enable QMP module for remote process, elena . ufimtseva, 2020/04/06
- [PATCH v6 35/36] multi-process: add the concept description to docs/devel/qemu-multiprocess, elena . ufimtseva, 2020/04/06
- [PATCH v6 02/36] multi-process: Refactor machine_init and exit notifiers, elena . ufimtseva, 2020/04/06