qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: Ian Brockbank <Ian.Brockbank@cirrus.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Alistair Francis <alistair.francis@wdc.com>,
	 Bin Meng <bmeng.cn@gmail.com>, Weiwei Li <liwei1518@gmail.com>,
	 Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
	Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
	 LIU Zhiwei <zhiwei_liu@c-sky.com>
Subject: Re: [PATCH 01/11 v2] target/riscv: Add CLIC CSR mintstatus
Date: Fri, 6 Sep 2024 13:04:54 +1000	[thread overview]
Message-ID: <CAKmqyKPrz2544MFpORh==F-63M5pMMbsWcjNipOSozMeTB7G5Q@mail.gmail.com> (raw)
In-Reply-To: <CAKmqyKP6DTHq=6Tv3F7DPzjiyXdJhUdr0isNokZPCFgstQV4gQ@mail.gmail.com>

On Fri, Sep 6, 2024 at 12:44 PM Alistair Francis <alistair23@gmail.com> wrote:
>
> On Tue, Aug 20, 2024 at 2:11 AM Ian Brockbank <Ian.Brockbank@cirrus.com> wrote:
> >
> > From: Ian Brockbank <ian.brockbank@cirrus.com>
> >
> > CSR mintstatus holds the active interrupt level for each supported
> > privilege mode. sintstatus, and user, uintstatus, provide restricted
> > views of mintstatus.
> >
> > Signed-off-by: Ian Brockbank <ian.brockbank@cirrus.com>
> > Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
>
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Whoops! Scratch that

