From nobody Fri Nov 7 14:44:56 2025 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 15480955614101013.8284061734914; Mon, 21 Jan 2019 10:32:41 -0800 (PST) Received: from localhost ([127.0.0.1]:57727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gleN8-0000hH-Vn for importer@patchew.org; Mon, 21 Jan 2019 13:32:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gldyJ-0004aH-KK for qemu-devel@nongnu.org; Mon, 21 Jan 2019 13:06:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gldyI-0004Nt-PX for qemu-devel@nongnu.org; Mon, 21 Jan 2019 13:06:55 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:33995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gldyI-0004Mx-It for qemu-devel@nongnu.org; Mon, 21 Jan 2019 13:06:54 -0500 Received: by mail-wm1-x336.google.com with SMTP id y185so6738241wmd.1 for ; Mon, 21 Jan 2019 10:06:54 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id 133sm56197732wme.9.2019.01.21.10.06.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 10:06:52 -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=5CBtt4xfXFFq047st/rPFliA064FpqbSDIzcqCQR2U8=; b=kQ386gw50KkAHMgjc93ST13YICdkVLGnB5PkPJoUOqaXzMhLUwJjFjoPqq4SaKGVwf Xqel71NfUbI1tPW+galOAvdhjmKBh5a2Vu7pIpBjWQ2QKS2jyCEJ8FyGdZkyJZANn2Og pDh9VD3PnckGjIBT1fK8iMaKkSmeST+3hTdDYQwihxhMBq8US0EgOgRc7c9jnmqZ/D7w D6NcaU2P+NJLbFZ4yNmqQ+wfAJeYNy9+c23po0uQ6nTZZEfUQgXZThdZfE6+X913FG5c B5UXxpV+MuFt4PtpUQnet0cqEjHUif0279kgqvUdBIMuw2SXdNpFsNKL3W1BrT9XmFlw 05vg== 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=5CBtt4xfXFFq047st/rPFliA064FpqbSDIzcqCQR2U8=; b=s3n0SUTczgy2Y6+dF3x3keHw2KzExIekt2vP8ZPC6Wq7xiBPCBMmLKrFzRN/hk3QKl c+mmfst/X0doId2ff8rmnK2MwZx9TbaqUBgXIMh4i20quZTya5ay2h70c7IfDy/pN6fa Ukrbz9WIfPL7Q4RntuKrJpph0vGBShviEQN8J3Rjjh/k71i745nx79AWZFwYknAy2Qx9 NxhXMTihWWFirLeMNKMNSsMkqqo4dxhcfVGtn9FPFU4kPz/iuuX2tGhkBxsS22k9uxPg bKXPLyD6UH8+H0BZB4cwzebY4fkMPJkogFWlSo1rOhzsjYPXUHsG0wSXISsCtALfdzOJ PB/Q== X-Gm-Message-State: AJcUukcpPl+N6Xgezq6J9Sq8Mw+23fenk0XqW18gFmM2LRUQE6S9G1fG FstKmtNuLFTo3CIXUMJ21z5OBMe9 X-Google-Smtp-Source: ALg8bN69/N51WnDVCRbCzRzpDByy4Td99auqSRUoyW79iYGzVTGbGLerBvFPcLBKx4z+DKvQNuYrdA== X-Received: by 2002:a1c:3d44:: with SMTP id k65mr435379wma.76.1548094013068; Mon, 21 Jan 2019 10:06:53 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 21 Jan 2019 19:06:02 +0100 Message-Id: <1548093980-43088-32-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548093980-43088-1-git-send-email-pbonzini@redhat.com> References: <1548093980-43088-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::336 Subject: [Qemu-devel] [PULL 31/49] optionrom/pvh: load initrd from 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 If we found initrd through fw_cfg, we can load it and use the first module of hvm_start_info to pass initrd address and size to the kernel. Signed-off-by: Stefano Garzarella Reviewed-by: Stefan Hajnoczi Reviewed-by: Liam Merwick Based-on: <1547554687-12687-1-git-send-email-liam.merwick@oracle.com> Signed-off-by: Paolo Bonzini --- pc-bios/optionrom/pvh_main.c | 21 +++++++++++++++++++-- pc-bios/pvh.bin | Bin 1536 -> 1536 bytes 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pc-bios/optionrom/pvh_main.c b/pc-bios/optionrom/pvh_main.c index 1dcc5c9..a015e1b 100644 --- a/pc-bios/optionrom/pvh_main.c +++ b/pc-bios/optionrom/pvh_main.c @@ -46,6 +46,7 @@ struct pvh_e820_table { struct pvh_e820_table pvh_e820 asm("pvh_e820") __attribute__ ((aligned)); =20 static struct hvm_start_info start_info; +static struct hvm_modlist_entry ramdisk_mod; static uint8_t cmdline_buffer[CMDLINE_BUFSIZE]; =20 =20 @@ -71,8 +72,8 @@ extern void pvh_load_kernel(void) asm("pvh_load_kernel"); void pvh_load_kernel(void) { void *cmdline_addr =3D &cmdline_buffer; - void *kernel_entry; - uint32_t cmdline_size, fw_cfg_version =3D bios_cfg_version(); + void *kernel_entry, *initrd_addr; + uint32_t cmdline_size, initrd_size, fw_cfg_version =3D bios_cfg_versio= n(); =20 start_info.magic =3D XEN_HVM_START_MAGIC_VALUE; start_info.version =3D 1; @@ -110,6 +111,22 @@ void pvh_load_kernel(void) fw_cfg_version); start_info.cmdline_paddr =3D (uintptr_t)cmdline_addr; =20 + /* Check if we have the initrd to load */ + bios_cfg_read_entry(&initrd_size, FW_CFG_INITRD_SIZE, 4, fw_cfg_versio= n); + if (initrd_size) { + bios_cfg_read_entry(&initrd_addr, FW_CFG_INITRD_ADDR, 4, + fw_cfg_version); + bios_cfg_read_entry(initrd_addr, FW_CFG_INITRD_DATA, initrd_size, + fw_cfg_version); + + ramdisk_mod.paddr =3D (uintptr_t)initrd_addr; + ramdisk_mod.size =3D initrd_size; + + /* The first module is always ramdisk. */ + start_info.modlist_paddr =3D (uintptr_t)&ramdisk_mod; + start_info.nr_modules =3D 1; + } + bios_cfg_read_entry(&kernel_entry, FW_CFG_KERNEL_ENTRY, 4, fw_cfg_vers= ion); =20 asm volatile("jmp *%1" : : "b"(&start_info), "c"(kernel_entry)); diff --git a/pc-bios/pvh.bin b/pc-bios/pvh.bin index 38a41761014957d50eb55d790b6957888cbeee0a..8033080ada2db4c4613fdc3bb5a= 69d79c7b0c0ca 100644 GIT binary patch delta 735 zcmZqRY2cYKndyM&#;Nv<`Y|dZ$5|Uh85k;#<{2MnZ2__v85kHA9sn{HZvYZIPJmb| zfW&duHKLQ5nUrMIfhw902-q@k@G+F$J|Cout)f{N^UIC!Q4iTVG=3Dc}~$y9I%~ogfvxH7Wv~w?60W5Uq#G zb^8ECzJtWNSyZ}1R9F_z0NXGJNbcZV*bKQ3xZ=3DQ(yf415}LN%^5^G8scV%O`y;R+Qji<3DDe^<^K@j Z2no&!h6hlR%ga4L7i~VsEX~MR4FFIY;aUIy delta 434 zcmZqRY2cYKnW;f!<5YV_{Sp>3=3D9kl8-R?(1wdj)2Z)sc zB#yJ@h)iZ?Qj%c@s%SnSV9UV4$549rIBNn>5(JL3rie^-WRk9*!N9`6V0pM)?4=3Dn{ zY40|WBv6CpVg5E%pg^}k~;W} z(J7;H+(iY*0P26n#NRp{$k;2u3Un37%Fb75@AnA;c{@QWdTUffIzN5R*&&(+mFxBa zirfc@b+f2+hp4bDjsV*b10;6{Ko!CC3V_t@289Gro525v%|~RS