From patchwork Wed May 6 19:12:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1284673 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Y6/Uw6SG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49HR7t2v3Nz9sSW for ; Thu, 7 May 2020 05:13:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0917281D1F; Wed, 6 May 2020 21:12:59 +0200 (CEST) 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="Y6/Uw6SG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C959B81C7F; Wed, 6 May 2020 21:12:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (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 33C5381C4C for ; Wed, 6 May 2020 21:12:53 +0200 (CEST) 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-x441.google.com with SMTP id e16so3507865wra.7 for ; Wed, 06 May 2020 12:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+0hF4eMVgDHLyprXNEQQKDIdFbv0x0Qaj6430v0BXO4=; b=Y6/Uw6SG+vD/qCmhIacgX666cHJyMTdCkgc7i1f5RtPLBLxQkKIZSwXNWDJtroQKua KoUC964cKDi/Uk7eAWCdBxU7l9kFjBR4ketL4O3eeYvgP8XjcesSZ6mplJpMLB59oK7h gGQsb6GISgETMh8jcSGacqmCEv23TDpYUh3JrSuyOhnum8RHM2C1LBGZi0Vse/ufQ2w8 xaizhnUJX+MWBa8AEc2Wm4fLL4IF8iyY4KXoRmP9MfJ8wEtImQGXxrkcr42BxlIlo7Gd WE7c9o8BdrQsxBcomouiOn9dhrtgBBqoLhKQz2WI7U1bVePpF2Hj6xh19p0CPGaSLfAz Rjsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+0hF4eMVgDHLyprXNEQQKDIdFbv0x0Qaj6430v0BXO4=; b=M9vTYwNqboBy6GKfaMgfTdD7vGKJcnMM/C1H4FOd8AHJtqybtnmqoG8T/pM7bAofFH ndSwmFw2mU2nR9fBVv7fio6m+FtM9U96SrH95Bvtiyo9nxodrk1ZK1ajFQVEozFJJ51C 3yTvrvBly2SpG0aHmCIoVqtHkvOWiwi7cLmlg2JiVYhAUzJKzhEWZ7uODwOaq698h6R2 qAh5bHBfTjs0PB96TO6Cowig5rnLZdw/41zjcfnfxB4j/yQt3xLNMFi+3DhpzqLeljjZ HCc+Jm9V2PIZcUio/LliCY2+1UOppj7N3p04+BEbsEn9eX0ShSjVn3018ATm4Ra+1SrN QB4g== X-Gm-Message-State: AGi0Pub/hJRMYsmv9rWr4FiP/bUfSUNLUEJRU1S8wK4nF5IUz8MpWzfY /ldvAbtGTHb/Ib5znadl7owAJb6VpTk= X-Google-Smtp-Source: APiQypJ+fCKwnJOEsTMM66PDxuUm1CVwOJiB6FkIS1iAL8ZTlNsR0cGag0XKvvruaSJl7wp/BKI07w== X-Received: by 2002:a5d:6806:: with SMTP id w6mr11403145wru.324.1588792372651; Wed, 06 May 2020 12:12:52 -0700 (PDT) Received: from apalos.home ([2a02:587:4652:c284:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id y3sm4271918wrm.64.2020.05.06.12.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:12:52 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: agraf@csgraf.de, ard.biesheuvel@linaro.org, Sughosh Ganu Subject: [PATCH 1/6] charset: Add support for calculating bytes occupied by a u16 string Date: Wed, 6 May 2020 22:12:41 +0300 Message-Id: <20200506191246.237790-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org> References: <20200506191246.237790-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean From: Sughosh Ganu The current code uses 'u16_strlen(x) + 1) * sizeof(u16)' in various places to calculate the number of bytes occupied by a u16 string. Let's introduce a wrapper around this. This wrapper is used on following patches Signed-off-by: Sughosh Ganu Reviewed-by: Heinrich Schuchardt --- include/charset.h | 11 +++++++++++ lib/charset.c | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/include/charset.h b/include/charset.h index fde6bddbc2fb..30faa72285e6 100644 --- a/include/charset.h +++ b/include/charset.h @@ -195,6 +195,17 @@ int u16_strncmp(const u16 *s1, const u16 *s2, size_t n); */ size_t u16_strlen(const void *in); +/** + * u16_strsize - count size of u16 string in bytes including the null character + * + * Counts the number of bytes occupied by a u16 string + * + * @in: null terminated u16 string + * Return: bytes in a u16 string + * + */ +size_t u16_strsize(const void *in); + /** * u16_strlen - count non-zero words * diff --git a/lib/charset.c b/lib/charset.c index 1c6a7f693de4..a28034ee1f1e 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -379,6 +379,11 @@ size_t u16_strnlen(const u16 *in, size_t count) return i; } +size_t u16_strsize(const void *in) +{ + return (u16_strlen(in) + 1) * sizeof(u16); +} + u16 *u16_strcpy(u16 *dest, const u16 *src) { u16 *tmp = dest; From patchwork Wed May 6 19:12:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1284674 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Z4bD49HH; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49HR876k7Cz9sSm for ; Thu, 7 May 2020 05:13:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0665681CC7; Wed, 6 May 2020 21:13:02 +0200 (CEST) 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="Z4bD49HH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9A32981CD1; Wed, 6 May 2020 21:12:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (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 495AB81C64 for ; Wed, 6 May 2020 21:12:54 +0200 (CEST) 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-wm1-x344.google.com with SMTP id x25so3764817wmc.0 for ; Wed, 06 May 2020 12:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gH01Jq3x0y6TBIGcCTDcoyRJ6bzd6msNaHdQoWin4wM=; b=Z4bD49HHfUYFe/d+jJOYwWafirZc+snBlJbwRRYrvb+6Y2Tu12fjgLRZTL5XHbxbPT wQO9oy/GbMjRfKwPgTJpEVnYR1IuylQ1D3LpWu7e3Ogy8YQlgNiZ5IFpCWgN/ZO0rkm5 ffZwwXZiOzhsmfq5p3iU2gAiDZhF4BW48PhxWjfLECMM5LRSsUoEUbN1abe1v9kuFfV4 2n536KVmka34+GLw5q48So+Eqd9z1qFZFUQdfZQ+DUfvU9dlqu2yUEPt2/LVBoIuJ8Lr zBFZT9bZrStIJYgOzlViLtNnXGZ2Z6SoHa/1UAHATT1zY51HkXK1ErTx6+PFFqKYKiws n9hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gH01Jq3x0y6TBIGcCTDcoyRJ6bzd6msNaHdQoWin4wM=; b=rJSbf399r2jdiKRybbMFBOl4s0Uo1yxTgtnADaxsEYugwteJ0ClrQMqrvpHN2kPccM HduDL3BiyjtIaK2gTZwfIljaFP2A3ijKddR9durYx/nOznF04tOSoEHMmNDQjptHLxxT JO01xZCO58CtVCYd278Zzo1m8SqwoxN1jcTMtH2iKBxyISfUkGKFaiu5epfA3UEkf7O2 xS/DhuVKxdCMpB8S54o0FdvICoKL6qatPO7j+Q3A0sAKc+8G0kz4kZChXSUHAfreWQbN ons/aGfP2v5LA4iu2KIV2MwHn78JGle35e7G9IvHSa03iXU1RQIw7frLHZ1EfDG1aC5c ROOw== X-Gm-Message-State: AGi0PubpE3ktpZK7GG39zEswDaLoLvqqXpza7bCmaC9jVMS9DaVgEnrv +Aq0a6C5klfrwvf1n74M2znC/UsfTUA= X-Google-Smtp-Source: APiQypJoEFB2OZG6JUpjFcWYkMXxcd16wnLPuSMAtNT/r9tQHi0AZzNT60c/UxEnlCGtmIDLu/iRJg== X-Received: by 2002:a1c:7715:: with SMTP id t21mr5668334wmi.182.1588792373718; Wed, 06 May 2020 12:12:53 -0700 (PDT) Received: from apalos.home ([2a02:587:4652:c284:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id y3sm4271918wrm.64.2020.05.06.12.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:12:53 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: agraf@csgraf.de, ard.biesheuvel@linaro.org, Sughosh Ganu , Ilias Apalodimas Subject: [PATCH 2/6] efi_loader: Add headers for EDK2 StandAloneMM communication Date: Wed, 6 May 2020 22:12:42 +0300 Message-Id: <20200506191246.237790-3-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org> References: <20200506191246.237790-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean From: Sughosh Ganu In Arm devices OP-TEE has the ability to run StandAloneMM (from EDK2) in a separate partition and handle UEFI variables. A following patch introduces this functionality. Add the headers needed for OP-TEE <--> StandAloneMM communication Signed-off-by: Sughosh Ganu Signed-off-by: Ilias Apalodimas --- include/mm_communication.h | 28 ++++++++++++++ include/mm_variable.h | 78 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 include/mm_communication.h create mode 100644 include/mm_variable.h diff --git a/include/mm_communication.h b/include/mm_communication.h new file mode 100644 index 000000000000..fb4c91103400 --- /dev/null +++ b/include/mm_communication.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Headers for EFI variable service via StandAloneMM, EDK2 application running + * in OP-TEE + * + * Copyright (C) 2020 Linaro Ltd. + * Copyright (C) 2020 Linaro Ltd. + */ + +#if !defined _MM_COMMUNICATION_H_ +#define _MM_COMMUNICATION_H_ + +/* defined in EDK2 MmCommunication.h */ +struct mm_communicate_header { + efi_guid_t header_guid; + size_t message_len; + u8 data[1]; +}; + +#define MM_COMMUNICATE_HEADER_SIZE \ + (offsetof(struct mm_communicate_header, data)) + +#define MM_RET_SUCCESS 0 +#define MM_RET_INVALID_PARAMS -2 +#define MM_RET_DENIED -3 +#define MM_RET_NO_MEMORY -4 + +#endif /* _MM_COMMUNICATION_H_*/ diff --git a/include/mm_variable.h b/include/mm_variable.h new file mode 100644 index 000000000000..f56c52597629 --- /dev/null +++ b/include/mm_variable.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Headers for EFI variable service via StandAloneMM, EDK2 application running + * in OP-TEE + * + * Copyright (C) 2020 Linaro Ltd. + * Copyright (C) 2020 Linaro Ltd. + */ + +#if !defined _MM_VARIABLE_H_ +#define _MM_VARIABLE_H_ + +#include + +/* defined in EDK2 SmmVariableCommon.h */ +struct mm_variable_communicate_header { + efi_uintn_t function; + efi_status_t ret_status; + u8 data[1]; +}; + +#define MM_VARIABLE_COMMUNICATE_SIZE \ + (offsetof(struct mm_variable_communicate_header, data)) + +#define MM_VARIABLE_FUNCTION_GET_VARIABLE 1 + +#define MM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2 + +#define MM_VARIABLE_FUNCTION_SET_VARIABLE 3 + +#define MM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4 + +#define MM_VARIABLE_FUNCTION_READY_TO_BOOT 5 + +#define MM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6 + +#define MM_VARIABLE_FUNCTION_GET_STATISTICS 7 + +#define MM_VARIABLE_FUNCTION_LOCK_VARIABLE 8 + +#define MM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_SET 9 + +#define MM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET 10 + +#define MM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE 11 + +struct mm_variable_access { + efi_guid_t guid; + efi_uintn_t data_size; + efi_uintn_t name_size; + u32 attr; + u16 name[1]; +}; + +#define MM_VARIABLE_ACCESS_HEADER_SIZE \ + (offsetof(struct mm_variable_access, name)) + +struct mm_variable_payload_size { + efi_uintn_t size; +}; + +struct mm_variable_getnext { + efi_guid_t guid; + efi_uintn_t name_size; + u16 name[1]; +}; + +#define MM_VARIABLE_GET_NEXT_HEADER_SIZE \ + (offsetof(struct mm_variable_getnext, name)) + +struct mm_variable_query_info { + u64 max_variable_storage; + u64 remaining_variable_storage; + u64 max_variable_size; + u32 attr; +}; + +#endif /* _MM_VARIABLE_H_ */ From patchwork Wed May 6 19:12:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1284676 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Ekg8tw8d; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49HR8X4Lzbz9sSc for ; Thu, 7 May 2020 05:13:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 523798226B; Wed, 6 May 2020 21:13:08 +0200 (CEST) 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="Ekg8tw8d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0703B81E4C; Wed, 6 May 2020 21:13:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,T_FILL_THIS_FORM_SHORT, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (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 619BF81C49 for ; Wed, 6 May 2020 21:12:56 +0200 (CEST) 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-wm1-x341.google.com with SMTP id z6so4014720wml.2 for ; Wed, 06 May 2020 12:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7t1tkA0nXL+hEeKDVVFNovZ/rbWc/DDc/ugceWOzcH0=; b=Ekg8tw8dLQpazweQvhQaL7BqG/O4PswlK+DA44P3k7GL8hDrcBXsRzku6aa/DH3N1d +Tk32VJjvk91aH3Oen34kVuqjqkue6+kqKI0G93fSWWoYUxnytd6msF3qeuKY7zQX1rL 6nob4lPt+VwyJNEGcD5CesBVTEoOwsp1vCrC/SlynR3D47t2jB37gQ/TTNmHuj3hUesA ry3NMB+EMAiMA+lkowXdBQKOT+Xd1fLPHKMv0/DPFJyKDf8peS0x2D2Rv+GHt1a239vm Pia37cqEuenxcj66Z68lmAE0H/DIqTSZI8g6I7otwKJNRUE5zc3cyRck8ZPiTeyT4sRG hA2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7t1tkA0nXL+hEeKDVVFNovZ/rbWc/DDc/ugceWOzcH0=; b=sOnJnYc9QktoZf+5AwU3ZjFko30A+wsoQgtC7j47NGM0vA6EfcAZZMNpnzd+jjpsAO mAFFLjuciPBZPNZmoiukPbKH2Cgoz5za42pkEZ3qpB9Sc+ZKuGm4JjqZ1rXAl4ZlQCjH h8lLm7sfJfH2I/ZjocyewV6tbM9InXZIgn1c8z1A/C6QKzPfHa6tFMk+Kqv/Z91C8hTh 6fKrSdcmu/SR2ErYLrSH73qo0BybnhOlHpfWUJZwO0NHTV4l7GKoBhUGT7yhGC2IalfK bW+BN3F5M3ejZQtHEgEAwVyjioOHPWWtV9N7qn0v/cYTx3VZPUPImIZE5HJ8m61eYrU7 Yb6A== X-Gm-Message-State: AGi0PuamVtj9xJR6KG5ButI86cqLOvNz9sS/fZSkIwB6flB3TbmVaSNp swf97S84zBK4TPsoUshOtKmGkqeJQ9I= X-Google-Smtp-Source: APiQypIeIEm+qpyr2aUbPjA4KkeU0InaF1J/EFmvb1NwoENTsEN6AdCBYRkDuJiRJxrEaVQdkDiK1g== X-Received: by 2002:a05:600c:295a:: with SMTP id n26mr6765546wmd.16.1588792375290; Wed, 06 May 2020 12:12:55 -0700 (PDT) Received: from apalos.home ([2a02:587:4652:c284:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id y3sm4271918wrm.64.2020.05.06.12.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:12:54 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: agraf@csgraf.de, ard.biesheuvel@linaro.org, Ilias Apalodimas , Pipat Methavanitpong , Sughosh Ganu Subject: [PATCH 3/6] efi_loader: Implement EFI variable handling via OP-TEE Date: Wed, 6 May 2020 22:12:43 +0300 Message-Id: <20200506191246.237790-4-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org> References: <20200506191246.237790-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean In OP-TEE we can run EDK2's StandAloneMM on a secure partition. StandAloneMM is responsible for the UEFI variable support. In combination with OP-TEE and it's U-Boot supplicant, variables are authenticated/validated in secure world and stored on an RPMB partition. So let's add a new config option in U-Boot implementing the necessary calls to OP-TEE for the variable management. Signed-off-by: Ilias Apalodimas Signed-off-by: Pipat Methavanitpong Signed-off-by: Sughosh Ganu --- lib/efi_loader/Kconfig | 9 + lib/efi_loader/Makefile | 4 + lib/efi_loader/efi_variable_tee.c | 645 ++++++++++++++++++++++++++++++ 3 files changed, 658 insertions(+) create mode 100644 lib/efi_loader/efi_variable_tee.c diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 1cfa24ffcf72..e385cd0b9dae 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -164,4 +164,13 @@ config EFI_SECURE_BOOT it is signed with a trusted key. To do that, you need to install, at least, PK, KEK and db. +config EFI_MM_COMM_TEE + bool "UEFI variables storage service via OP-TEE" + depends on SUPPORT_EMMC_RPMB + default n + help + If OP-TEE is present and running StandAloneMM dispatch all UEFI variable + related operations to that. The application will verify, authenticate and + store the variables on an RPMB + endif diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index eff3c25ec301..dba652121eab 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -34,7 +34,11 @@ obj-y += efi_root_node.o obj-y += efi_runtime.o obj-y += efi_setup.o obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += efi_unicode_collation.o +ifeq ($(CONFIG_EFI_MM_COMM_TEE),y) +obj-y += efi_variable_tee.o +else obj-y += efi_variable.o +endif obj-y += efi_watchdog.o obj-$(CONFIG_LCD) += efi_gop.o obj-$(CONFIG_DM_VIDEO) += efi_gop.o diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c new file mode 100644 index 000000000000..d4e206e22073 --- /dev/null +++ b/lib/efi_loader/efi_variable_tee.c @@ -0,0 +1,645 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI variable service via OP-TEE + * + * Copyright (C) 2019 Linaro Ltd. + * Copyright (C) 2019 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define PTA_STMM_CMDID_COMMUNICATE 0 +#define PTA_STMM_UUID { 0xed32d533, 0x99e6, 0x4209, {\ + 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7 } } + +#define EFI_MM_VARIABLE_GUID \ + EFI_GUID(0xed32d533, 0x99e6, 0x4209, \ + 0x9c, 0xc0, 0x2d, 0x72, 0xcd, 0xd9, 0x98, 0xa7) + +static efi_uintn_t max_buffer_size; /* comm + var + func + data */ +static efi_uintn_t max_payload_size; /* func + data */ + +struct mm_connection { + struct udevice *tee; + u32 session; +}; + +int get_connection(struct mm_connection *conn) +{ + static const struct tee_optee_ta_uuid uuid = PTA_STMM_UUID; + struct udevice *tee = NULL; + struct tee_open_session_arg arg; + int rc; + + tee = tee_find_device(tee, NULL, NULL, NULL); + if (!tee) + return -ENODEV; + + memset(&arg, 0, sizeof(arg)); + tee_optee_ta_uuid_to_octets(arg.uuid, &uuid); + rc = tee_open_session(tee, &arg, 0, NULL); + if (!rc) { + conn->tee = tee; + conn->session = arg.session; + } + + return rc; +} + +/** + * optee_mm_communicate() - Pass a buffer to StandaloneMM running in OP-TEE + * + * @comm_buf: Locally allocted communcation buffer + * @dsize: Buffer size + * Return: status code + */ +static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize) +{ + ulong buf_size; + efi_status_t ret; + struct mm_communicate_header *mm_hdr; + struct mm_connection conn = { NULL, 0 }; + struct tee_invoke_arg arg; + struct tee_param param[2]; + struct tee_shm *shm = NULL; + int rc; + + if (!comm_buf) + return EFI_INVALID_PARAMETER; + + mm_hdr = (struct mm_communicate_header *)comm_buf; + buf_size = mm_hdr->message_len + sizeof(efi_guid_t) + sizeof(size_t); + + if (dsize != buf_size) + return EFI_INVALID_PARAMETER; + + rc = get_connection(&conn); + if (rc) { + log_err("Unable to open OP-TEE session (err=%d)\n", rc); + return EFI_UNSUPPORTED; + } + + if (tee_shm_register(conn.tee, comm_buf, buf_size, 0, &shm)) { + log_err("Unable to register shared memory\n"); + return EFI_UNSUPPORTED; + } + + memset(&arg, 0, sizeof(arg)); + arg.func = PTA_STMM_CMDID_COMMUNICATE; + arg.session = conn.session; + + memset(param, 0, sizeof(param)); + param[0].attr = TEE_PARAM_ATTR_TYPE_MEMREF_INOUT; + param[0].u.memref.size = buf_size; + param[0].u.memref.shm = shm; + param[1].attr = TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT; + + rc = tee_invoke_func(conn.tee, &arg, 2, param); + if (rc) + return EFI_INVALID_PARAMETER; + tee_shm_free(shm); + tee_close_session(conn.tee, conn.session); + + switch (param[1].u.value.a) { + case MM_RET_SUCCESS: + ret = EFI_SUCCESS; + break; + + case MM_RET_INVALID_PARAMS: + ret = EFI_INVALID_PARAMETER; + break; + + case MM_RET_DENIED: + ret = EFI_ACCESS_DENIED; + break; + + case MM_RET_NO_MEMORY: + ret = EFI_OUT_OF_RESOURCES; + break; + + default: + ret = EFI_ACCESS_DENIED; + } + + return ret; +} + +/** + * mm_communicate() - Adjust the cmonnucation buffer to StandAlonneMM and send + * it to OP-TEE + * + * @comm_buf: Locally allocted communcation buffer + * @dsize: Buffer size + * Return: status code + */ +static efi_status_t mm_communicate(u8 *comm_buf, efi_uintn_t dsize) +{ + efi_status_t ret; + struct mm_communicate_header *mm_hdr; + struct mm_variable_communicate_header *var_hdr; + + dsize += MM_COMMUNICATE_HEADER_SIZE + MM_VARIABLE_COMMUNICATE_SIZE; + mm_hdr = (struct mm_communicate_header *)comm_buf; + var_hdr = (struct mm_variable_communicate_header *)mm_hdr->data; + + ret = optee_mm_communicate(comm_buf, dsize); + if (ret != EFI_SUCCESS) { + log_err("%s failed!\n", __func__); + return ret; + } + + return var_hdr->ret_status; +} + +/** + * setup_mm_hdr() - Allocate a buffer for StandAloneMM and initialize the + * header data. + * + * @dptr: Pointer address of the corresponding StandAloneMM + * function + * @payload_size: Buffer size + * @func: StandAloneMM function number + * @ret: EFI return code + * Return: Buffer or NULL + */ +static u8 *setup_mm_hdr(void **dptr, efi_uintn_t payload_size, + efi_uintn_t func, efi_status_t *ret) +{ + const efi_guid_t mm_var_guid = EFI_MM_VARIABLE_GUID; + struct mm_communicate_header *mm_hdr; + struct mm_variable_communicate_header *var_hdr; + u8 *comm_buf; + + /* On the init function we initialize max_buffer_size with + * get_max_payload(). So skip the test if max_buffer_size is initialized + * StandAloneMM will perform similar checks and drop the buffer if it's + * too long + */ + if (max_buffer_size && max_buffer_size < + (MM_COMMUNICATE_HEADER_SIZE + + MM_VARIABLE_COMMUNICATE_SIZE + + payload_size)) { + *ret = EFI_INVALID_PARAMETER; + return NULL; + } + + comm_buf = calloc(1, MM_COMMUNICATE_HEADER_SIZE + + MM_VARIABLE_COMMUNICATE_SIZE + + payload_size); + if (!comm_buf) { + *ret = EFI_OUT_OF_RESOURCES; + return NULL; + } + + mm_hdr = (struct mm_communicate_header *)comm_buf; + guidcpy(&mm_hdr->header_guid, &mm_var_guid); + mm_hdr->message_len = MM_VARIABLE_COMMUNICATE_SIZE + payload_size; + + var_hdr = (struct mm_variable_communicate_header *)mm_hdr->data; + var_hdr->function = func; + if (dptr) + *dptr = var_hdr->data; + *ret = EFI_SUCCESS; + + return comm_buf; +} + +/** + * Get variable payload size from StandAloneMM + * + * @size: Size of the variable in storage + * Return: status code + */ +efi_status_t EFIAPI get_max_payload(efi_uintn_t *size) +{ + struct mm_variable_payload_size *var_payload = NULL; + efi_uintn_t payload_size; + efi_status_t ret; + u8 *comm_buf; + + if (!size) + return EFI_INVALID_PARAMETER; + + payload_size = sizeof(*var_payload); + comm_buf = setup_mm_hdr((void **)&var_payload, payload_size, + MM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE, &ret); + if (!comm_buf) + return EFI_EXIT(ret); + + ret = mm_communicate(comm_buf, payload_size); + if (ret != EFI_SUCCESS) + goto out; + + *size = var_payload->size; + +out: + free(comm_buf); + return ret; +} + +/** + * efi_get_variable() - retrieve value of a UEFI variable + * + * This function implements the GetVariable runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @name: name of the variable + * @guid: vendor GUID + * @attr: attributes of the variable + * @data_size: size of the buffer to which the variable value is copied + * @data: buffer to which the variable value is copied + * Return: status code + */ +efi_status_t EFIAPI efi_get_variable(u16 *name, const efi_guid_t *guid, + u32 *attr, efi_uintn_t *data_size, + void *data) +{ + struct mm_variable_access *var_acc; + efi_uintn_t payload_size; + efi_uintn_t name_size; + efi_uintn_t tmp_dsize; + efi_status_t ret; + u8 *comm_buf; + + EFI_ENTRY("\"%ls\" %pUl %p %p %p", name, guid, attr, data_size, data); + + if (!name || !guid || !data_size) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + /* Check payload size */ + name_size = u16_strsize(name); + if (name_size > max_payload_size - MM_VARIABLE_ACCESS_HEADER_SIZE) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + /* Trim output buffer size */ + tmp_dsize = *data_size; + if (name_size + tmp_dsize > + max_payload_size - MM_VARIABLE_ACCESS_HEADER_SIZE) { + tmp_dsize = max_payload_size - + MM_VARIABLE_ACCESS_HEADER_SIZE - + name_size; + } + + /* Get comm buffer and initialize header */ + payload_size = MM_VARIABLE_ACCESS_HEADER_SIZE + name_size + tmp_dsize; + comm_buf = setup_mm_hdr((void **)&var_acc, payload_size, + MM_VARIABLE_FUNCTION_GET_VARIABLE, &ret); + if (!comm_buf) + return EFI_EXIT(ret); + + /* Fill in contents */ + guidcpy(&var_acc->guid, guid); + var_acc->data_size = tmp_dsize; + var_acc->name_size = name_size; + var_acc->attr = attr ? *attr : 0; + memcpy(var_acc->name, name, name_size); + + /* Communicate */ + ret = mm_communicate(comm_buf, payload_size); + if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { + /* Update with reported data size for trimmed case */ + *data_size = var_acc->data_size; + } + if (ret != EFI_SUCCESS) + goto done; + + if (attr) + *attr = var_acc->attr; + if (data) + memcpy(data, (u8 *)var_acc->name + var_acc->name_size, + var_acc->data_size); + else + ret = EFI_INVALID_PARAMETER; + +done: + free(comm_buf); + return EFI_EXIT(ret); +} + +/** + * efi_get_next_variable_name() - enumerate the current variable names + * + * @variable_name_size: size of variable_name buffer in byte + * @variable_name: name of uefi variable's name in u16 + * @guid: vendor's guid + * + * This function implements the GetNextVariableName service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * Return: status code + */ +efi_status_t EFIAPI efi_get_next_variable_name(efi_uintn_t *variable_name_size, + u16 *variable_name, + efi_guid_t *guid) +{ + struct mm_variable_getnext *var_getnext; + efi_uintn_t payload_size; + efi_uintn_t tmp_dsize; + efi_uintn_t name_size; + efi_status_t ret; + efi_uintn_t out_name_size; + efi_uintn_t in_name_size; + u8 *comm_buf; + + EFI_ENTRY("%p \"%ls\" %pUl", variable_name_size, variable_name, guid); + + if (!variable_name_size || !variable_name || !guid) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + out_name_size = *variable_name_size; + in_name_size = u16_strsize(variable_name); + + name_size = u16_strsize(variable_name); + if (name_size > max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + /* Trim output buffer size */ + tmp_dsize = *variable_name_size; + if (name_size + tmp_dsize > + max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE) { + tmp_dsize = max_payload_size - + MM_VARIABLE_GET_NEXT_HEADER_SIZE - + name_size; + } + + payload_size = MM_VARIABLE_GET_NEXT_HEADER_SIZE + + max(out_name_size, in_name_size); + comm_buf = setup_mm_hdr((void **)&var_getnext, payload_size, + MM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME, + &ret); + if (!comm_buf) + return EFI_EXIT(ret); + + /* Fill in contents */ + guidcpy(&var_getnext->guid, guid); + var_getnext->name_size = out_name_size; + memcpy(var_getnext->name, variable_name, in_name_size); + if (out_name_size > in_name_size) { + memset((u8 *)var_getnext->name + in_name_size, 0x0, + out_name_size - in_name_size); + } + + /* Communicate */ + ret = mm_communicate(comm_buf, payload_size); + if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { + /* Update with reported data size for trimmed case */ + *variable_name_size = var_getnext->name_size; + } + if (ret != EFI_SUCCESS) + goto done; + + guidcpy(guid, &var_getnext->guid); + memcpy(variable_name, (u8 *)var_getnext->name, + var_getnext->name_size); + +done: + free(comm_buf); + return EFI_EXIT(ret); +} + +/** + * efi_set_variable() - set value of a UEFI variable + * + * This function implements the SetVariable runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @name: name of the variable + * @guid: vendor GUID + * @attr: attributes of the variable + * @data_size: size of the buffer with the variable value + * @data: buffer with the variable value + * Return: status code + */ +efi_status_t EFIAPI efi_set_variable(u16 *name, const efi_guid_t *guid, + u32 attr, efi_uintn_t data_size, + const void *data) +{ + struct mm_variable_access *var_acc; + efi_uintn_t payload_size; + efi_uintn_t name_size; + efi_status_t ret; + u8 *comm_buf; + + EFI_ENTRY("\"%ls\" %pUl %x %zu %p", name, guid, attr, data_size, data); + + if (!name || name[0] == 0 || !guid) + return EFI_EXIT(EFI_INVALID_PARAMETER); + if (data_size > 0 && !data) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + /* Check payload size */ + name_size = u16_strsize(name); + payload_size = MM_VARIABLE_ACCESS_HEADER_SIZE + name_size + data_size; + if (payload_size > max_payload_size) + return EFI_EXIT(EFI_INVALID_PARAMETER); + + /* Get comm buffer and initialize header */ + comm_buf = setup_mm_hdr((void **)&var_acc, payload_size, + MM_VARIABLE_FUNCTION_SET_VARIABLE, &ret); + if (!comm_buf) + return EFI_EXIT(ret); + + /* Fill in contents */ + guidcpy(&var_acc->guid, guid); + var_acc->data_size = data_size; + var_acc->name_size = name_size; + var_acc->attr = attr; + memcpy(var_acc->name, name, name_size); + memcpy((u8 *)var_acc->name + name_size, data, data_size); + + /* Communicate */ + ret = mm_communicate(comm_buf, payload_size); + free(comm_buf); + + return EFI_EXIT(ret); +} + +/** + * efi_query_variable_info() - get information about EFI variables + * + * This function implements the QueryVariableInfo() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @attributes: bitmask to select variables to be + * queried + * @maximum_variable_storage_size: maximum size of storage area for the + * selected variable types + * @remaining_variable_storage_size: remaining size of storage are for the + * selected variable types + * @maximum_variable_size: maximum size of a variable of the + * selected type + * Returns: status code + */ +efi_status_t EFIAPI __efi_runtime +efi_query_variable_info(u32 attributes, u64 *max_variable_storage_size, + u64 *remain_variable_storage_size, + u64 *max_variable_size) +{ + struct mm_variable_query_info *mm_query_info; + efi_uintn_t payload_size; + efi_status_t ret; + u8 *comm_buf; + + EFI_ENTRY("%x %p %p %p", attributes, max_variable_storage_size, + remain_variable_storage_size, max_variable_size); + + payload_size = sizeof(*mm_query_info); + comm_buf = setup_mm_hdr((void **)&mm_query_info, payload_size, + MM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO, &ret); + if (!comm_buf) + return EFI_EXIT(ret); + + mm_query_info->attr = attributes; + ret = mm_communicate(comm_buf, payload_size); + if (ret != EFI_SUCCESS) + goto out; + *max_variable_storage_size = mm_query_info->max_variable_storage; + *remain_variable_storage_size = + mm_query_info->remaining_variable_storage; + *max_variable_size = mm_query_info->max_variable_size; + +out: + free(comm_buf); + return EFI_EXIT(ret); +} + +/** + * efi_get_variable_runtime() - runtime implementation of GetVariable() + * + * @variable_name: name of the variable + * @guid: vendor GUID + * @attributes: attributes of the variable + * @data_size: size of the buffer to which the variable value is copied + * @data: buffer to which the variable value is copied + * Return: status code + */ +static efi_status_t __efi_runtime EFIAPI +efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *guid, + u32 *attributes, efi_uintn_t *data_size, void *data) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_get_next_variable_name_runtime() - runtime implementation of + * GetNextVariable() + * + * @variable_name_size: size of variable_name buffer in byte + * @variable_name: name of uefi variable's name in u16 + * @guid: vendor's guid + * Return: status code + */ +static efi_status_t __efi_runtime EFIAPI +efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size, + u16 *variable_name, efi_guid_t *guid) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_query_variable_info() - get information about EFI variables + * + * This function implements the QueryVariableInfo() runtime service. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @attributes: bitmask to select variables to be + * queried + * @maximum_variable_storage_size: maximum size of storage area for the + * selected variable types + * @remaining_variable_storage_size: remaining size of storage are for the + * selected variable types + * @maximum_variable_size: maximum size of a variable of the + * selected type + * Returns: status code + */ +efi_status_t EFIAPI __efi_runtime +efi_query_variable_info_runtime(u32 attributes, u64 *max_variable_storage_size, + u64 *remain_variable_storage_size, + u64 *max_variable_size) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_set_variable_runtime() - runtime implementation of SetVariable() + * + * @variable_name: name of the variable + * @guid: vendor GUID + * @attributes: attributes of the variable + * @data_size: size of the buffer with the variable value + * @data: buffer with the variable value + * Return: status code + */ +static efi_status_t __efi_runtime EFIAPI +efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *guid, + u32 attributes, efi_uintn_t data_size, + const void *data) +{ + return EFI_UNSUPPORTED; +} + +/** + * efi_variables_boot_exit_notify() - notify ExitBootServices() is called + */ +void efi_variables_boot_exit_notify(void) +{ + u8 *comm_buf; + efi_status_t ret; + + comm_buf = setup_mm_hdr(NULL, 0, MM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE, + &ret); + if (comm_buf) + ret = mm_communicate(comm_buf, 0); + else + ret = EFI_NOT_FOUND; + + if (ret != EFI_SUCCESS) + log_err("Unable to notify StMM for ExitBootServices\n"); + free(comm_buf); + + /* Update runtime service table */ + efi_runtime_services.query_variable_info = + efi_query_variable_info_runtime; + efi_runtime_services.get_variable = efi_get_variable_runtime; + efi_runtime_services.get_next_variable_name = + efi_get_next_variable_name_runtime; + efi_runtime_services.set_variable = efi_set_variable_runtime; + efi_update_table_header_crc32(&efi_runtime_services.hdr); +} + +/** + * efi_init_variables() - initialize variable services + * + * Return: status code + */ +efi_status_t efi_init_variables(void) +{ + efi_status_t ret; + + ret = get_max_payload(&max_payload_size); + if (ret != EFI_SUCCESS) + return ret; + + max_buffer_size = MM_COMMUNICATE_HEADER_SIZE + + MM_VARIABLE_COMMUNICATE_SIZE + + max_payload_size; + + return EFI_SUCCESS; +} From patchwork Wed May 6 19:12:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1284675 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=J5rioaVl; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49HR8J6Smfz9sSc for ; Thu, 7 May 2020 05:13:36 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92DB081D97; Wed, 6 May 2020 21:13:06 +0200 (CEST) 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="J5rioaVl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 53B7381E40; Wed, 6 May 2020 21:13:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 EFFB581C4C for ; Wed, 6 May 2020 21:12:56 +0200 (CEST) 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-x442.google.com with SMTP id i15so3078256wrx.10 for ; Wed, 06 May 2020 12:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qLs3NJWIWjP+oSmBYBu4g1HuLk7Dg0QRQ8aumJkg8cg=; b=J5rioaVl6HaevUwyQL/SlXpTH5ts+3otEoZBIJiiF25IxAO8ci9anx8yW+iEFj9BDO SBtW7l8/g81JpWee3L0gvgDDUsJ/VS3cq+0B9cYs6HMxPtdiJ/pghYa+s9ZSG+oPCg7q jGr9BzUCz5eJBMHEtTrVekmLTtJrRVshqwM2boc7rha+RkjVvuzjVzrVUzhCpVHczNkz HQF82ZVy/gxD9RUDsbnV8Q9RJjSdNtmDO18cEMUbluBa/IwQm5MswMF0KcAKkQlmJmDz nt00DBzHwpYbXDExqDyROHhkzQ7np533DQbrnq44aXndSwyWchs9W5XTL4AOWPJKmevM pHLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qLs3NJWIWjP+oSmBYBu4g1HuLk7Dg0QRQ8aumJkg8cg=; b=IX87Kdzec5lbTlcg/CvWQVAJfj/fTM6LA1lzj+tlPa/LT3Q/itO8J68JtA6IV1+AST /Sp3QgBagy+dj+EeZWdcOsQeUPrtyIySCIv/NLYyVvCHZawP1j2XCAhU681VatNBQt2N f24A7w8ZSEtkY/sJll7/gUo8TErn/27n6GJhrCMPBW6kiHjRgGQ3xqsT0YWiv+124yVm dXXI7yWqr3aX2Gb2pwGyQhyeOtbXVWViXi1PWyTa3hL0Gzb+UnjfHfGI9NsiE1+OLMDD MAb15Rtdhxv88xX2+v32ouSu8TPHqLNlRQhnqnXfP62Pw7qgqBK8hcD+t8HqG6RyZHF8 G3tA== X-Gm-Message-State: AGi0Pua7N+grImZ7pb7LF2cK+v2NFRqNJ+MQKhX1kPR5/jcbz3jpGXPl Z5LglZFrNrJDav4YDxjv8LOcnuEi8Ks= X-Google-Smtp-Source: APiQypJotHDLpEx+7LVHxm+p8HrX8jPTZ987WxncmmrhyZBh49WdFQInE749vfiDJ4JpbVhwNxIbDQ== X-Received: by 2002:adf:b1c9:: with SMTP id r9mr12047898wra.271.1588792376313; Wed, 06 May 2020 12:12:56 -0700 (PDT) Received: from apalos.home ([2a02:587:4652:c284:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id y3sm4271918wrm.64.2020.05.06.12.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:12:55 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: agraf@csgraf.de, ard.biesheuvel@linaro.org, Ilias Apalodimas Subject: [PATCH 4/6] cmd: efidebug: Add support for querying UEFI variable storage Date: Wed, 6 May 2020 22:12:44 +0300 Message-Id: <20200506191246.237790-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org> References: <20200506191246.237790-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean With the previous patches that use OP-TEE and StandAloneMM for UEFI variable storage we've added functionality for efi_query_variable_info. So let's add the relevant command to efidebug and retrieve information about the container used to store UEFI variables Signed-off-by: Ilias Apalodimas --- cmd/efidebug.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index d8a76d78a388..17e36ef76d69 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1160,6 +1160,45 @@ static int do_efi_test(cmd_tbl_t *cmdtp, int flag, return cp->cmd(cmdtp, flag, argc, argv); } +/** + * do_efi_query_info() - QueryVariableInfo EFI service + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, + * CMD_RET_USAGE or CMD_RET_FAILURE on failure + * + * Implement efidebug "test" sub-command. + */ + +static int do_efi_query_info(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + efi_status_t ret; + u32 attr = EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS | + EFI_VARIABLE_NON_VOLATILE; + u64 max_variable_storage_size; + u64 remain_variable_storage_size; + u64 max_variable_size; + + ret = EFI_CALL(efi_query_variable_info(attr, + &max_variable_storage_size, + &remain_variable_storage_size, + &max_variable_size)); + if (ret != EFI_SUCCESS) + return CMD_RET_FAILURE; + + printf("%.*s ====================\n", EFI_HANDLE_WIDTH, sep); + printf("Max storage size %llu\n", max_variable_storage_size); + printf("Remaining storage size %llu\n", remain_variable_storage_size); + printf("Max variable size %llu\n", max_variable_size); + + return CMD_RET_SUCCESS; +} + static cmd_tbl_t cmd_efidebug_sub[] = { U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""), U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices, @@ -1176,6 +1215,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = { "", ""), U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_efi_test, "", ""), + U_BOOT_CMD_MKENT(query, CONFIG_SYS_MAXARGS, 1, do_efi_query_info, + "", ""), }; /** @@ -1247,7 +1288,9 @@ static char efidebug_help_text[] = "efidebug tables\n" " - show UEFI configuration tables\n" "efidebug test bootmgr\n" - " - run simple bootmgr for test\n"; + " - run simple bootmgr for test\n" + "efidebug query\n" + " - show information of the container used to store UEFI variables\n"; #endif U_BOOT_CMD( From patchwork Wed May 6 19:12:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1284677 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=mYAbrfq+; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49HR8n0SQHz9sSc for ; Thu, 7 May 2020 05:14:00 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E54C82275; Wed, 6 May 2020 21:13:09 +0200 (CEST) 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="mYAbrfq+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 65E4D82267; Wed, 6 May 2020 21:13:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (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 0537F81CC7 for ; Wed, 6 May 2020 21:12:58 +0200 (CEST) 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-x443.google.com with SMTP id y4so3486028wrm.11 for ; Wed, 06 May 2020 12:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KNFNMsKX+2fgRAh9qo50jx081PKKSHy1xTrgrB1+k6k=; b=mYAbrfq+FbLdsiARcfz2+QJAAaXC7hKvYv4+msxUNHWv98Pc5EZdTrLSMK0bGOMT/0 pdw9IsY47sSLJvkWeaLf0q9hEPUsuTCfsuud8u/cAjY/xLmI853q01JM8x3hLSlhb8St 46UHYyhghrfLJfzQ/at/pfvnOJdTKGYsrgKwWiR8CeGolXETMNVtkavpUFlBrRINOwt2 fhFoWBUTRs5gEPOH0oFmbM98Ea4HbZ0Y3MXW/rRVeosjr4Wl/YXV+BxF7WRAhkOqcQEv gxKfqxxvExmRXMwug7uTs3nQ8ybsdQmYmiRz6pqAbz5XYI4AYwBX9AiNpkI2IjNUNiqE 1XfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KNFNMsKX+2fgRAh9qo50jx081PKKSHy1xTrgrB1+k6k=; b=Xn58CFb6bjPPbBf1+Dqb/froMHBMXcW3avZG7G/wB2ZFbkyYw6zRBcpjtvnogjKTio CHNLZHRmadgpST7VHbIcVXgOM/4Eov1T2Xktr6aN3z6+b80Lun24cNJy4B4l7NJcVX4N 7d9tTc1N+9yqKAvtlJk8QPOG+Fdp9NUvhLrWi4WlaFPgX9wmJHKDxDz6o/1KVd3OWrBa pE96riDhK08qIQH76OjNU+GJtgqOvBSbFZId/0Ojb4Lrk5VFWiA9GuwKhHIauXDNXmyB EsLBrkz6uLTyyqLxgilFtC0w6Hr30a+xl1yuVUyLje2xk9lLzW+PYXarKoVBCnCzK5pv ounw== X-Gm-Message-State: AGi0PuYTcXXAeT/2DqqIvvNM0WEqQKkztj0KCCq270SoMYbcVdacq1JL q/xmp/LLf4ipIuhuc2yfiYH0KM/iqWg= X-Google-Smtp-Source: APiQypKqVNDslDvebtm6l2hsHaFwHstGw72iw7XOfKCWbXycdn+Hx3zsQEdDNHabjQZjJYUk8XE7fQ== X-Received: by 2002:adf:9444:: with SMTP id 62mr11200488wrq.68.1588792377348; Wed, 06 May 2020 12:12:57 -0700 (PDT) Received: from apalos.home ([2a02:587:4652:c284:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id y3sm4271918wrm.64.2020.05.06.12.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:12:56 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: agraf@csgraf.de, ard.biesheuvel@linaro.org, Ilias Apalodimas Subject: [PATCH 5/6] MAINTAINERS: Add maintainer for EFI variables via OP-TEE Date: Wed, 6 May 2020 22:12:45 +0300 Message-Id: <20200506191246.237790-6-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org> References: <20200506191246.237790-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Add myself as maintainer for the OP-TEE related UEFI variable storage and add the headers files on the existing EFI list Signed-off-by: Ilias Apalodimas --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ec59ce8b8802..f33fd74b330b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -625,6 +625,8 @@ F: include/cp437.h F: include/efi* F: include/pe.h F: include/asm-generic/pe.h +F: include/mm_communication.h +F: include/mm_variable.h F: lib/charset.c F: lib/efi*/ F: test/py/tests/test_efi* @@ -635,6 +637,11 @@ F: cmd/efidebug.c F: cmd/nvedit_efi.c F: tools/file2include.c +EFI VARIABLES VIA OP-TEE +M: Ilias Apalodimas +S: Maintained +F: lib/efi_loader/efi_variable_tee.c + ENVIRONMENT M: Joe Hershberger R: Wolfgang Denk From patchwork Wed May 6 19:12:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1284678 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=g2KwN58E; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49HR8z1L6yz9sSc for ; Thu, 7 May 2020 05:14:10 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A76EA8227C; Wed, 6 May 2020 21:13:10 +0200 (CEST) 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="g2KwN58E"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA68781E4C; Wed, 6 May 2020 21:13:02 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (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 E980A81C64 for ; Wed, 6 May 2020 21:12:58 +0200 (CEST) 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-x441.google.com with SMTP id h9so3533282wrt.0 for ; Wed, 06 May 2020 12:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PpoAhC/kNIYt3WI3HCinHt3Lt+2GgeVlpfp+RGwr+Sw=; b=g2KwN58EGPsUBYqNUvK/HrFR+BixkNfDLZuDL3fegxFlspZs12mj0+bkp0BnklAb8r csf22kvcjCD1iXKjVsYP32ej/L71HmbPwdy1+1/KABnvZ28zXDBijWBcRcer3qIDBriN ezkctI+vpxTzzLn00FTv0z8pz8W+WrPc8Qx2Wvdt20UxpKX/G+NgkIT4/Y5aYrJ9UrWT XET4Jv4fLD++yQ3zAeM93AmWLk0MXWDR/X3x9wU56qppzmAsgWBBgDQMah17we14DELS hvFHLN6TDUQEhYmE5xFwRqGcAqg8FOPbqOVjr3r7x8gJ7C6f5GiIbyiLG/iPb1BjDzif ZGmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PpoAhC/kNIYt3WI3HCinHt3Lt+2GgeVlpfp+RGwr+Sw=; b=Uz/kEqplYGROrwdftr9iLFaFtdEKv3Veo9JwN/RX2lWLJQA0sOC0Q9Ezx2Ws1K3jzK 93dGel200/jdVSeUt6d/TyEELXHrs/koLxef8X5wg1F/Qpi80271uDKMnrHD4PJeF+qO A/r6r4DxT7bBIPbJhZQYNNAfmXCGGkypAlULf/y/N/vikfzfVzCsbuEjDg37kwR/99W6 /TPco1Iv9ZAm48LKlXzKZeuCyz/viNYFkzOq6C9GC2lL2R47tXK2UncDP43U0bMUV7Ke /4p8G2rC0qp6VNJ7RZaZHJsBfnGQO73EsJLVoKxn9Ic2UhQAS3mDJBtFsUu0Xgo0GI2W JpPQ== X-Gm-Message-State: AGi0Pub5Hjdm9Xkihpo1V6Tq5wuR5wC7F2jh/Dl0JffjXqeXoQea2jTT x9VspgqN9GGIWDiopiFEDQxGZDMn0Y4= X-Google-Smtp-Source: APiQypKCEApljTUq9Z3Wydyq22Du8RVF5htBU0lYU++UNYMt6Ml7uiuwAgZLzpa6DwPY3uDClnLB/A== X-Received: by 2002:a5d:628e:: with SMTP id k14mr11947013wru.390.1588792378420; Wed, 06 May 2020 12:12:58 -0700 (PDT) Received: from apalos.home ([2a02:587:4652:c284:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id y3sm4271918wrm.64.2020.05.06.12.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 12:12:58 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de, xypron.glpk@gmx.de Cc: agraf@csgraf.de, ard.biesheuvel@linaro.org, Ilias Apalodimas Subject: [PATCH 6/6] doc: uefi.rst: Add OP-TEE variable storage config options Date: Wed, 6 May 2020 22:12:46 +0300 Message-Id: <20200506191246.237790-7-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200506191246.237790-1-ilias.apalodimas@linaro.org> References: <20200506191246.237790-1-ilias.apalodimas@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean If OP-TEE is compiled with an EDK2 application running in secure world it can process and store UEFI variables in an RPMB. Add documentation for the config options enabling this Signed-off-by: Ilias Apalodimas --- doc/uefi/uefi.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/uefi/uefi.rst b/doc/uefi/uefi.rst index 4fda00d68721..93b0faadd26e 100644 --- a/doc/uefi/uefi.rst +++ b/doc/uefi/uefi.rst @@ -188,6 +188,16 @@ on the sandbox cd pytest.py test/py/tests/test_efi_secboot/test_signed.py --bd sandbox +Using OP-TEE for EFI variables +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If an RPMB and it's drivers is available in U-Boot, OP-TEE can be used for +variable services. +Enabling CONFIG_EFI_MM_COMM_TEE=y will dispatch the variables services to +OP-TEE. OP-TEE needs to be compiled with a secure application (coming from EDK2) +which will process variables in the Secure World and store them in the RPMB +using the OP-TEE supplicant. + Executing the boot manager ~~~~~~~~~~~~~~~~~~~~~~~~~~