Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB7F0C54EAA for ; Fri, 27 Jan 2023 11:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232384AbjA0LmE (ORCPT ); Fri, 27 Jan 2023 06:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233513AbjA0Ll2 (ORCPT ); Fri, 27 Jan 2023 06:41:28 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D2FF78AEB; Fri, 27 Jan 2023 03:41:06 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 480471576; Fri, 27 Jan 2023 03:41:19 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BEBA93F64C; Fri, 27 Jan 2023 03:40:34 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 17/31] arm: Add kernel size to VM context Date: Fri, 27 Jan 2023 11:39:18 +0000 Message-Id: <20230127113932.166089-18-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Elisei 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 [Fix kernel size printed in debug messages] Signed-off-by: Suzuki K Poulose --- 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