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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 768D5C433DB for ; Mon, 25 Jan 2021 12:43: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 F234922597 for ; Mon, 25 Jan 2021 12:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F234922597 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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.74066.133106 (Exim 4.92) (envelope-from ) id 1l41CX-0004co-A9; Mon, 25 Jan 2021 12:42:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74066.133106; Mon, 25 Jan 2021 12:42:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l41CX-0004ch-7B; Mon, 25 Jan 2021 12:42:37 +0000 Received: by outflank-mailman (input) for mailman id 74066; Mon, 25 Jan 2021 12:42:35 +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 1l41CV-0004cc-QO for xen-devel@lists.xenproject.org; Mon, 25 Jan 2021 12:42:35 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id dae24bd6-1d6e-4489-a423-0948b1f9c35a; Mon, 25 Jan 2021 12:42:34 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id ABB6EAF23; Mon, 25 Jan 2021 12:42:33 +0000 (UTC) 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" X-Inumbo-ID: dae24bd6-1d6e-4489-a423-0948b1f9c35a 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=1611578553; h=from:from:reply-to: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=18WX+0Vif/IawecigNCcnryWqDWfKWSTlk7Ru5oyvr0=; b=vIt1E6/CyOPYUQv4MeS019e2x9uYXsaeIQ5G5V2wOAnt7EYCBIo7NZ9tfJoQftaL2jctXk S5ltXizWQ76tL9faNNJeCAMs0QWYG+TYqbmBF9Ek7IFTI13dkxvHYprUmMTh3/LgpdaFTo DSQxO3nMSThOvFuFqEJD4Tn96QOucko= Subject: Re: [PATCH v2.5 1/5] libxenguest: support zstd compressed kernels To: Ian Jackson Cc: "xen-devel@lists.xenproject.org" , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , M A Young References: <24590.44019.51460.33930@mariner.uk.xensource.com> From: Jan Beulich Message-ID: Date: Mon, 25 Jan 2021 13:42:33 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <24590.44019.51460.33930@mariner.uk.xensource.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 25.01.2021 12:30, Ian Jackson wrote: > Hi. Thanks for this. Firstly, RM hat: this is the tools half of zstd > decompression support which I think is a blocker for the release. So > I am going to waive the last posting date requirement. Therefore, > > Assuming it's committed this week: > > Release-Acked-by: Ian Jackson Thanks. > Secondly, I think it would be sensible for me to review it: > >> As far as configure.ac goes, I'm pretty sure there is a better (more >> "standard") way of using PKG_CHECK_MODULES(). > > Yes, what you have done is rather unidiomatic and seems to rely on > undocumented internals of the PKG_*. macros. Which specific part of the construct are you referring to? I didn't think I used anything outright undocumented. Of course I did have some trouble finding suitable docs, but in the end I managed to locate at least something that I was able to grok. > Why not do as was done for bz2, lzma, lzo2 ? Because the pkg-config approach is more flexible - aiui AC_CHECK_HEADER() and AC_CHECK_LIB() won't find a dependency when sitting in some custom place, which the *.pc files are specifically supposed to cover for. > Printing the errors to configure's terminal is > not normally done, either. With this you mean the AC_MSG_WARN()? I'm okay to drop it; I was actually half tempted to myself already, but thought having it would be better in line with PKG_CHECK_MODULES() when not passed a 4th argument (where it gets quite verbose, but of course also fails the configure process altogether). >> The construct also gets >> put next to the other decompression library checks, albeit I think they >> all ought to be x86-specific (e.g. placed in the existing case block a >> few lines down). > > I don't understand why there is an x86-specific angle here. On a "normal" libxenguest build decompression is available only on x86, because of SRCS-$(CONFIG_X86) += xg_dom_bzimageloader.c Hence the dependencies thereof also only ought to need checking on x86. I have to admit I'm uncertain about the stubdom build. I was merely implying that if decompression is unavailable in "normal" builds outside of x86, then _if_ non-x86 builds of stubdom exist in the first place, decompression code there is at best dead (the quoted restriction from Makefile applies in this case too, and hence I can't see callers of that code, despite ifeq ($(CONFIG_LIBXC_MINIOS),y) SRCS-y += xg_dom_decompress_unsafe.c SRCS-y += xg_dom_decompress_unsafe_bzip2.c SRCS-y += xg_dom_decompress_unsafe_lzma.c SRCS-y += xg_dom_decompress_unsafe_lzo1x.c SRCS-y += xg_dom_decompress_unsafe_xz.c SRCS-y += xg_dom_decompress_unsafe_zstd.c endif not restricting it to x86). >> This follows the logic used for other decompression methods utilizing an >> external library, albeit here we can't ignore the 32-bit size field >> appended to the compressed image - its presence causes decompression to >> fail. Leverage the field instead to allocate the output buffer in one >> go, i.e. without incrementally realloc()ing. > >> + insize = *size - 4; >> + outsize = *(uint32_t *)(*blob + insize); > > Potentiallty unaligned access. IDK if this kind of thing is thought > OK in hypervisor code but it it's not sufficiently portable for tools. Also a possible endianness issue, yes. Since as per above this code gets used on x86 only, I thought this would be fine at least for now. In fact before using this simplistic approach I did check whether xg_dom_bzimageloader.c had suitable abstraction available, yet I couldn't spot any. > The rest of this code looks OK to me. I spent quite a while trying to > figure out the memory management / ownership rules for the interface > to these decompression functions. This business where they all > allocate a new buffer, and overwrite their input pointer with it (but > only on success), is pretty nasty. I wasn't able to find where the > old buffer was freed. But the other decompressors all seem to work > the same way. Urgh. In summary: nasty, but, this new code seems to > follow the existing convension. Yes, this isn't pretty, but looks to have served the purpose. I'd be happy to see it improved, but I'm afraid beyond what's in this series I won't have much time to help the overall situation. Jan