From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 27E7D3858D32 for ; Fri, 5 Jan 2024 06:49:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27E7D3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 27E7D3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704437365; cv=none; b=jJuZ4EWezdbw0t2UQEUGboPFIoy/U+EJeRYDt0TQDAblkNAWmitq2ayiEK0t99EZ2jro3Fvxj8m5JfEJnEzRxir7Ea2X9HFdFlSauV9sQ6QU/9FDwPNzwgqoc8mmzP7KvD2NYwhwjy4DrrOJR7+0LrVPV068pOeV9E/FKSOFQnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704437365; c=relaxed/simple; bh=IbWRWQAuGAGWmYDzaeKHX3J3jlenuZIof195d3jLbSk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=a67qCknOWXyGj2scZVRNcoarU1wc+wakVKybxmsCNBUqWrZOxTM9f4kdWbWk4UaqThswW0Rs+ijNA0I2McHnDR8q+tNjqoj8+LkuB8Ou6y6nGg9fQXeVCdTSS6i2MIPUA2/hkS1Iuj+vjfNuEaWQUhGfIRoQH/kNkY6wgBa0clg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-555e07761acso1550587a12.0 for ; Thu, 04 Jan 2024 22:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704437362; x=1705042162; 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=ey9YALtv2PO9SN8cGFM7CuxArxHo+zwUSwhhZ3ETkLU=; b=KEPxzXLHjXoz7tIBL0tf2EFIrDPq1OI8x/LdwqlMszWEcMjfQL2RPnZ5WUc4IaIU8A hbXx/wPYPgb8nrZ9gem+Ln6NSPOAB/NltY6fVYLy0YIRYxW+Mwdx1GTC0Irzo7Y7Yj+R p/t6GMwrEln8dD0Wn9z00RBwyvE90MNjFHSJTRsPQOpL4z32RWlBDHE48WRgZDj4qB1/ EnbLxZ7HKhqZoFpJWc5MWmcE+gzWejHIzzTW2FMKQyylobG8qK3hnHrk0YJ+9ZOSf7Fc tJrf52UM1Q8YSSXbcvgr+buoV0NJb0EJi/4NDpk9qryTe9m1upfL2etsEHDPHnMdRz+j AHEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704437362; x=1705042162; 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=ey9YALtv2PO9SN8cGFM7CuxArxHo+zwUSwhhZ3ETkLU=; b=msLC2MT5pu+PGzXPtifGskZyFju0rugqCHTVEyCwueLfxOEFBuD40z3oaOqXb+AcUb U6n+MoBnpj/dt/LMSWz/C6BAgFSy/kODFVGXp1wCGVratmxhLGb6EAIllCOZR1/uDsJC grX0C1/Nf1pxkyRiiHr6seeiJie0YelVP+0xGcCkY+PA3oi+RV1ZtctE4oSGURLikn4/ vMec9Y0AcdniSX/nHJpYZVq/a6oK9+qE9QF2HvGBhdjy6OdfUDFZ1ZXkd+7ItZFfBvMQ TAPvTUfhvYUu3DricEGjdIwmUMSxXC9Emj1tpMMzTA+iZyBDnR5J/9zfkM3/DTq2Ypun IcPw== X-Gm-Message-State: AOJu0YwS3opVTASP21QV7ZjcDmKnAeP2cDrxH4g/R0uEx4vsHzsgyqg1 TldXuRCVfuStz9flAztrSXZZ/onOWbY04KHw0WL0LQNYcEA= X-Google-Smtp-Source: AGHT+IH4LPaiahF7ra7TNT+eFlS14T41b62axPkmFZgb8RCupQCmpD3K/FQoqM0kQDokvhZG/8W6JpB5cErxc6ZS6JA= X-Received: by 2002:a50:99d1:0:b0:556:e176:ab03 with SMTP id n17-20020a5099d1000000b00556e176ab03mr712417edb.70.1704437361480; Thu, 04 Jan 2024 22:49:21 -0800 (PST) MIME-Version: 1.0 References: <20240105030709.4179529-1-hau.hsu@sifive.com> In-Reply-To: <20240105030709.4179529-1-hau.hsu@sifive.com> From: Kito Cheng Date: Fri, 5 Jan 2024 14:49:09 +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=-8.7 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,T_SCC_BODY_TEXT_LINE 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 Fri, Jan 5, 2024 at 11:07=E2=80=AFAM Hau Hsu wrote: > > 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. > > Also use csr number directly instead of using symbolic name to prevent th= e > backward incompatible issue. > > 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 | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S > index 7a4e4e32c..187ca4a56 100644 > --- a/libgloss/riscv/crt0.S > +++ b/libgloss/riscv/crt0.S > @@ -26,6 +26,19 @@ _start: > addi gp, gp, %pcrel_lo(1b) > .option pop > > + /* Initialize jvt CSR (reg addr: 0x0017) */ > + .weak __jvt_base$ > + lla a0, __jvt_base$ > + beqz a0, .Ljvt_init_end > + /* Enable zicsr to set jvt. > + Also need to exclude conflict extensions. */ ^^^ comment seems not in sync with the code? > +.option push > +.option norelax > +.option arch, +zicsr > + csrw 0x17, a0 > +.option pop > +.Ljvt_init_end: > + > # Clear the bss segment > la a0, __bss_start > la a2, _end > -- > 2.37.1 >