Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1774997rdb; Mon, 9 Oct 2023 02:26:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVA5OJ+VjV4DWGZ/fQzEA3Erl/aRarEJXGn+67jMSXdFZZYXJ+I/G+AbjZtR0ekc7e+jog X-Received: by 2002:a05:6808:f11:b0:3a4:8251:5f43 with SMTP id m17-20020a0568080f1100b003a482515f43mr20877560oiw.40.1696843619526; Mon, 09 Oct 2023 02:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696843619; cv=none; d=google.com; s=arc-20160816; b=aIMGDPGBxCmGSc9uJgaRn70U7hP0GjcvuxJN9ED2Al1Ndc6RxMTAOGM9Zu3I7Ht74u vAc7yiX1eToylHLCT8I+SKli/8fbZaaLHvH9Kj2fs/AVZ6PbaUW+ajlUocv1ChDe2WWf TaEX+YFOrRH9iZvjvXcyaPwJJzmaKJqycSDExbdt/ARasoUT8T9f9sALe8Gy6QQfK3jq FVIqP158GwtI98oXapWwJmCSThLHXquc0bWWaw3BZgaKKtxOpRyZkGQ0r1IyDf3HXjPb ci8+YOg9boIfzFNduBYbEu+uxCv8QtDLjLK2fd+aIoSWhARFvm4CuJQv5og4dSqcJmKR Fw8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UF4HHtAjsWoW8COUfPjIq04oTy0Y9WnIOpm6XrK+h+s=; fh=H5MloS0j/jsXAU2c9fMfp5EUSorAglylJrccTjY5GI4=; b=dNaReu0XKesjYg+/jWTbx45hoJrOH7XvgFx0ADYs1NjBhgelm7MeSTuPrGC6khgymA r2fubKyyrdQpVY5DkOyPIjvL1mQkWkIoEBTc0P+y844i11hIgGHWcBMvMf3fgSfOMrFD t10gE/DxPPXkdnploNkmyrJLRSi56Wbwhnxdy/UYAzKZ+G9zig3ucoPJDlanoWV9po1q EdI7W+uJx9wN2PsoK314uX7lqOn3FWnrsIeKjT38PN6yf5e1JO8LLMSef2k4NE3PVaoA 87gDX+Nh0cMiJfy2Jv6JrAo6yZSah8eOQ5EA/CkYhuz26ZhxErn4Hxj4AxrOCjzmNxAZ Tt4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YS7xzKT4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n188-20020a6340c5000000b00578f1ab2287si8916983pga.354.2023.10.09.02.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 02:26:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YS7xzKT4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ED06A80930FA; Mon, 9 Oct 2023 02:26:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346039AbjJIJ0V (ORCPT + 99 others); Mon, 9 Oct 2023 05:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346028AbjJIJ0F (ORCPT ); Mon, 9 Oct 2023 05:26:05 -0400 Received: from mail-ua1-x929.google.com (mail-ua1-x929.google.com [IPv6:2607:f8b0:4864:20::929]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05144172E for ; Mon, 9 Oct 2023 02:24:51 -0700 (PDT) Received: by mail-ua1-x929.google.com with SMTP id a1e0cc1a2514c-7b0ec7417bdso1260158241.2 for ; Mon, 09 Oct 2023 02:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696843490; x=1697448290; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UF4HHtAjsWoW8COUfPjIq04oTy0Y9WnIOpm6XrK+h+s=; b=YS7xzKT46ZMifl9oguA8263a5DF7FCAM9sN3edMXX9XJ7+Q3rOFpuGhmM+bMuezBZY g8MDqQBksM/+6adprZMFR2fUwDOK0C4JTiB286ouhont4CIiB81GlkK+kS/HcOLpYDWG QWlwORx/6+y1m38t/Q1u1NBP33amrg18IJMbH+OLK1Mbt8yi2mPoE+PR5WBpo3B8elkU JIS9qpfGhM03SRcslNE1tIswUXFhD4QwLeD59nHgCy9GgBUrfSDy6ihgGKHBRi9WXQ1N VAjqVwlaMq6sbE+EJK9vDKTEgH4myDWeNlAJ1RHv9h7qUAhg6ol8Vz3IEDJT/bYdl9br pzCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696843490; x=1697448290; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UF4HHtAjsWoW8COUfPjIq04oTy0Y9WnIOpm6XrK+h+s=; b=ofy/Wz8NmneUe4gZOjUFrHtTM6/DX1PBhIhWKfXuOL1iZN7SKjQmUdfNdpPcvSkrz3 mDFn/QdV1GzmUb1m0bWAYimuu6VyPBVjGUlhShWPjej45zTa1nbq92MZhK8pJf2yzLMY 5L+MKc1HXX1cfilACWTM7Q3Yk7h4U510YxmE6SfI+DksjAYhBb/XMDKimUMpwjXym6Hk 30EoCwguMkwf9S0oyuQZ6EwKjJRW0SKPPRzfffidSSdnQlC5ieYgqUyqHOm9vdH8LkJ2 eZ89joe0NTB6E4aUozSSDml5Uu4gmCqGI1ZOJSI4DeDIgJO8m9Z05eOMR4N0sKdpk5ld bbcw== X-Gm-Message-State: AOJu0Yw/jhO/rkmLhPblQjRu9b9NRCd3g58M7K8hy+QKveudkMlMiL9O VsDXFGDsdlcWBDbv5NHwQ1U2gmYMjOlgaBjnNRnbEw== X-Received: by 2002:a67:fc86:0:b0:452:7380:5517 with SMTP id x6-20020a67fc86000000b0045273805517mr13662328vsp.32.1696843490622; Mon, 09 Oct 2023 02:24:50 -0700 (PDT) MIME-Version: 1.0 References: <20231007170448.505487-1-masahiroy@kernel.org> In-Reply-To: From: Sumit Garg Date: Mon, 9 Oct 2023 14:54:39 +0530 Message-ID: Subject: Re: [PATCH 1/5] modpost: fix tee MODULE_DEVICE_TABLE built on big endian host To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Thompson , Jens Wiklander , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 09 Oct 2023 02:26:32 -0700 (PDT) X-Spam-Level: ** On Mon, 9 Oct 2023 at 12:27, Masahiro Yamada wrote: > > On Mon, Oct 9, 2023 at 3:27=E2=80=AFPM Sumit Garg = wrote: > > > > Hi Masahiro, > > > > On Sat, 7 Oct 2023 at 22:34, Masahiro Yamada wro= te: > > > > > > When MODULE_DEVICE_TABLE(tee, ) is built on a host with a different > > > endianness from the target architecture, it results in an incorrect > > > MODULE_ALIAS(). > > > > > > For example, see a case where drivers/char/hw_random/optee-rng.c > > > is built as a module. > > > > > > If you build it on a little endian host, you will get the correct > > > MODULE_ALIAS: > > > > > > $ grep MODULE_ALIAS drivers/char/hw_random/optee-rng.mod.c > > > MODULE_ALIAS("tee:ab7a617c-b8e7-4d8f-8301-d09b61036b64*"); > > > > > > However, if you build it on a big endian host, you will get a wrong > > > MODULE_ALIAS: > > > > > > $ grep MODULE_ALIAS drivers/char/hw_random/optee-rng.mod.c > > > MODULE_ALIAS("tee:646b0361-9bd0-0183-8f4d-e7b87c617aab*"); > > > > > > This issue has been unnoticed because the ARM kernel is most likely b= uilt > > > on a little endian host (cross-build on x86 or native-build on ARM). > > > > > > The uuid field must not be reversed because uuid_t is an array of __u= 8. > > > > > > > To me it wasn't obvious that DEF_FIELD() has certain endianness limitat= ions. > > > > > Fixes: 0fc1db9d1059 ("tee: add bus driver framework for TEE based dev= ices") > > > Signed-off-by: Masahiro Yamada > > > --- > > > > > > scripts/mod/file2alias.c | 10 +++++----- > > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > > > index 7056751c29b1..70bf6a2f585c 100644 > > > --- a/scripts/mod/file2alias.c > > > +++ b/scripts/mod/file2alias.c > > > @@ -1348,13 +1348,13 @@ static int do_typec_entry(const char *filenam= e, void *symval, char *alias) > > > /* Looks like: tee:uuid */ > > > static int do_tee_entry(const char *filename, void *symval, char *al= ias) > > > { > > > - DEF_FIELD(symval, tee_client_device_id, uuid); > > > > As you have mentioned in patch #3: the limitations of TO_NATIVE(), if > > you can update comments for DEF_FIELD() as well to make it clear that > > it doesn't support byte arrays/strings would be helpful. I think the > > following check that you have introduced in patch #3 can still be > > bypassed for byte arrays/strings. > > > > + _Static_assert(sizeof(x) =3D=3D 1 || sizeof(x) =3D=3D 2 || \ > > + sizeof(x) =3D=3D 4 || sizeof(x) =3D=3D 8, "bug"); > > > > > I am afraid you missed the point. > > bswap_2, bswap_4, bswap_8 do not take a pointer. > > If you pass an array or a string, > it will result in a build error > due to the compiler's prototype checking. > > The kbuild test robot will catch a build error anyway. > I see your point. > > "You cannot build it in the first place" > is better than a comment. > That's fine with me as long as it's a build problem. -Sumit > > > > > > > > > > > BTW, for this fix feel free to add: > > > > Reviewed-by: Sumit Garg > > > > -Sumit > > > > > + DEF_FIELD_ADDR(symval, tee_client_device_id, uuid); > > > > > > sprintf(alias, "tee:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%0= 2x-%02x%02x%02x%02x%02x%02x", > > > - uuid.b[0], uuid.b[1], uuid.b[2], uuid.b[3], uuid.b[4]= , > > > - uuid.b[5], uuid.b[6], uuid.b[7], uuid.b[8], uuid.b[9]= , > > > - uuid.b[10], uuid.b[11], uuid.b[12], uuid.b[13], uuid.= b[14], > > > - uuid.b[15]); > > > + uuid->b[0], uuid->b[1], uuid->b[2], uuid->b[3], uuid-= >b[4], > > > + uuid->b[5], uuid->b[6], uuid->b[7], uuid->b[8], uuid-= >b[9], > > > + uuid->b[10], uuid->b[11], uuid->b[12], uuid->b[13], u= uid->b[14], > > > + uuid->b[15]); > > > > > > add_wildcard(alias); > > > return 1; > > > -- > > > 2.39.2 > > > > > > > -- > Best Regards > Masahiro Yamada