@@ -17,6 +17,7 @@ struct kvm_config_arch {
};
int irqchip_parser(const struct option *opt, const char *arg, int unset);
+int fw_addr_parser(const struct option *opt, const char *arg, int unset);
#define OPT_ARCH_RUN(pfx, cfg) \
pfx, \
@@ -34,7 +35,9 @@ int irqchip_parser(const struct option *opt, const char *arg, int unset);
"[gicv2|gicv2m|gicv3|gicv3-its]", \
"Type of interrupt controller to emulate in the guest", \
irqchip_parser, NULL), \
- OPT_U64('\0', "firmware-address", &(cfg)->fw_addr, \
- "Address where firmware should be loaded"),
+ OPT_CALLBACK('\0', "firmware-address", NULL, "addr[BKMGTP]", \
+ "Address where firmware should be loaded. The default unit"\
+ " of measurement is megabytes (M)", \
+ fw_addr_parser, kvm),
#endif /* ARM_COMMON__KVM_CONFIG_ARCH_H */
@@ -18,6 +18,19 @@ struct kvm_ext kvm_req_ext[] = {
{ 0, 0 },
};
+int fw_addr_parser(const struct option *opt, const char *arg, int unset)
+{
+ struct kvm *kvm = opt->ptr;
+ char *next;
+
+ kvm->cfg.arch.fw_addr = parse_mem_option(arg, &next);
+
+ if (*next != '\0')
+ die("Invalid firmware address: %s", arg);
+
+ return 0;
+}
+
bool kvm__arch_cpu_supports_vm(void)
{
/* The KVM capability check is enough. */
@@ -112,7 +112,7 @@ static int parse_mem_unit(char **next)
return shift;
}
-static u64 parse_mem_option(const char *nptr, char **next)
+u64 parse_mem_option(const char *nptr, char **next)
{
u64 shift;
u64 val;
@@ -211,6 +211,7 @@ static inline bool kvm__arch_has_cfg_ram_address(void)
void *guest_flat_to_host(struct kvm *kvm, u64 offset);
u64 host_to_guest_flat(struct kvm *kvm, void *ptr);
+u64 parse_mem_option(const char *nptr, char **next);
bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd,
const char *kernel_cmdline);
The arm and arm64 permit the user to specify the load address, in RAM, for the firmware image. Make it possible to use the standard size specifiers (B/K/M/G/P/T) when doing so. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- arm/include/arm-common/kvm-config-arch.h | 7 +++++-- arm/kvm.c | 13 +++++++++++++ builtin-run.c | 2 +- include/kvm/kvm.h | 1 + 4 files changed, 20 insertions(+), 3 deletions(-)