Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp3568507rwb; Sun, 30 Jul 2023 10:27:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlEc24r1RnBsxFbqpHRRz8aampp2vl121zivb3tpV9qcJoVSLYWbZJ1zu6LnpfOw4m9hryKF X-Received: by 2002:aa7:df99:0:b0:522:1bdd:d41a with SMTP id b25-20020aa7df99000000b005221bddd41amr8157510edy.4.1690738044602; Sun, 30 Jul 2023 10:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690738044; cv=none; d=google.com; s=arc-20160816; b=nDML3YSXhVaH2pqsrkY74xe7uujXGByXuTY6LL+dSyhnKz6JSfd/iB4B3gRDk9Kad/ yIJsN1sjNpsRVHz/z3IHNgRNxHnw/dRuw/8Tj6sYkbo+qENGyyjf+49fV5SaPqQZCPeg VUuYVjEUQBaNBZUUE7TRJK2ELUg7nLx4qOkKDAmwePL8s0/JUbnmFsXpRwZMUHtMNk9o +B3qLrEatjwYaUyWBYTFhrchBuAEAn/sbqTvRuwuPcm5B/6qSjvfzTbAJAunLOWFio6I XDD1OkHdQIDXU0z61nkAmF8KD+7ftdrep2HHpbchpYBwE2USU4wVfO6GvHhxIk/CfgJe 1gWw== 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=a9yciUwcqPp7vxkA0tX3c4DgVq60cq74Tw4ZK4zb2CE=; fh=Q4AlY5YxR1nZkOvJzDkrpwm5ga1fsuQyHzzE8ITuvZ0=; b=WJeRuh5PN8V4v/KG1ySGqMJOr3hZMohD/cNxEhvCA6oSKQTl/5Nh16awRfvTYcJRke HlFTi2Ki7JQJqu6y062/5Te8d3Vi74mtweSegziHj95FE/rISOiqBF3NZfJsHuM0PxWl Orn+Sn/ZKJDGpfuVVW6hypW3AoRGfw5bLCbKwvmpqf5W9QNXGbWCXIvkYibywv4iocRo hyy+9rzKCK4lOAdEWROO0UlZEWzcdBUV8exPv88WHiAs6dYi7uDTseJfMNyUN2DVaPBI sXY88Pbq1l5isWdMAXxS5X6FwuWW8y2a+KXfGsPn7OOLMtQIiVjrWrXo9C6waslTY4wx 4POA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oKc+Okt5; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a056402128600b005227a2fd0afsi5532866edv.369.2023.07.30.10.27.00; Sun, 30 Jul 2023 10:27:24 -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=@gmail.com header.s=20221208 header.b=oKc+Okt5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229483AbjG3QTS (ORCPT + 99 others); Sun, 30 Jul 2023 12:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjG3QTQ (ORCPT ); Sun, 30 Jul 2023 12:19:16 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43DB6E7A; Sun, 30 Jul 2023 09:19:15 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-99357737980so599355766b.2; Sun, 30 Jul 2023 09:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690733954; x=1691338754; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=a9yciUwcqPp7vxkA0tX3c4DgVq60cq74Tw4ZK4zb2CE=; b=oKc+Okt5cyxQRykiFRQ0w28E6t3uBK7LtEnm2NH5WPLBITVmG4eDgGGFQzoHZ/wVAv tVJB3GTOCmbpLzfRWdFQqjHH8lRPEpXpbRgC7z0aW4SkB7vTO5Zm0vyOqY3zfKg7z5l6 c2qlzQLSI+UxMdv9C8VIhrsfYEHdF5OuokiDmFNYiIxy3ubJFd3gojpOp40NICdpKjn3 Ft6SLCGXqMHo2eqi+4Ou6vr9oNKihAShHj8ZCMyhRiBkx6J7Ssx3xD4DdKD6MEoLgoI6 jdxOyvHsiz39h//xGJil7RkacecYILtNyYWwywD5rxAAWB/K3sV/Kab7xSytC4isRpJl bWwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690733954; x=1691338754; 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=a9yciUwcqPp7vxkA0tX3c4DgVq60cq74Tw4ZK4zb2CE=; b=Uxx6lHkGtu5mOSVl3ev62EW1Z/gv7fQrInNPc5fZH/UsyOHSyXbsW5LOq/9tRJaj0M Gd6iWv3fb07tGespbtSX3sL7YQgPGo5sDwHi7bwJnKKwUOH2HXS16ikgvKPbShugWIx8 mD7KSQTUaJvzRYVcquTV65YIuwb8Dku26d71gBxjHNPHmudC5sLJhyA5RUBX7UDIbQRR PmkZO14+Ty8ojalokvnk4J6qngR40Lqso6e98jtvStfK1WkyAm7W/2WHTsNR5NCFLrNx N/Vs9DcBNyYK3ce9sIrMVbKrnpMSWs1QXNKbga3NPLYGDGMxRPuuBTyT/bss2yxetqFb nZJA== X-Gm-Message-State: ABy/qLZ5fQTCuwFFL1e1XSQEOEeE70su1qZcIBGOY/r8DvIRAnttBezE hrGtOjVmTqQfKHcizfsX7GM= X-Received: by 2002:a17:906:30c5:b0:99b:c985:cf7e with SMTP id b5-20020a17090630c500b0099bc985cf7emr5771936ejb.54.1690733953475; Sun, 30 Jul 2023 09:19:13 -0700 (PDT) Received: from xws.fritz.box ([2a02:8071:b783:140:927c:82ba:d32d:99c1]) by smtp.gmail.com with ESMTPSA id va16-20020a17090711d000b00992aea2c55dsm4858798ejb.153.2023.07.30.09.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 09:19:12 -0700 (PDT) From: Maximilian Luz To: Bjorn Andersson Cc: Maximilian Luz , Andy Gross , Konrad Dybcio , Ard Biesheuvel , Ilias Apalodimas , Srinivas Kandagatla , Sudeep Holla , Johan Hovold , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 0/3] firmware: Add support for Qualcomm UEFI Secure Application Date: Sun, 30 Jul 2023 18:19:01 +0200 Message-ID: <20230730161906.606163-1-luzmaximilian@gmail.com> X-Mailer: git-send-email 2.41.0 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,FREEMAIL_FROM, 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 adds basic support for the QSEECOM interface used to communicate with secure applications running in the TrustZone on certain Qualcomm devices. In addition to that, it also provides a driver for "uefisecapp", the secure application managing access to UEFI variables on such platforms. For a more detailed description, see the blurb of v1. Previous versions: - V4: https://lore.kernel.org/lkml/72c0359a-eda6-30ea-0ec0-b7e9b804b87b@gmail.com/t/ - V3: https://lore.kernel.org/lkml/20230305022119.1331495-4-luzmaximilian@gmail.com/t/ - V2: https://lore.kernel.org/lkml/20230127184650.756795-1-luzmaximilian@gmail.com/ - V1: https://lore.kernel.org/lkml/20220723224949.1089973-1-luzmaximilian@gmail.com/ Changes in v5: - Re-introduce a dedicated platform device for managing QSEECOM client devices. The device is now added via qcom_scm.c instead of the device tree (as has been done in v3). - Replace ucs2_strlcpy() with ucs2_strscpy() - Drop "firmware: qcom_scm: Clear scm pointer on probe failure" and sort out probe-related issue. - Clean up comments in qcom_qseecom_uefisecapp.c Changes in v4: - Integrate the QSEECOM interface into qcom_scm.c instead of instantiating a custom device and requiring device-tree bindings for it. With that, drop the respective patches exporting SCM call functions from qcom_scm.c and the DT bindings. - Restructure management of DMA memory and move DMA mapping entirely into the app_send() command, removing the need for DMA handling in app client drivers. - Add support for EFI's query_variable_info() call. - Move UCS-2 string helpers to lib/ucs2_string.c (introduces patch 1). - Add fix for related cleanup-issue in qcom_scm.c (introduces patch 2). (Refer to individual patches for more details.) Changes in v3: - Fix doc comment in qcom_scm.c - Rebase on top of latest changes to qcom_scm. Changes in v2: - Bind the qseecom interface to a device. - Establish a device link between the new qseecom device and the SCM device to ensure proper PM and remove ordering. - Remove the compatible for uefisecapp. Instead, introduce a compatible for the qseecom device. This directly reflects ACPI tables and the QCOM0476 device described therein, which is responsible for the secure app / qseecom interface (i.e., the same purpose). Client devices representing apps handled by the kernel (such as uefisecapp) are now directly instantiated by the qseecom driver, based on the respective platform-specific compatible. - Rename the base name (qctree -> qseecom) to allow differentiation between old (qseecom) and new (smcinvoke) interfaces to the trusted execution environment. This directly reflects downstream naming by Qualcomm. Maximilian Luz (3): lib/ucs2_string: Add UCS-2 strscpy function firmware: qcom_scm: Add support for Qualcomm Secure Execution Environment SCM interface firmware: Add support for Qualcomm UEFI Secure Application MAINTAINERS | 12 + drivers/firmware/Kconfig | 33 + drivers/firmware/Makefile | 2 + drivers/firmware/qcom_qseecom.c | 130 +++ drivers/firmware/qcom_qseecom_uefisecapp.c | 869 +++++++++++++++++++++ drivers/firmware/qcom_scm.c | 392 ++++++++++ include/linux/firmware/qcom/qcom_qseecom.h | 46 ++ include/linux/firmware/qcom/qcom_scm.h | 21 + include/linux/ucs2_string.h | 1 + lib/ucs2_string.c | 35 + 10 files changed, 1541 insertions(+) create mode 100644 drivers/firmware/qcom_qseecom.c create mode 100644 drivers/firmware/qcom_qseecom_uefisecapp.c create mode 100644 include/linux/firmware/qcom/qcom_qseecom.h -- 2.41.0