[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 1/6] tools/console: use xenforeigmemory to map console ring


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 22 Sep 2021 10:21:18 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=p6U9+CcoG+mX2fECvTxGB38bv2Hcg2ZxfYzHOKtfzAE=; b=W6AD/rIiqS1Wdj9hwk2VvkOfrh4Vf0jCKuByWPSvg0fEhXqbwaTsO2WamWaBWnQUMqdwgX6zqx8mRV3bhfOGoYxACqfYWj13vx2Z2Z+k5QDnR3L/JQ5cMG61MexAq1y9lEpZHXU0OfIDNr5cCqo4wvVdY0yrBK0EsSCTLCBzLsvuswmrt68GS3hLsCT7H3T2vbCafpsaNHwzKSXysPMdJ5flMgO+oj2SA30BkHS2ORFyaGGFrmGJYSojSXbX2ot3nsAv/cTEFUt9xkW5moRVBHR9krxtz3+qF3m86+sX3YSM7WSw4pYsPi9b61F/Joi2ndUhuf3o4eYH+dEx1j4yxg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhLjhOMPDYiYOtBcyO2HEUeAYNvrcM5dhfeIUy+QLs7kaEWe52aTLcv4WaG93gCxtCIQ6StY5BuQArA8SbQ4BhUEyp9QAejSB3M9GcWXiMhwoNcki+culN/MWcxKZCqgKsDDvYuerfuji2/JWJiZXvXyRlXrsUp48JcBCJ1tQNh6AJ+wgZgUk7ONi2o0At/C/2ufiDiARIw1ta796cSd6p2XVple/2gJtiv0LnlkNEL+BowmADNKy8reIDMiRhAgLHZQlQikVmM97+DlxL60lTc16DVXT9R6qOUjhgYPCvEl/NxL3JiKwvyv5CvCMElBy/WNvVx6PGGPT5rAPsAlhg==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 22 Sep 2021 08:22:04 +0000
  • Ironport-data: A9a23:Uidazq3ONy1j7cfDBPbD5cp2kn2cJEfYwER7XKvMYLTBsI5bpzEPy mZKXmDTOPnYZzfyLdgiaYnk/UpXu5XWmNMyS1NtpC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCan0ZqTNMEn970EoywbRh2OaEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhvdt94 Y9f7sSMYzwLYaLsveg2cDlHHHQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r8pWycUr 6VecW1TKEDY7w616OvTpu1EnMMsIdOtJIoCknph0SvYHbAtRpWrr6DiuIQDhWps3Zgm8fD2Z ZAhYyFMK076eSZdZVlJOYMgvriIiSyqG9FfgA3M/vdmi4TJ9yRu1JD9PdyTfcaFLe1UgUSwt m/A537+ABwRKJqY0zXt2mKhgKrDkD32XKoWFaak7bh6jVuL3GsRBRYKE1yhrpGEZlWWAowFb RZOo2x38PZ0pBfDosTBswOQgnWIl0QOAIJsOdYYtw6t76b/wCaGCT1RJtJeU+DKpPPaVBRzi ATTxoO3WWQ22FGGYSnCrebP9FteLQBQdDVbNHFeFWPp9vG++Nlbs/7Zcjp0/EdZZPXOEDfsy nihqCEkjt3/ZuZaiv3moTgrb9+qz6Ul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L+puiwzvYiUmRoXue iJhy1lE9V46nvXcG3wiRzx2zP42DJr0HPmwU/wuwqqneXJABYBT+ZRj4NQdRXUr2A6ustn7a 5N12WF87JKEBLphk3Glpj1fiAvsnDxjWspkOYVgXAae5AZcqVtoYsW+14QOIscHRj99JssHI BVfYDhDc5tABGnhk3izyxSKITGZAV2Iv7GeDlNhiWt6UkUoJgjpHFog/D2nR87hdsAotd/lq L52gkBrsA7ciYsV9MOOA42e7rANoX8e2O+DIusGyWTKEh+AQO0l3fW2sR/2Aj4Qu1D8HMN8K 6xJ2+w81RCIn7TNQ==
  • Ironport-sdr: IDblU9qmfXikEPp8GctaHMIy18ZtDSb5xCLFEX0CVudyjJix0RqPbadI5AgIvonUTL52uvlhl4 a6ex4/Vfcv3bwX8e2M5zoMW94MxKbUoMJnrWiuJKSM1aj/eGQlQI5ZPLr4qeukeWTaTVlEcg/b 2ZxHdkHhiB7nqheC9sesO2Rzmk6w0xqz7sjOWFiVMTuOEulNU46IxK/FAXAjxK0Wx3uxNVrO91 /FBCzjb3Lzy0eqou1TpJxRy75Gn9fS0b3V5kOWgj2TK96MQsRmHiak8FHiJWJqP4+dPGvBvOXY 8HU1BWgknW8uGpOpTPBYKEvl
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This patch replaces the usage of xc_map_foreign_range with
xenforeignmemory_map from the stable xenforeignmemory library. Note
there are still other uses of libxc functions which prevents removing
the dependency.

