[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230127113932.166089-18-suzuki.poulose@arm.com>
Date: Fri, 27 Jan 2023 11:39:18 +0000
From: Suzuki K Poulose <suzuki.poulose@....com>
To: kvm@...r.kernel.org, kvmarm@...ts.linux.dev
Cc: suzuki.poulose@....com,
Alexandru Elisei <alexandru.elisei@....com>,
Andrew Jones <andrew.jones@...ux.dev>,
Christoffer Dall <christoffer.dall@....com>,
Fuad Tabba <tabba@...gle.com>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Joey Gouly <Joey.Gouly@....com>, Marc Zyngier <maz@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Oliver Upton <oliver.upton@...ux.dev>,
Paolo Bonzini <pbonzini@...hat.com>,
Quentin Perret <qperret@...gle.com>,
Steven Price <steven.price@....com>,
Thomas Huth <thuth@...hat.com>, Will Deacon <will@...nel.org>,
Zenghui Yu <yuzenghui@...wei.com>, linux-coco@...ts.linux.dev,
kvmarm@...ts.cs.columbia.edu, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Subject: [RFC kvmtool 17/31] arm: Add kernel size to VM context
From: Alexandru Elisei <alexandru.elisei@....com>
Add the kernel image size to the VM context, as we are going to use it
later. This matches what we already do with the initrd.
Signed-off-by: Alexandru Elisei <alexandru.elisei@....com>
[Fix kernel size printed in debug messages]
Signed-off-by: Suzuki K Poulose <suzuki.poulose@....com>
---
arm/include/arm-common/kvm-arch.h | 1 +
arm/kvm.c | 8 +++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h
index 41b31f11..b5a4b851 100644
--- a/arm/include/arm-common/kvm-arch.h
+++ b/arm/include/arm-common/kvm-arch.h
@@ -108,6 +108,7 @@ struct kvm_arch {
*/
u64 memory_guest_start;
u64 kern_guest_start;
+ u64 kern_size;
u64 initrd_guest_start;
u64 initrd_size;
u64 dtb_guest_start;
diff --git a/arm/kvm.c b/arm/kvm.c
index 2510a322..acb627b2 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -153,7 +153,6 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd,
limit = kvm->ram_start + min(kvm->ram_size, (u64)SZ_256M) - 1;
pos = kvm->ram_start + kvm__arch_get_kern_offset(kvm, fd_kernel);
- kvm->arch.kern_guest_start = host_to_guest_flat(kvm, pos);
file_size = read_file(fd_kernel, pos, limit - pos);
if (file_size < 0) {
if (errno == ENOMEM)
@@ -161,9 +160,12 @@ bool kvm__arch_load_kernel_image(struct kvm *kvm, int fd_kernel, int fd_initrd,
die_perror("kernel read");
}
+
+ kvm->arch.kern_guest_start = host_to_guest_flat(kvm, pos);
+ kvm->arch.kern_size = file_size;
kernel_end = pos + file_size;
- pr_debug("Loaded kernel to 0x%llx (%zd bytes)",
- kvm->arch.kern_guest_start, file_size);
+ pr_debug("Loaded kernel to 0x%llx (%llu bytes)",
+ kvm->arch.kern_guest_start, kvm->arch.kern_size);
/*
* Now load backwards from the end of memory so the kernel
--
2.34.1
Powered by blists - more mailing lists