Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2591949pxb; Mon, 19 Apr 2021 09:06:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2+TjL375PL9a5yXoHSQEP/VdLLFJvIdOWv3hIE/sY6EsF821wKJSLzxyn4XGfF00sQlzm X-Received: by 2002:aa7:db04:: with SMTP id t4mr12810467eds.274.1618848408589; Mon, 19 Apr 2021 09:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618848408; cv=none; d=google.com; s=arc-20160816; b=geJtJLLHj3PhLJNXqLVLZzZs5QG2kftkwv6SWBEcm3oG10Js3G4afi28jz5mhZE/v7 YL0hK1pn+Y9CQILUNed7LHlQ7BRaz2a+J8US4qveCh75uD6Rdw1qjN3+PxnWi4FUMP9L U1YXIdAwsWFasY5OZWVjnoJXehnMsWjudWFa4y6doNKBE1e5bVG5GvFmTkXD92cXIB8k 3S1WRMKuNkD/Az+NClzPsfbK9ubZETTBb7zze3fiAbdLp0E6EMUvG65rPUePwgEFXXcG dyslCwMi8lYCmSHa+xqX49xwCiOSZZsjXkWC34Kro9Vj5pWbdXeuvv/e1yWGMOlSAMBZ cJWw== 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=Gj46eHqwGog6MM83EGWyn/d2gDw8gFPwgfxb+P24o6o=; b=feW4j+USReX9BauooXiLNmJPBAc6ntkB7wgTLo06dTFBnaEtQJynEKk4vqbdlWMp6D aSqeJ7nKhgqZhMhCZEWLxdCktRX8Mzv+Ly5b1mmJdurYK6oX/q7EOS7YnP0LsU/D6Iv8 6hkWJu/WSb5ho7VToT33PIMzpKTgTt4WuTLTbIt0KpVt5tPSchI16wM6eqb3o0RhVxHf 6jhrHIRIi5rmhfqs2x4uxxXhHC+AXqy1hBbGOZ6BOgYuj0WQSnar1X7QLYtEdsp8cFe/ AzgSJfkGt5MAhu+XddxlGCk5zIN7UnCjL847omplg2djs9Lwezqle+PD6q3y/d1sAOXb g3JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lkjySsHH; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ao17si12590209ejc.205.2021.04.19.09.06.24; Mon, 19 Apr 2021 09:06:48 -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=@linaro.org header.s=google header.b=lkjySsHH; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239790AbhDSOar (ORCPT + 99 others); Mon, 19 Apr 2021 10:30:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232302AbhDSOan (ORCPT ); Mon, 19 Apr 2021 10:30:43 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBFC6C06174A for ; Mon, 19 Apr 2021 07:30:12 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id v19-20020a0568300913b029028423b78c2dso24097482ott.8 for ; Mon, 19 Apr 2021 07:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gj46eHqwGog6MM83EGWyn/d2gDw8gFPwgfxb+P24o6o=; b=lkjySsHHyCKy9V1I4ctG8Ub1AgpYKyAuzEzcSNEdD6DDIejJcaBrdvFQij3q1W6nkh ph3/QcpKP1doY1wwlSUTOL0ycAOL4E/i45ucmDsMszNr+VDpKTZdTAwGkRgdjJ4MFQZt Sy2J6LBcsk0shbd+V9/F055vcs32TuxuRm78E3BVgiFgv7oQ8brYvpy9cQyR3KQw2GKW YIcZuEUq6FO7ZvIWcmLQw/A/7mMFXXUY9s1blDA4b2iE2W4scxuIDudwarlynD8QuCSn /hbFjEeejeoK6D5kjnmwKPWGbXlRpyOFlHAZjdPFaUC5aqNgx07oVpzTUNGwbIkle7f7 G+oQ== 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=Gj46eHqwGog6MM83EGWyn/d2gDw8gFPwgfxb+P24o6o=; b=aQeMbqkY2iSmDQM6vuBjSHNkKMB1Fu8jviM4XgWWwUtI1osvUuh2BZgdBOSopVuCHK OlCNBfrpuDZsEvWaXAfEa+9nnt1HvxAQcXFDPjO5ZgA9oASCaAJnT4MKXRUhxMppwAd+ h1YD+QWI+7EWYvHhQmCHPfWtdUWS9xkNU5JNxFt1wKRv2a9ooXMGmFSt3XNdJ8eodDe8 KORqKn/u65JAhqzpAHbZhQmz9vhOF44xEO4KGTZ9u7Fp9Z5HjTrn8fasJLFrVpdGIVKe dzmZvd4Oh4YGqGDXJL4s6k/ev/rhiC1tbgn2OQAj5n2BeUgNXUhOYFU56qzzTceFKDX+ 8FIg== X-Gm-Message-State: AOAM531JIgRy0P/oXSPMMJAopP5dNQagGQoRtcmy34IxY0WzPYwRANrx WHSbPEeN3rO3m0pw+r4yBjDiii2MTc9/kpepv8vUSw== X-Received: by 2002:a9d:5f8c:: with SMTP id g12mr2582275oti.283.1618842611531; Mon, 19 Apr 2021 07:30:11 -0700 (PDT) MIME-Version: 1.0 References: <20210415145857.34183-1-andriy.shevchenko@linux.intel.com> In-Reply-To: From: Jens Wiklander Date: Mon, 19 Apr 2021 16:30:00 +0200 Message-ID: Subject: Re: [PATCH v1 1/1] tee: optee: Provide special parameter field for UUID values To: Andy Shevchenko 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 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(). > > 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. Cheers, Jens