From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BBD8C433FE for ; Fri, 7 Oct 2022 08:13:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 31B336B0072; Fri, 7 Oct 2022 04:13:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2CA996B0073; Fri, 7 Oct 2022 04:13:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 145DA6B0074; Fri, 7 Oct 2022 04:13:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EFA066B0072 for ; Fri, 7 Oct 2022 04:13:11 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BC95E120937 for ; Fri, 7 Oct 2022 08:13:11 +0000 (UTC) X-FDA: 79993438182.29.4C5720B Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf19.hostedemail.com (Postfix) with ESMTP id 5D0381A001A for ; Fri, 7 Oct 2022 08:13:10 +0000 (UTC) Received: by mail-pg1-f181.google.com with SMTP id f193so4080315pgc.0 for ; Fri, 07 Oct 2022 01:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=n8VvFVGhEVMZdHi8+5seVzuqaqkjdyrnFvIS6loiHwQ=; b=HtkV+NUpGjW7HXSzGJ6oZnrPPTREyGeCYFxDvh7RlDGAcijsSCgwmHoR9SvGnmuab4 RsXVY5O3pLgan83+qkOJvhAaNmKc9TwmI6qEB5F+EydiYfkpYtJnEUUzb5G4TyildDnm dsvdCtBlg7drsXYMJvDzlxYjxh4GvEthtGbcdbws1UG/qVdX9gSufwzp7srZJyBYc8ca FYlRxDr5roboKs6JuzY359e2+MgipzjxTOw1OLhQ7NY4lnzxmtQze/7t0G80HJ+ORaUb +pW67ITt3KaHOmYgsRfhAJVQTn3JdR3WFf+uaO3FWT1/sIk7UcnjVYjXyf+3XZTn8UmX n+rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=n8VvFVGhEVMZdHi8+5seVzuqaqkjdyrnFvIS6loiHwQ=; b=rGui7qQurq5VsGuksEeqgfKd+yoHaGsV5CWuHOwKpGY3q+j75f0brVfvtPqzjqO0kk RLKoxao8+oZj4Go8WExL95ysg3bFqbOuMHmnF5fa4nF6wzU1vP2nbHEdP/qvgu4gLYh/ 0Ekc5Yc9lFcvIburLeE0L2xZ9/kqRsDU+jrn6y+3v4RXv/2/YwagNnyUgfiVe8KK3k8P ulkB/H83k28hbeXT1q9Emu7bZsltsfWaMxNdIslc1nI5goHy6shShOJtQ9twwIVfb1IC j3fCoTb/XhU5XePSIKoh4Vrnwtt/Vri2n25nYfu0SC5fBWFl99VZh+lst2J5UYyFuokR eTRA== X-Gm-Message-State: ACrzQf2ni5tCQrE9zjPsWmRSH0UL+NUXhsv1gvFbSGig1Q8XfSu4J4ur 534B8Ak5a+wjkI7X9oXt0ClGYmXZzoFhUeIqbsSpfA== X-Google-Smtp-Source: AMsMyM68Bm1nFSvBPk7n2zafQw6ucnG0uukpNbiIy7kClP9xZYK6Z4ajGqFrItQYiTZlZU9CwF24JXqJDcADBkzlKiU= X-Received: by 2002:a63:5b48:0:b0:458:1e98:c862 with SMTP id l8-20020a635b48000000b004581e98c862mr3472673pgm.568.1665130389005; Fri, 07 Oct 2022 01:13:09 -0700 (PDT) MIME-Version: 1.0 References: <20221002002326.946620-1-ira.weiny@intel.com> <20221002002326.946620-3-ira.weiny@intel.com> In-Reply-To: From: Jens Wiklander Date: Fri, 7 Oct 2022 10:12:57 +0200 Message-ID: Subject: Re: [PATCH 2/4] tee: Remove vmalloc page support To: Linus Torvalds Cc: Sumit Garg , =?UTF-8?B?UGhpbCBDaGFuZyAo5by15LiW5YuzKQ==?= , "ira.weiny@intel.com" , Andrew Morton , Al Viro , "Fabio M. De Francesco" , Christoph Hellwig , "op-tee@lists.trustedfirmware.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665130390; a=rsa-sha256; cv=none; b=NOxbesCi7m6vAQS8+SI9nJdz+hp5iuMVRDLdr1G6kOgc0r/9BT94flWEWzXRDDMfBhq+Pa BhQmGLGVIzh9ZAsgRu+trkUunUAssW0DozXKyRhDfkyXHZ4QqjsInDHTsfkscc6/U1LmBr Ez2LeVJ5Poqv5jPxoKeRh5Ag6V+4b7M= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=HtkV+NUp; spf=pass (imf19.hostedemail.com: domain of jens.wiklander@linaro.org designates 209.85.215.181 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (policy=none) header.from=linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665130390; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=n8VvFVGhEVMZdHi8+5seVzuqaqkjdyrnFvIS6loiHwQ=; b=sRHnTJWf2aTIVgmWext2B+96xxrrYJr4gkVaX+1skAUwPD7UkndbIoEx8OqP1lUYelB+IV l2A8EK/UCD/yLfIjDdzFjahueiizjasAf/t84vvN0QZ0s0FrcUyjGodfTjYkLIHEj2KXaA pn9YfyjeR2YfkEWoNmwpRT0SQtCb0Gw= X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=HtkV+NUp; spf=pass (imf19.hostedemail.com: domain of jens.wiklander@linaro.org designates 209.85.215.181 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (policy=none) header.from=linaro.org X-Stat-Signature: tfjt7h9biemgxgd14wsotpn1e3u6nj6o X-Rspamd-Queue-Id: 5D0381A001A X-Rspamd-Server: rspam01 X-HE-Tag: 1665130390-252640 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 6, 2022 at 8:20 PM Linus Torvalds wrote: > > On Wed, Oct 5, 2022 at 11:24 PM Sumit Garg wrote: > > > > Sorry but you need to get your driver mainline in order to support > > vmalloc interface. > > Actually, I think even then we shouldn't support vmalloc - and > register_shm_helper() just needs to be changed to pass in an array of > actual page pointers instead. register_shm_helper() is an internal function, I suppose it's what's passed to tee_shm_register_user_buf() and especially tee_shm_register_kernel_buf() in this case. So the gain is that in the kernel it becomes the caller's responsibility to provide the array of page pointers and the TEE subsystem doesn't need to care about what kind of kernel memory it is any longer. Yes, that should avoid eventual complexities with vmalloc() etc. > > At that point TEE_SHM_USER_MAPPED should also go away, because then > it's the caller that should just do either the user space page > pinning, or pass in the kernel page pointer. > > JensW, is there some reason that wouldn't work? We still need to know if it's kernel or user pages in release_registered_pages(). The struct tee_shm:s acquired with syscalls from user space are reference counted. As are the kernel tee_shm:s, but I believe we could separate them to avoid reference counting tee_shm:s used by kernel clients if needed. I'll need to look closer at this if we're going to use that approach. Without reference counting the caller of tee_shm_free() can be certain that the secure world is done with the memory so we could delegate the kernel pages part of release_registered_pages() to the caller instead. Cheers, Jens > > Linus