From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) by sourceware.org (Postfix) with ESMTPS id 6B7813858CDA for ; Mon, 25 Sep 2023 06:18:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B7813858CDA 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-x931.google.com with SMTP id a1e0cc1a2514c-7ab9ad973e6so890686241.1 for ; Sun, 24 Sep 2023 23:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695622692; x=1696227492; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gUdNrpXSoYrgBXlpSl/htT1zYJ+biqBRyizhyCWGF6g=; b=V0yXaJ5r9OC/9JlmmTGNJJFFecXAmXldAuGVvHys+SI+xT9LhHLbs1U/MFO2CZCUR9 CMkkiw9K7GupNou59AEzcpX9dyAMzSXQ1VWNccXnfCz+VxDDU7xLAq/mNYQKLx5YrDIP suenFSilczrCjGNzZWVuWbZr67egkXKBrJVUQGZUKRND4s2rWSv6q/zdeOKYQlZ4AV/X 3EGrFr4O9w7Ktr5cTiFrbk2zKQifrjtGoZV7QbBM8hTVRXzIec0QSpExZkxcaVU46xFy H47v1qUBbYGTSFZEmOuvLyIcJL8fl4aDteIEymc1IgecWJz0yHHdwC4cCq8LhuwC3TYy Yvow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695622692; x=1696227492; h=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=gUdNrpXSoYrgBXlpSl/htT1zYJ+biqBRyizhyCWGF6g=; b=pvKhHcPSO8MYRn3euyvmKtC7u2jGzTQjbJYiwvhNjmBlsmWf1vvDmccpjxuNVbNmaL 6umPlyHY9K95EE0f9NCIoZnnW4iOnzOxCz3f+KAjDSrNlYu1jT0eAlrQzoi2H674jKK7 anYWAq/Qwe5PLqWU40q/3Bgpd/MMkgmMC1islZeK2TxtNrDg4yKbqz22Wvft/l0R7QDv ez6EwONFrY0TfWYOL+aZe+oNjWomSKGVBqvFhzD32DVPgPo70lr7mfEfWycshovQtJRd qLUYK4WMGhj4wmgtUv/cNM0mOlcUPtakMr0WlrOm6OSJ62/JpZd/sUeygbJYKh/oiJCM kQ7w== X-Gm-Message-State: AOJu0YyB3LkpWUCP1SRelzIGmEZmU+JlY2q9vb5yYL4DEINATY0OnH45 MRq6Mi3+5el+SZc1BXWaVTcUjEigEpJgbau5qus= X-Google-Smtp-Source: AGHT+IGFaCjFwq+LWV9PIF4AVBzHI6hP9miPhGzHQIUbV3H9T4omvzeeB7+Wh0SyFk2ZvMntDsX0ovGYeDlMjtTXKiU= X-Received: by 2002:a67:fc48:0:b0:44d:6256:ac8b with SMTP id p8-20020a67fc48000000b0044d6256ac8bmr3292449vsq.4.1695622691097; Sun, 24 Sep 2023 23:18:11 -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: Mon, 25 Sep 2023 07:17:59 +0100 Message-ID: Subject: Re: [PATCH] RISC-V: Initialize the jvt CSR To: Hau Hsu Cc: Newlib Content-Type: multipart/alternative; boundary="0000000000002d1202060628ec4a" X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,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: --0000000000002d1202060628ec4a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable LGTM Hau Hsu via Newlib =E6=96=BC 2023=E5=B9=B49=E6=9C= =8825=E6=97=A5 =E9=80=B1=E4=B8=80 06:37 =E5=AF=AB=E9=81=93=EF=BC=9A > 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 > + 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 > > --0000000000002d1202060628ec4a--