Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5085571pxj; Wed, 9 Jun 2021 08:49:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwf51dAHhCjhk583eht1dX2p5+0nLR6AFwEm0wcBkySzydv3uND8vHzuptMbYDv3MXceCS X-Received: by 2002:a17:906:2c4a:: with SMTP id f10mr475850ejh.493.1623253789776; Wed, 09 Jun 2021 08:49:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623253789; cv=none; d=google.com; s=arc-20160816; b=gzq7Vl4RynT3/6fVe3NKHdgzlPNxzRfoaD207l+Pv47WYYWviauBmkBjxZi1TqJEXw ZR9zl3ZNmPRt7H+sdkt23BZZX/jgD0h3DtN8GHRAaRbGnt9wqssRgKBdRVZrnI1kTk3G GxXv6tmD73qC8+phZrtwAUxtXzMYlZmV9WMn0fyjPoeDJdxffjhlkFZERhcHFl+enF2L FbS8wD7+PfB5/cGvwY+uDII1YAJvprld0PAVuWBkwRLAeQbPGM8hqc9zwNJaP9weO8Nz iCSMh2pCrKPNpdVQmUC0KRPcVyyUY1lQ9XUSYHEFPjb4OBq6I8qa2oKM6sfhndBzETbQ dbVQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=NeJm9Sv8T7FXNiunLp/bvLL/Ts+yZdRrx9+3BOizJYo=; b=JE+EFnYabZFXt1CQAo8P8KS8Hgyd7n+St0SNsfnNLy55CPRDF768pOfp6S3+D3jZrO jl9puX37IqjBeZr1A8vZozc5blj+rc9FOen2xdgTPEoS362Q4IbnYKieETZGE5F7nMKo qovlLBK4FVfJ0kQ/5AcGlNwM7ev/9GPe6/LgeMGJxD+MCpb4tJ+hDj/rvQgHDljYsUdt T+Q/tKomVuUrkSNIPAJQ8IxdPDYTw2+NA6qqRbDnOpEZEaNzHOARtGrKYC0C8O73uHP3 kyLUfXbtyEl7mQUMUzen1dcNGGifZlqWrE5zABlfuPq3wMPMNcb+RxHbXr0Gjb/IBNHH h62w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Im2bNCAo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h93si61897edd.605.2021.06.09.08.49.25; Wed, 09 Jun 2021 08:49:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Im2bNCAo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238300AbhFIOxS (ORCPT + 99 others); Wed, 9 Jun 2021 10:53:18 -0400 Received: from linux.microsoft.com ([13.77.154.182]:54000 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237221AbhFIOxR (ORCPT ); Wed, 9 Jun 2021 10:53:17 -0400 Received: from sequoia (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id C2EF320B7188; Wed, 9 Jun 2021 07:51:21 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C2EF320B7188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1623250282; bh=NeJm9Sv8T7FXNiunLp/bvLL/Ts+yZdRrx9+3BOizJYo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Im2bNCAoGQsV+pp/wA4+jYTFrlKIeZ6z1AjrrfXLMo9fbn8UkuXcZsaZt/7NqA6kk 5W+qebRTmAATVGPnKzrs+AbgmxQwjhJNowWhVpojhYeUoa/B+S771VpBTh30b8Dkwe MODYzUioElbeF29xxAUMLJCQcdrY3Mv9konmw/qQ= Date: Wed, 9 Jun 2021 09:51:19 -0500 From: Tyler Hicks To: Jens Wiklander Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, op-tee@lists.trustedfirmware.org, Sumit Garg , Herbert Xu , Sakkinen , Sasha Levin , Thirupathaiah Annapureddy , Vikas Gupta , "David S . Miller" Subject: Re: [PATCH 3/7] tee: add tee_shm_alloc_kernel_buf() Message-ID: <20210609145119.GG4910@sequoia> References: <20210609102324.2222332-1-jens.wiklander@linaro.org> <20210609102324.2222332-4-jens.wiklander@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210609102324.2222332-4-jens.wiklander@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-06-09 12:23:20, Jens Wiklander wrote: > Adds a new function tee_shm_alloc_kernel_buf() to allocate shared memory > from a kernel driver. This function can later be made more lightweight > by unnecessary dma-buf export. > > Signed-off-by: Jens Wiklander Reviewed-by: Tyler Hicks Tyler > --- > drivers/tee/tee_shm.c | 18 ++++++++++++++++++ > include/linux/tee_drv.h | 1 + > 2 files changed, 19 insertions(+) > > diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c > index b9dbf4bce149..63fce8d39d8b 100644 > --- a/drivers/tee/tee_shm.c > +++ b/drivers/tee/tee_shm.c > @@ -192,6 +192,24 @@ struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags) > } > EXPORT_SYMBOL_GPL(tee_shm_alloc); > > +/** > + * tee_shm_alloc_kernel_buf() - Allocate shared memory for kernel buffer > + * @ctx: Context that allocates the shared memory > + * @size: Requested size of shared memory > + * > + * The returned memory registered in secure world and is suitable to be > + * passed as a memory buffer in parameter argument to > + * tee_client_invoke_func(). The memory allocated is later freed with a > + * call to tee_shm_free(). > + * > + * @returns a pointer to 'struct tee_shm' > + */ > +struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size) > +{ > + return tee_shm_alloc(ctx, size, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF); > +} > +EXPORT_SYMBOL_GPL(tee_shm_alloc_kernel_buf); > + > struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, > size_t length, u32 flags) > { > diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h > index 62b7c7a55743..58b319766f8e 100644 > --- a/include/linux/tee_drv.h > +++ b/include/linux/tee_drv.h > @@ -282,6 +282,7 @@ void *tee_get_drvdata(struct tee_device *teedev); > * @returns a pointer to 'struct tee_shm' > */ > struct tee_shm *tee_shm_alloc(struct tee_context *ctx, size_t size, u32 flags); > +struct tee_shm *tee_shm_alloc_kernel_buf(struct tee_context *ctx, size_t size); > > /** > * tee_shm_register() - Register shared memory buffer > -- > 2.31.1 >