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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 67F85C433F5 for ; Sat, 18 Dec 2021 21:52:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C05FD8304A; Sat, 18 Dec 2021 22:52:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EjGkW2Zo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4672583028; Sat, 18 Dec 2021 22:52:00 +0100 (CET) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AD25C83458 for ; Sat, 18 Dec 2021 22:51:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wr1-x436.google.com with SMTP id e5so11371629wrc.5 for ; Sat, 18 Dec 2021 13:51:47 -0800 (PST) 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=N5yp4A1vgu3rhHla2LqOPCwy69ZaiP64aEC88zcxY1U=; b=EjGkW2Zo6eJ/5Wbf2KxGZQvpVhuibmaT77EjMta6cSnSthNLFOcWPzpiomf3m2X8ko yNZ40qXfmpTEeiD89Ugq7yqCHjY53n9pnzTGWLTdrrQnFIY0/tt681iJfnvKYoEm5bxw L7zyMRP8+LoNX8k7PycX9nmed8rADIUhy94ebXWAgYhTvIgZ5+8bs0oRrm4N8AY5TE8u /hErUJfFDKKH5AqHGb5b3gn5HZXQq+YgCsD1b/7+J16/RN1a6UAYmLol9FmTxB0l+n8v AdexmdPt61X77aHE8p2DPd0qhRNx0PQxTL7CDkF4lqNSA+9oBSocUCuTR89V3Jh9KN6r /7hQ== 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=N5yp4A1vgu3rhHla2LqOPCwy69ZaiP64aEC88zcxY1U=; b=VH81floNi9d8cjCm6Zq2Rl+kbkslM1pQqoCHQiIf53gR1d1j3tj/oKxVq2V0FKWgVM jPE2/TGvJzsFv7FMeN6Ypprp3C+WG7skL9pIvV6KNY1d4nwvpSKRguv2RbzdqZfQPszB 0N8tz/HrGmhGO0pBwDnO2/qQgh1EG6vWh7/nTPpk2rZm7HXWDiPDVeJ7N3RBTZI1k4f7 Tn8Qb9XNzR4tTuyszM3kHyILSC+KDX370l6TrHXREuSBWB9u0pP8lufR8/fVQAH4xBXF iZ6ifyS/Qnmt/m28I3T5PGbwegwU5ZqwIVCw6KlkRz/9Srd17xzDDfJZzNWJJ5IvTcCn 9FuA== X-Gm-Message-State: AOAM532kONRtNfbyvWgcKM5/R5J3+5DaguIhlLZQqg9UeB5vcNXl3XC6 xPGQHrsf226pGQE3rbnDNoVcLbCcAVRS0w== X-Google-Smtp-Source: ABdhPJyZ6WssTzJsV51uxAr1Bcrwo+joxVv6bbrNQeWJBVh/JJ1eLIXChwwYmBbyEgw5Moc5Mz76gw== X-Received: by 2002:adf:c146:: with SMTP id w6mr7583259wre.541.1639864307186; Sat, 18 Dec 2021 13:51:47 -0800 (PST) Received: from hades (athedsl-4461669.home.otenet.gr. [94.71.4.85]) by smtp.gmail.com with ESMTPSA id c8sm3544907wrp.40.2021.12.18.13.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Dec 2021 13:51:46 -0800 (PST) Date: Sat, 18 Dec 2021 23:51:44 +0200 From: Ilias Apalodimas To: Heinrich Schuchardt Cc: paul.liu@linaro.org, Alexander Graf , u-boot@lists.denx.de Subject: Re: [PATCH] efi_loader: Bump the number of shared pages with StandAloneMM Message-ID: References: <20211215075000.1885137-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Hi Heinrich, On Sat, Dec 18, 2021 at 12:03:34PM +0100, Heinrich Schuchardt wrote: > > > On 12/15/21 08:50, Ilias Apalodimas wrote: > > Currently we allow (and explicitly check) a single shared page with > > StandAloneMM. This is dictated by OP-TEE which runs the application. > > However there's no way for us dynamically discover the number of pages we > > are allowed to use. Since writing big EFI signature list variables > > requires more than a page, OP-TEE has bumped the number of shared pages to > > four. Bump our page checks to four as well. > > > > Note here that checking some kind of version and reason with the > > compatibility doesn't make too much sense. We sanitize the number of pages > > internally in our U-Boot code but eventually OP-TEE will fail if we try to > > write more than it's allowing. The error will just happen later on when we > > access StandAloneMM. So in order to avoid compatibility checks change the > > number to four unconditionally. > > > > Signed-off-by: Ilias Apalodimas > > Tested-by: Ying-Chun Liu (PaulLiu) > > --- > > lib/efi_loader/efi_variable_tee.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c > > index 281f886124af..95eaeaa5fd9d 100644 > > --- a/lib/efi_loader/efi_variable_tee.c > > +++ b/lib/efi_loader/efi_variable_tee.c > > @@ -261,8 +261,8 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size) > > * with StMM. Since OP-TEE will reject to map anything bigger than that, > > * make sure we are in bounds. > > */ > > - if (*size > OPTEE_PAGE_SIZE) > > - *size = OPTEE_PAGE_SIZE - MM_COMMUNICATE_HEADER_SIZE - > > + if (*size > 4 * OPTEE_PAGE_SIZE) > > + *size = 4 * OPTEE_PAGE_SIZE - MM_COMMUNICATE_HEADER_SIZE - > > MM_VARIABLE_COMMUNICATE_SIZE; > > Why do we need this check at all if OPTEE checks again? > OP-TEE will have to try and register the memory in tee_shm_register() to fail. So since we know if only allows 4 pages we have an internal sanity checking to bail out earlier. Regards /Ilias > Best regards > > Heinrich > > > /* > > * There seems to be a bug in EDK2 miscalculating the boundaries and