Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A19EC433E0 for ; Fri, 19 Jun 2020 17:15:38 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 290F420757 for ; Fri, 19 Jun 2020 17:15:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="GMqtRlsd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 290F420757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jmKbm-00055t-Nk; Fri, 19 Jun 2020 17:15:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jmKbl-00055o-J1 for xen-devel@lists.xenproject.org; Fri, 19 Jun 2020 17:15:17 +0000 X-Inumbo-ID: 71b91404-b250-11ea-bbc2-12813bfff9fa Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 71b91404-b250-11ea-bbc2-12813bfff9fa; Fri, 19 Jun 2020 17:15:16 +0000 (UTC) Received: from localhost (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C920B20757; Fri, 19 Jun 2020 17:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592586916; bh=cqrOmi0QLWtV24IgR/WAUNmM6ppN3/hW917OU1uM3ZY=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=GMqtRlsdS+sWl/wd7cGocuwPut9kC8EExQTOf2+RsBxtvBMbKYpgsV8rkCF0L78rv wszWBJxZAupnkTBcd556zaeO0xsYPH+6u90IwHrpJoYuEsnGuMQNFQd3fdXptQqhyq KYsK+p9DyXXoG4Tjo9WyFmpfGvjH6I5pr2rwjGkk= Date: Fri, 19 Jun 2020 10:15:09 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-T480s To: Julien Grall Subject: Re: [PATCH] xen/arm: optee: allow plain TMEM buffers with NULL address In-Reply-To: Message-ID: References: <2a32c7c2048333169c9378194d6a435e2e7ed2d7.camel@epam.com> <1b596a11-95b5-3e87-bbf5-c0c4dceb6489@xen.org> <878sgk2bst.fsf@epam.com> <8d2f3475-4191-fa80-f476-e72af73e0559@xen.org> <87h7v71ixf.fsf@epam.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: "xen-devel@lists.xenproject.org" , "sstabellini@kernel.org" , Volodymyr Babchuk , "paul@xen.org" Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Fri, 19 Jun 2020, Julien Grall wrote: > Hi Volodymyr, > > On 19/06/2020 10:52, Volodymyr Babchuk wrote: > > > > > > OP-TEE represents this null memory reference as a TMEM parameter > > > > > > with > > > > > > buf_ptr == NULL. This is the only case when we should allow TMEM > > > > > > buffer without the OPTEE_MSG_ATTR_NONCONTIG flag. > > > > > > > > > > IIUC, 0 with OPTEE_MSG_ATTR_NONCONTIG set would mean "use the buffer > > > > > at address 0" but with the flag cleared, it would mean "return the > > > > > size". Am I correct? > > > > > > > > Not exactly. This flag does not affect behavior for buffers with address > > > > NULL. In any case, this would not mean "return the size" to > > > > OP-TEE. This is because OP-TEE works as a transport between CA and TA > > > > and it does not assign any meaning to client buffers. But certainly, > > > > null buffer will mean "return the size" for some TAs, as described in > > > > GlobalPlatform specification. > > > > > > Does it mean a guest TA may potentially access address 0? > > > > TA is running in S-EL0. That buffer with PA=0x0 will be not mapped in TA > > address space at all. So, if TA will try to access address 0, it > > will be terminated with data abort. > > > > > I am asking that because 0 can be a valid host physical address. We > > > are currently carving out 0 from the heap allocator to workaround a > > > bug, but there is no promise this address will be used by the boot > > > allocator and therefore Xen. > > > > > > > Well, this is a potential issue in OP-TEE. It does not treat 0 as a > > valid address. So, in that rare case, when REE will try to use 0 > > as a correct address for data buffer, OP-TEE will not map it into > > TA address space, instead it will pass NULL to TA, so TA will think that > > no buffer was provided. > > Thanks! That's reassuring. Although, I think we may still need to prevent MFN > 0 to be allocated for a guest using OP-TEE. So they don't end up with weird > failure. > > I don't think this is an issue so far, but this may change with Stefano's > dom0less series to support direct mapping. Yes, it is interesting to know about this limitation. In regards to this patch, it looks OK as-is in terms of code changes. Aside from a link to this conversation in the xen-devel archives, is there anything else you would like to add to the commit message?