Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE93BC4727C for ; Tue, 29 Sep 2020 15:37:34 +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 5552E207F7 for ; Tue, 29 Sep 2020 15:37:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Ffff11AB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5552E207F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.282.745 (Exim 4.92) (envelope-from ) id 1kNHgx-0001la-J9; Tue, 29 Sep 2020 15:37:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 282.745; Tue, 29 Sep 2020 15:37:23 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNHgx-0001lT-Fn; Tue, 29 Sep 2020 15:37:23 +0000 Received: by outflank-mailman (input) for mailman id 282; Tue, 29 Sep 2020 15:37:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNHgw-0001lO-HW for xen-devel@lists.xenproject.org; Tue, 29 Sep 2020 15:37:22 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id bf763712-4f1c-4684-93c1-78ae8030bf85; Tue, 29 Sep 2020 15:37:21 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CC200AD03; Tue, 29 Sep 2020 15:37:20 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNHgw-0001lO-HW for xen-devel@lists.xenproject.org; Tue, 29 Sep 2020 15:37:22 +0000 X-Inumbo-ID: bf763712-4f1c-4684-93c1-78ae8030bf85 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id bf763712-4f1c-4684-93c1-78ae8030bf85; Tue, 29 Sep 2020 15:37:21 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601393840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6dCDqa7MgvM9c6YKWUGY7xkqT2Pa7rxICpICN7h3/Hs=; b=Ffff11ABlAM7M9NajXzvMnMAMi68gnkp64IJfQe6qXpO1EAGiX/2dv9LnRMXE4xst5ON92 tEONkGBlPnRfzprcnpUeew/wzd0iSMa+DxztYRDXqHHqTTb/O1KO9HACeJLKuJ3SHT0glK fzjT+izbst2hglnikd0uahbazdU2lPo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CC200AD03; Tue, 29 Sep 2020 15:37:20 +0000 (UTC) Subject: Re: [PATCH v6 4/5] efi: Enable booting unified hypervisor/kernel/initrd images To: Trammell Hudson References: <20200921115113.1278655-1-hudson@trmm.net> <20200921115113.1278655-5-hudson@trmm.net> Cc: xen-devel@lists.xenproject.org From: Jan Beulich Message-ID: <6062d534-70b7-d8db-7526-ade453c373f8@suse.com> Date: Tue, 29 Sep 2020 17:37:20 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200921115113.1278655-5-hudson@trmm.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 21.09.2020 13:51, Trammell Hudson wrote: > @@ -624,6 +626,22 @@ static bool __init read_file(EFI_FILE_HANDLE dir_handle, CHAR16 *name, > return true; > } > > +static bool __init read_section(const EFI_LOADED_IMAGE *image, > + CHAR16 *name, struct file *file, > + const char *options) > +{ > + file->ptr = pe_find_section(image->ImageBase, image->ImageSize, > + name, &file->size); > + if ( !file->ptr ) > + return false; > + > + file->need_to_free = false; In patch 2 you don't bother clearing the field, presumably because it's static data and hence zero-filled anyway. This same assumption would then hold here. Or else, to be consistent, the earlier patch would want clearing added. > +static int __init pe_name_compare(const struct PeSectionHeader *sect, > + const CHAR16 *name) > +{ > + size_t i; > + > + if ( sect->Name[0] != '.' ) > + return -1; > + > + for ( i = 1; i < sizeof(sect->Name); i++ ) > + { > + const char c = sect->Name[i]; > + const CHAR16 cw = name[i-1]; > + if ( cw == 0 && c == 0 ) Blank line between declarations and statements please. > + return 0; > + if ( cw < c ) > + return -1; > + if ( cw > c ) > + return +1; > + } > + > + if ( name[i-1] < 0 ) > + return -1; I'm afraid this is liable to trigger compiler warnings, for checking an unsigned quantity to be negative. Also throughout here "i-1" wants spelling "i - 1". > +const void *__init pe_find_section(const void *image, const UINTN image_size, > + const CHAR16 *section_name, UINTN *size_out) > +{ > + const struct DosFileHeader *dos = image; > + const struct PeHeader *pe; > + const struct PeSectionHeader *sect; > + UINTN offset, i; > + > + if ( image_size < sizeof(*dos) || > + memcmp(dos->Magic, "MZ", 2) != 0 ) > + return NULL; > + > + offset = dos->ExeHeader; > + pe = image + offset; > + > + offset += sizeof(*pe); > + if ( image_size < offset || > + memcmp(pe->Magic, "PE\0\0", 4) != 0 ) > + return NULL; > + > + /* PE32+ Subsystem type */ > + if ( pe->FileHeader.Machine != PE_HEADER_MACHINE ) > + return NULL; Comment and code don't look to be in line. Jan