Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp605849rwb; Fri, 7 Oct 2022 01:23:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OQUfSPIkH4DSdhzXaNP0RVx7aaCIf5dYWOk9N8badGFOiLXNeIWU2BBBVVxRb/uyO+R9w X-Received: by 2002:a05:6a00:27a0:b0:55a:fa17:5cf9 with SMTP id bd32-20020a056a0027a000b0055afa175cf9mr3996987pfb.15.1665130985774; Fri, 07 Oct 2022 01:23:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665130985; cv=none; d=google.com; s=arc-20160816; b=tpRK8tuv697DFyesH0YdYcrL53qhcsH+1QrOhKezzGD6EUAm+KRr2UjEvxWUT3TnBZ WlR/IeFusmapyd6OsmrGJnA3+2+ikJY3hfpUzZtk2XGsNKp+uaO7yBFLrwGTFqjJsG0X RIkCx91MzafEM8jJ2yqL2XaXI3b+uYRVf0yFSs/xCDfv8JfutFSgOtzwB/1i5rZAIfvP swIXx/yYJnyB3Q+cvzVmU/rFnkZRVg+73FYu1GdBmCx4TYSdLSyF8tWNqLuvhQ8r3Wj3 thBIwJgbd41FIavgrwmibeUr0qZvYftFMWM0vzzDwksCWfH7cg5UbtVI0hLry9PcI1N3 x07g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=n8VvFVGhEVMZdHi8+5seVzuqaqkjdyrnFvIS6loiHwQ=; b=EtOI3KUVdY87GjsPPrIzEXaN6+u5zseu9HrRxzTqOddIQhr7TxgFC0xlX8HxbtFC25 9M0RZ7SD+bC9eO5O04itVlh6XYkBo3T/zsR/yzEkbqx73imvIMMB7helH14GlvOnl0Gh ekgMVIe95ZkMdTgiqcO2t0+P7lMSnM2NiF+yBM8vP74sGi5/VrAKgzmHy5X6ysDn9whR 2Ou220jE3bzas6PWmiDPcPdy7xKEqj9OtWlkmlaUsukPT+F3dE0Z82ciIA2Aq/+MFrFA ihcDN898Gg4dnLdGZwSZ4nYxkZ6WA9mohVl/cuykR/pT8o7Sr5rxnsnpOPhL03KHqQ7V UmsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HtkV+NUp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a170903240a00b00172c46b7ebfsi1508537plo.403.2022.10.07.01.22.53; Fri, 07 Oct 2022 01:23:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HtkV+NUp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbiJGINO (ORCPT + 99 others); Fri, 7 Oct 2022 04:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbiJGINL (ORCPT ); Fri, 7 Oct 2022 04:13:11 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893FDEB7EF for ; Fri, 7 Oct 2022 01:13:09 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id s206so4028675pgs.3 for ; Fri, 07 Oct 2022 01:13:09 -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=dv4QocelsjXMjDSl7d1QDipkbh7pce+Ymv6Gr0JTJ3c1i8PMdlL3mAkfi+X/fHngMY BQUXZvFNq7ALi7tQzEzxaNw8w2otu1waVUWk6RPJSeAmOHgpwD+GZeXD04PyfQMq2rNP o73e6ilhKJLY1wM3sHOtlcbC8VCiAY7ugg407t03psaI7II7/3jshG7ML4dU26SbDUxR eu1dAHKT7ZQoCuLb5hcaQzLE5qHE3di5RWb9tgT24AepA06i66jGdrQCY8pReVhQeQRl Kjof0ShPFPhlQqDNitzsqz0kMjLcuOPtxA+m7RI4KDwVy0tOM6XEHQjFJjpe9L1YjjKp kltg== X-Gm-Message-State: ACrzQf3ybjxA3JjJCVkJljToYOXsjbxxYB8TLlfh8D3Z3xI+kkMql4kN brE31fMXq4OAhJTgYnLHb0DDzlZjX0bE10HufkCx/g== 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" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 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