From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 34813C433DB for ; Wed, 13 Jan 2021 17:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBCA52343F for ; Wed, 13 Jan 2021 17:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727144AbhAMRUz (ORCPT ); Wed, 13 Jan 2021 12:20:55 -0500 Received: from foss.arm.com ([217.140.110.172]:39616 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726996AbhAMRUz (ORCPT ); Wed, 13 Jan 2021 12:20:55 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D43F1FB; Wed, 13 Jan 2021 09:20:09 -0800 (PST) Received: from bogus (unknown [10.57.35.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D49D73F66E; Wed, 13 Jan 2021 09:20:06 -0800 (PST) Date: Wed, 13 Jan 2021 17:20:00 +0000 From: Sudeep Holla To: Achin Gupta Cc: Jens Wiklander , Linux ARM , Devicetree List , Trilok Soni , arve@android.com, Sudeep Holla , Andrew Walbran , David Hartley , Arunachalam Ganapathy , nd@arm.com Subject: Re: [PATCH v3 6/7] firmware: arm_ffa: Setup in-kernel users of FFA partitions Message-ID: <20210113170527.3qcxrfgrinfotfbh@bogus> References: <20201204121137.2966778-1-sudeep.holla@arm.com> <20201204121137.2966778-7-sudeep.holla@arm.com> <20210113094408.pjkno4nalk5zizxa@bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Wed, Jan 13, 2021 at 01:58:56PM +0000, Achin Gupta wrote: > On Wed, Jan 13, 2021 at 01:30:56PM +0100, Jens Wiklander wrote: > > On Wed, Jan 13, 2021 at 10:44 AM Sudeep Holla wrote: > > [...] > > > > > > +static int ffa_partition_probe(const char *uuid_str, > > > > > > + struct ffa_partition_info *buffer) > > > > > > +{ > > > > > > + int count; > > > > > > + uuid_t uuid; > > > > > > + u32 uuid0_4[4] = { 0 }; > > > > > > + > > > > > > + if (uuid_parse(uuid_str, &uuid)) { > > > > > > + pr_err("invalid uuid (%s)\n", uuid_str); > > > > > > + return -ENODEV; > > > > > > + } > > > > > > + > > > > > > + export_uuid((u8 *)uuid0_4, &uuid); > > > > > > + count = __ffa_partition_info_get(uuid0_4[0], uuid0_4[1], uuid0_4[2], > > > > > > + uuid0_4[3], &buffer); > > > > Wrong byte order? > > > > According to section 5.3 of the SMCCC, UUIDs are returned as a single > > > > 128-bit value using the SMC32 calling convention. This value is mapped > > > > to argument registers x0-x3 on AArch64 (resp. r0-r3 on AArch32). x0 > > > > for example shall hold bytes 0 to 3, with byte 0 in the low-order > > > > bits. > > > > > > > > > > I need to spend some time to understand the concern here. Initially I agreed > > > with your analysis and then a quick review make be realise it is all OK. > > > I need to check if my understanding is correct again. I thought I will > > > take example and check here itself. > > > > > > UUID: "fd02c9da-306c-48c7-a49c-bbd827ae86ee" > > IIUC this maps to (as per RFC4122). > > fd02c9da = time_low (bytes 0-3) > 306c48c7 = time_mid & time_hi_and_version (bytes 4-7) > a49cbbd8 = clock_seq_hi_and_reserved, clock_seq_low and bytes/octets 0-1 of node (bytes 8-11) > 27ae86ee = bytes 2-5 of node (bytes 12-15) > > SMCCC says: > > w0 : bytes 0-3 with byte 0 in the lower order bits. > w1 : bytes 4-7 with byte 4 in the lower order bits. > w2 : bytes 8-11 with byte 8 in the lower order bits. > w3 : bytes 12-15 with byte 12 in the lower order bits. > > This should amount to: > > w0 = dac902fd > w1 = c7486c30 > w2 = d8bb9ca4 > w3 = ee86ae27 > > So, even though RFC4122 uses big-endian i.e network byte order. The UUID is > encoded as little-endian as per the SMCCC. > > What do you reckon? > Thank Achin, that matches my understanding too. I spent some time looking at RFC4122[1] and concluded what we have is fine. @Jens, one thing to note, I am not claiming to support this driver with big-endian kernel. I plan to take that up once we settle with basic support. > cheers, > Achin > > > > > > > UUID[0] UUID[1] UUID[2] UUID[3] (referring uuid0_4 above) > > > dac902fd c7486c30 d8bb9ca4 ee86ae27 > > > Matches w0-w3 above, thanks for detailed explanation > > > It seems correct as per SMCCC convention to me, or am I missing something > > > obvious ? > > > > In this example I'd expect the first register to hold 0xfd02c9da > > regardless of the byte order of the machine. If there is a different > > byte order in the receiver it will still be received as 0xfd02c9da. > > That's how I've understood the specification. > -- Regards, Sudeep [1] https://tools.ietf.org/html/rfc4122 From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 55A4CC433DB for ; Wed, 13 Jan 2021 17:22:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 CD40023437 for ; Wed, 13 Jan 2021 17:22:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD40023437 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F6E7fqdMK8aIwMP6Rr2ngvxkDfEHC0m6mvTwACrWLTk=; b=ScO9ul2BHwyNIULwXPsQB7g9H xjRPIu9OJ4Jt2THrIN52u+Pt5Ocdo6MD1ipOBDgG5OzwZpSgR9cJ2E/vN2luecD5Q0NoIG0Atzhy1 IxfIMh59CqXU7eS5SyKqvr0mrafcjj6Ip+uSCUDKbhEnvblzQHgR83SKOxT7N1no4Fx01FMi/q+LW STSGv3rZXGzZvjFibT5oPrSWPh1T3O2SLurdSz/S6jacp0fqwTQdGp66M4CpcCYLXgOUR3RIFV3LC lsXPaU4xRnQpmyQJXG8JZQBWcM+AbN91djI1BYjGID49kBk3Avr9V++S4HgydBBUMLifrkstC8z8k eMnllNQOw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzjoe-0001Za-MP; Wed, 13 Jan 2021 17:20:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzjoY-0001YW-OF for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2021 17:20:14 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D43F1FB; Wed, 13 Jan 2021 09:20:09 -0800 (PST) Received: from bogus (unknown [10.57.35.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D49D73F66E; Wed, 13 Jan 2021 09:20:06 -0800 (PST) Date: Wed, 13 Jan 2021 17:20:00 +0000 From: Sudeep Holla To: Achin Gupta Subject: Re: [PATCH v3 6/7] firmware: arm_ffa: Setup in-kernel users of FFA partitions Message-ID: <20210113170527.3qcxrfgrinfotfbh@bogus> References: <20201204121137.2966778-1-sudeep.holla@arm.com> <20201204121137.2966778-7-sudeep.holla@arm.com> <20210113094408.pjkno4nalk5zizxa@bogus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210113_122011_277914_606FAA66 X-CRM114-Status: GOOD ( 26.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Trilok Soni , Devicetree List , David Hartley , Andrew Walbran , arve@android.com, Sudeep Holla , Arunachalam Ganapathy , nd@arm.com, Jens Wiklander , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jan 13, 2021 at 01:58:56PM +0000, Achin Gupta wrote: > On Wed, Jan 13, 2021 at 01:30:56PM +0100, Jens Wiklander wrote: > > On Wed, Jan 13, 2021 at 10:44 AM Sudeep Holla wrote: > > [...] > > > > > > +static int ffa_partition_probe(const char *uuid_str, > > > > > > + struct ffa_partition_info *buffer) > > > > > > +{ > > > > > > + int count; > > > > > > + uuid_t uuid; > > > > > > + u32 uuid0_4[4] = { 0 }; > > > > > > + > > > > > > + if (uuid_parse(uuid_str, &uuid)) { > > > > > > + pr_err("invalid uuid (%s)\n", uuid_str); > > > > > > + return -ENODEV; > > > > > > + } > > > > > > + > > > > > > + export_uuid((u8 *)uuid0_4, &uuid); > > > > > > + count = __ffa_partition_info_get(uuid0_4[0], uuid0_4[1], uuid0_4[2], > > > > > > + uuid0_4[3], &buffer); > > > > Wrong byte order? > > > > According to section 5.3 of the SMCCC, UUIDs are returned as a single > > > > 128-bit value using the SMC32 calling convention. This value is mapped > > > > to argument registers x0-x3 on AArch64 (resp. r0-r3 on AArch32). x0 > > > > for example shall hold bytes 0 to 3, with byte 0 in the low-order > > > > bits. > > > > > > > > > > I need to spend some time to understand the concern here. Initially I agreed > > > with your analysis and then a quick review make be realise it is all OK. > > > I need to check if my understanding is correct again. I thought I will > > > take example and check here itself. > > > > > > UUID: "fd02c9da-306c-48c7-a49c-bbd827ae86ee" > > IIUC this maps to (as per RFC4122). > > fd02c9da = time_low (bytes 0-3) > 306c48c7 = time_mid & time_hi_and_version (bytes 4-7) > a49cbbd8 = clock_seq_hi_and_reserved, clock_seq_low and bytes/octets 0-1 of node (bytes 8-11) > 27ae86ee = bytes 2-5 of node (bytes 12-15) > > SMCCC says: > > w0 : bytes 0-3 with byte 0 in the lower order bits. > w1 : bytes 4-7 with byte 4 in the lower order bits. > w2 : bytes 8-11 with byte 8 in the lower order bits. > w3 : bytes 12-15 with byte 12 in the lower order bits. > > This should amount to: > > w0 = dac902fd > w1 = c7486c30 > w2 = d8bb9ca4 > w3 = ee86ae27 > > So, even though RFC4122 uses big-endian i.e network byte order. The UUID is > encoded as little-endian as per the SMCCC. > > What do you reckon? > Thank Achin, that matches my understanding too. I spent some time looking at RFC4122[1] and concluded what we have is fine. @Jens, one thing to note, I am not claiming to support this driver with big-endian kernel. I plan to take that up once we settle with basic support. > cheers, > Achin > > > > > > > UUID[0] UUID[1] UUID[2] UUID[3] (referring uuid0_4 above) > > > dac902fd c7486c30 d8bb9ca4 ee86ae27 > > > Matches w0-w3 above, thanks for detailed explanation > > > It seems correct as per SMCCC convention to me, or am I missing something > > > obvious ? > > > > In this example I'd expect the first register to hold 0xfd02c9da > > regardless of the byte order of the machine. If there is a different > > byte order in the receiver it will still be received as 0xfd02c9da. > > That's how I've understood the specification. > -- Regards, Sudeep [1] https://tools.ietf.org/html/rfc4122 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel