Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp834294rdg; Wed, 11 Oct 2023 06:56:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQ/8r9o4QSJhTSvzQ0zycAZVm7/BwtpPMNVfRcIhQ5zx6G8dYrOAlFMdJ3L9Fg6MZV+OZm X-Received: by 2002:a05:6e02:160c:b0:351:4dcd:7655 with SMTP id t12-20020a056e02160c00b003514dcd7655mr25418394ilu.31.1697032613733; Wed, 11 Oct 2023 06:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697032613; cv=none; d=google.com; s=arc-20160816; b=mnQuSEhYGXajErMKL56q6BM7ki1l0jQJQS22yHSh0V1lpQURUVteRUGHV//nwI49ny NXOI5G7gWANPr6dfBgTHE+K0oovmMVw52k5zP3pmbz5tz3SuqsxO3uUDvCZzlQ7nZeLG Qdl60IyuH8L0OFey+yQ9e0EWzEsV2APJHaL/0YGjP7NgaO5K2yCyN0unKSeWg0AQVK7f oOwWnPRRW4RyweT54VPe6yZ0gaR22VRibgwZoe078huPxrabkNQqdoLKEJJ3WFiA9/Gx OBbItLL2PU3rvnejHi7z6PrBm3PgEaUAd31kwBEMaH+wf/2iO/LsDi2SArM4NP79hWQu 8vZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CCQEtnJtqrl4ZQlzrkW0UsHRVRuDX1lNSfSKzLC2Fyw=; fh=4jyF2ZUBQ/SiJHAfGoV+niA288FYUMeb6Ahk+NIw7Pw=; b=yYsSkYQMFf7R81NrMZvgh8ECJBb33SwI87kAtAkC4DD62iXvMFia4kICwn5hf+bd7y tQzklQrrWihUZsRoigbPk/VVxamMoY9WpvvsAHG4ng1sZYhVknSgfPYflOhM9w+E/MkX JSkBEf7BeA79HobMmCRRj1c1yVqYhvngxsv5SlTTat71ksATITVDpjOtTjyJDKGSEBp/ ca64GyG7aV13nY6K+Kal4d0ZJuQtcsNL0UWjxAzv9vFCjn8ed5HsCQX0OcAQNlMSTVxq oodltlN+WXjxp4NLj9YfomwKAdRyDZUnLJ8R63+V0ylqKnRO8SnH8lqfASVAwmrP/xLe KfAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hfKkioAP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q8-20020a056a00084800b0069338b22bfdsi12567173pfk.205.2023.10.11.06.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hfKkioAP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6D5C381CEB1C; Wed, 11 Oct 2023 06:56:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232202AbjJKN4p (ORCPT + 99 others); Wed, 11 Oct 2023 09:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbjJKN4n (ORCPT ); Wed, 11 Oct 2023 09:56:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79D5590 for ; Wed, 11 Oct 2023 06:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697032554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CCQEtnJtqrl4ZQlzrkW0UsHRVRuDX1lNSfSKzLC2Fyw=; b=hfKkioAPJAFuEUWeIHuCkyhmSEoX81gxy8HV/MDRIcrJIC7Ichn+OlGsDTcmqs4WvNWMjh CTm6RN9N4kD/peQCeSCEsZ9lzvMRM31UdpSp+GUHP8Jz8AbPydYE/3HSpaXAS5MZkUdLkt xGYRkq67ZYyS9T1x2loV+3Ndp4mCXeI= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-mL34rKmhNnC6INHukD-YbQ-1; Wed, 11 Oct 2023 09:55:53 -0400 X-MC-Unique: mL34rKmhNnC6INHukD-YbQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-775751c3437so915808485a.3 for ; Wed, 11 Oct 2023 06:55:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697032552; x=1697637352; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CCQEtnJtqrl4ZQlzrkW0UsHRVRuDX1lNSfSKzLC2Fyw=; b=Z2/fsbWkvSV1xrgn8+6MzOII/oanlht3/uIDBf8AYjh7n4k9f9uPEctkS56zoVuO+e CsX/8pR9Dbm5qI98XwmETyPVm0DVe+7UuSYXeYVnnc6Q12ynFd5m87nfcmv5y4qlgCYT meNSjS6X204kYa1vFh4BNbGBM3+2s3hkUAS+2QloEglahcCj05AKiOJj7mgAW64kVGYH rpcxD2slHujZcbtu4u5mvq6Os6QPWUIwWWDoDc5WRPYYi2KO0l8khiA22VmJUQJQElqW 928fRYtzBkoMMN2mo4IpwwlhAVI8K1XEJLNIqDxI49xqvGRYXLNCKG74E+0J933fuRw8 F6YQ== X-Gm-Message-State: AOJu0YxjseZAeRdAjb/Uw3dZ5ufU1Zq405JGdfCFbhLgDKfIoUvAGE7/ 94cQhipTmjzNqXnn356rFNKixNMz1rz2/LgtlYP422imoIOqmcvX8AaRRpDSu3t2mgJ+A0b6nZA A/J87FBy46dzanDCNoUMRmWtwxJ7RYrXR X-Received: by 2002:a05:620a:2493:b0:773:dce0:b2b8 with SMTP id i19-20020a05620a249300b00773dce0b2b8mr25704056qkn.17.1697032552590; Wed, 11 Oct 2023 06:55:52 -0700 (PDT) X-Received: by 2002:a05:620a:2493:b0:773:dce0:b2b8 with SMTP id i19-20020a05620a249300b00773dce0b2b8mr25704032qkn.17.1697032552283; Wed, 11 Oct 2023 06:55:52 -0700 (PDT) Received: from fedora ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j30-20020a05620a001e00b00767d2870e39sm5243919qki.41.2023.10.11.06.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:55:51 -0700 (PDT) Date: Wed, 11 Oct 2023 08:55:49 -0500 From: Andrew Halaney To: Bartosz Golaszewski 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 Subject: Re: [PATCH v3 11/15] firmware: qcom: qseecom: convert to using the TZ allocator Message-ID: References: <20231009153427.20951-1-brgl@bgdev.pl> <20231009153427.20951-12-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 06:56:48 -0700 (PDT) On Wed, Oct 11, 2023 at 09:44:54AM +0200, Bartosz Golaszewski wrote: > On Wed, Oct 11, 2023 at 12:49 AM 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(struct qcuefi_client *qcuefi, > > > return EFI_INVALID_PARAMETER; > > > > > > status = qcom_qseecom_app_send(qcuefi->client, req_data, req_size, rsp_data, rsp_size); > > > - if (status) { > > > - efi_status = EFI_DEVICE_ERROR; > > > - goto out_free; > > > - } > > > + if (status) > > > + return EFI_DEVICE_ERROR; > > > > > > - if (rsp_data->command_id != QSEE_CMD_UEFI_GET_NEXT_VARIABLE) { > > > - efi_status = EFI_DEVICE_ERROR; > > > - goto out_free; > > > - } > > > + if (rsp_data->command_id != QSEE_CMD_UEFI_GET_NEXT_VARIABLE) > > > + return EFI_DEVICE_ERROR; > > > > > > - if (rsp_data->length < sizeof(*rsp_data)) { > > > - efi_status = 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(struct qcuefi_client *qcuefi, > > > if (efi_status == EFI_BUFFER_TOO_SMALL) > > > *name_size = rsp_data->name_size; > > > > > > - goto out_free; > > > + return efi_status; > > > } > > > > > > - if (rsp_data->length > rsp_size) { > > > - efi_status = 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->length) { > > > - efi_status = EFI_DEVICE_ERROR; > > > - goto out_free; > > > - } > > > + if (rsp_data->name_offset + rsp_data->name_size > rsp_data->length) > > > + return EFI_DEVICE_ERROR; > > > > > > - if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->length) { > > > - efi_status = EFI_DEVICE_ERROR; > > > - goto out_free; > > > - } > > > + if (rsp_data->guid_offset + rsp_data->guid_size > rsp_data->length) > > > + return EFI_DEVICE_ERROR; > > > > > > if (rsp_data->name_size > *name_size) { > > > *name_size = rsp_data->name_size; > > > - efi_status = EFI_BUFFER_TOO_SMALL; > > > - goto out_free; > > > + return EFI_BUFFER_TOO_SMALL; > > > } > > > > > > - if (rsp_data->guid_size != sizeof(*guid)) { > > > - efi_status = EFI_DEVICE_ERROR; > > > - goto out_free; > > > - } > > > + if (rsp_data->guid_size != sizeof(*guid)) > > > + return EFI_DEVICE_ERROR; > > > > > > memcpy(guid, ((void *)rsp_data) + rsp_data->guid_offset, rsp_data->guid_size); > > > status = ucs2_strscpy(name, ((void *)rsp_data) + rsp_data->name_offset, > > > rsp_data->name_size / sizeof(*name)); > > > *name_size = rsp_data->name_size; > > > > > > - if (status < 0) { > > > + if (status < 0) > > > /* > > > * Return EFI_DEVICE_ERROR here because the buffer size should > > > * have already been validated above, causing this function 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 = 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 = devm_qcom_tzmem_pool_new(&aux_dev->dev, SZ_256K); > > > > 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? I've got no insight into these firmware interfaces unfortunately. Was mostly curious if Qualcomm had provided a suggestion behind the scenes or if this was picked as a "sufficiently large" pool size. > > Bart > > > Reviewed-by: Andrew Halaney > > >