Message ID | 20230925053657.24959-1-hau.hsu@sifive.com |
---|---|
State | New |
Headers |
Return-Path: <newlib-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1DEF3857B9B for <patchwork@sourceware.org>; Mon, 25 Sep 2023 05:37:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1DEF3857B9B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695620263; bh=eNJKNhwXGrUgsqQnAwrszsPeNKbbpcWhKSZs2WPhur0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Q66yqBxs6CtkyL03g9ncCBdAGYXHxidcDHBcI3EKVP66Xml1HyL4L2hRWHXswCmcI c5JdHUcbb9vORTdGvdBoDDnm9zceIeM5RsSb3LsZLyfsvgzDnigceiq4lfaub7arRA WsKaN+hUCYscP08vsLGvnbGxT/0pWvxrUrF8NSKc= X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 117BC3858CDA for <newlib@sourceware.org>; Mon, 25 Sep 2023 05:37:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 117BC3858CDA Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-690d25b1dbdso5019072b3a.2 for <newlib@sourceware.org>; Sun, 24 Sep 2023 22:37:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695620246; x=1696225046; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eNJKNhwXGrUgsqQnAwrszsPeNKbbpcWhKSZs2WPhur0=; b=QCCBu83HjArJeKwCT1av6Lw4fqyH+Cp/AOqgRibkiBZXiNiF8inRADRhejoAjAvpQW L71lv6Ema56pBRcGQMKTpamgp5reILCrWXTqou3tIWmEsycROIwlePUxhCRrW8iVPrPq gbQPVB7f7rgl35bbIz/ojVWuc7UX4nZvvzoWmIGJnG8A0ChgbRPcIi4PcRSSxYgXngZ6 pTCL949qs3liBBW80p9YH0CPQZhSpwqrKfr/Dgw/yABSISfIsw5+0egI9FySg0U57LjZ zeqUURd0uGZoXWBE685ySprGx8sQWZe+IUC4onXFk13XEtMy7QjHY7GRjrLIQr9AOPLi jt/w== X-Gm-Message-State: AOJu0YxFD6GaWN0wVvHnVBqIb/0xQYlTeUDmBE3ivXjSKbxjkVgsigSY DFs14dVev673AyCIXmM2XROM0g== X-Google-Smtp-Source: AGHT+IFZs3pHF2zTAgH1ioXX2ZlVgM6XN78THuhclA1ewe1/cVSw6WsFDlMTmx7TY29nUTDKlTHw+g== X-Received: by 2002:a05:6a00:21ce:b0:68f:b5a1:12bf with SMTP id t14-20020a056a0021ce00b0068fb5a112bfmr8062979pfj.29.1695620246087; Sun, 24 Sep 2023 22:37:26 -0700 (PDT) Received: from hsinchu15.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id j14-20020aa78dce000000b006906aaf1e4dsm7171041pfr.150.2023.09.24.22.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 22:37:25 -0700 (PDT) To: hau.hsu@sifive.com, newlib@sourceware.org, kito.cheng@gmail.com Subject: [PATCH] RISC-V: Initialize the jvt CSR Date: Mon, 25 Sep 2023 13:36:57 +0800 Message-ID: <20230925053657.24959-1-hau.hsu@sifive.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> From: Hau Hsu via Newlib <newlib@sourceware.org> Reply-To: Hau Hsu <hau.hsu@sifive.com> Errors-To: newlib-bounces+patchwork=sourceware.org@sourceware.org Sender: "Newlib" <newlib-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
RISC-V: Initialize the jvt CSR
|
|
Commit Message
Hau Hsu
Sept. 25, 2023, 5:36 a.m. UTC
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/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation --- libgloss/riscv/crt0.S | 10 ++++++++++ 1 file changed, 10 insertions(+)
Comments
LGTM Hau Hsu via Newlib <newlib@sourceware.org> 於 2023年9月25日 週一 06:37 寫道: > 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/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/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 > >
We found a potential ISA conflict when compiling the crt0.S with zcd extension. We already have a new patch under testing. I'll send it after it is verified. Best, Hau Hsu Software Engineer hau.hsu@sifive.com > Kito Cheng <kito.cheng@gmail.com> 於 2023年9月25日 下午2:17 寫道: > > LGTM > > Hau Hsu via Newlib <newlib@sourceware.org <mailto:newlib@sourceware.org>> 於 2023年9月25日 週一 06:37 寫道: >> 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/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/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 >>
On Mon, Sep 25, 2023 at 1:37 PM Hau Hsu via Newlib <newlib@sourceware.org> 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/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/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 >
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