From patchwork Wed Dec 15 07:50:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 524242 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp102451imb; Tue, 14 Dec 2021 23:50:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9yzmmusQdG8A2qbg3BbUpDtDohPr0Ftck50rNL0ptJ2103Q5xuR6YugojqaAdYhQPrP73 X-Received: by 2002:a17:907:9801:: with SMTP id ji1mr9963703ejc.170.1639554613868; Tue, 14 Dec 2021 23:50:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639554613; cv=none; d=google.com; s=arc-20160816; b=ptdPCHx8sxBFf8/o91t11+hTYbO/6Ad7dRB3coIQ+Hn7FoaJjfdcnRXd433fJp6cAP ZLYZsskdJII2R4xEiN3uGp9Q4wC5OrCHqdpctauG5pRwotWa8S6QRUwpGC3rDas2xqIo sZSDz1NMUGRgRkrnpPQuOFP2S+cMstfiehm3o0p43UgUe2+75YBTQjGR7derXElDcuhL 0A91gw+7WPIIZBW9627sjJ0mNWq4N9z3qVBQc14wh2XaIKYri1AjOrTv13DtcByETkWr z4JHNCV3qD0Zp7Xj1Y5XAAfrT6hqQKGHyFUQuJEnvQMCG+APVnkJ49ZZGYru859Oeje0 4sfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=li+bZMyXFmllfeNROs+FUeZVOVMUYd0Pf+fn1JIK2Q4=; b=dPpOlKDyJfjjXmrncYcmunhB8Ia1/M+hhp9h4VIIQ/7KjoGkeMGxDcYjMXREvTqrxU 8K4kwWbXmr58EZImhokmS4vci8yCIAq02TUn+jXPUZKJvokzEz7OxwrJkjuWehjdwDqM pnaEXtpYBANgCnuOt063bnPq56fnUfVO+yJoSmZBw12/7CQxKJqQo/QxZdmKiG/WBLGh Wl+yQmKuTakj0eczL79rk7PRqPx4yHqER9yrBbjZrQiMZKO3UZmQUMhUUxzbIVwqIjU3 TDXa5Kqnuec5FELO+c/vv8PSOqQtvxMVDnk4uVpqOQZs3bj6/y313d+sS8r06P88JB7m 4fMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SPIKqaPH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id f10si1074519edf.573.2021.12.14.23.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 23:50:13 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SPIKqaPH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3645A8302F; Wed, 15 Dec 2021 08:50:10 +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="SPIKqaPH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D643083035; Wed, 15 Dec 2021 08:50:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 15AFC83022 for ; Wed, 15 Dec 2021 08:50:04 +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-x432.google.com with SMTP id o13so36531607wrs.12 for ; Tue, 14 Dec 2021 23:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=li+bZMyXFmllfeNROs+FUeZVOVMUYd0Pf+fn1JIK2Q4=; b=SPIKqaPHiJHxYyZbrpAbC8uQ+WAfb1JLLCbA0x0SpQSOslfEej4tYLOePQj5yLGaOj Ej7hOZjgI4yV8geKFnnmJQ+p/r1CmKdrWzK1rTNgzAcOuWXiJXkrUCdYla+ROZJ6zJnR vB2TNI5dQKVzQLi3oGiYa8qEjXX64JidWny48O4POZD8+SlpXK2pZTEiKIsvdwldc3Xv aAsEYE5qCgBUm31zptgPI26YopF6+eD15v21EzqzSi5jylIg0EYdTt92E70DzCAi0r/K 5BpTRn8+Eg66echxTKJErYokJXNPY+8S8yDAQjY5DokbxpPYfVg72T8Vi4pLlmg3mLoB /v0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=li+bZMyXFmllfeNROs+FUeZVOVMUYd0Pf+fn1JIK2Q4=; b=6/dk8Hqhk4w9nNK/X93tVqBp3i9UN+gFBjWuzNz4IvylxQcv3ACGKTgL3r3ZI90NDj wXlrYElJwfnENplom018WbSpX6bIfKNpnUW8h3SiHDSfa5+0hMBobQUazkGu0dy3dUa6 3obr3Knt0wf7i367KUPrc7AvEwOWXwZmaNNMGOLitief36ZGhQpJDRorPvY/X1fO8OlX 4JovKbj70v3ztHTX0iHlTGfj6Yr+w8ct45mGEOzG+cT4eLetXklkUIsArAbGPXqNYjUU 3bcReLJmPQ3gwO2dW9YceWWdaWl5iURIaGp5yADkXt2NVjxcVal8V/8SsYJuTJ1qi2q+ 8fkw== X-Gm-Message-State: AOAM530YW9TIzt/631Y1rn3mt4LvEki0jF2jaoBRNCWZAu0uUhU8V0pr IOKgDSajoTXzRIPAfpuexSVAvQ== X-Received: by 2002:a05:6000:118a:: with SMTP id g10mr3024770wrx.533.1639554603635; Tue, 14 Dec 2021 23:50:03 -0800 (PST) Received: from hades.. ([2a02:587:46a6:e776:230:64ff:fe3b:505d]) by smtp.gmail.com with ESMTPSA id p12sm1364091wrr.10.2021.12.14.23.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 23:50:03 -0800 (PST) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: paul.liu@linaro.org, Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Bump the number of shared pages with StandAloneMM Date: Wed, 15 Dec 2021 09:50:00 +0200 Message-Id: <20211215075000.1885137-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 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 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; /* * There seems to be a bug in EDK2 miscalculating the boundaries and