From patchwork Wed Mar 18 11:46:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11445101 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B92D92A for ; Wed, 18 Mar 2020 11:47:33 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 482932076D for ; Wed, 18 Mar 2020 11:47:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="eGq9fm8Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 482932076D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEX9M-0000UQ-Mw; Wed, 18 Mar 2020 11:46:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jEX9L-0000UF-1o for xen-devel@lists.xenproject.org; Wed, 18 Mar 2020 11:46:15 +0000 X-Inumbo-ID: 0f764bc6-690e-11ea-bec1-bc764e2007e4 Received: from merlin.infradead.org (unknown [2001:8b0:10b:1231::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0f764bc6-690e-11ea-bec1-bc764e2007e4; Wed, 18 Mar 2020 11:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Mime-Version:Content-Type:References: In-Reply-To:Date:Cc:To:From:Subject:Message-ID:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=aPkZx7QPuwQCIokxmoArl+PgtcspxzdH4d11avC+0K4=; b=eGq9fm8YhiwHxUXFUt7TqPoPFb e+P6U5LsB9b/NqKxIEhhrFdVYGajw6KFcMgHGCng/uEcCmp7NLRlnIgwYdxwxUb4hptMtu+c3cPhN gLl9loOU6NCB0zDZI5xy6SLB1RmzCRmk9j2mJu7r+3Z2hRQD1hcBuXpIHqXjCFGqxKsS+fO+mqZbt oryIE1uGqgTkcdMSh9/AtoMGxgnuH0Z6i7vPel8AjY5LZoXaXmBamtR1ghX4SZATKS8T9AhaA8thB JrnS40X4htIouwxSx2LFolRgt28ztDhs9M2FCGCw5w17J9ZrwiEUCR4IvrLUPZ9KzTh3iNNyvdML0 YK47g2/A==; Received: from 54-240-197-227.amazon.com ([54.240.197.227] helo=edge-m1-r3-134.e-iad16.amazon.com) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEX9E-0001BU-HO; Wed, 18 Mar 2020 11:46:08 +0000 Message-ID: From: David Woodhouse To: xen-devel@lists.xenproject.org Date: Wed, 18 Mar 2020 11:46:06 +0000 In-Reply-To: <916bbc82cafac74f0a203b48eebfbc711bd33a70.camel@infradead.org> References: <916bbc82cafac74f0a203b48eebfbc711bd33a70.camel@infradead.org> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [PATCH 1/2] x86/setup: simplify handling of initrdidx when no initrd present X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , Wei Liu , Andrew Cooper , Paul Durrant , Jan Beulich , Roger Pau =?iso-8859-1?q?Monn=E9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse Remove a ternary operator that made my brain hurt. Replace it with something simpler that makes it somewhat clearer that the check for initrdidx < mbi->mods_count is because larger values are what find_first_bit() will return when it doesn't find anything. Also drop the explicit check for module #0 since that would be the dom0 kernel and the corresponding bit is always clear in module_map. Signed-off-by: David Woodhouse Acked-by: Julien Grall Reviewed-by: Wei Liu --- xen/arch/x86/setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index c87040c890..2986cf5a3a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -688,7 +688,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) char *cmdline, *kextra, *loader; unsigned int initrdidx, num_parked = 0; multiboot_info_t *mbi; - module_t *mod; + module_t *mod, *initrd = NULL; unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; int i, j, e820_warn = 0, bytes = 0; bool acpi_boot_table_init_done = false, relocated = false; @@ -1798,6 +1798,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) xen_processor_pmbits |= XEN_PROCESSOR_PM_CX; initrdidx = find_first_bit(module_map, mbi->mods_count); + if ( initrdidx < mbi->mods_count ) + initrd = mod + initrdidx; if ( bitmap_weight(module_map, mbi->mods_count) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", @@ -1822,9 +1824,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * We're going to setup domain0 using the module(s) that we stashed safely * above our heap. The second module, if present, is an initrd ramdisk. */ - if ( construct_dom0(dom0, mod, modules_headroom, - (initrdidx > 0) && (initrdidx < mbi->mods_count) - ? mod + initrdidx : NULL, cmdline) != 0) + if ( construct_dom0(dom0, mod, modules_headroom, initrd, cmdline) != 0 ) panic("Could not set up DOM0 guest OS\n"); if ( cpu_has_smap )