From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F309FC433F5 for ; Tue, 12 Apr 2022 17:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M2D75y37fE7/pvebIt0wdKerpGpx7W70jbTcNmYgDZg=; b=MNfwSbLjTJqXER 0M+WjlOSkjk7KD+cLgUEvt1R84F9scihT+GqxICK1X21zQ6tDZ167o08gk0PX98Pn/aXCe32qVWqg qRKNUFSGqw2mqnsp8Kq8n0dJB/qm4d2OZO16SA6UXntTAdB3j37RDSFvwAWwZWZPk/MWnRDnRMdWo YvQXwXMWeitrYgxjQGTJOcutRb4OxqtgsaxjJht8WUtiAiex85wp++42ciRNLP3HK6Y6P5G1fiGW/ /hrSHdMejfY+bPjPtjOcO7WWXapd/1s3uxbDMg4gGFhje0T3TlA1kndiJAAHS+VdP/IIVUmL1k114 ezXRJwcZ9CVsgPoxcRjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1neKce-00FMgG-RB; Tue, 12 Apr 2022 17:48:14 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neKcW-00FMdN-5M for linux-arm-kernel@lists.infradead.org; Tue, 12 Apr 2022 17:48:05 +0000 Received: by mail-pf1-x434.google.com with SMTP id bo5so18144251pfb.4 for ; Tue, 12 Apr 2022 10:48:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kBQhwTh4wGFWQQwe4mM4wltP+peU9rNcUNkHbTMG0qg=; b=oM7dH7p7ixQjtv91MZcAmU9zCDwrKw6QynMRiSX5QxutMf0ZdCJgbAgDI3wJL5UPpr 6FNHRy3Pr24OYLzFQqtgyX6b4MNf3y71tgLfbqW0trh7/KnJE/0HQAploRCAyFaZYvM8 tw4EdzYpXIYkg4ExyuFf3MB5rg8/wUR31ymFufKgvNZDXMx+s4ypDJfnPQjaYCcRXB9g SQ/Z28O0piaUYOJ3l4THQfw26JLJwXgZEP271PAEgipV9/Ot8KaQrsUgIvOsxvU/cdXX L1B/z6tDEFv9hPe1xt8fkP7DujOqR4Jz+vP3s0wHPv7PzwlDtqw0eJ1B+O1cSEfek26o T66A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kBQhwTh4wGFWQQwe4mM4wltP+peU9rNcUNkHbTMG0qg=; b=DHjY8WhiDBJgi4KowgGUchR19QOqDDlPCLXS2sO84F19lVpcYFoZhxlP7hlvMNt2R0 kKVzSKS2kv4CKbqjlJw3fxNxX3UfEeRmXOBVxoMgIAjgSQTHG84/ZPrGJWdy5q3BO9q9 ipaISKr+jVOn73ulqAa+ft+Y5ZiokBeBNyN1Zz279KqX0t0dCHuJERaknTMIIBV46wY5 LEFV/5JQSJ/EwSbuxgPAjsrjPFIczyuz8pFAg89AMIcF5nKKIiHNZ5A7hSTuvO3p44Um QQNOUkg0CgLzWdykGjh8dM6gJPJ+JAnIRpbZa2E0puzlZKXFikvZoEhj52YA9rPs5YBE D9hg== X-Gm-Message-State: AOAM533v7bfGoyc+rc0W/tZkHmrv8LyrfwGpn0CBJ+SGEzTuFWQxw7gB RDZfteNpi8ZomxWwsBZR39c/9A== X-Google-Smtp-Source: ABdhPJy0V0sgG6uM7pznulDzc1E8eQeVDwDpFM11r3aOV36Hr5GwPLKpjkcmRjXwpK47iDiMzaJ6dg== X-Received: by 2002:a63:ec0c:0:b0:39d:3aa6:4513 with SMTP id j12-20020a63ec0c000000b0039d3aa64513mr11851204pgh.391.1649785682142; Tue, 12 Apr 2022 10:48:02 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id 13-20020a17090a0ccd00b001cb8984dc28sm137579pjt.22.2022.04.12.10.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 10:48:00 -0700 (PDT) Date: Tue, 12 Apr 2022 11:47:58 -0600 From: Mathieu Poirier To: "Peng Fan (OSS)" Cc: bjorn.andersson@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, shengjiu.wang@nxp.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org, Peng Fan Subject: Re: [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Message-ID: <20220412174758.GB465495@p14s> References: <20220323064944.1351923-1-peng.fan@oss.nxp.com> <20220323064944.1351923-2-peng.fan@oss.nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220323064944.1351923-2-peng.fan@oss.nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220412_104804_303039_6649831B X-CRM114-Status: GOOD ( 24.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Peng, On Wed, Mar 23, 2022 at 02:49:43PM +0800, Peng Fan (OSS) wrote: > From: Peng Fan > > Per elf specification, > p_filesz: This member gives the number of bytes in the file image of > the segment; it may be zero. > p_memsz: This member gives the number of bytes in the memory image > of the segment; it may be zero. > > There is a case that i.MX DSP firmware has segment with PT_LOAD and > p_memsz/p_filesz set to zero. Such segment needs to be ignored, > otherwize rproc_da_to_va would report error. > > Signed-off-by: Peng Fan > --- > drivers/remoteproc/remoteproc_elf_loader.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c > index d635d19a5aa8..cb77f9e4dc70 100644 > --- a/drivers/remoteproc/remoteproc_elf_loader.c > +++ b/drivers/remoteproc/remoteproc_elf_loader.c > @@ -181,7 +181,14 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) > bool is_iomem = false; > void *ptr; > > - if (type != PT_LOAD) > + /* > + * There is a case that with PT_LOAD type, the > + * filesz = memsz = 0. If memsz = 0, rproc_da_to_va > + * should return NULL ptr, then error is returned. > + * So this case should be skipped from the loop. > + * Add !memsz checking here. There are several architecture where XYZ_da_to_va() does not return a NULL pointer when @len is 0, making this comment inaccurate. Please remove that part. > + */ > + if (type != PT_LOAD || !memsz) > continue; I have reflected long and hard on this one... If @memsz is 0 then @filesz _has_ to be 0, otherwise rproc_elf_load_segments() returns -EINVAL. If @filesz is also 0 then nothing gets copied (for architectures where XYZ_da_to_va() doesn't return a NULL pointer when @len is 0), which is exactly the same as what the above change does. As such I am inclined to view this set favourably. That being said we will have to proceed cautiously. If something breaks we will have to revert it. Please send another revision as quickly as possible so that it can stay in linux-next long enough to, hopefully, catch any problems. With the above and for this set: Reviewed-by: Mathieu Poirier > > dev_dbg(dev, "phdr: type %d da 0x%llx memsz 0x%llx filesz 0x%llx\n", > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel