From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x92a.google.com (mail-ua1-x92a.google.com [IPv6:2607:f8b0:4864:20::92a]) by sourceware.org (Postfix) with ESMTPS id A83733858C52 for ; Fri, 29 Sep 2023 02:26:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A83733858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ua1-x92a.google.com with SMTP id a1e0cc1a2514c-7a282340fdfso5645937241.0 for ; Thu, 28 Sep 2023 19:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695954393; x=1696559193; darn=sourceware.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=lZQxT+jL88MPyeilfgio6g31Yn9rS6oZJzV0vcc20Ec=; b=CnpvkQwtfpTXzDh+8QV+A8hYf9bEdIR5bPY4efWqb+JC8jtfRorVPRbLaOOGg/Ucu8 Jc0yABCCWrajUxQt8LrtrV5sKOfvyVyfGEA/g+Nh04N8aN8MH0nEC4bLfi1ioIy5YlJ7 1uIz+rgXqZZ4yfuWLfPcfiUSvrF+EhjWD1iQ1B1XlxTsplHfitLRYG7fxjJuYs1/KwTL SlEEq/OmZ48XJzEuskwyp0teRKPEghU+8fNoWnfIluJO4UXXsH9zTh5soN2NbrHXeCVR MeRRBuD8uwKpozlIAxaXXI/2NRL952MZv8Eqhh5rpvhvazVy6VAqGFVxVce1V9x0iTD9 Kvfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695954393; x=1696559193; 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=lZQxT+jL88MPyeilfgio6g31Yn9rS6oZJzV0vcc20Ec=; b=dLNwSp1p9XvV+r9ISV+y397qMahmY+E1YSu5KJx/3QLeRxDZ03YOmR/EWegIstmLzt qrOE83CU9BdCR6lkFxxTVBLE6uqP1M919hlsG4Z106Stz026q69K8S46J1SwxdRUPVue RlJB6CEvSRbmKsXDXcba/sQld7pfvzuPG1I35/YjzIybY2neMQCEYC7jVq1OnDeG2je3 1kunCR+/cswP/qcIWYjemxqsYEnfsNBTUSKQZA+sscpVIiU1oHAnbiBdcz6nAwRjBRnc 1VSULbpB0q97II/CmQOdWFFivA7qUWiruaNIW6U3B48ffp4ccKZRADr1k7Kdsg6hWoDu iesg== X-Gm-Message-State: AOJu0YwH91AiCvy1vOmlMVKrcMTS6jkFqEv1b3uhbYxor6d8XkZunH7U bjJbd50ff5hUZyw+J3DBVJ/OODP0EdzhjHtnF9c= X-Google-Smtp-Source: AGHT+IHaa7yTFBHuYubdaC9AiuHwSd6ocpxwFCdOzFJG0/u5y3SjM7OF+xeLV8flWJucvJ+1krpsnxeSktedW80brkg= X-Received: by 2002:a05:6102:2828:b0:44d:47a2:789c with SMTP id ba8-20020a056102282800b0044d47a2789cmr3173310vsb.25.1695954392631; Thu, 28 Sep 2023 19:26:32 -0700 (PDT) MIME-Version: 1.0 References: <20230925053657.24959-1-hau.hsu@sifive.com> In-Reply-To: <20230925053657.24959-1-hau.hsu@sifive.com> From: Kito Cheng Date: Fri, 29 Sep 2023 10:26:21 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: Initialize the jvt CSR To: Hau Hsu Cc: newlib@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Sep 25, 2023 at 1:37=E2=80=AFPM Hau Hsu via Newlib wrote: > > We set symbol '__jvt_base$' as weak. So if the symbol is not set in the > linker script, the address would be 0. We initialize jvt CSR only if > the address is not 0. > > psabi reference: > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8b1= 1e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation > --- > libgloss/riscv/crt0.S | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S > index 7a4e4e32c..4744ba039 100644 > --- a/libgloss/riscv/crt0.S > +++ b/libgloss/riscv/crt0.S > @@ -26,6 +26,16 @@ _start: > addi gp, gp, %pcrel_lo(1b) > .option pop > > + /* Initialize jvt CSR */ > + .weak __jvt_base$ > +.option push > +.option arch, +zcmt, +zicsr I guess I am little concerned about the backward compatibility, zcmt isn't supported by trunk binutils even, so maybe we should just +zicsr to make sure csrw is usable, and use csr number directly instead of using symbolic name to prevent the backward incompatible issue. > + lla a0, __jvt_base$ > + beqz a0, .Ljvt_init_end > + csrw jvt, a0 > +.Ljvt_init_end: > +.option pop > + > # Clear the bss segment > la a0, __bss_start > la a2, _end > -- > 2.42.0 >