Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp440984imn; Thu, 28 Jul 2022 05:37:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tOyuAULeOPpeUtCtUhyF76lhhQfPZum90QJ2KHhoTYYzBp9Mu0nV4WBbKjH1AATX1xHTYS X-Received: by 2002:a17:90b:3ec1:b0:1f1:edcf:dd2b with SMTP id rm1-20020a17090b3ec100b001f1edcfdd2bmr10200748pjb.156.1659011839637; Thu, 28 Jul 2022 05:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659011839; cv=none; d=google.com; s=arc-20160816; b=AHnnFy2TFlzUsSmUDMnk8qtXx8Rjp4wQxRL9ndczde9NUDo2xlG9QP/t7Y2gBgq0Z/ sRAf48fi0UJLJtN/FsIopELZ3be+UGxEdlzd9CznMHJSQWb5zMCKiyXKf9DI3psHi/Fo j40hI7bxLx5Iqga1hdgs8g1avduxcfu8lME4BSb4LySEZjarDbyFjaKC0FZ5nWjyW9Iu AMFOrCNQ3xyq0l4NYrOwYlt0UE28mbO/rmPoSfp5ExK9pv2+5Y5fErNEeIQJoHQEorqS i2zbCUiTJMcCzOErWjcophMGDJXedThuKUJc1m9Uk0Ee+02wuRvflzNQJCOix4iXtv1T MeIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l6kv977iX0DxQe8GqSszxDwkV+ebVuYMRRbZ1g3snjc=; b=SMVPT/yPmR//Dq0fBF7RBt7RB5IAE3c0OtxXp+5E4X8Gb9TRnQ6l6+VuaOKPtnLzUj ph7Tyv1B4tblc7NuzxtZybOmDcQIpc1HC1TE6lc5vogq8ePgJgBQ/TyeqvOaOckxnGxJ pBgnaECbmTSUW4E+OKXYwAqgshEo6Wskmb9CAFwxlY8PtotIkfFU/bHqQ9wiFAPYRJWs k3uq2Csh3Mqm+BIktbp7ZhTp4k5ajwT85e3rMRIrwbPXcbhpaOO4iWlk/u6tT4/Px4H4 qZ/5ogcap88pvh5Yo0Jgwdk0GmGMFU2oPXhdvvue7xhb5Oh7i/ZaUKn8j7R1eGGQ0yUJ zVcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v7uH8UZV; 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 k6-20020a056a00134600b0052589c13629si542894pfu.249.2022.07.28.05.37.03; Thu, 28 Jul 2022 05:37:19 -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=v7uH8UZV; 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 S238700AbiG1Mf7 (ORCPT + 99 others); Thu, 28 Jul 2022 08:35:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235098AbiG1Mf6 (ORCPT ); Thu, 28 Jul 2022 08:35:58 -0400 Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 078AF65D78 for ; Thu, 28 Jul 2022 05:35:57 -0700 (PDT) Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-31f1d1c82c8so17614417b3.8 for ; Thu, 28 Jul 2022 05:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l6kv977iX0DxQe8GqSszxDwkV+ebVuYMRRbZ1g3snjc=; b=v7uH8UZVPUY1DgE+baRwICn8k4lVtu4x39Wor3Siqsh5ebSZO6yD/Yux6yzwiRQH9Y t7flcF5rbKQPtcSbqdAeCfIh5F1wzgKosuS4A66Nj5mS1FxzuVEwlJAQYDZU7/KLY1DZ 2bgWnL258OJuEzxrf4rPJ1VBLSie8koqO4vryM6xiJa+AKDMODACMzTsJHAbIjpcwgpw 2V0FI9iCw+jkrjnWnc37TQ2neLspwkUEXgKYrEi2hIlRLqJJsI4LjdkWSZ+av1ph3O11 9Na9kpX65gzqHrNLlBXA/KxWoMeQ9bx8QVqllwcC7REyDJf6KlnV6WTSOUlGR6qT/Zym /O9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=l6kv977iX0DxQe8GqSszxDwkV+ebVuYMRRbZ1g3snjc=; b=OfyOMP6jntciM94sLHDzHiURAvedSvTA+BzocE7yw0UVXOn02TR2ki98Wk1SLpc/J9 11Ka7n+YK2y0eohwd4OLi37o5UQqKhM84sz1vF81DuU5Q3BLkQmMhZh+zuDPnO1IPEDn SEKCqGEDoKzAKFKydzBxXfmLCQRChmQfYKfT/vDXSuqzIDZaYlSuqc2h3HkN2BqQDc1r AnFYUuKXDqf1ywQ7DPpn35f1FNLkdluU5N4LGW7PEu7jnWr/tHNfzP7Ybb1R6WlE2EpU wHGXcH8dnwnwviFywmDybkOlapA8FPvTR+FVj0F2GVKna00wxp+VHYrERTHWlv6+rnAK ULGA== X-Gm-Message-State: ACgBeo1OoDJki9KI7kOjkmO3esXCh6IXnrcVZRJRGh+eOLZYRVamC2WC 14+mgkuLqhU8ACq20ahqSFKw51BMAiPD4Yl9EMN8Tw== X-Received: by 2002:a81:6a07:0:b0:323:8614:10c2 with SMTP id f7-20020a816a07000000b00323861410c2mr17175ywc.191.1659011756195; Thu, 28 Jul 2022 05:35:56 -0700 (PDT) MIME-Version: 1.0 References: <20220723224949.1089973-1-luzmaximilian@gmail.com> <20220723224949.1089973-5-luzmaximilian@gmail.com> <20220726143005.wt4be7yo7sbd3xut@bogus> <829c8fee-cae5-597d-933d-784b4b57bd73@gmail.com> <20220726154138.74avqs6iqlzqpzjk@bogus> <7284953b-52bb-37ac-fbe1-1fa845c44ff9@linaro.org> <3d752603-365d-3a33-e13e-ca241cee9a11@gmail.com> <20220727132437.pjob3z2nyxsuxgam@bogus> In-Reply-To: From: Ilias Apalodimas Date: Thu, 28 Jul 2022 15:35:20 +0300 Message-ID: Subject: Re: [PATCH 4/4] dt-bindings: firmware: Add Qualcomm UEFI Secure Application client To: Maximilian Luz Cc: Sudeep Holla , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Ard Biesheuvel , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Steev Klimaszewski , Shawn Guo , Cristian Marussi , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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_NONE, SPF_HELO_NONE,SPF_PASS 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 Hi Maximilian On Thu, 28 Jul 2022 at 13:48, Maximilian Luz wrote: > > On 7/28/22 08:03, Ilias Apalodimas wrote: > > Hi all, > > > > On Wed, 27 Jul 2022 at 16:24, Sudeep Holla wrote: > >> > >> On Wed, Jul 27, 2022 at 03:03:49PM +0200, Maximilian Luz wrote: > >>> > >>> Is there really a good way around it? > >> > >> Yes rely on the firmware preferably auto discover, if that is not an option, > >> how about query. It seem to be working in your case. > > > > That's a good point. We have a similar situation with some Arm > > devices and U-Boot. Let me try to explain a bit. > > > > There's code plugged in in OP-TEE and U-Boot atm which allows you to > > store EFI variables on an RPMB. This is a nice alternative if your > > device doesn't have any other secure storage, however it presents > > some challenges after ExitBootServices, similar to the ones you have > > here. > > > > The eMMC controller usually lives in the non-secure world. OP-TEE > > can't access that, so it relies on a userspace supplicant to perform > > the RPMB accesses. That supplicant is present in U-Boot and > > Get/SetVariable works fine before ExitBootServices. Once Linux boots, > > the 'U-Boot supplicant' goes away and we launch the linux equivalent > > one from userspace. Since variable accessing is a runtime service and > > it still has to go through the firmware we can't use those anymore > > since U-Boot doesn't preserve the supplicant, the eMMC driver and the > > OP-TEE portions needed in the runtime section(and even if it did we > > would now have 2 drivers racing to access the same hardware). Instead > > U-Boot copies the variables in runtime memory and > > GetVariable/GetNextVariable still works, but SetVariable returns > > EFI_UNSUPPORTED. > > > > I've spent enough time looking at available solutions and although > > this indeed breaks the EFI spec, something along the lines of > > replacing the runtime services with ones that give you direct access > > to the secure world, completely bypassing the firmware is imho our > > least bad option. > > This sounds very similar to what Qualcomm may be doing on some devices. > The TrEE interface allows for callbacks and there are indications that > one such callback-service is for RPMB. I believe that at least on some > platforms, Qualcomm also stores UEFI variables in RPMB and uses the same > uefisecapp interface in combination with RPMB listeners installed by the > kernel to access them. > > > I have an ancient branch somewhere that I can polish up and send an > > RFC [1], but the way I enabled that was to install an empty config > > table from the firmware. That empty table is basically an indication > > to the kernel saying "Hey I can't store variables, can you do that for > > me". > > > > Is there any chance we can do something similar on that device (or > > find a reasonable way of inferring that we need to replace some > > services). That way we could at least have a common entry point to > > the kernel and leave out the DT changes. > > > > [1] https://git.linaro.org/people/ilias.apalodimas/net-next.git/log/?h=setvar_rt_optee_3 > > I would very much like to avoid the need for special bootloaders. The > devices we're talking about are WoA devices, meaning they _should_ > ideally boot just fine with EFI and ACPI. I've already responded to following email, but I'll repeat it here for completeness. It's not a special bootloader. It's the opposite, it's a generic UEFI compliant bootloader which takes advantage of the fact EFI is extensible. We are doing something very similar in how we load our initrd via the EFI_LOAD_FILE2 protocol. Whether Qualcomm can add that to their bootloaders is a different topic though. But at some point we need to draw a line than keep overloading the DT because a vendor decided to go down it's own path. > > From an end-user perspective, it's annoying enough that we'll have to > stick with DTs for the time being due to the use of PEPs in ACPI. I > really don't want to add some special bootloader for fixups to that. > Also, this would just move the problem from kernel to bootloader. But it *is* a bootloader problem. The bootloader is aware of the fact that it can't provide runtime services for X reasons and that's exactly why we are trying to set EFI_RT_PROPERTIES_TABLE correctly from the firmware. All we are doing is install a config table to tell the OS "I can't do that, can you find a way around it?". Regards /Ilias > > If you have any suggestions for another way of detecting this, please > feel free to share. I, unfortunately, don't. > > Regards, > Max