From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mx.groups.io with SMTP id smtpd.web11.6448.1671167547230716928 for ; Thu, 15 Dec 2022 21:12:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@ventanamicro.com header.s=google header.b=EmevnbIq; spf=pass (domain: ventanamicro.com, ip: 209.85.216.53, mailfrom: sunilvl@ventanamicro.com) Received: by mail-pj1-f53.google.com with SMTP id z8-20020a17090abd8800b00219ed30ce47so4912362pjr.3 for ; Thu, 15 Dec 2022 21:12:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Mro1Yilz5qpcYQckJD12QTdF+UTvZcfr7fEQxtTjFao=; b=EmevnbIqdbDKlkX407IcEZh70nwZW6GPcwZ3UAE1poY6AXJnZ3uyzWERD/mh0qvh5I 86L2+GcMx9ldS3khQWDhOh3G27RaKcppiDxj7qlYJIIe2WiVJax9HxGtX87GmVu6xEkY rcvp92oI+fArQKdpbKTwgh8NI7nLVrO0K9QIKnxEEZo9SGf7epNrRnpEtjjafvmibx6I ojdE+Yyq2MSRQybsADMhAZDImKaxxEocOpHLHV2uUyJT9yvrJ+BKFfkSin0wxBXKNCZI Nv3W1rPY5YfTbE2b6LjRAvzj5a3sS5GrSzTNhwznpMh1+wOP/l/YgYHAXKC0lSI6saiz E3Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Mro1Yilz5qpcYQckJD12QTdF+UTvZcfr7fEQxtTjFao=; b=iJRzGMsw7ndQXMjvt/UarstVt4nXl20Fr1tv00yXaeAhB7TfLkQtyJlJNEZCYYPFUj xLrTyyhxAzNL7ZImZLlRW95yUa+32mwsgq86uw8akhC75AwDHqqI8aAv5Hup361w+3g/ Hzlc/qV4lbNaeL2mnscPhRhY7wPHKWJgtOLeH4R4Gkhhpkx7G5Xlq3qg1oM7ESDEbXT0 78PwqNVYLy+RTWA+li17J8B6crhPnAaEJlhsC1o7/9s5e6pDjW1AvqFJYuIKv4lwXLrs fmm/TxyCT12Z7/knpQiWfHw9RYhNHauWCqkHZq/MI5KygAwx0VQVefjz9zT4VkdPRfom BDgQ== X-Gm-Message-State: ANoB5plSteYidj4viE9Pn+6mq/rpFOy9IG+x8B/FQQyVMx6RPnqQfh4r Fd5lh13eRI7YMLI+nsMw4AP2bg== X-Google-Smtp-Source: AA0mqf4TIpKmxgfs2Fnnc+gWUfqnbJc9jI7za3JmsjvqO4uKnAghAKn8/i+p3dtu9fAc+Gybk9QvCg== X-Received: by 2002:a05:6a20:549e:b0:a3:218a:c761 with SMTP id i30-20020a056a20549e00b000a3218ac761mr46389942pzk.5.1671167546568; Thu, 15 Dec 2022 21:12:26 -0800 (PST) Return-Path: Received: from sunil-laptop ([49.206.11.246]) by smtp.gmail.com with ESMTPSA id s11-20020a65584b000000b004771bf66781sm572219pgr.65.2022.12.15.21.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 21:12:26 -0800 (PST) Date: Fri, 16 Dec 2022 10:42:19 +0530 From: "Sunil V L" To: Tuan Phan Cc: devel@edk2.groups.io Subject: Re: [PATCH] CryptoPkg/IntrinsicLib: RiscV: Provide implementation of memcpy and __ctzdi2 Message-ID: References: <20221215174859.11638-1-tphan@ventanamicro.com> MIME-Version: 1.0 In-Reply-To: <20221215174859.11638-1-tphan@ventanamicro.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Dec 15, 2022 at 09:48:59AM -0800, Tuan Phan wrote: > The RiscV toolchain doesn't provide __ctzdi2 implementation when > compiled with -nostdlib that needed by openssl library when EC > enabled. So adding the simple implementation of __ctzdi2. > > Forcing to use CopyMem of EDK2 as builtin memcpy disabled for RiscV > with -fno-builtin-memcpy flag. > Hi Tuan, Thanks for the patch. Please add "REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4103" in the commit message and add the copyright in the new file created. Please CC Mike (Michael D Kinney ) and the maintainers of CryptoPkg. Acked-by: Sunil V L Thanks Sunil > Signed-off-by: Tuan Phan > --- > .../Library/IntrinsicLib/CompilerHelper.c | 41 +++++++++++++++++++ > .../Library/IntrinsicLib/IntrinsicLib.inf | 6 ++- > 2 files changed, 46 insertions(+), 1 deletion(-) > create mode 100644 CryptoPkg/Library/IntrinsicLib/CompilerHelper.c > > diff --git a/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c > new file mode 100644 > index 000000000000..9e700a11ed17 > --- /dev/null > +++ b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c > @@ -0,0 +1,41 @@ > +/** @file > + Implement functions that not available when compiled with -nostdlib flag. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +unsigned int > +__ctzdi2 (unsigned long long x) > +{ > + unsigned int ret = 0; > + > + if (!x) { > + return 64; > + } > + if (!(x & 0xffffffff)) { > + x >>= 32; > + ret |= 32; > + } > + if (!(x & 0xffff)) { > + x >>= 16; > + ret |= 16; > + } > + if (!(x & 0xff)) { > + x >>= 8; > + ret |= 8; > + } > + if (!(x & 0xf)) { > + x >>= 4; > + ret |= 4; > + } > + if (!(x & 0x3)) { > + x >>= 2; > + ret |= 2; > + } > + if (!(x & 0x1)) { > + x >>= 1; > + ret |= 1; > + } > + return ret; > +} > diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf > index 86e74b57b109..6796b39b07cf 100644 > --- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf > +++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf > @@ -18,7 +18,7 @@ > # > # The following information is for reference only and not required by the build tools. > # > -# VALID_ARCHITECTURES = IA32 X64 > +# VALID_ARCHITECTURES = IA32 X64 RISCV64 > # > > [Sources] > @@ -43,6 +43,10 @@ > [Sources.X64] > CopyMem.c > > +[Sources.RISCV64] > + CopyMem.c > + CompilerHelper.c > + > [Packages] > MdePkg/MdePkg.dec > > -- > 2.25.1 >