Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1153303ybb; Fri, 10 Apr 2020 18:57:19 -0700 (PDT) X-Google-Smtp-Source: APiQypKPVmcFPlYnH9X72XuayOp3fSLaDpuwG4HbXIlzW53nLm9Wy7+do4PIdXUx+9YY7JVtsn4I X-Received: by 2002:a0c:a899:: with SMTP id x25mr7914742qva.232.1586570239424; Fri, 10 Apr 2020 18:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586570239; cv=none; d=google.com; s=arc-20160816; b=ZBTS49rm1XHNSOomb/fOjhuoJdfHWEryY2chtnxFQdzkBQse3rwQuK2YzqJMirw6lE VAaD4EuL5wDz60+UViMJYPSj3bYe6tkp0EsH6VZp9ShY1NmKDkzp01BiEMtv9GgygEIl mQHe8hiZdEVgtbMSVXEk6wgRZRnHaLGyk/Oc+Jzm+A/E6H18jxO+ZnsXaGpot97vOVOQ vomYjwktYFE5uxBgrkXzFzNOXdlTQkxi/Vo79h+2QXkgZStv9DT3pmsNLBtSXqHPcFEd 4Ppw/wMkL17PNPqaJq6pYX7fzOS4Q3Tl3Zn6VNkrFh/oHSmx9/o63oYQNDZXV7LbW5Om ALhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=E2bgb+oAffEcAeqUQQsolpBF7Sog6SMgq/QFxjAFZ7E=; b=TjQjQDzkgtBBn0K1XFwLvtgSmI/6RHjV0epwtNLAUDTZszQoENnOAHzaSABKbdXVOm pB9zGLjPQLiHr6UmoKB/xTRxQKz5OrdlKJJiet2DL70LsEYCf9LqNSOrHM40KsHDEH4x QK2Ix7yWC45+SWr8oS1Zr/TjWSZSNqP1VyKfILICp3MbyNoDsR/WVkz+CZ/2EMGpUJuz /HL9KeZtOOIiivBCBPl17JSYkbnzhQhKdpIUwvY9sxkMILRJ/ZU7oDj1uqeLPEn4Fe4L ivddXCKUGqthYRMr/T/dnx+irN1TAFci2NqAa/JzcUV58SPtPd1lgDTe1D5aXPTcqEIq k+oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m4puwzcB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n74si2244066qke.375.2020.04.10.18.57.04; Fri, 10 Apr 2020 18:57:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m4puwzcB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbgDKBzQ (ORCPT + 99 others); Fri, 10 Apr 2020 21:55:16 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46562 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbgDKBzP (ORCPT ); Fri, 10 Apr 2020 21:55:15 -0400 Received: by mail-pg1-f196.google.com with SMTP id k191so1703655pgc.13 for ; Fri, 10 Apr 2020 18:55:13 -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=E2bgb+oAffEcAeqUQQsolpBF7Sog6SMgq/QFxjAFZ7E=; b=m4puwzcBIV/VTFWnJGyENhqTPmhh4XIOMy47RIuxV3TKzVlyumWFjMN9HtMR74j2f2 +j8ruJBuoZ0lLzLmd9NxBi9pF4uNP+PD+d4mnP3TwvGQ5ElZ7lvJ/HDm5dfPKTz0do70 dIpHKSiAG8+AwMyNZY1ttFNPS7rGbeicOe20eIBQOVGifuXE/qlSfZZpIr6UMgYQZIYj EHGn+jkROhii88gOcXrQoTbb6Pp4/2zcfW5+wosyvg04Vk77na1lBARiI++l9oLnBMNo h84Jx3Q4m9J2sDA0/szn6lX+oiUtqH0cZtoHdCrL7NG8jOjElCbm5DbCRTzUr64xt6ew gqNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=E2bgb+oAffEcAeqUQQsolpBF7Sog6SMgq/QFxjAFZ7E=; b=lyIh9STSz4Ne9QrJGZ1iO3eAn6n9gCXCtqD3dZyxuUTiBB/DxHpKjVjS5GEIp4CSJN 7TA/XtZlml6V5lX/+TMkmEFrF6GvFN10ZYkybDH9l8ox8+jgxQcm7iRxhvDsq0E+KR81 pjWITqGdA57WRM+FzY1YKTDf/HeBnN4/+Xmc2XpoZw5rkeJbJHJc3OZfWXWvLn0s/PlJ b0SzoGOnVE4yUXjqS4FLlkphYNgNlXZ4opDbQ3vdegYJw/y6CDROPr39nHtv/rWSxuYK HlUD0dmqZ4fFI3dc9aHdl2Vr7iGNVCke66gCLnVBg6H18VAMVszbqd4u+FW8jW8UdVh2 GODg== X-Gm-Message-State: AGi0PubIMA0WkP0hCgc1jbwIBf7wjdQMjWmVgHdUcv4VK4VynnBtiAMB cGNbDBfHJxft3DCN6lg022GpMJ5NV9k= X-Received: by 2002:a63:4625:: with SMTP id t37mr6712802pga.83.1586570113100; Fri, 10 Apr 2020 18:55:13 -0700 (PDT) Received: from builder.lan (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id m11sm2830542pfh.57.2020.04.10.18.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 18:55:12 -0700 (PDT) Date: Fri, 10 Apr 2020 18:55:22 -0700 From: Bjorn Andersson To: Peng Fan Cc: "ohad@wizery.com" , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx Subject: Re: [PATCH 2/2] remoteproc: use filesz as backup when translate memsz fail Message-ID: <20200411015522.GK576963@builder.lan> References: <1586420572-28353-1-git-send-email-peng.fan@nxp.com> <1586420572-28353-2-git-send-email-peng.fan@nxp.com> <20200410012226.GV20625@builder.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 09 Apr 18:32 PDT 2020, Peng Fan wrote: > Hi Bjorn, > > > Subject: Re: [PATCH 2/2] remoteproc: use filesz as backup when translate > > memsz fail > > > > On Thu 09 Apr 01:22 PDT 2020, Peng Fan wrote: > > > > > Since we no need memset if memsz is larger than filesz, we could use > > > filesz for the da to va translation when memsz translation fail. > > > > > > > To me this implies that the firmware has a segment that's larger than the > > memory that it's going to run in. I think even if we're not writing to the entire > > memsz, asking da_to_va for the entire memsz provides a valuable sanity > > check. > > da_to_va implies that Linux should have the va map to da. However > that will be case that Linux is not able to touch all da, it only able touch > half. Then Linux should also map all da? > So you have memory described in your ELF that can only be accessed by the remoteproc? And this memory is covered by segments of type PT_LOAD? What's your strategy for making sure that filesz stays within the boundaries that the ELF loader is allowed to touch? Regards, Bjorn > Thanks, > Peng. > > > > > Regards, > > Bjorn > > > > > Signed-off-by: Peng Fan > > > --- > > > drivers/remoteproc/remoteproc_elf_loader.c | 12 ++++++++++-- > > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/remoteproc/remoteproc_elf_loader.c > > > b/drivers/remoteproc/remoteproc_elf_loader.c > > > index cc50fe70d50c..74d425a4b34c 100644 > > > --- a/drivers/remoteproc/remoteproc_elf_loader.c > > > +++ b/drivers/remoteproc/remoteproc_elf_loader.c > > > @@ -229,8 +229,16 @@ int rproc_elf_load_segments(struct rproc *rproc, > > const struct firmware *fw) > > > if (!ptr) { > > > dev_err(dev, "bad phdr da 0x%llx mem 0x%llx\n", da, > > > memsz); > > > - ret = -EINVAL; > > > - break; > > > + > > > + ptr = rproc_da_to_va(rproc, da, filesz); > > > + if (!ptr) { > > > + dev_err(dev, > > > + "bad phdr da 0x%llx mem 0x%llx\n", > > > + da, filesz); > > > + ret = -EINVAL; > > > + break; > > > + } > > > + > > > } > > > > > > /* put the segment where the remote processor expects it */ > > > -- > > > 2.16.4 > > >