Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp639873rdg; Wed, 11 Oct 2023 00:46:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETCAiOVw13aDU3Oa2sVvr8+M9+PJiATjrO4LzfpiBdyxwz5uJEN3rZoYtnDbtIv3Gf5Des X-Received: by 2002:a05:6870:65a9:b0:1d6:56d8:a787 with SMTP id fp41-20020a05687065a900b001d656d8a787mr23732044oab.11.1697010390229; Wed, 11 Oct 2023 00:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697010390; cv=none; d=google.com; s=arc-20160816; b=iuypi32/hllr72T+YjCloaxxbzGJ3RFeIcYuVuQxBOEZqqKgExJiTMFNppsYmqjEWs e3NO/1wydIkjSV/TInTqQrAhW0AMSW82WYNXUUnkTms/HrbIaUfYR9BIqnBbCfjfPRTD qXgZC4Vrfsi4Ie47uugeh94J8KxlchqrvWgHj2SwWcCCcfnTVP4340fqMO+TLK5gtk7S /cidBjdAc8JbGv1Jcj7qQLHQcHgzOreF7p2vy6WFuVWgMk1G9faFJo41zKbJaBtn4gXK Z4SMLkKp99CsR9DIvlrBxQ53qTN8uImlP0mensb7Msy5UJVBdi3DkzBphNgEumthuwI0 GywA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kH8dO8P8jk4qRPtIhdpshR5FUbXSZA/6Cs8Pjyzxf8I=; fh=89S32swxLyeX0nV1QKEbzPKxVMotD+YOi0T3gfQ3XuI=; b=ZBELemkbwoShLhogjlqBugK8wR4T9zqW/N1xloAw+Mj9FSHpqFzcvkqGEedbhHGYGg bBL2sZ5wDT9NNPpm1rJ6LdyFpcZQ5X87t97KNGwXSKWygDjK7cWc5NuijjJS0bZ06ilp 6o2aw+qbA/NsuIXxDoGD46oGmEgksodCsrSRTVo0SZbv/PqBLC0jK/yhf2b3WquMqYII 111Ih3GIJQgq/0iPWvgl/PQMSNveOtuSvb0WR/k1eJfsl0iIy2qC2+Z/NHxAIQIY2Stb H+n9p7PKGLk+Krb52C30KbL6rfj/Atbh4x63OKsIamkFQ4gRMJLFr7ob9v/DcbpwmeRi Ilxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="H4/o8NBF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id g190-20020a636bc7000000b0056336fb99aasi13494630pgc.850.2023.10.11.00.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 00:46:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="H4/o8NBF"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 24DC480689E2; Wed, 11 Oct 2023 00:45:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345349AbjJKHpM (ORCPT + 99 others); Wed, 11 Oct 2023 03:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344927AbjJKHpK (ORCPT ); Wed, 11 Oct 2023 03:45:10 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A90C9C for ; Wed, 11 Oct 2023 00:45:06 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id ada2fe7eead31-4577c1259c6so1128285137.3 for ; Wed, 11 Oct 2023 00:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697010305; x=1697615105; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kH8dO8P8jk4qRPtIhdpshR5FUbXSZA/6Cs8Pjyzxf8I=; b=H4/o8NBFF4tEYVkdZwImKnHmOBbCUsXQK09IMzqCTs5P21MJfi1bZUZh/FDyzz9Lmx Q1hnCpjTl2MU4r6XLkTT3ZbzoyQGf2nL8dKppTG+B222VolDIEx6CAkKCzX7DwZlNMLi yUglhzX0CDVSNzm1qD1gq9xsRO+UkrIa/fPNDgC7q2edfTbK1dEuOtvEj/JBUdj908AJ zRx1YuRF7hreV4BeWyE8pS92eIBp1tek5gFjQdIXIig+klez4OK9WRqLLspxAGmbgO34 0jNudXH3rocr+YGnhC4CyB/otAILxrFnjziwUbpmFSvVcw6L4K376frvEJ6bzAb5XAYj FYQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697010305; x=1697615105; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kH8dO8P8jk4qRPtIhdpshR5FUbXSZA/6Cs8Pjyzxf8I=; b=idfHLVSioaJxJA//iDipfNGD1gDT5VqKXA/+sWKKKnt/hyapaL3sz2ncyOjgCoCAuV U0PPrvAtr2Ez62aW6BN1Wj8G7yehw9bIsJA24WQbnn0nfvhCbjq5S15P0m2inobWocGa /M9v612G8ZIxD2cWZ92bAURXMjh9NzJV/IN2fYiJz6e75Dvc4pnRBHrWd/g9T0O8ERKf Q2RXmnKbT1qM8iyfQYzR894VPkqqjdUIoeIZFUYskbRgRfzGmFK35WIHkVqgAgTXbi0G 7BAPnJ7704PgWzUDVm3vlE98HXH3NrO/q1kyN4ocgcpMbjKSMxFMFiCKnv7veub+5Tl+ 0xyw== X-Gm-Message-State: AOJu0YxqEWes+ZaLAr1BfJvSwW1zEEH7Vwo2BG94Gs2m+H6UeteSnIHz ENBbSkqt7mfPHaLVxL5S/8AKeNA6kdGq441zxkR5kw== X-Received: by 2002:a67:ce13:0:b0:44d:3d29:4940 with SMTP id s19-20020a67ce13000000b0044d3d294940mr12207630vsl.35.1697010305073; Wed, 11 Oct 2023 00:45:05 -0700 (PDT) MIME-Version: 1.0 References: <20231009153427.20951-1-brgl@bgdev.pl> <20231009153427.20951-12-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Wed, 11 Oct 2023 09:44:54 +0200 Message-ID: Subject: Re: [PATCH v3 11/15] firmware: qcom: qseecom: convert to using the TZ allocator To: Andrew Halaney Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Elliot Berman , Krzysztof Kozlowski , Guru Das Srinagesh , Maximilian Luz , Alex Elder , Srini Kandagatla , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@quicinc.com, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 00:45:46 -0700 (PDT) X-Spam-Level: ** On Wed, Oct 11, 2023 at 12:49=E2=80=AFAM Andrew Halaney wrote: > > On Mon, Oct 09, 2023 at 05:34:23PM +0200, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > Drop the DMA mapping operations from qcom_scm_qseecom_app_send() and > > convert all users of it in the qseecom module to using the TZ allocator > > for creating SCM call buffers. Together with using the cleanup macros, > > it has the added benefit of a significant code shrink. As this is > > largely a module separate from the SCM driver, let's use a separate > > memory pool. > > > > Signed-off-by: Bartosz Golaszewski > > > > > @@ -567,20 +529,14 @@ static efi_status_t qsee_uefi_get_next_variable(s= truct qcuefi_client *qcuefi, > > return EFI_INVALID_PARAMETER; > > > > status =3D qcom_qseecom_app_send(qcuefi->client, req_data, req_si= ze, rsp_data, rsp_size); > > - if (status) { > > - efi_status =3D EFI_DEVICE_ERROR; > > - goto out_free; > > - } > > + if (status) > > + return EFI_DEVICE_ERROR; > > > > - if (rsp_data->command_id !=3D QSEE_CMD_UEFI_GET_NEXT_VARIABLE) { > > - efi_status =3D EFI_DEVICE_ERROR; > > - goto out_free; > > - } > > + if (rsp_data->command_id !=3D QSEE_CMD_UEFI_GET_NEXT_VARIABLE) > > + return EFI_DEVICE_ERROR; > > > > - if (rsp_data->length < sizeof(*rsp_data)) { > > - efi_status =3D EFI_DEVICE_ERROR; > > - goto out_free; > > - } > > + if (rsp_data->length < sizeof(*rsp_data)) > > + return EFI_DEVICE_ERROR; > > > > if (rsp_data->status) { > > dev_dbg(qcuefi_dev(qcuefi), "%s: uefisecapp error: 0x%x\n= ", > > @@ -595,77 +551,59 @@ static efi_status_t qsee_uefi_get_next_variable(s= truct qcuefi_client *qcuefi, > > if (efi_status =3D=3D EFI_BUFFER_TOO_SMALL) > > *name_size =3D rsp_data->name_size; > > > > - goto out_free; > > + return efi_status; > > } > > > > - if (rsp_data->length > rsp_size) { > > - efi_status =3D EFI_DEVICE_ERROR; > > - goto out_free; > > - } > > + if (rsp_data->length > rsp_size) > > + return EFI_DEVICE_ERROR; > > > > - if (rsp_data->name_offset + rsp_data->name_size > rsp_data->lengt= h) { > > - efi_status =3D EFI_DEVICE_ERROR; > > - goto out_free; > > - } > > + if (rsp_data->name_offset + rsp_data->name_size > rsp_data->lengt= h) > > + return EFI_DEVICE_ERROR; > > > > - if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->lengt= h) { > > - efi_status =3D EFI_DEVICE_ERROR; > > - goto out_free; > > - } > > + if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->lengt= h) > > + return EFI_DEVICE_ERROR; > > > > if (rsp_data->name_size > *name_size) { > > *name_size =3D rsp_data->name_size; > > - efi_status =3D EFI_BUFFER_TOO_SMALL; > > - goto out_free; > > + return EFI_BUFFER_TOO_SMALL; > > } > > > > - if (rsp_data->guid_size !=3D sizeof(*guid)) { > > - efi_status =3D EFI_DEVICE_ERROR; > > - goto out_free; > > - } > > + if (rsp_data->guid_size !=3D sizeof(*guid)) > > + return EFI_DEVICE_ERROR; > > > > memcpy(guid, ((void *)rsp_data) + rsp_data->guid_offset, rsp_data= ->guid_size); > > status =3D ucs2_strscpy(name, ((void *)rsp_data) + rsp_data->name= _offset, > > rsp_data->name_size / sizeof(*name)); > > *name_size =3D rsp_data->name_size; > > > > - if (status < 0) { > > + if (status < 0) > > /* > > * Return EFI_DEVICE_ERROR here because the buffer size s= hould > > * have already been validated above, causing this functi= on to > > * bail with EFI_BUFFER_TOO_SMALL. > > */ > > return EFI_DEVICE_ERROR; > > - } > > Personally (no idea what the actual style guide says) leaving braces > around the multiline if statement would be nice.... that being said, > that's my opinion :) > > > > @@ -704,12 +635,7 @@ static efi_status_t qsee_uefi_query_variable_info(= struct qcuefi_client *qcuefi, > > if (max_variable_size) > > *max_variable_size =3D rsp_data->max_variable_size; > > > > -out_free: > > - kfree(rsp_data); > > -out_free_req: > > - kfree(req_data); > > -out: > > - return efi_status; > > + return EFI_SUCCESS; > > } > > > > /* -- Global efivar interface. ---------------------------------------= ------- */ > > @@ -838,6 +764,10 @@ static int qcom_uefisecapp_probe(struct auxiliary_= device *aux_dev, > > if (status) > > qcuefi_set_reference(NULL); > > > > + qcuefi->mempool =3D devm_qcom_tzmem_pool_new(&aux_dev->dev, SZ_25= 6K); > > Any particular reason for this size? Just curious, it was (one) of the > reasons I had not marked patch 4 yet (it looks good, but I wanted to get > through the series to digest the Kconfig as well). > I cannot test this. Do you know what the minimum correct size would be? Bart > Reviewed-by: Andrew Halaney >