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

[PATCH v4 2/5] tools/init-xenstore-domain: Replace variable MB() usage


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Mon, 25 Mar 2024 16:45:12 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kpYFdzJHkuO60SpR1aTtd436m2Cbip6KFJuG8vrlzio=; b=jADnyZeSgMJbTcIXMPTsMtEgjC4VggM4IvtHgeH+4aZjpOrmL9zp9rcrOQ++TioYMv3kwhRspU61W1z9Smh9ClttRw4PBUChEev6ikwJOVGdfXjmiEa070GxnP9vKrX1ZDbN5yeDuT/KW+gpVildZ1jS5+3CTJH15JUBvWtG5z6E9Hg27mMOcwf4Vq+Y1Kpdb4rzTLbUL+L+cCy9BPsJJryN2i2UsO11EuMHnhTAX9fmSdPc10WcuAlFh6tHj3qoTdUW5EqZ281f4EGNSkBiQcVo3AptMJmJt8a8zEl8i9y7aGMniFndrepEXqpJUtxy8lUzdtM82oc19tyqLrkUHg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h8c9LXgrQixHW3dAYWgw/rqZ7cHqAt8cAdh31W2RurJpVS+qFY/D9EhCZbBfCBXaLgGBXdzBKanf2I8KQU8VzAM5foVb3RcZzUOrBLyqVk3EQzx8TNGKCZezzfSLIDvdVwuTu0Y2XHZ5cf1zN/TaLgS/9oc/tZmY9iiRUH2Nz0xLch1iLumBVqkNBT9QoLYkNzSMJgofYYuPdP1p5sIz49dAEYqmp++s2OZhrbG12hqbsLKlnyr1w8dDc1ITx2J5G6mqaZojpGnwwR2GDM1sTckA2+XabLSB28NY3znfb4HFLfKPPVonKXvmoytoEFlTlgAbAegcwGZIkpxnus6LqQ==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Mon, 25 Mar 2024 20:45:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The local MB() & GB() macros will be replaced with a common
implementation, but those only work with constant values.  Introduce a
static inline mb_to_bytes() in place of the MB() macro to convert the
variable values.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
v4:
New
---
 tools/helpers/init-xenstore-domain.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/helpers/init-xenstore-domain.c 
b/tools/helpers/init-xenstore-domain.c
index 1683438c5c..5405842dfe 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -20,7 +20,6 @@
 #include "init-dom-json.h"
 
 #define LAPIC_BASE_ADDRESS  0xfee00000UL
-#define MB(x)               ((uint64_t)x << 20)
 #define GB(x)               ((uint64_t)x << 30)
 
 static uint32_t domid = ~0;
@@ -36,6 +35,11 @@ static xc_evtchn_port_or_error_t console_evtchn;
 static xentoollog_level minmsglevel = XTL_PROGRESS;
 static void *logger;
 
+static inline uint64_t mb_to_bytes(int mem)
+{
+       return (uint64_t)mem << 20;
+}
+
 static struct option options[] = {
     { "kernel", 1, NULL, 'k' },
     { "memory", 1, NULL, 'm' },
@@ -76,8 +80,8 @@ static int build(xc_interface *xch)
     int rv, xs_fd;
     struct xc_dom_image *dom = NULL;
     int limit_kb = (maxmem ? : memory) * 1024 + X86_HVM_NR_SPECIAL_PAGES * 4;
-    uint64_t mem_size = MB(memory);
-    uint64_t max_size = MB(maxmem ? : memory);
+    uint64_t mem_size = mb_to_bytes(memory);
+    uint64_t max_size = mb_to_bytes(maxmem ? : memory);
     struct e820entry e820[3];
     struct xen_domctl_createdomain config = {
         .ssidref = SECINITSID_DOMU,
-- 
2.44.0




 


Rackspace

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