From patchwork Thu Apr 28 15:56:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 12830989 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D6D3C433F5 for ; Thu, 28 Apr 2022 16:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Tz3bpU9sxQ0HRlW0PMuhp1udCHjAiJfPvH9eFa9sTo8=; b=B/oFMT1Bf9qoMc shrdpg1gm9WqK058WBTjeIZnyC/mla0MueFPmJZgN3A13E0LwDtQh1a/4r3ZiscDED5rGjIV8G5Jz lbsqcnx6yUcKkkcu2X94zj4Ptb+TEXfzAzcuSCwat4qIi5oMu88yGRKWWfP495MVoesnE9mtJDvfn niJd4xar6uL8vLph9NhSCiO99GynDG983rmpmFoDFI/hvlRmCz7dBAGAmpazxa/3IM42yamIqWVJg 5YROe9ZNA3nRYqI/CAa+7J1gXz+q/K4DFTzBAErgjzZ34bh2APOdvjXJxpK26+BmTb8EcZkno3iZq mcP+rv3B5HaKem8tYa6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nk6Zw-007mhd-5Z; Thu, 28 Apr 2022 16:01:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nk6VK-007kOb-N9 for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2022 15:56:32 +0000 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 473121474; Thu, 28 Apr 2022 08:56:30 -0700 (PDT) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D750B3F774; Thu, 28 Apr 2022 08:56:28 -0700 (PDT) From: Alexandru Elisei To: julien.thierry.kdev@gmail.com, will@kernel.org, maz@kernel.org, suzuki.poulose@arm.com, julien@xen.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, james.morse@arm.com Subject: [PATCH kvmtool 14/15] arm/arm64: Treat --firmware-address when no --firmware as an error Date: Thu, 28 Apr 2022 16:56:01 +0100 Message-Id: <20220428155602.29445-15-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220428155602.29445-1-alexandru.elisei@arm.com> References: <20220428155602.29445-1-alexandru.elisei@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220428_085630_845589_2A966FAC X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 --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. */