Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4076263rwb; Mon, 31 Jul 2023 00:21:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFpissVO4SKpPRBzxiljBCrGwpm998gwB9atuj+HuG2Ht3kv/EjUvcbahDJOE1gv+Oa4aRU X-Received: by 2002:a05:6a21:6da1:b0:13d:82eb:795a with SMTP id wl33-20020a056a216da100b0013d82eb795amr3353047pzb.56.1690788061799; Mon, 31 Jul 2023 00:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690788061; cv=none; d=google.com; s=arc-20160816; b=vYQgcP29ERKVmZsaZ2gYiwqwvuZJzgpGT5K7WSIyynSBegWUb6usc6ykEajYPfyS4F B3RhBq3Bbo+pnNGzmrbM6WNkOYGXe6QIs0elcXQFbAGl/6bvL8ff+t7xFOlIfZDxVgyT F+63t8r3fjQa+GYR1pot1LYFmITJg5j/aMBRzb9pvojA1D9wsiCu759fCpBUbJKwjxj9 YPJ7PKhhuR0vqRxgjHn/90HnCg+b9MtI2E7xfIM5QML+OdUVOBR7vzaX25nznPAab4jZ 208ne8F675oSqyVo86awJWhRXyJ7pBEPjZ+MNWZT5mo6xRSRhodExhPWokSNQ7TFTcMh nhtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=PcaSH+xAT+b5wVpK8POC10eQBnpVHRHNmuLx6GhPb68=; fh=9iYD2JJA0rZ2yEYce/29GKufZQDvXypnPU9JTh+xNL0=; b=YhLJk8+4HPVjUQX669VKWMq8knnwA2ainhwBC6PP6LDzYpMNr6CAQiCcV5+ttIzO8n r0fPEMmKw1tU53GaHAuAZ7wNqcDhdF1bRygrEwyYwi7mlJehj+7UOhabTZLHw3sJ+14q gGOapMMh5TXnpY5rEQwm43Oq7VxqU8Oy2MBs2U81y/wB+vbwv6zk9X3UQ/VPZcertS6I 9ssk99Tt1CUKozsahf2JuX6whWLFvRypXqar6xhyg+spGm9QiDINXSALiot6mxcvd+Tm U1Wd0B3iSTo/PHXk4I+m2cQ56fdK2PGWxYEuwbfGPkszi62QMYZs96RCHd4Cj/63T/Xc uxGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=auBIuu3b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l66-20020a633e45000000b005428f25f67bsi6738050pga.784.2023.07.31.00.20.49; Mon, 31 Jul 2023 00:21:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=auBIuu3b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbjGaGu6 (ORCPT + 99 others); Mon, 31 Jul 2023 02:50:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbjGaGuw (ORCPT ); Mon, 31 Jul 2023 02:50:52 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CCE31A5 for ; Sun, 30 Jul 2023 23:50:51 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bbf8cb61aeso9495515ad.2 for ; Sun, 30 Jul 2023 23:50:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690786251; x=1691391051; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PcaSH+xAT+b5wVpK8POC10eQBnpVHRHNmuLx6GhPb68=; b=auBIuu3b4cSfQ3gpIvHYKCevfsUjoIPARKH7iBZfpzCrl2cdD+E9HVOYxTQyPyRKnR jy8N8KNxPqFw04J2aZaPzQo0vx6hLB4t3F4xH3imt7Mg3OIH0iKhrkijRpIEhKVeEVBV qiHiB3rxpJavLVsI9BEWXgGm3WQrVhUE+7Gd5q9CNl8x7HB1nttGGOlxrT78XIskocof dEi2oZKcPfJI/WoJmrdEdqOTqEgc4FD7XmavWRGk1pJ81md7Oixu+sr2lIfvJmk6//DJ wdTHbm4Ocgb4TDvEXohZ8szkBt61kLSCKY8KKiC+660FNiiXVFRbYelqPz5b69FaUBed NWKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690786251; x=1691391051; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PcaSH+xAT+b5wVpK8POC10eQBnpVHRHNmuLx6GhPb68=; b=AM9dodswhX+QJaYY/8SumBeHUFfp2Fb2I4JYb8u5PGsoGGmgTExxEO8ykrCUMBoxWz sTHPPuDhfd1bs57W6DmBBmlW56mvpcxw2DkJ/IP3d/8/y7E2O8AtaYLF7DSiZyzfOuf/ GsPYT+IcJ9y/+LCnBX6i9Ow2u05g/SjOa1APYGdbM2F2iZL3dUgk9YXyUTY4s9LN8mwu OrOwuRw1tg6VUpb2OLCIxIqq6+Pfn8yLU3F+SrCctlYI86F8FfCn1rZcFsYIdX1skPnN IxbV3kIHQlmkZV3D3DnN1Kk32d2xdLxw7GneaGwoDLKGtHjeJz7tZmmSa2PR1b+GNcS7 yyuA== X-Gm-Message-State: ABy/qLYf75ZhHNNt8UhdNeENyjzU5Fvxr0hNcr5uT+/en6FRFxRK+Cvr cNAHl4+VQDMW8/to+SY539WqXSdHE+JBvyNiHqo= X-Received: by 2002:a17:902:e88f:b0:1b5:26d4:517d with SMTP id w15-20020a170902e88f00b001b526d4517dmr9001601plg.29.1690786251093; Sun, 30 Jul 2023 23:50:51 -0700 (PDT) Received: from localhost.localdomain (fp9875a45d.knge128.ap.nuro.jp. [152.117.164.93]) by smtp.gmail.com with ESMTPSA id kb14-20020a170903338e00b001b8ad8382a4sm7706245plb.216.2023.07.30.23.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 23:50:50 -0700 (PDT) From: Masahisa Kojima To: Ard Biesheuvel , Jens Wiklander , Jan Kiszka , Sumit Garg , linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org Cc: Ilias Apalodimas , Johan Hovold , Masahisa Kojima Subject: [PATCH v7 0/5] introduce tee-based EFI Runtime Variable Service Date: Mon, 31 Jul 2023 15:50:35 +0900 Message-Id: <20230731065041.1447-1-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series introduces the tee based EFI Runtime Variable Service. The eMMC device is typically owned by the non-secure world(linux in this case). There is an existing solution utilizing eMMC RPMB partition for EFI Variables, it is implemented by interacting with OP-TEE, StandaloneMM(as EFI Variable Service Pseudo TA), eMMC driver and tee-supplicant. The last piece is the tee-based variable access driver to interact with OP-TEE and StandaloneMM. Changelog: v6 -> v7 Patch #1-#4 are not updated. Patch #5 is added into this series, original patch is here: https://lore.kernel.org/all/20230609094532.562934-1-ilias.apalodimas@linaro.org/ There are two issues in the v6 series and v7 series addresses those. 1) efivar ops is not restored when the tee-supplicant daemon terminates. -> As the following patch says, user must remove the device before terminating tee-supplicant daemon. https://lore.kernel.org/all/20230728134832.326467-1-sumit.garg@linaro.org/ 2) cause panic when someone remounts the efivarfs as RW even if SetVariable is not supported -> The fifth patch addresses this issue. "[PATCH v7 5/5] efivarfs: force RO when remounting if SetVariable is not supported" Changelog: v5 -> v6 - new patch #4 is added in this series, #1-#3 patches are unchanged. automatically update super block flag when the efivarops support SetVariable runtime service, so that user does not need to manually remount the efivarfs as RW. v4 -> v5 - rebase to efi-next based on v6.4-rc1 - set generic_ops.query_variable_info, it works as expected as follows. $ df -h /sys/firmware/efi/efivars/ Filesystem Size Used Avail Use% Mounted on efivarfs 16K 1.3K 15K 8% /sys/firmware/efi/efivars v3 -> v4: - replace the reference from EDK2 to PI Specification - remove EDK2 source code reference comments - prepare nonblocking variant of set_variable, it just returns EFI_UNSUPPORTED - remove redundant buffer size check - argument name change in mm_communicate - function interface changes in setup_mm_hdr to remove (void **) cast v2 -> v3: - add CONFIG_EFI dependency to TEE_STMM_EFI - add missing return code check for tee_client_invoke_func() - directly call efivars_register/unregister from tee_stmm_efi.c rfc v1 -> v2: - split patch into three patches, one for drivers/tee, one for include/linux/efi.h, and one for the driver/firmware/efi/stmm - context/session management into probe() and remove() same as other tee client driver - StMM variable driver is moved from driver/tee/optee to driver/firmware/efi - use "tee" prefix instead of "optee" in driver/firmware/efi/stmm/tee_stmm_efi.c, this file does not contain op-tee specific code, abstracted by tee layer and StMM variable driver will work on other tee implementation. - PTA_STMM_CMD_COMMUNICATE -> PTA_STMM_CMD_COMMUNICATE - implement query_variable_store() but currently not used - no use of TEEC_SUCCESS, it is defined in driver/tee/optee/optee_private.h. Other tee client drivers use 0 instead of using TEEC_SUCCESS - remove TEEC_ERROR_EXCESS_DATA status, it is referred just to output error message Ilias Apalodimas (1): efivarfs: force RO when remounting if SetVariable is not supported Masahisa Kojima (4): efi: expose efivar generic ops register function efi: Add EFI_ACCESS_DENIED status code efi: Add tee-based EFI variable driver efivarfs: automatically update super block flag drivers/firmware/efi/Kconfig | 15 + drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/efi.c | 18 + drivers/firmware/efi/stmm/mm_communication.h | 236 +++++++ drivers/firmware/efi/stmm/tee_stmm_efi.c | 638 +++++++++++++++++++ drivers/firmware/efi/vars.c | 8 + fs/efivarfs/super.c | 45 ++ include/linux/efi.h | 12 + 8 files changed, 973 insertions(+) create mode 100644 drivers/firmware/efi/stmm/mm_communication.h create mode 100644 drivers/firmware/efi/stmm/tee_stmm_efi.c base-commit: 2e28a798c3092ea42b968fa16ac835969d124898 -- 2.30.2