From patchwork Tue Aug 10 17:30:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 494370 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4194108jap; Tue, 10 Aug 2021 11:00:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrGKykiNm4lhEKac2UbLBnn5foTLAUFcvXt/dX8x3uCMlcdsP0Xs+vFsnJwNQL6MODKg/T X-Received: by 2002:a05:6e02:1c2a:: with SMTP id m10mr291702ilh.114.1628618431963; Tue, 10 Aug 2021 11:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628618431; cv=none; d=google.com; s=arc-20160816; b=ZELl2za1/fKAmmBEoNfHTs/tiTPPq+LOMnI2gY4SkVFT+tk/p0xMxyEg5IDruKuJHE +mWulh94WG3N+bguUkPpigCJLnbxL/Wy7clKHUUOKw4CHmJbZrGdsncL/ox3ZdDHo20S OZ24hv0WJ+eyFXgQSbbkBKUokt71Qx6/m3pthjlETw5FH+imGpMCuVJ6PodCoeQfOIet mX35yoAPtsDm4jp6bOU/GAq8RxaKGRbfpEaAaLy6LOTANOTPb4duD+JxbMnXrNIxHIyZ tMLZCYYpDIS4NYIo8R1Woie0aY8SAZovRy5RQv3ygTBZkSf55rKWJdH8XtEk3S43JXaX XWmA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T49vJrJ0iZXvrqZCCfvtHVYNL6rJGUY4SGtMCR0cf7s=; b=KzpWLkzSk0N17THLwjPibqzR7jb2VjebHfD+HVRLx3kTbQtZMMlBccUoQLbGr4bze4 uubmfJ6szXizcFYCftMYfdHqewhtPDS8XwpaT3tkLUAMqB/xeUVecmnfuD2bRXAv3TXs KWMUDXktGAoE9hUBzVF/leoy011k41AIzqkqiR6gFypFCzsp9AuQCT8peRWwz0P0KYI5 kmpVTv5ZgJhwOk5JXKTR01H6qW0ZRUD1a7ly5la1YE1TAJkgW73NgBNc1qWukt6M5vKV i8aWNDo/YckP/noByTDnNhxmnja+tOGOi400JO/r3bGLPZjjgPN7sytEY02iWx77bmo5 xmZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=herybrq8; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si19403639ioe.34.2021.08.10.11.00.31; Tue, 10 Aug 2021 11:00:31 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=herybrq8; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237263AbhHJSA0 (ORCPT + 12 others); Tue, 10 Aug 2021 14:00:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:55582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236635AbhHJR6l (ORCPT ); Tue, 10 Aug 2021 13:58:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38EF561153; Tue, 10 Aug 2021 17:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617553; bh=A+ZmOuKwtpvP7/Z98qWtfl5PW+bujj7O8LS/Hqb3aoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=herybrq8KuHScrRmqtH2Dh5EhNIHYNvjp7c/+bz9NCMqxQbM4wd3qgRsJedUU1NX5 wb7pHuSKW6ARoaHxjnB4XABIAVqN1KOmtHONI08ocBzsXmzHfwyR9xGOR6IPS8PT+Z vLIEB0duvrfroyS9kDPca0dBDbmcoDbiBaJZv+xY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyler Hicks , Sumit Garg , Jens Wiklander Subject: [PATCH 5.13 110/175] tee: add tee_shm_alloc_kernel_buf() Date: Tue, 10 Aug 2021 19:30:18 +0200 Message-Id: <20210810173004.580878234@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810173000.928681411@linuxfoundation.org> References: <20210810173000.928681411@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jens Wiklander commit dc7019b7d0e188d4093b34bd0747ed0d668c63bf upstream. 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. Cc: stable@vger.kernel.org Reviewed-by: Tyler Hicks Reviewed-by: Sumit Garg Signed-off-by: Jens Wiklander Signed-off-by: Greg Kroah-Hartman --- drivers/tee/tee_shm.c | 18 ++++++++++++++++++ include/linux/tee_drv.h | 1 + 2 files changed, 19 insertions(+) --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -193,6 +193,24 @@ err_dev_put: } 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) { --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -332,6 +332,7 @@ void *tee_get_drvdata(struct tee_device * @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