diff mbox series

[kvmtool,14/15] arm/arm64: Treat --firmware-address when no --firmware as an error

Message ID 20220428155602.29445-15-alexandru.elisei@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: Allow the user to set RAM base address | expand

Commit Message

Alexandru Elisei April 28, 2022, 3:56 p.m. UTC
It makes little sense for the user to specify the firmware address when
loading a kernel instead of a firmware image. Treat it as an error.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arm/aarch32/kvm.c                 | 2 +-
 arm/aarch64/kvm.c                 | 2 +-
 arm/include/arm-common/kvm-arch.h | 3 +++
 arm/kvm.c                         | 8 ++++++++
 4 files changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arm/aarch32/kvm.c b/arm/aarch32/kvm.c
index 768a56bbb5b4..a7bb3b79db8c 100644
--- a/arm/aarch32/kvm.c
+++ b/arm/aarch32/kvm.c
@@ -1,6 +1,6 @@ 
 #include "kvm/kvm.h"
 
-void kvm__arch_validate_cfg(struct kvm *kvm)
+void kvm__arm_validate_cfg(struct kvm *kvm)
 {
 	if (kvm->cfg.ram_size > ARM_LOMAP_MAX_MEMORY) {
 		die("RAM size 0x%llx exceeds maximum allowed 0x%llx",
diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c
index 581c836eb6ae..8fb44a924aa4 100644
--- a/arm/aarch64/kvm.c
+++ b/arm/aarch64/kvm.c
@@ -10,7 +10,7 @@  u64 kvm__arch_default_ram_address(void)
 	return ARM_MEMORY_AREA;
 }
 
-void kvm__arch_validate_cfg(struct kvm *kvm)
+void kvm__arm_validate_cfg(struct kvm *kvm)
 {
 	if (kvm->cfg.arch.aarch32_guest &&
 	    kvm->cfg.ram_size > ARM_LOMAP_MAX_MEMORY) {
diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h
index cbe2bb2381ef..1d1ccc8bb172 100644
--- a/arm/include/arm-common/kvm-arch.h
+++ b/arm/include/arm-common/kvm-arch.h
@@ -88,6 +88,9 @@  static inline bool arm_addr_in_ioport_region(u64 phys_addr)
 	return phys_addr >= KVM_IOPORT_AREA && phys_addr < limit;
 }
 
+struct kvm;
+void kvm__arm_validate_cfg(struct kvm *kvm);
+
 struct kvm_arch {
 	/*
 	 * We may have to align the guest memory for virtio, so keep the
diff --git a/arm/kvm.c b/arm/kvm.c
index 83df1c9a0cde..3edc6fdbcb5f 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -31,6 +31,14 @@  int fw_addr_parser(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
+void kvm__arch_validate_cfg(struct kvm *kvm)
+{
+	if (kvm->cfg.arch.fw_addr && !kvm->cfg.firmware_filename)
+		die("--firmware-address is only valid when loading a firmware image");
+
+	kvm__arm_validate_cfg(kvm);
+}
+
 bool kvm__arch_cpu_supports_vm(void)
 {
 	/* The KVM capability check is enough. */