From nobody Mon Feb 9 20:32:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549306249298273.8954288822997; Mon, 4 Feb 2019 10:50:49 -0800 (PST) Received: from localhost ([127.0.0.1]:47443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqjKK-0007jH-Ss for importer@patchew.org; Mon, 04 Feb 2019 13:50:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqj6r-00052G-7j for qemu-devel@nongnu.org; Mon, 04 Feb 2019 13:36:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqj6p-0003TE-Oa for qemu-devel@nongnu.org; Mon, 04 Feb 2019 13:36:45 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:35690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gqj6o-0003Q3-B2 for qemu-devel@nongnu.org; Mon, 04 Feb 2019 13:36:43 -0500 Received: by mail-wm1-x344.google.com with SMTP id t200so1041338wmt.0 for ; Mon, 04 Feb 2019 10:36:37 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s132sm8836236wmf.28.2019.02.04.10.36.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Feb 2019 10:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rMf2i+KQIoMJtbtg/r71tVuAyaCoUEi0C2x/JJQlUZU=; b=AlGwcwW1ccOx6PlWfKgdCblPBpXh4LYnrwVfZ8KsYTrxRWmiwoVqQID63CU7rhjYwz c/9WmYKY6qguN/aDqc6vIzOlvsbMePfb4jpbmWcDon7kcWRDLWIQlJf9nLJBVN7rAmFf K5J5w+jlRayIBwijHW7/5nwVs5DBvNw1JHs1R+Ve8hnaL6ERtYjhY4ARKr2zTiCQfduK D/cY9E+jHyMCDgwRlz/KqF/KqZHHRe/T+XkMj+Xf53pW//8r+sGUah/lTlzjW05RdiDc xztEHPA1ZYmFKkbHqQhZgzG0fUUZk66icr8JAvJzEEevcdnN/TUehQzgVj9cbGN0grzx 0Jag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=rMf2i+KQIoMJtbtg/r71tVuAyaCoUEi0C2x/JJQlUZU=; b=POU0LBNJ30ypK0cnAJUtXdimzKcbKKtY2O2h0YSJ1qSsPMItq+RWThvisyM5vBsrXm dWqJ6ms4HwrHJblFZjJzlTl3ALefzHCbFSrLkpHtzoD6W4Kx7G+eLmmdshhu6w/XgSLF RFYPI/Hlq2bAmrY9qZbvfou1gm9wdvcI7aNPK4xDDfoNd8ALuaAaPTMJuIb7mWD6lCAH 203WaN1yOS0TGbS3t9zPakYUHzCPGT6JyvOklPoVsU7fmONJKFOOduTQ/EATWemWyokt ul0a2X2e8blF7HHumDLNLICu0dzZFlpa0SbJYyITklt1KR3GJ2LwGwtdhjF0fiKlpnWQ ufBA== X-Gm-Message-State: AHQUAuabnnW4J+kPNI4B8YTfjnxes0HT0hbCNfYHAxB3XPwwpidHOuLf LXE2iWFcr91Ipx79jKQCMGphG9dT X-Google-Smtp-Source: AHgI3IbTZ2Z69tEfewuWSCONJDAhLhmQMFOlZ+IZaNWeR2X6kOMTG/KWMRE2Vg10dSbrYPGWcfXUqQ== X-Received: by 2002:a1c:7510:: with SMTP id o16mr591898wmc.38.1549305396480; Mon, 04 Feb 2019 10:36:36 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 4 Feb 2019 19:35:18 +0100 Message-Id: <1549305379-51117-17-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1549305379-51117-1-git-send-email-pbonzini@redhat.com> References: <1549305379-51117-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PULL 16/77] pvh: load initrd and expose it through fw_cfg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella When initrd is specified, load and expose it to the guest firmware through fw_cfg. The firmware will fill the hvm_start_info for the kernel. Signed-off-by: Stefano Garzarella Based-on: <1545422632-24444-5-git-send-email-liam.merwick@oracle.com> Signed-off-by: Liam Merwick Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e39ef5c..5d61557 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1222,25 +1222,45 @@ static void load_linux(PCMachineState *pcms, */ if (load_elfboot(kernel_filename, kernel_size, header, pvh_start_addr, fw_cfg)) { - struct hvm_modlist_entry ramdisk_mod =3D { 0 }; - fclose(f); =20 fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline) + 1); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); =20 - assert(machine->device_memory !=3D NULL); - ramdisk_mod.paddr =3D machine->device_memory->base; - ramdisk_mod.size =3D - memory_region_size(&machine->device_memory->mr); - - fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, &ramdisk_mod, - sizeof(ramdisk_mod)); fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, sizeof(header)); fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, header, sizeof(header)); =20 + /* load initrd */ + if (initrd_filename) { + gsize initrd_size; + gchar *initrd_data; + GError *gerr =3D NULL; + + if (!g_file_get_contents(initrd_filename, &initrd_data, + &initrd_size, &gerr)) { + fprintf(stderr, "qemu: error reading initrd %s: %s\n", + initrd_filename, gerr->message); + exit(1); + } + + initrd_max =3D pcms->below_4g_mem_size - pcmc->acpi_data_s= ize - 1; + if (initrd_size >=3D initrd_max) { + fprintf(stderr, "qemu: initrd is too large, cannot sup= port." + "(max: %"PRIu32", need %"PRId64")\n", + initrd_max, (uint64_t)initrd_size); + exit(1); + } + + initrd_addr =3D (initrd_max - initrd_size) & ~4095; + + fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); + fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); + fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, + initrd_size); + } + return; } /* This looks like a multiboot kernel. If it is, let's stop --=20 1.8.3.1