tools/init-xenstore-domain: Replace variable MB() usage

The local MB() & GB() macros will be replaced with a common
implementation, but those only work with numeric values.  Introduce a
static inline mb_to_bytes() in place of the MB() macro to convert the
variable values, at the same time addressing the lack of
parenthesization of the prior macro's parameter.

Fixes: 134d53f577 ("tools/init-xenstore-domain: fix memory map for PVH stubdom")
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
This commit is contained in:
Jason Andryuk authored and Jan Beulich committed 2024-04-04 12:00:59 +02:00
1 parent 1e6cd4155d
commit 4c41749852
1 file changed
+7 -3
+7 -3
View File
@@ -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,
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.