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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 2FC33C48BE5 for ; Tue, 22 Jun 2021 07:24:32 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8899161026 for ; Tue, 22 Jun 2021 07:24:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8899161026 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4DB498298E; Tue, 22 Jun 2021 09:24:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=protonmail.com header.i=@protonmail.com header.b="InPRyCBe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4BD28296A; Tue, 22 Jun 2021 09:24:26 +0200 (CEST) Received: from mail-40136.protonmail.ch (mail-40136.protonmail.ch [185.70.40.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 79F6480EC6 for ; Tue, 22 Jun 2021 09:24:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=protonmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=litchi.pi@protonmail.com Date: Tue, 22 Jun 2021 07:24:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1624346662; bh=hMIihPW2Js+7IJR5PbjlIiAfvMHFZCxoS2wpx0pIN7U=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=InPRyCBelOSZcQcp7cLTO9c7UsyjY1PtnlYcg7ngCwMSP7R9aQjEbXv+UE6qJXMPA JgtaAuAPK+9fiANThb7timyZoxoAJV508iNVIFM9gQhjxADvuyXgRdkaAMxhFHTr3v qcSibR7p1a+I7WmduPL02Sv+/pH4pYA0PsmZRRHQ= To: u-boot@lists.denx.de From: "litchi.pi" Cc: Peng Fan , Jens Wiklander , litchipi , "xypron.glpk@gmx.de" Subject: Re: [PATCH] mmc: rpmb: Fix driver routing memory alignment with tmp buffer Message-ID: In-Reply-To: <20210615085255.24899-1-litchi.pi@protonmail.com> References: <20210615085255.24899-1-litchi.pi@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: "litchi.pi" Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hello, Does anyone have a feedback on that fix ? I think the location of the fix is important to be discussed too as it need= s to be generic but not overlap with existing checks. Have a nice day, Timoth=C3=A9e Cercueil =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Tuesday, June 15th, 2021 at 10:53 AM, Timoth=C3=A9e Cercueil wrote: > From: litchipi litchi.pi@protonmail.com > > Fix mmc_rpmb_route_frames() implementation to comply with most MMC > > drivers that expect some alignment of MMC data frames in memory. > > When called from drivers/tee/optee/rpmb.c, the address passed is not > > aligned properly. OP-TEE OS inserts a 6-byte header before a raw RPMB > > frame which makes RPMB data buffer not 32bit aligned. To prevent breaking > > ABI with OPTEE-OS RPC memrefs, allocate a temporary buffer to copy the > > data into an aligned memory. > > Many RPMB drivers implicitly expect 32bit alignment of the eMMC frame > > including arm_pl180_mmci.c, sandbox_mmc.c and stm32_sdmmc2.c > > Signed-off-by: Timoth=C3=A9e Cercueil timothee.cercueil@st.com > > Signed-off-by: Timoth=C3=A9e Cercueil litchi.pi@protonmail.com > > drivers/mmc/rpmb.c | 18 ++++++++++++++++-- > > 1 file changed, 16 insertions(+), 2 deletions(-) > > Changes since v1: > > - Fixed the Signed-off-by errors from previous patch. > > - This patch follows the subject discussed at: https://lists.denx.de/pipe= rmail/u-boot/2021-June/451687.html > > - Changed the commit log 1st line > > diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c > > index ea7e506666..b68d98573c 100644 > > --- a/drivers/mmc/rpmb.c > > +++ b/drivers/mmc/rpmb.c > > @@ -480,10 +480,24 @@ int mmc_rpmb_route_frames(struct mmc *mmc, void *re= q, unsigned long reqlen, > > * and possibly just delay an eventual error which will be harder > > * to track down. > > */ > > - void *rpmb_data =3D NULL; > - int ret; > > if (reqlen % sizeof(struct s_rpmb) || rsplen % sizeof(struct s_rpmb)) > > return -EINVAL; > > - return rpmb_route_frames(mmc, req, reqlen / sizeof(struct s_rpmb), > - =09=09 rsp, rsplen / sizeof(struct s_rpmb)); > > > > - if (!IS_ALIGNED((uintptr_t)req, ARCH_DMA_MINALIGN)) { > - /* Memory alignment is required by MMC driver */ > > > - rpmb_data =3D malloc(reqlen); > > > - if (!rpmb_data) > > > - =09return -ENOMEM; > > > > - memcpy(rpmb_data, req, reqlen); > > > - req =3D rpmb_data; > > > - } > > - ret =3D rpmb_route_frames(mmc, req, reqlen / sizeof(struct s_rpmb), > - =09=09rsp, rsplen / sizeof(struct s_rpmb)); > > > - free(rpmb_data); > - return ret; > > } > > -- > > 2.17.1