aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Elisei <alexandru.elisei@arm.com>2021-09-23 15:45:05 +0100
committerWill Deacon <will@kernel.org>2021-10-12 09:40:46 +0100
commitdc6646192057e63084ef8dd76eb1e2bff5398aa8 (patch)
treefa905956ce65f44cc8a88e14328eac947c3c010e
parent5303f0964ffdc4940e323e1e28d28cd1e0172aa3 (diff)
downloadkvmtool-dc6646192057e63084ef8dd76eb1e2bff5398aa8.tar.gz
arm64: Be more permissive when parsing the kernel header
kvmtool complains loudly when it parses the kernel header and doesn't find what it expects, but unless it outright fails to read the kernel image, it will copy the image in the guest memory at the default offset of 0x80000. There's no technical reason to stop the user from loading payloads other than a Linux kernel with the --kernel option. These payloads can behave just like a kernel and can use an initrd (which is not possible with --firmware), but don't have the kernel header (like kvm-unit-tests), and the warnings kvmtool emites can be confusing for this type of payloads. Change the warnings to debug statements, which can be enabled via the --debug kvmtool command line option, to make them disappear for these cases where they aren't really relevant. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Link: https://lore.kernel.org/r/20210923144505.60776-11-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arm/aarch64/kvm.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c
index b38365fb..56a0aedc 100644
--- a/arm/aarch64/kvm.c
+++ b/arm/aarch64/kvm.c
@@ -16,7 +16,7 @@ unsigned long long kvm__arch_get_kern_offset(struct kvm *kvm, int fd)
struct arm64_image_header header;
off_t cur_offset;
ssize_t size;
- const char *warn_str;
+ const char *debug_str;
/* the 32bit kernel offset is a well known value */
if (kvm->cfg.arch.aarch32_guest)
@@ -25,8 +25,8 @@ unsigned long long kvm__arch_get_kern_offset(struct kvm *kvm, int fd)
cur_offset = lseek(fd, 0, SEEK_CUR);
if (cur_offset == (off_t)-1 ||
lseek(fd, 0, SEEK_SET) == (off_t)-1) {
- warn_str = "Failed to seek in kernel image file";
- goto fail;
+ debug_str = "Failed to seek in kernel image file";
+ goto default_offset;
}
size = xread(fd, &header, sizeof(header));
@@ -36,16 +36,16 @@ unsigned long long kvm__arch_get_kern_offset(struct kvm *kvm, int fd)
lseek(fd, cur_offset, SEEK_SET);
if (memcmp(&header.magic, ARM64_IMAGE_MAGIC, sizeof(header.magic))) {
- warn_str = "Kernel image magic not matching";
- goto fail;
+ debug_str = "Kernel image magic not matching";
+ goto default_offset;
}
if (le64_to_cpu(header.image_size))
return le64_to_cpu(header.text_offset);
- warn_str = "Image size is 0";
-fail:
- pr_warning("%s, assuming TEXT_OFFSET to be 0x80000", warn_str);
+ debug_str = "Image size is 0";
+default_offset:
+ pr_debug("%s, assuming TEXT_OFFSET to be 0x80000", debug_str);
return 0x80000;
}