From patchwork Thu Jan 30 16:13:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11358287 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 3AB6414E3 for ; Thu, 30 Jan 2020 16:15:03 +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 1658320707 for ; Thu, 30 Jan 2020 16:15:03 +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="G1/6HPsM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1658320707 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none 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 1ixCSE-0004Ib-HS; Thu, 30 Jan 2020 16:14:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixCSD-0004I9-MT for xen-devel@lists.xenproject.org; Thu, 30 Jan 2020 16:14:05 +0000 X-Inumbo-ID: 75a285c6-437b-11ea-ad98-bc764e2007e4 Received: from bombadil.infradead.org (unknown [2607:7c80:54:e::133]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 75a285c6-437b-11ea-ad98-bc764e2007e4; Thu, 30 Jan 2020 16:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=T0s0/VAvwl0g9rp0gJ4yY/77JC3YwThEFwhhDArumQc=; b=G1/6HPsMgAzG3s+MOV47+gA3NV sfGWXzmNR3s5kh9gAonDoxdtbbYQcRmRhp3tRXi/xsftM8i8cjTcXMUi021fDJPsNqj9YRZ6/2BsY 5viv9TgQhUyeDogP1g/HzbWdjEjJJxrRfqSdH3fWgVVcOzy8wDgrOWXM+B3vQ9guTQLcQ2srQqV9g QQ4AfCYsSv307IN8Eox8ArlbNrEy5dspmlat49/EKdkFOT1tsFK7T7IyRPkg+8iadi35Ut3aEyXTQ P1zofnPq1Hv1epqfSy7zcN5rvUedscczOTzYfywxRrvUV6prUkhf3dPWgN4yrr0iDZ0IdoUysCw7C OFOSN1UQ==; Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1ixCRf-0005A6-SI; Thu, 30 Jan 2020 16:13:31 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1ixCRe-009keW-LF; Thu, 30 Jan 2020 16:13:30 +0000 From: David Woodhouse To: Xen-devel Date: Thu, 30 Jan 2020 16:13:30 +0000 Message-Id: <20200130161330.2324143-22-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200130161330.2324143-1-dwmw2@infradead.org> References: <20200130161330.2324143-1-dwmw2@infradead.org> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Subject: [Xen-devel] [RFC PATCH v3 22/22] 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: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Varad Gautam , paul@xen.org, Ian Jackson , Hongyan Xia , Amit Shah , =?utf-8?q?Ro?= =?utf-8?q?ger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: David Woodhouse Remove a ternary operator that made my brain hurt and replace it with something simpler that makes it clearer that the >= mbi->mods_count is because of what find_first_bit() returns when it doesn't find anything. Just have a simple condition to set initrdidx to zero in that case, and a much simpler ternary operator in the create_dom0() call. Signed-off-by: David Woodhouse --- xen/arch/x86/setup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 53f7b9ced4..6b3a5777cb 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1993,6 +1993,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) else { initrdidx = find_first_bit(module_map, mbi->mods_count); + if ( initrdidx >= mbi->mods_count ) + initrdidx = 0; + if ( bitmap_weight(module_map, mbi->mods_count) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", @@ -2002,8 +2005,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) * safely above our heap. The second module, if present, is an initrd. */ dom0 = create_dom0(mod, modules_headroom, - (initrdidx > 0) && (initrdidx < mbi->mods_count) - ? mod + initrdidx : NULL, kextra, loader); + initrdidx ? mod + initrdidx : NULL, + kextra, loader); if ( dom0 == NULL ) panic("Could not set up DOM0 guest OS\n"); }