No functional change intended.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Reviewed-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
---
 tools/console/Makefile    |  4 ++--
 tools/console/daemon/io.c | 25 ++++++++++++++++++++-----
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/tools/console/Makefile b/tools/console/Makefile
index 84796eac8f..3f4cddab03 100644
--- a/tools/console/Makefile
+++ b/tools/console/Makefile
@@ -29,9 +29,9 @@ clean:
 distclean: clean
 
 daemon/main.o: daemon/_paths.h
-daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) 
$(CONSOLE_CFLAGS-y)
+daemon/io.o: CFLAGS += $(CFLAGS_libxenevtchn) $(CFLAGS_libxengnttab) 
$(CFLAGS_libxenforeignmemory) $(CONSOLE_CFLAGS-y)
 xenconsoled: $(patsubst %.c,%.o,$(wildcard daemon/*.c))
-       $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) 
$(LDLIBS_libxengnttab) $(LDLIBS_xenconsoled) $(APPEND_LDFLAGS)
+       $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(LDLIBS_libxenevtchn) 
$(LDLIBS_libxengnttab) $(LDLIBS_libxenforeignmemory) $(LDLIBS_xenconsoled) 
$(APPEND_LDFLAGS)
 
 client/main.o: client/_paths.h
 xenconsole: $(patsubst %.c,%.o,$(wildcard client/*.c))
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 200b575d76..682c1f4008 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -22,6 +22,7 @@
 #include "utils.h"
 #include "io.h"
 #include <xenevtchn.h>
+#include <xenforeignmemory.h>
 #include <xengnttab.h>
 #include <xenstore.h>
 #include <xen/io/console.h>
@@ -73,6 +74,7 @@ static int log_time_guest_needts = 1;
 static int log_hv_fd = -1;
 
 static xengnttab_handle *xgt_handle = NULL;
+static xenforeignmemory_handle *xfm_handle;
 
 static struct pollfd  *fds;
 static unsigned int current_array_size;
@@ -675,7 +677,7 @@ static void console_unmap_interface(struct console *con)
        if (xgt_handle && con->ring_ref == -1)
                xengnttab_unmap(xgt_handle, con->interface, 1);
        else
-               munmap(con->interface, XC_PAGE_SIZE);
+               xenforeignmemory_unmap(xfm_handle, con->interface, 1);
        con->interface = NULL;
        con->ring_ref = -1;
 }
@@ -722,11 +724,12 @@ static int console_create_ring(struct console *con)
                con->ring_ref = -1;
        }
        if (!con->interface) {
+               xen_pfn_t pfn = ring_ref;
+
                /* Fall back to xc_map_foreign_range */
-               con->interface = xc_map_foreign_range(
-                       xc, dom->domid, XC_PAGE_SIZE,
-                       PROT_READ|PROT_WRITE,
-                       (unsigned long)ring_ref);
+               con->interface = xenforeignmemory_map(
+                       xfm_handle, dom->domid, PROT_READ|PROT_WRITE, 1,
+                       &pfn, NULL);
                if (con->interface == NULL) {
                        err = EINVAL;
                        goto out;
@@ -1341,6 +1344,14 @@ void handle_io(void)
                      errno, strerror(errno));
        }
 
+       xfm_handle = xenforeignmemory_open(NULL, 0);
+       if (xfm_handle == NULL) {
+               dolog(LOG_ERR,
+                     "Failed to open xen foreign memory handle: %d (%s)",
+                     errno, strerror(errno));
+               goto out;
+       }
+
        enum_domains();
 
        for (;;) {
@@ -1462,6 +1473,10 @@ void handle_io(void)
                xengnttab_close(xgt_handle);
                xgt_handle = NULL;
        }
+       if (xfm_handle != NULL) {
+               xenforeignmemory_close(xfm_handle);
+               xfm_handle = NULL;
+       }
        log_hv_evtchn = -1;
 }
 
-- 
2.33.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.