Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp40940pxj; Thu, 10 Jun 2021 14:11:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu4G8QgaT4YnagjC52KUyX7OMqcagNtYhaOhkFEhoWZdwVmRxX42llH9WMqxbQZZePstKr X-Received: by 2002:a17:906:49ce:: with SMTP id w14mr443718ejv.273.1623359517625; Thu, 10 Jun 2021 14:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623359517; cv=none; d=google.com; s=arc-20160816; b=kPnIVW8c3OA5SVE+ggrEtZ/r811OjdkGDyVYp9h3aWCQh2I8uAJ0i49vSWP7MdzUm/ KzO079FNUwZT5eU1efFIFfmdR7DXyVs8gibMdccXKTG9ixXz++yr39jNfyejz1cVfvK/ lzvi5gOTJ4E7QXwNdBWUZxKHJ1O7e2+i2Rr31NSFYkYoC+X96rsE62mhrphlt32DiBV5 pv3Y3GAwnVgUY/uCADntpIALPMrh6RJb/nIU88nO36+jUw09kKdScWnaZbV1G4fTIEoi j4VySADPDxp9zWP7W10zaizGOpbtkABr/IuMf9jY1iVM4bZSTVu8hRln2wsmhbJ9Q1cI s8ug== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=rS0KO2g5L8Xhkc4V95Ph1/HTme6zsuqiHbL+4FmEy0o=; b=jQm3nrUFqnWrJjf+oBgKgzU+G0JQMcCxDsDncCatNJg1rwjkRnr8gtM6FZlEf4Ragy DfYyZi5a3fUgXsZpu8f3fJ6KT/aogUAA8JvJYY2v2F6MpRoFZFuaFUwrizQgZGCD5MCc s6MlXyvhsuLMBK7GtmogvXDZhNjE7HU65FhmZwFcq32kX+wov6ouifZxsDff8wUxYzcp 2akjVQu8QW5jijPIaZsEuQf4Pwo5SD33B/si+TCGZHG+sEyQSOSFg5bJB4Hr4isVYBo7 z/kMMqsssxHWvzI8cFq5ckRcIQzBjJxCYvnIoSgQSwBVYNzTK70WDaZ8fDmLV//QhGKG TksA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=HC7WlPPb; 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 l20si3197859ejz.525.2021.06.10.14.11.32; Thu, 10 Jun 2021 14:11:57 -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=HC7WlPPb; 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 S231252AbhFJVL5 (ORCPT + 99 others); Thu, 10 Jun 2021 17:11:57 -0400 Received: from linux.microsoft.com ([13.77.154.182]:60524 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231156AbhFJVLs (ORCPT ); Thu, 10 Jun 2021 17:11:48 -0400 Received: from sequoia.work.tihix.com (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 3745220B83CB; Thu, 10 Jun 2021 14:09:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3745220B83CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1623359391; bh=rS0KO2g5L8Xhkc4V95Ph1/HTme6zsuqiHbL+4FmEy0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HC7WlPPbsJsawizQdIikbgX8/Ami2E6QH32qPb8NDJsoE7jpuSCVaEbYFYL4cauXO Ap/uC7IemAfkJGODp5MtlIrJlIEjFQfbPzWusP36l4j3NMZ6hutk+LyPe+EA9qe+JX L3fLgCBt4ixF/jVzATUibqkw5o5ohs+Z5b6GdnJM= From: Tyler Hicks To: Jens Wiklander , Allen Pais , Sumit Garg , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Vikas Gupta Cc: Thirupathaiah Annapureddy , Pavel Tatashin , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , op-tee@lists.trustedfirmware.org, linux-integrity@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 5/8] tee: add tee_shm_alloc_kernel_buf() Date: Thu, 10 Jun 2021 16:09:10 -0500 Message-Id: <20210610210913.536081-6-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210610210913.536081-1-tyhicks@linux.microsoft.com> References: <20210610210913.536081-1-tyhicks@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jens Wiklander 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 --- 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 00472f5ce22e..c65e44707cd6 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -193,6 +193,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 54269e47ac9a..8990f7628387 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -332,6 +332,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.25.1