From nobody Sun Nov 9 23:02:28 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155211787715523.969448768600955; Fri, 8 Mar 2019 23:51:17 -0800 (PST) Received: from localhost ([127.0.0.1]:55292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Wl9-0005Jw-1P for importer@patchew.org; Sat, 09 Mar 2019 02:51:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Wic-0003qi-6f for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2WiZ-0000Pn-Oo for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:30 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:39837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2WiW-0000LG-Fn for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:25 -0500 Received: by mail-wr1-x431.google.com with SMTP id l12so7191067wrp.6 for ; Fri, 08 Mar 2019 23:48:23 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id 11sm5252294wmg.27.2019.03.08.23.48.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 23:48:21 -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=AM8HhrwvKQY6Ow4NfI33vktmHaZVGL6hHIAkSjpQLFY=; b=LweokVyr26pgYoP9vGhHSjHpxpRY0V+lKAiGf/mAU9DdtVj2jA+nhuVEcnVxHu1h+u cecg2vXtNAFdkNVbJYwu3jhEVliCnfK3XlvbJlB/OzeTTrSO2AZbvpK04L7kZuihAh0l CPgjMMJcWxR1Ek83ufL5FfCih5JV9b/NOERE0i53aRjXMSfGZg5KrfG2A0C2Yz1JXc25 qCxgK0Kr+FelM7JTrbl4qAb35xjvNhbE0P/CPPhTrq586p4xrCJm6cMNGB3nqonpz1PY lvhezRHKsx/FcTksYdEhnEJPdJG/XE7ZRU2ZaECYOVWR7vqeW/64rb0JgCPxsSK5IOBX gxAA== 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=AM8HhrwvKQY6Ow4NfI33vktmHaZVGL6hHIAkSjpQLFY=; b=TCp60XNzVspfDer6SKwueKL/VxgWWiViWXbdT688SRtoW+1MTS58TsZdXkBjc6BGTG 61qC6XkzOqfbHdMfrHAZDsmegc7ECdlJ4sURBqS7mLZipFvLsfB1hsn8Mh4Ml/oL7ULz 2RAviS9KhLwhi5Gg+7VctIgPks8daecuHWuDZU5Hibiwrp5NPutVK79SjMb1fKnbbMXC cwu9ZeLZiLQ/cKoF+6S0A+QT2xTLVdOo6czohSbX1g2UJugY2CDVrE7cxJS0roB7P/6g VyleH/YMQogBHO3c+p+Y0GSisv4h7oArOEUGmmP4amdGg6M0fxD7Tr4736ctu4fMbXLB t0LA== X-Gm-Message-State: APjAAAU8dUbYCyc44pII41fBwruXUJX8KFwkTTYrc+CX9hJZUN7bjptL t3yMHMXLzH8jDZls8J4mL0JLTpSf X-Google-Smtp-Source: APXvYqyf2cubQbiEmeTdzBngYe5BpG9kzx/lPQVAbYTZ47o7VByXJXWQDf4JTi4vyZLqquXU9zW72A== X-Received: by 2002:a05:6000:1152:: with SMTP id d18mr14274167wrx.128.1552117702506; Fri, 08 Mar 2019 23:48:22 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 9 Mar 2019 08:47:56 +0100 Message-Id: <1552117698-12355-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1552117698-12355-1-git-send-email-pbonzini@redhat.com> References: <1552117698-12355-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::431 Subject: [Qemu-devel] [PULL 03/25] hw/i386/pc: run the multiboot loader before the PVH loader 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 Some multiboot images could be in the ELF format. In the current implementation QEMU fails because we try to load these images as a PVH image. In order to fix this issue, we should try multiboot first (we already check the multiboot magic header before to load it). If it is not a multiboot image, we can try the PVH loader. Fixes: ab969087da6 ("pvh: Boot uncompressed kernel using direct boot ABI", = 2019-01-15) Reported-by: Paolo Bonzini Signed-off-by: Stefano Garzarella Message-Id: <20190214180216.246707-1-sgarzare@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 4212818..9c8f833 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1210,6 +1210,17 @@ static void load_linux(PCMachineState *pcms, protocol =3D lduw_p(header+0x206); } else { /* + * This could be a multiboot kernel. If it is, let's stop treating= it + * like a Linux kernel. + * Note: some multiboot images could be in the ELF format (the sam= e of + * PVH), so we try multiboot first since we check the multiboot ma= gic + * header before to load it. + */ + if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, + kernel_cmdline, kernel_size, header)) { + return; + } + /* * Check if the file is an uncompressed kernel file (ELF) and load= it, * saving the PVH entry point used by the x86/HVM direct boot ABI. * If load_elfboot() is successful, populate the fw_cfg info. @@ -1262,12 +1273,6 @@ static void load_linux(PCMachineState *pcms, =20 return; } - /* This looks like a multiboot kernel. If it is, let's stop - treating it like a Linux kernel. */ - if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, - kernel_cmdline, kernel_size, header)) { - return; - } protocol =3D 0; } =20 --=20 1.8.3.1