Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2716955pxb; Mon, 19 Apr 2021 12:03:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrynlLpLNBKoFYjrJx0xmzadF5aRPVaQZ9r6+m/v9CPIcU2BMBf0LSOrCoBTYZqG5lvSj/ X-Received: by 2002:a17:907:2485:: with SMTP id zg5mr23568695ejb.43.1618859020004; Mon, 19 Apr 2021 12:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618859019; cv=none; d=google.com; s=arc-20160816; b=jT7XJelYvdK1AFkfn4WCG7ru5pjyzYutPNLyqPGGx0OYya7lCBaiR5fs4UiUdyolpw UWGAYbDubnCS8ZThNjqdL4oQEL9aHHm35S397WvNeXn8tP8jrZa0HqZnxZJAhfK02MH5 3jodVb/cNip3jcAyZmi9vXV8mTDVh1eI+/rUtIUcAvqrwjIISch4UXd756wTATv8VcSr LtWZjDDKNA6PurkukcDPTac1dlzHxrheIliGfeJXSUXWzCq6cMGCtC2n62EYIOTklpC8 A+e/gJiFcBP0En5W8d8XK4hZyQ4tppRQtCCmGwNiTfSFJv0i0YIsIpxtaSaAAa72rRrW o8AA== 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=sfXdvJ1fort8YfUZHhPvEtiQfHEl5DuslQu28H8S8Bw=; b=yb+68iA/G7Zo1JusYhdDOv/6Yagnw7kZoN5ndCebvZ4jA93mz5DIQB+gtvVzVty7oZ M+yHS+3f7/haz+f46YYQFtCpDKbLWlLtDuE9Qm/TmmAwhHdMNy35pzVEdKIIJ2boqPaH unDf4vv3GpfNXD0WzDoWNgaqd77KaU/6Va/Mamm14rRJKS1KzQWDasT3AXDipKAm+ujY po5jiDSWFAlLxbGWV0r78evzLRDImX6teVpN7gL2qMZql1rRS+MjxcjHEBSPLfMEy5u7 7FQpYosqkUfw3JnJCjZJxfIXcH4l1fyg+8fDqle1UbLenIH4gFf/gBeefZ1yZTB55t5L GACg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IS8hhieX; 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 f20si13167862ejx.483.2021.04.19.12.03.16; Mon, 19 Apr 2021 12:03:39 -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=IS8hhieX; 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 S240475AbhDSOmo (ORCPT + 99 others); Mon, 19 Apr 2021 10:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240270AbhDSOmm (ORCPT ); Mon, 19 Apr 2021 10:42:42 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C3A3C061761 for ; Mon, 19 Apr 2021 07:42:13 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id e2so13512243plh.8 for ; Mon, 19 Apr 2021 07:42:13 -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=sfXdvJ1fort8YfUZHhPvEtiQfHEl5DuslQu28H8S8Bw=; b=IS8hhieXJzbGQDJb6Jaf/h7G83Q6KehbtblpZt7edrHNDlvla//ikL9ohOHRfUiUsQ inLLyto3hFn5P1IJNt19ccIYNeFlMpf+4rrhxgtbg0Gmkf847sBtKW1MiYtXoSYldE8H 6Ip/at1yH/dkXcUe5OmxHQo+2BDUdE2MERpKcFoEE2PqJSjcvYqoMRu2YdjGqge/7VU3 s6qz5pAZZg/5UaOM1VNNiwj3dGX3JuuBxpX4C9QTCorBbMQqRycqojIoBzaYNImAl90P EKNsvmNInRuMwjkaJXIwBelpWQ4W6fyuoL++aZ0Q9h5M8Py4cnZ1FaqsyGtBsZb3evH7 Kp6w== 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=sfXdvJ1fort8YfUZHhPvEtiQfHEl5DuslQu28H8S8Bw=; b=tedGkb4mvJNSavSQsr1qojLnRCTzKoaUZ8rq2sUiaq7dqwPcKDfdBB8mAOCn2gr3vZ 1yL0BLfaJyOEcOb5+ud1ZXqk/EYHxyjjLc+BZWfcB6OdimW8+E2YdDGNN8ncQVP6farT fdpaAYv1nnq4h/t0lx2lEZ7r3HmwIy1sjYn4As0KTWJ+1XCOunlE+bQCL8LiUv1DfLk4 B10YkOHQGEgPF1XMA7byCz7kbk4Vj1F7GI0/hvDL6l9eucC7ejbRnnE3f9z8W3w8xqEE RJZOUuo360WlWfZzg7Xr4iRQhbk1cr/sYF1YVcBnxwAEfTidHjNfkRenWM7biyJiiWAn rgdw== X-Gm-Message-State: AOAM531n4YweBmvwF/MRlzBqq/W2Va39hkVszCxwJjwxjfFaMeB0wT5K UIddvz4yQE48i+lMTsxyswSDCC5fQUUgH4jZtlGCTe6oS/s= X-Received: by 2002:a17:902:a406:b029:e6:78c4:71c8 with SMTP id p6-20020a170902a406b02900e678c471c8mr23284959plq.17.1618843332560; Mon, 19 Apr 2021 07:42:12 -0700 (PDT) MIME-Version: 1.0 References: <20210415145857.34183-1-andriy.shevchenko@linux.intel.com> In-Reply-To: From: Andy Shevchenko Date: Mon, 19 Apr 2021 17:41:56 +0300 Message-ID: Subject: Re: [PATCH v1 1/1] tee: optee: Provide special parameter field for UUID values To: Jens Wiklander Cc: Andy Shevchenko , OP-TEE TrustedFirmware , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 19, 2021 at 5:30 PM Jens Wiklander wrote: > On Mon, Apr 19, 2021 at 3:40 PM Andy Shevchenko > wrote: > > On Mon, Apr 19, 2021 at 4:30 PM Jens Wiklander > > wrote: > > > On Mon, Apr 19, 2021 at 2:01 PM Andy Shevchenko > > > wrote: > > > > On Mon, Apr 19, 2021 at 01:35:51PM +0200, Jens Wiklander wrote: > > > > > On Thu, Apr 15, 2021 at 4:58 PM Andy Shevchenko > > > > > wrote: > > > > > > > > Thanks for review, my answer below. > > > > > > > > > > struct optee_msg_param_tmem tmem; > > > > > > struct optee_msg_param_rmem rmem; > > > > > > struct optee_msg_param_value value; > > > > > > + uuid_t uuid; > > > > > > > > > > It's nice to get rid of the cast above, but I'm not that keen on the > > > > > change in this struct. This file defines the ABI towards Secure world > > > > > and adding dependencies on external complex types is a larger problem > > > > > than the cast above in my opinion. > > > > > > > > I understand. > > > > > > > > So, the cast is simply wrong there. Can you add a comment above that cast to > > > > explain that and make it is marked as FIXME? Because there is no guarantee that > > > > internal Linux types can be 1:1 mapped to the ABI of something. > > > > > > We might as well fix it directly instead. How about storing the > > > intermediate result in a proper uuid_t and then export it as: > > > export_uuid((u8 *)&msg_arg->params[1].u.uuid, &myuuid); > > > > Still a casting here. > > With u64 members you have a (potential) endianness issue (consider > > BE-32 platform). Also you never know that a b c translates properly to > > byte array. > > > > I would rather see a custom function > > > > optee_import_uuid(param, uuid_t *uuid) > > { > > u8 uuid_raw[UUID_SIZE]; > > > > put_unaligned_le64(&uuid_raw[0], param.a); // not sure about endianness > > put_unaligned_le64(&uuid_raw[0], param.b); // ditto > > I believe it's a memcpy() we want then, since UUIDs are supposed to be > transmitted using a big endian memory pattern. > We should perhaps add > u8 octets[24]; > to that union. Then should the result be well defined using export_uuid(). Right, if you do that, it would be wonderful! > > import_uuid(); > > } > > > > > > What you need, perhaps, is a middle layer function that will copy u64 data > > > > to uuid_t or so. Also, u64 is not an ABI type, why the respective __uXX > > > > variants are not in use? > > > > > > Does it make any difference? The file isn't shared with user space and > > > I need to sync the file manually anyway since OP-TEE doesn't have the > > > same include files. > > > > Yes. It gives a hint that these are ABI (that's why I felt free to add > > a member to the union. I have no idea that's an ABI). Optionally a > > comment suggesting that. > > It does say that it defines a protocol at the beginning of the file, I > can add ABI too if you think that helps. I read the structure definition, perhaps some clarification on a data type level would be nice. Thanks! -- With Best Regards, Andy Shevchenko