>
> > ---
> >  target/riscv/cpu.h      |  3 +++
> >  target/riscv/cpu_bits.h | 11 +++++++++++
> >  target/riscv/csr.c      | 31 +++++++++++++++++++++++++++++++
> >  3 files changed, 45 insertions(+)
> >
> > diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> > index 1619c3acb6..95303f50d3 100644
> > --- a/target/riscv/cpu.h
> > +++ b/target/riscv/cpu.h
> > @@ -259,6 +259,7 @@ struct CPUArchState {
> >      bool software_seip;
> >
> >      uint64_t miclaim;
> > +    uint64_t mintstatus; /* clic-spec */
> >
> >      uint64_t mie;
> >      uint64_t mideleg;
> > @@ -461,6 +462,8 @@ struct CPUArchState {
> >      QEMUTimer *vstimer; /* Internal timer for VS-mode interrupt */
> >      bool vstime_irq;
> >
> > +    void *clic;       /* clic interrupt controller */
> > +
> >      hwaddr kernel_addr;
> >      hwaddr fdt_addr;
> >
> > diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h
> > index 32b068f18a..2e65495b54 100644
> > --- a/target/riscv/cpu_bits.h
> > +++ b/target/riscv/cpu_bits.h
> > @@ -165,6 +165,7 @@
> >  #define CSR_MCAUSE          0x342
> >  #define CSR_MTVAL           0x343
> >  #define CSR_MIP             0x344
> > +#define CSR_MINTSTATUS      0xfb1 /* clic-spec-draft */
> >
> >  /* Machine-Level Window to Indirectly Accessed Registers (AIA) */
> >  #define CSR_MISELECT        0x350
> > @@ -206,6 +207,7 @@
> >  #define CSR_SCAUSE          0x142
> >  #define CSR_STVAL           0x143
> >  #define CSR_SIP             0x144
> > +#define CSR_SINTSTATUS      0xdb1 /* clic-spec-draft */
> >
> >  /* Sstc supervisor CSRs */
> >  #define CSR_STIMECMP        0x14D
> > @@ -733,6 +735,15 @@ typedef enum RISCVException {
> >  #define SIP_SEIP                           MIP_SEIP
> >  #define SIP_LCOFIP                         MIP_LCOFIP
> >
> > +/* mintstatus */
> > +#define MINTSTATUS_MIL                     0xff000000 /* mil[31:24] */
> > +#define MINTSTATUS_SIL                     0x0000ff00 /* sil[15:8] */
> > +#define MINTSTATUS_UIL                     0x000000ff /* uil[7:0] */
> > +
> > +/* sintstatus */
> > +#define SINTSTATUS_SIL                     0x0000ff00 /* sil[15:8] */
> > +#define SINTSTATUS_UIL                     0x000000ff /* uil[7:0] */
> > +
> >  /* MIE masks */
> >  #define MIE_SEIE                           (1 << IRQ_S_EXT)
> >  #define MIE_UEIE                           (1 << IRQ_U_EXT)
> > diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> > index ea3560342c..f9ed7b9079 100644
> > --- a/target/riscv/csr.c
> > +++ b/target/riscv/csr.c
> > @@ -578,6 +578,16 @@ static RISCVException debug(CPURISCVState *env, int csrno)
> >
> >      return RISCV_EXCP_ILLEGAL_INST;
> >  }
> > +
> > +static int clic(CPURISCVState *env, int csrno)
> > +{
> > +    if (env->clic) {

This isn't enough. There are smclic (M-mode) and ssclic (S-mode)
extensions that need to be checked against here to access the CSRs.

At the end of the series they can then be exposed as CPU properties
(which the virt machine can enable when required)

Alistair


  reply	other threads:[~2024-09-06  3:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <https://lists.gnu.org/archive/html/qemu-riscv/2024-08/msg00234.html>
2024-08-14  8:27 ` [PATCH 00/11] RISC-V: support CLIC v0.9 specification Ian Brockbank
2024-08-14  8:27   ` [PATCH 03/11] hw/intc: Add CLIC device Ian Brockbank
2024-08-14  8:27   ` [PATCH 02/11] target/riscv: Update CSR xintthresh in CLIC mode Ian Brockbank
2024-08-14  8:27   ` [PATCH 01/11] target/riscv: Add CLIC CSR mintstatus Ian Brockbank
2024-08-14  8:27   ` [PATCH 04/11] target/riscv: Update CSR xie in CLIC mode Ian Brockbank
2024-08-14  8:27   ` [PATCH 05/11] target/riscv: Update CSR xip " Ian Brockbank
2024-08-14  8:27   ` [PATCH 07/11] target/riscv: Update CSR xnxti " Ian Brockbank
2024-08-14  8:27   ` [PATCH 06/11] target/riscv: Update CSR xtvec " Ian Brockbank
2024-08-14 14:11   ` [PATCH 00/11] RISC-V: support CLIC v0.9 specification Ian Brockbank
2024-08-19 16:02 ` [PATCH 00/11 v2] " Ian Brockbank
2024-08-19 16:02   ` [PATCH 01/11 v2] target/riscv: Add CLIC CSR mintstatus Ian Brockbank
2024-09-06  2:44     ` Alistair Francis
2024-09-06  3:04       ` Alistair Francis [this message]
2024-08-19 16:02   ` [PATCH 02/11 v2] target/riscv: Update CSR xintthresh in CLIC mode Ian Brockbank
2024-09-06  2:52     ` Alistair Francis
2024-08-19 16:02   ` [PATCH 03/11 v2] hw/intc: Add CLIC device Ian Brockbank
2024-08-19 16:02   ` [PATCH 04/11 v2] target/riscv: Update CSR xie in CLIC mode Ian Brockbank
2024-09-06  2:58     ` Alistair Francis
2024-09-06  3:20       ` Alistair Francis
2024-08-19 16:02   ` [PATCH 05/11 v2] target/riscv: Update CSR xip " Ian Brockbank
2024-08-19 16:02   ` [PATCH 06/11 v2] target/riscv: Update CSR xtvec " Ian Brockbank
2024-09-06  3:02     ` Alistair Francis
2024-08-19 16:02   ` [PATCH 07/11 v2] target/riscv: Update CSR xnxti " Ian Brockbank
2024-08-19 16:02   ` [PATCH 08/11 v2] target/riscv: Update interrupt handling " Ian Brockbank
2024-09-06  3:49     ` Alistair Francis
2024-08-19 16:02   ` [PATCH 09/11 v2] target/riscv: Update interrupt return " Ian Brockbank
2024-08-19 16:02   ` [PATCH 10/11 v2] hw/riscv: add CLIC into virt machine Ian Brockbank
2024-08-19 16:02   ` [PATCH 11/11 v2] tests: add riscv clic qtest case and a function in qtest Ian Brockbank
2024-09-06  3:52     ` Alistair Francis
2024-09-04  7:57   ` [PATCH 00/11 v2] RISC-V: support CLIC v0.9 specification Ian Brockbank
2024-09-06  2:48   ` Alistair Francis
2024-09-06  3:56   ` Alistair Francis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKmqyKPrz2544MFpORh==F-63M5pMMbsWcjNipOSozMeTB7G5Q@mail.gmail.com' \
    --to=alistair23@gmail.com \
    --cc=Ian.Brockbank@cirrus.com \
    --cc=alistair.francis@wdc.com \
    --cc=bmeng.cn@gmail.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@c-sky.com \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).