From patchwork Wed Oct 6 11:37:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Hedde X-Patchwork-Id: 1537090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.a=rsa-sha256 header.s=mail header.b=oumFwzBG; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HPXZw1wnZz9sP7 for ; Wed, 6 Oct 2021 22:40:55 +1100 (AEDT) Received: from localhost ([::1]:35202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mY5I3-00052t-3W for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2021 07:40:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mY5Eh-00052O-Ae for qemu-devel@nongnu.org; Wed, 06 Oct 2021 07:37:23 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:55600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mY5Ef-0002Ft-7s for qemu-devel@nongnu.org; Wed, 06 Oct 2021 07:37:23 -0400 Received: from crumble.bar.greensocs.com (unknown [172.17.10.6]) by beetle.greensocs.com (Postfix) with ESMTPS id DE5A920779; Wed, 6 Oct 2021 11:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1633520238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=q2PlIwlIoWmZ/WSoA+/auG3v2XMzXedpqi/AaDsiKSM=; b=oumFwzBGi9Jp+CgJt+MKyTWPdopn8KvJpq+DPYC8vWZbP6gDj2Of3D8mDWqLJOsVVWuO70 2YesMrpRc5jRfUetFwciau1Qc6VImTvLbXV0A7cvFqo0Px9MfXk+78PcxZgYy4l411LSIC dCE7yXbuj54VhQs19M33uxN+OKvy8p8= From: Damien Hedde To: qemu-devel@nongnu.org Subject: [PATCH] generic-loader: remove the ram_size limit when a loading binary file Date: Wed, 6 Oct 2021 13:37:07 +0200 Message-Id: <20211006113707.96907-1-damien.hedde@greensocs.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Received-SPF: pass client-ip=5.135.226.135; envelope-from=damien.hedde@greensocs.com; helo=beetle.greensocs.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Alistair Francis Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Right now, we cannot load some binary file if it is bigger than the machine's ram size. This limitation only occurs when loading a binary file: we can load a corresponding elf file without this limitation. This is an issue for machines that have small ram or do not use the ram_size feature at all. Also get rid of "hw/boards.h" include, since we needed it only to access `current_machine`. Fixes: e481a1f63c9 ("generic-loader: Add a generic loader") Signed-off-by: Damien Hedde --- Hi Alistair, I found this while experimenting with a ram_size=0 machine. I checked the original discussion: it seems to me there was no intention to specifically limit to the ram size but we had to put some limit. See this: https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg04668.html https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg04681.html Thanks for your feedback, Damien --- hw/core/generic-loader.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index d14f932eea..102605c07b 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -34,7 +34,6 @@ #include "hw/core/cpu.h" #include "sysemu/dma.h" #include "sysemu/reset.h" -#include "hw/boards.h" #include "hw/loader.h" #include "hw/qdev-properties.h" #include "qapi/error.h" @@ -153,8 +152,8 @@ static void generic_loader_realize(DeviceState *dev, Error **errp) } if (size < 0 || s->force_raw) { - /* Default to the maximum size being the machine's ram size */ - size = load_image_targphys_as(s->file, s->addr, current_machine->ram_size, as); + /* Do not limit the file size */ + size = load_image_targphys_as(s->file, s->addr, -1, as); } else { s->addr = entry; }