Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2608157ybk; Mon, 18 May 2020 03:32:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8FtmKw7AhJo7Vu/sSNSgvF/rKFphxzqJfiiICo+4qbbiMFtuoLmKtei6RcfuG1U/eGRJb X-Received: by 2002:aa7:c5d3:: with SMTP id h19mr7574880eds.112.1589797926758; Mon, 18 May 2020 03:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589797926; cv=none; d=google.com; s=arc-20160816; b=Sf8592BHLtq9JBfyuGhlud1R7biQrLvklHIIKuSuuvRUksabbdQBP5iSLvn2J3C70j XdzJchBPO2dngKkIYSqzhLBJUofv6cT4uV4WsBkBlfz35kuKCONQaJWidCYJmys0GNP3 LIoyKtNAoq0RcxVFJ+C6yzpeyFu8GHvqwjX9KNJDq9UGbUriXiTkaLHVWLE+HFwyoGA6 tR1WBFxAMchR35fb9Ci4i/0o6CrXhym/TxyOLbf5k54a+/zts6p7i99wPVxxAUhyaI74 /vjOb9rth+y2p/SC54n/ClQ3MAYvoSusfgNrkOSAlhq0a/eqGjxYCrWFPRfW+V8wkqDW fwrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cfQBXo2vLHdFIaGQ6LQWu/Oo3H1KHRcSXWcWEEMW+9o=; b=dJVUGAaeWa/smHs7F+o1YdDOPa/Baglidpc4ShgEnAP8U8F53P1cIV4LbNHQobPGXj ZwPcv/kUqSjo4iQHchkfJu/CwPLsCWyHB9V4DeCpGTN5qlai/xXDF1LNWVdzRGxIfGza nyalSEEU90EvZpUUb3LErXXKbE4qFU+7qP/b26Z6wTzQW628o+FKtUK1OJGtyW3oCza8 2hsYxLqyGbtZbe9O3B0813udfsdRf3VC836MMsDXqnfCWmT3YwtKKzw0RzoCYtnoymGw TzAMq580WppgSFUH/oO4+j7a1FzB4zTgZa+ctJLWexu+1KX2BU0zheXBkPGvB5mVcdXI o7sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HCul2NXQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r26si1774542edi.376.2020.05.18.03.31.43; Mon, 18 May 2020 03:32:06 -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=@gmail.com header.s=20161025 header.b=HCul2NXQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726339AbgERK1k (ORCPT + 99 others); Mon, 18 May 2020 06:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbgERK1j (ORCPT ); Mon, 18 May 2020 06:27:39 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85075C061A0C for ; Mon, 18 May 2020 03:27:39 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id w65so2569071vsw.11 for ; Mon, 18 May 2020 03:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cfQBXo2vLHdFIaGQ6LQWu/Oo3H1KHRcSXWcWEEMW+9o=; b=HCul2NXQfwBhaC9FJEWSxkBkQ4oFSzTQkOYSby+W+yX78lzZ40tzmU5pqXZCoJF7zw wEAPsmQV8woaVQnkTwLVwW8uB0xSNBzyg0BQzDDo3EN5EXezWlKZpKVZdsrxb3Uqzkav f5zlBQGaDrj0c6i7cfiywi9Bh1FiXtSBODv4r3AiA1cG5haCgdaZH2j8ItHSopEkE7vr 2d/pR7HfNp5KBSw2L+7dieWWumH23kwsXOtmMZzfLt+KUH7MRWy4ORGtMKunqF91lvIF sOr4W4VownvcQeP9P0NjgMwajustfXbk2A6XEKS9YWGpa1PM/GSR1JlzfiblLEdDzthn UyOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cfQBXo2vLHdFIaGQ6LQWu/Oo3H1KHRcSXWcWEEMW+9o=; b=sLQTMlhf8Ok1/iipfoTPvgnuxCR4lNPM0YsoxRproW7A4FEke3quZ3/Yleob31k+Xe xpZCoOoJgRj2cEbm6MbfyHIkYAbeN4a1NLQE9RC4EaKkBuCll6oAUl0L75k4wDjl//7F pV+UAZn9UcUyVHM3bVTUkNz6db37whQbX+kyT/Ec3DdTTx87XLSv+ZUlf6um1E86TeQt GMdG186yZQyvd2s7dW9GZEmzZLnfWWCBmksV4htooFvNk97/oSMBqMLqPf7vK5vLZqng puqFwGuVeA0uwX5gVeF0XoD0IWIbO8gmQm/sKHyLUaGkmzdcE+0vS+1QSTQtbM5Rvhdq slhw== X-Gm-Message-State: AOAM532bs90DQwnHnHInjprz/+3/HzviYGp1fKT/Vm3ksAi5Y4JsKMDW SaBHc0wOClfJ1KhecMXcp/NM38yYhPDVRKR33CF53Q== X-Received: by 2002:a67:df02:: with SMTP id s2mr2609029vsk.210.1589797658617; Mon, 18 May 2020 03:27:38 -0700 (PDT) MIME-Version: 1.0 References: <20200513003430.651232-1-vlad.babchuk@gmail.com> <20200513003625.651340-1-vlad.babchuk@gmail.com> In-Reply-To: From: Volodymyr Babchuk Date: Mon, 18 May 2020 13:27:27 +0300 Message-ID: Subject: Re: [PATCH] optee: don't fail on unsuccessful device enumeration To: Sumit Garg Cc: Jens Wiklander , open list , "tee-dev @ lists . linaro . org" , Jerome Forissier Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sumit, On Fri, 15 May 2020 at 07:55, Sumit Garg wrote: > > Hi Volodymyr, > > On Fri, 15 May 2020 at 06:32, Volodymyr Babchuk wrote: > > > > Hi Sumit, > > > > On Thu, 14 May 2020 at 08:38, Sumit Garg wrote: > > > > > > Hi Volodymyr, > > > > > > On Thu, 14 May 2020 at 06:48, Volodymyr Babchuk wrote: > > > > > > > > Hi Sumit, > > > > > > > > On Wed, 13 May 2020 at 11:24, Sumit Garg wrote: > > > > > > > > > > Hi Volodymyr, > > > > > > > > > > On Wed, 13 May 2020 at 13:30, Jens Wiklander wrote: > > > > > > > > > > > > Hi Volodymyr, > > > > > > > > > > > > On Wed, May 13, 2020 at 2:36 AM Volodymyr Babchuk > > > > > > wrote: > > > > > > > > > > > > > > optee_enumerate_devices() can fail for multiple of reasons. For > > > > > > > example, I encountered issue when Xen OP-TEE mediator NACKed > > > > > > > PTA_CMD_GET_DEVICES call. > > > > > > > > > > Could you share a detailed description of the issue which you are > > > > > facing? optee_enumerate_devices() is a simple invocation of pseudo TA > > > > > and cases where OP-TEE doesn't provide corresponding pseudo TA are > > > > > handled very well. > > > > > > > > Yes, I did some research and looks like issue is broader, than I > > > > expected. It is my fault, that I wasn't paying attention to the tee > > > > client support in the kernel. Basically, it is incompatible with the > > > > virtualization feature. You see, the main issue with virtual machines > > > > is the second stage MMU. Intermediate physical address, that appear to > > > > be contiguous for the kernel may be not contiguous in the real > > > > physical memory due to 2nd stage MMU mappings. This is the reason I > > > > introduced OPTEE_MSG_ATTR_NONCONTIG in the kernel driver. > > > > > > > > But, looks like kernel-side optee client does not use this feature. It > > > > tries to provide SHM buffer as a simple contiguous span of memory. Xen > > > > blocks calls with OPTEE_MSG_ATTR_TYPE_TMEM_* but without > > > > OPTEE_MSG_ATTR_NONCONTIG , because it can't translate IPAs to PAs for > > > > such buffers. This is why call to PTA_CMD_GET_DEVICES fails. > > > > > > > > Valid fix would be to use OPTEE_MSG_ATTR_NONCONTIG whenever possible. > > > > > > > > > > Thanks for the detailed analysis. It looks like you are missing the > > > following fix patch in your tree which basically fixed broken > > > tee_shm_alloc() in case dynamic shared memory is enabled (IIRC > > > virtualization only supports dynamic shared memory). > > > > > > commit a249dd200d03791cab23e47571f3e13d9c72af6c > > > > Actually, I have this patch in my tree. So, it does not fixes the > > issue. Which is weird, actually. I'm planning to look deeper into > > this. > > AFAICT, the only difference here is that it's the kernel memory > registered rather than user-space memory. But I am not very conversant > with the Xen environment. So I hope you will be able to find the root > cause as to why Xen is blocking this invocation. Yes. I have found issue in Xen mediator code. It didn't allowed TMEM with NULL buf_ptr and without ATTR_NONCONTIG flag. This is clearly a bug and I already sent the patch to Xen ML. -- WBR Volodymyr Babchuk aka lorc [+380976646013] mailto: vlad.babchuk@gmail.com