Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3199754ybb; Mon, 13 Apr 2020 02:56:03 -0700 (PDT) X-Google-Smtp-Source: APiQypKlanxKK09RsYgd4JRXMlAi/0nRbg3Cc5ZZs/zz+omq3vB0ix3/Pcpz7qojnNHRPi5Ko2XV X-Received: by 2002:a17:906:55d2:: with SMTP id z18mr15139129ejp.359.1586771763668; Mon, 13 Apr 2020 02:56:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1586771763; cv=pass; d=google.com; s=arc-20160816; b=H9xbGMnj86/Zm51kYHu8ejJ8XoY4Ui4jGxtpbhQ3VHIRtpvGYq9qEn5zcYcEHmkYe4 MSqwJ68AA776W4Ki5PY8mUGNpD3EauuqpbLszYa6vA/0xJQ/tQ5cx4tmOvrJVU6aGcwZ lM46sp98R6cnHVs/iBN9Np6HSdEdWNAlifnvWJskE1g+esZgA5hpCP9W/JyOVqiUOS1+ YR77ANe0svW4O15U/wa7zGSjjPFptGLIu28YOw7mIGi0ben6IoDUanqKDRz/z2ClZV3s cQ/3eQWCGu9nhZGdaZm4mobgLvDQwcYwKJ0skCkVpucTuWzUdJdY5WvgD6a1qBi/9C1w h1Og== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=FtNy7eOo4kYwRmxieTsNVo0TpJFD1FVYxj4rvMSdu0s=; b=j1iMlJAEwKXhzjwnEHQAIMS8m9oentLMgPJ7QjSs7NqWNN8oYWdaSEdmR6Rps5sZeI BmpVa7WcjyZv3zAgb1o3/dbbfnQaPoGiAllxqZu2eeh+CN9TcwdRIYJWvpQvYurei6Ui z6DzyIBteoFIkZFOCn0GpbI7CwAH1bKN252KMo0JoXbZ8pAEj9A8dy5FLCWJRx1tZPW0 WM48vOSDUhCNMBGxdv+X8wp8HTFsjYMNHN1dOQJw3p7Wv8rCdI2mxMXkwjKsol6DFCCn e6pvDBILXC+ZkGUe0Q7caE/tP4LFqqg7AQpSp5Qwd9iS2juGJDj++G2kexFxzd/D9vr/ jclQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=UmAVr+U1; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si6612519ejj.79.2020.04.13.02.55.39; Mon, 13 Apr 2020 02:56:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=UmAVr+U1; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728142AbgDMJGC (ORCPT + 99 others); Mon, 13 Apr 2020 05:06:02 -0400 Received: from mail-eopbgr40084.outbound.protection.outlook.com ([40.107.4.84]:9462 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727889AbgDMJGB (ORCPT ); Mon, 13 Apr 2020 05:06:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QnpB2J6uUMazwRSgGVEBBC+OlyEt5ANPiZV7R1cYRNSLmsNcb94m+DTw6XyWUWSLa40VyINJQe7jY3SMfKRuESU+6vXHwLU9a9bA823XKMrQg4MCfw/w7i25pZSVuouP4QBQQtYqjUCY3XfXsUFNLAaKSTeU8zS4tmmZuvqvkmPjTBAfObj072pVy9qePddC6KNdCT0prscPjCAPfKwGkSc374RYN9R/2BAcDlHilSv4cffAG7Bhj0HcVx7jvoRi/bYc8Mf6D/B8fOR0X5hBC1zl6jNK9UNDT1UiBe0cpnfZNmOTnP7+cqZWpph1/sYGxYovO7dhf814/nhyzUV7+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FtNy7eOo4kYwRmxieTsNVo0TpJFD1FVYxj4rvMSdu0s=; b=nWDpjPoMkchCcmDJ7fAh6ihMSk6W+fC5ZHH2Z/MoNjHNKmFZzkDUfGXfgB30pZmPPeB/Kskx9zhEn2Nd/hKmIl2WgLobkkb13/zMoZf5ror6gwo/4CXmq4+tnwx4Enu9myshF/ucoGYouLt7l7DBf+je4YFO3GagglV+IPnej1/hBzdznnnytDK2uIUDqPDAhrdLXMo0Ve9sYN06b5r9x78UOJqejuhLh3jSyPnOl7wJw4m12dbglBeK81cZMwaHNtD1AP5LeXDS42ij/dRcEbs2EAgwlM6tDosKCvD+R//O1mDAokTi/Q3UGWNHGu6ILW+brxhZ1ZZkShpDGWjP5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FtNy7eOo4kYwRmxieTsNVo0TpJFD1FVYxj4rvMSdu0s=; b=UmAVr+U176Sa3jsVNHV0dz8AQ+d3XUHCS6zOCRCg6KHqxOXjTHsrwTPbLAfii3gAiaiUcWHnRT/RvQaAr5Gz1iRamnM1MPYaXZ1KYYb5+IUuJR+Tz8z9agwDFVKvtbSbITtvT8j/DdE3lnDzNG/F2rjitfuMMJSHJsLVNMdQ3Rk= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) by AM0PR04MB5090.eurprd04.prod.outlook.com (2603:10a6:208:bf::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.17; Mon, 13 Apr 2020 09:05:54 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::ad44:6b0d:205d:f8fc]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::ad44:6b0d:205d:f8fc%7]) with mapi id 15.20.2900.026; Mon, 13 Apr 2020 09:05:54 +0000 From: Peng Fan To: Bjorn Andersson CC: "ohad@wizery.com" , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , dl-linux-imx Subject: RE: [PATCH 1/2] remoteproc: drop memset when loading elf segments Thread-Topic: [PATCH 1/2] remoteproc: drop memset when loading elf segments Thread-Index: AQHWDkksD911aIjfYEmeF50HneT1dahxj+QAgAAA5uCAAZn1AIADm4TQ Date: Mon, 13 Apr 2020 09:05:53 +0000 Message-ID: References: <1586420572-28353-1-git-send-email-peng.fan@nxp.com> <20200410012034.GU20625@builder.lan> <20200411015104.GJ576963@builder.lan> In-Reply-To: <20200411015104.GJ576963@builder.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: fdd4cf23-8d89-4f2f-54c7-08d7df89def1 x-ms-traffictypediagnostic: AM0PR04MB5090:|AM0PR04MB5090: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 037291602B x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB4481.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(346002)(376002)(366004)(39860400002)(396003)(136003)(6916009)(54906003)(33656002)(316002)(55016002)(6506007)(52536014)(9686003)(71200400001)(5660300002)(66556008)(66946007)(7696005)(8676002)(2906002)(186003)(8936002)(478600001)(4326008)(44832011)(64756008)(66446008)(76116006)(26005)(66476007)(86362001)(81156014);DIR:OUT;SFP:1101; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BjTddog6dwyQhPkK0T1F/ylMsZRPLM5v8Vp8kqBjmC62/ixRMMkV+WcfzNvDfOmALhpNCn1HW3l0f3UO6SHM5lfUjmQJ6d1iYl7uA2QGqpr5lw+4xznwtmxELsuwIGMYHQuNbPjop6PKvsZwt3FAo+lxlm6nsA2K1TOP3xaTgkLagTNbi1tk/m1Y1RoVjcXvhzt1hLXEFR6bXnXUfKB/74TugsIw9XC6EvaNH25eyYQX4muEI1ooeExvzLZcZHHU+9CM4vVxK/af/eCBaYbcnuo+RVrjKvbIqLU1y//MazPO3HRFHEU5jDNbgmRLMh7vgE2Iqe3XXt1c9f433ZC1TVWnhytE3Alkd4HH3kagWjOTildIaishuqqNSq6TtSQIr3elvTtUQEPEffG3f4j0+pcURfl56eRBLF+NZfPjY0lNBw3bILQcLTXbcqfXrHSX x-ms-exchange-antispam-messagedata: TSLI+5xqJj4ot/DeGtJeshwC6h/kyHR43FohJ9sjEEoRcCOC+sG9NkeK7GBbFl9QSgDS2WZGy6J+whWrFsRuHq2ALBL3OiO7V4O19wP0+P+bT1uKYiXA4a6cu8syAShW/qdIL9t0PgBvfCEI+UQk2w== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fdd4cf23-8d89-4f2f-54c7-08d7df89def1 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Apr 2020 09:05:53.9516 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: vqBU7JJOBlwQxGJ46OPEDZsF20rCOZvrXIy5+4XqatlKB87wWXbvpbYnFQCPk2ONXIyAY6qGEetWgKSWHr4mxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5090 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf > segments >=20 > On Thu 09 Apr 18:29 PDT 2020, Peng Fan wrote: >=20 > > Hi Bjorn, > > > > > Subject: Re: [PATCH 1/2] remoteproc: drop memset when loading elf > > > segments > > > > > > On Thu 09 Apr 01:22 PDT 2020, Peng Fan wrote: > > > > > > > To arm64, "dc zva, dst" is used in memset. > > > > Per ARM DDI 0487A.j, chapter C5.3.8 DC ZVA, Data Cache Zero by VA, > > > > > > > > "If the memory region being zeroed is any type of Device memory, > > > > this instruction can give an alignment fault which is prioritized > > > > in the same way as other alignment faults that are determined by > > > > the memory type." > > > > > > > > On i.MX platforms, when elf is loaded to onchip TCM area, the > > > > region is ioremapped, so "dc zva, dst" will trigger abort. > > > > > > > > Since memset is not strictly required, let's drop it. > > > > > > > > > > This would imply that we trust that the firmware doesn't expect > > > remoteproc to zero out the memory, which we've always done. So I > > > don't think we can say that it's not required. > > > > Saying an image runs on a remote core needs Linux to help zero out BSS > > section, this not make sense to me. >=20 > Maybe not, but it has always done it, so if there's firmware out there th= at > depends on it such change would break them.. Got it. >=20 > > My case is as following, I need to load section 7 data. > > I no need to let remoteproc to memset section 8/9/10/11/12, the > > firmware itself could handle that. Just because the memsz is larger > > than filesz, remoreproc must memset? >=20 > By having a PT_LOAD segment covering these I think it's reasonable to > assume that the ELF loader should be able to touch the associated memory. >=20 > > Section Headers: > > [Nr] Name Type Addr Off Size > ES Flg Lk Inf Al > > [ 0] NULL 00000000 000000 > 000000 00 0 0 0 > > [ 1] .interrupts PROGBITS 1ffe0000 010000 000240 00 > A 0 0 4 > > [ 2] .resource_table PROGBITS 1ffe0240 010240 000058 00 > A 0 0 1 > > [ 3] .text PROGBITS 1ffe02a0 0102a0 009ccc 00 > AX 0 0 16 > > [ 4] .ARM ARM_EXIDX 1ffe9f6c 019f6c 000008 > 00 AL 3 0 4 > > [ 5] .init_array INIT_ARRAY 1ffe9f74 019f74 000004 04 > WA 0 0 4 > > [ 6] .fini_array FINI_ARRAY 1ffe9f78 019f78 000004 04 > WA 0 0 4 > > [ 7] .data PROGBITS 1fff9240 029240 000084 > 00 WA 0 0 4 > > [ 8] .ncache.init PROGBITS 1fff92c4 0292c4 000000 00 > W 0 0 1 > > [ 9] .ncache NOBITS 1fff92c4 0292c4 000a80 > 00 WA 0 0 4 > > [10] .bss NOBITS 1fff9d44 0292c4 01f5c0 > 00 WA 0 0 4 > > [11] .heap NOBITS 20019304 0292c4 000404 > 00 WA 0 0 1 > > [12] .stack NOBITS 20019708 0292c4 000400 > 00 WA 0 0 1 > > > > > > > > > Signed-off-by: Peng Fan > > > > --- > > > > drivers/remoteproc/remoteproc_elf_loader.c | 7 ++----- > > > > 1 file changed, 2 insertions(+), 5 deletions(-) > > > > > > > > diff --git a/drivers/remoteproc/remoteproc_elf_loader.c > > > > b/drivers/remoteproc/remoteproc_elf_loader.c > > > > index 16e2c496fd45..cc50fe70d50c 100644 > > > > --- a/drivers/remoteproc/remoteproc_elf_loader.c > > > > +++ b/drivers/remoteproc/remoteproc_elf_loader.c > > > > @@ -238,14 +238,11 @@ int rproc_elf_load_segments(struct rproc > > > > *rproc, > > > const struct firmware *fw) > > > > memcpy(ptr, elf_data + offset, filesz); > > > > > > > > /* > > > > - * Zero out remaining memory for this segment. > > > > + * No need zero out remaining memory for this segment. > > > > * > > > > * This isn't strictly required since dma_alloc_coherent already > > > > - * did this for us. albeit harmless, we may consider removing > > > > - * this. > > > > + * did this for us. > > > > > > In the case of recovery this comment is wrong, we do not > > > dma_alloc_coherent() the carveout during a recovery. > > > > Isn't the it the firmware's job to memset the region? > > >=20 > I'm not aware of this being a documented requirement, we've always done i= t > here for them, so removing this call would be a change in behavior. >=20 > > > > > > And in your case you ioremapped existing TCM, so it's never true. > > > > > > > */ > > > > - if (memsz > filesz) > > > > - memset(ptr + filesz, 0, memsz - filesz); > > > > > > So I think you do want to zero out this region. Question is how we do= it... > > > > I have contacted our M4 owners, we no need clear it from Linux side. >=20 > And I think _most_ firmware out there, like yours, does clear BSS etc dur= ing > initialization. >=20 > > We also support booting m4 before booting Linux, at that case, Linux > > has noting to do with memset. It is just I try loading m4 image with > > Linux, and met the issue that memset trigger abort. > > >=20 > Please see the proposal for attaching to already running remoteproc's fro= m > Mathieu. I don't expect that you want to load your PROGBITS either in thi= s > case? No need to load for early boot case. It is just userspace load trigger kernel panic, because memset arm64 could not work for ioremapped memory. How about adding ops hooks for memset and memcpy to let driver have their own implementation? Thanks, Peng. >=20 > Regards, > Bjorn