1 | From: Alistair Francis <alistair.francis@wdc.com> | 1 | From: Alistair Francis <alistair.francis@wdc.com> |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit c5fbdd60cf1fb52f01bdfe342b6fa65d5343e1b1: | 3 | The following changes since commit 6160d8ff81fb9fba70f5dad88d43ffd0fa44984c: |
4 | 4 | ||
5 | Merge tag 'qemu-sparc-20211121' of git://github.com/mcayland/qemu into staging (2021-11-21 14:12:25 +0100) | 5 | Merge tag 'edgar/xilinx-next-2022-09-21.for-upstream' of https://github.com/edgarigl/qemu into staging (2022-09-22 13:24:28 -0400) |
6 | 6 | ||
7 | are available in the Git repository at: | 7 | are available in the Git repository at: |
8 | 8 | ||
9 | git@github.com:alistair23/qemu.git tags/pull-riscv-to-apply-20211122 | 9 | git@github.com:alistair23/qemu.git pull-riscv-to-apply-20220923-2 |
10 | 10 | ||
11 | for you to fetch changes up to 526e7443027c71fe7b04c29df529e1f9f425f9e3: | 11 | for you to fetch changes up to a4260684f8e2c8722d1feae0d41d956fc4109007: |
12 | 12 | ||
13 | hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset (2021-11-22 10:46:22 +1000) | 13 | hw/riscv/sifive_e: Fix inheritance of SiFiveEState (2022-09-23 09:11:34 +1000) |
14 | 14 | ||
15 | ---------------------------------------------------------------- | 15 | ---------------------------------------------------------------- |
16 | Seventh RISC-V PR for QEMU 6.2 | 16 | Second RISC-V PR for QEMU 7.2 |
17 | 17 | ||
18 | - Deprecate IF_NONE for SiFive OTP | 18 | * Fixup typos and register addresses for Ibex SPI |
19 | - Don't reset SiFive OTP content | 19 | * Cleanup the RISC-V virt machine documentation |
20 | * Remove the sideleg and sedeleg CSR macros | ||
21 | * Fix the CSR check for cycle{h}, instret{h}, time{h}, hpmcounter3-31{h} | ||
22 | * Remove fixed numbering from GDB xml feature files | ||
23 | * Allow setting the resetvec for the OpenTitan machine | ||
24 | * Check the correct exception cause in vector GDB stub | ||
25 | * Fix inheritance of SiFiveEState | ||
20 | 26 | ||
21 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
22 | Philippe Mathieu-Daudé (1): | 28 | Alex Bennée (1): |
23 | hw/misc/sifive_u_otp: Do not reset OTP content on hardware reset | 29 | docs/system: clean up code escape for riscv virt platform |
24 | 30 | ||
25 | Thomas Huth (1): | 31 | Alistair Francis (3): |
26 | hw/misc/sifive_u_otp: Use IF_PFLASH for the OTP device instead of IF_NONE | 32 | target/riscv: Set the CPU resetvec directly |
33 | hw/riscv: opentitan: Fixup resetvec | ||
34 | hw/riscv: opentitan: Expose the resetvec as a SoC property | ||
27 | 35 | ||
28 | docs/about/deprecated.rst | 6 ++++++ | 36 | Andrew Burgess (2): |
29 | hw/misc/sifive_u_otp.c | 22 +++++++++++++--------- | 37 | target/riscv: remove fflags, frm, and fcsr from riscv-*-fpu.xml |
30 | 2 files changed, 19 insertions(+), 9 deletions(-) | 38 | target/riscv: remove fixed numbering from GDB xml feature files |
31 | 39 | ||
40 | Bernhard Beschow (1): | ||
41 | hw/riscv/sifive_e: Fix inheritance of SiFiveEState | ||
42 | |||
43 | Frank Chang (1): | ||
44 | target/riscv: Check the correct exception cause in vector GDB stub | ||
45 | |||
46 | Rahul Pathak (1): | ||
47 | target/riscv: Remove sideleg and sedeleg | ||
48 | |||
49 | Weiwei Li (1): | ||
50 | target/riscv: fix csr check for cycle{h}, instret{h}, time{h}, hpmcounter3-31{h} | ||
51 | |||
52 | Wilfred Mallawa (2): | ||
53 | hw/ssi: ibex_spi: fixup typos in ibex_spi_host | ||
54 | hw/ssi: ibex_spi: update reg addr | ||
55 | |||
56 | docs/system/riscv/virt.rst | 13 +++++++++---- | ||
57 | include/hw/riscv/opentitan.h | 2 ++ | ||
58 | include/hw/riscv/sifive_e.h | 3 ++- | ||
59 | target/riscv/cpu.h | 3 +-- | ||
60 | target/riscv/cpu_bits.h | 2 -- | ||
61 | disas/riscv.c | 2 -- | ||
62 | hw/riscv/opentitan.c | 8 +++++++- | ||
63 | hw/ssi/ibex_spi_host.c | 8 ++++---- | ||
64 | target/riscv/cpu.c | 13 +++---------- | ||
65 | target/riscv/csr.c | 13 +++++++++---- | ||
66 | target/riscv/gdbstub.c | 36 ++++-------------------------------- | ||
67 | target/riscv/machine.c | 6 +++--- | ||
68 | gdb-xml/riscv-32bit-cpu.xml | 6 +----- | ||
69 | gdb-xml/riscv-32bit-fpu.xml | 10 +--------- | ||
70 | gdb-xml/riscv-64bit-cpu.xml | 6 +----- | ||
71 | gdb-xml/riscv-64bit-fpu.xml | 10 +--------- | ||
72 | 16 files changed, 48 insertions(+), 93 deletions(-) | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Wilfred Mallawa <wilfred.mallawa@wdc.com> | ||
1 | 2 | ||
3 | This patch fixes up minor typos in ibex_spi_host | ||
4 | |||
5 | Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
8 | Message-Id: <20220823061201.132342-2-wilfred.mallawa@opensource.wdc.com> | ||
9 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | --- | ||
11 | hw/ssi/ibex_spi_host.c | 6 +++--- | ||
12 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/hw/ssi/ibex_spi_host.c b/hw/ssi/ibex_spi_host.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/ssi/ibex_spi_host.c | ||
17 | +++ b/hw/ssi/ibex_spi_host.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void ibex_spi_host_irq(IbexSPIHostState *s) | ||
19 | & R_INTR_STATE_SPI_EVENT_MASK; | ||
20 | int err_irq = 0, event_irq = 0; | ||
21 | |||
22 | - /* Error IRQ enabled and Error IRQ Cleared*/ | ||
23 | + /* Error IRQ enabled and Error IRQ Cleared */ | ||
24 | if (error_en && !err_pending) { | ||
25 | /* Event enabled, Interrupt Test Error */ | ||
26 | if (s->regs[IBEX_SPI_HOST_INTR_TEST] & R_INTR_TEST_ERROR_MASK) { | ||
27 | @@ -XXX,XX +XXX,XX @@ static void ibex_spi_host_write(void *opaque, hwaddr addr, | ||
28 | case IBEX_SPI_HOST_TXDATA: | ||
29 | /* | ||
30 | * This is a hardware `feature` where | ||
31 | - * the first word written TXDATA after init is omitted entirely | ||
32 | + * the first word written to TXDATA after init is omitted entirely | ||
33 | */ | ||
34 | if (s->init_status) { | ||
35 | s->init_status = false; | ||
36 | @@ -XXX,XX +XXX,XX @@ static void ibex_spi_host_write(void *opaque, hwaddr addr, | ||
37 | break; | ||
38 | case IBEX_SPI_HOST_ERROR_STATUS: | ||
39 | /* | ||
40 | - * Indicates that any errors that have occurred. | ||
41 | + * Indicates any errors that have occurred. | ||
42 | * When an error occurs, the corresponding bit must be cleared | ||
43 | * here before issuing any further commands | ||
44 | */ | ||
45 | -- | ||
46 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Wilfred Mallawa <wilfred.mallawa@wdc.com> | ||
1 | 2 | ||
3 | Updates the `EVENT_ENABLE` register to offset `0x34` as per | ||
4 | OpenTitan spec [1]. | ||
5 | |||
6 | [1] https://docs.opentitan.org/hw/ip/spi_host/doc/#Reg_event_enable | ||
7 | |||
8 | Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-Id: <20220823061201.132342-5-wilfred.mallawa@opensource.wdc.com> | ||
11 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
12 | --- | ||
13 | hw/ssi/ibex_spi_host.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/ssi/ibex_spi_host.c b/hw/ssi/ibex_spi_host.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/ssi/ibex_spi_host.c | ||
19 | +++ b/hw/ssi/ibex_spi_host.c | ||
20 | @@ -XXX,XX +XXX,XX @@ REG32(ERROR_STATUS, 0x30) | ||
21 | FIELD(ERROR_STATUS, CMDINVAL, 3, 1) | ||
22 | FIELD(ERROR_STATUS, CSIDINVAL, 4, 1) | ||
23 | FIELD(ERROR_STATUS, ACCESSINVAL, 5, 1) | ||
24 | -REG32(EVENT_ENABLE, 0x30) | ||
25 | +REG32(EVENT_ENABLE, 0x34) | ||
26 | FIELD(EVENT_ENABLE, RXFULL, 0, 1) | ||
27 | FIELD(EVENT_ENABLE, TXEMPTY, 1, 1) | ||
28 | FIELD(EVENT_ENABLE, RXWM, 2, 1) | ||
29 | -- | ||
30 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
1 | 2 | ||
3 | The example code is rendered slightly mangled due to missing code | ||
4 | block. Properly escape the code block and add shell prompt and qemu to | ||
5 | fit in with the other examples on the page. | ||
6 | |||
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Message-Id: <20220905163939.1599368-1-alex.bennee@linaro.org> | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | --- | ||
12 | docs/system/riscv/virt.rst | 13 +++++++++---- | ||
13 | 1 file changed, 9 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/docs/system/riscv/virt.rst b/docs/system/riscv/virt.rst | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/docs/system/riscv/virt.rst | ||
18 | +++ b/docs/system/riscv/virt.rst | ||
19 | @@ -XXX,XX +XXX,XX @@ Enabling TPM | ||
20 | |||
21 | A TPM device can be connected to the virt board by following the steps below. | ||
22 | |||
23 | -First launch the TPM emulator | ||
24 | +First launch the TPM emulator: | ||
25 | |||
26 | - swtpm socket --tpm2 -t -d --tpmstate dir=/tmp/tpm \ | ||
27 | +.. code-block:: bash | ||
28 | + | ||
29 | + $ swtpm socket --tpm2 -t -d --tpmstate dir=/tmp/tpm \ | ||
30 | --ctrl type=unixio,path=swtpm-sock | ||
31 | |||
32 | -Then launch QEMU with: | ||
33 | +Then launch QEMU with some additional arguments to link a TPM device to the backend: | ||
34 | + | ||
35 | +.. code-block:: bash | ||
36 | |||
37 | - ... | ||
38 | + $ qemu-system-riscv64 \ | ||
39 | + ... other args .... \ | ||
40 | -chardev socket,id=chrtpm,path=swtpm-sock \ | ||
41 | -tpmdev emulator,id=tpm0,chardev=chrtpm \ | ||
42 | -device tpm-tis-device,tpmdev=tpm0 | ||
43 | -- | ||
44 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Rahul Pathak <rpathak@ventanamicro.com> | ||
1 | 2 | ||
3 | sideleg and sedeleg csrs are not part of riscv isa spec | ||
4 | anymore, these csrs were part of N extension which | ||
5 | is removed from the riscv isa specification. | ||
6 | |||
7 | These commits removed all traces of these csrs from | ||
8 | riscv spec (https://github.com/riscv/riscv-isa-manual) - | ||
9 | |||
10 | commit f8d27f805b65 ("Remove or downgrade more references to N extension (#674)") | ||
11 | commit b6cade07034d ("Remove N extension chapter for now") | ||
12 | |||
13 | Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com> | ||
14 | Reviewed-by: Andrew Jones <ajones@ventanamicro.com> | ||
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | Message-Id: <20220824145255.400040-1-rpathak@ventanamicro.com> | ||
17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
18 | --- | ||
19 | target/riscv/cpu_bits.h | 2 -- | ||
20 | disas/riscv.c | 2 -- | ||
21 | 2 files changed, 4 deletions(-) | ||
22 | |||
23 | diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/riscv/cpu_bits.h | ||
26 | +++ b/target/riscv/cpu_bits.h | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | |||
29 | /* Supervisor Trap Setup */ | ||
30 | #define CSR_SSTATUS 0x100 | ||
31 | -#define CSR_SEDELEG 0x102 | ||
32 | -#define CSR_SIDELEG 0x103 | ||
33 | #define CSR_SIE 0x104 | ||
34 | #define CSR_STVEC 0x105 | ||
35 | #define CSR_SCOUNTEREN 0x106 | ||
36 | diff --git a/disas/riscv.c b/disas/riscv.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/disas/riscv.c | ||
39 | +++ b/disas/riscv.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static const char *csr_name(int csrno) | ||
41 | case 0x0043: return "utval"; | ||
42 | case 0x0044: return "uip"; | ||
43 | case 0x0100: return "sstatus"; | ||
44 | - case 0x0102: return "sedeleg"; | ||
45 | - case 0x0103: return "sideleg"; | ||
46 | case 0x0104: return "sie"; | ||
47 | case 0x0105: return "stvec"; | ||
48 | case 0x0106: return "scounteren"; | ||
49 | -- | ||
50 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Weiwei Li <liweiwei@iscas.ac.cn> | ||
1 | 2 | ||
3 | - modify check for mcounteren to work in all less-privilege mode | ||
4 | - modify check for scounteren to work only when S mode is enabled | ||
5 | - distinguish the exception type raised by check for scounteren between U | ||
6 | and VU mode | ||
7 | |||
8 | Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn> | ||
9 | Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Message-Id: <20220817083756.12471-1-liweiwei@iscas.ac.cn> | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | --- | ||
14 | target/riscv/csr.c | 13 +++++++++---- | ||
15 | 1 file changed, 9 insertions(+), 4 deletions(-) | ||
16 | |||
17 | diff --git a/target/riscv/csr.c b/target/riscv/csr.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/riscv/csr.c | ||
20 | +++ b/target/riscv/csr.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static RISCVException ctr(CPURISCVState *env, int csrno) | ||
22 | |||
23 | skip_ext_pmu_check: | ||
24 | |||
25 | - if (((env->priv == PRV_S) && (!get_field(env->mcounteren, ctr_mask))) || | ||
26 | - ((env->priv == PRV_U) && (!get_field(env->scounteren, ctr_mask)))) { | ||
27 | + if (env->priv < PRV_M && !get_field(env->mcounteren, ctr_mask)) { | ||
28 | return RISCV_EXCP_ILLEGAL_INST; | ||
29 | } | ||
30 | |||
31 | if (riscv_cpu_virt_enabled(env)) { | ||
32 | - if (!get_field(env->hcounteren, ctr_mask) && | ||
33 | - get_field(env->mcounteren, ctr_mask)) { | ||
34 | + if (!get_field(env->hcounteren, ctr_mask) || | ||
35 | + (env->priv == PRV_U && !get_field(env->scounteren, ctr_mask))) { | ||
36 | return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; | ||
37 | } | ||
38 | } | ||
39 | + | ||
40 | + if (riscv_has_ext(env, RVS) && env->priv == PRV_U && | ||
41 | + !get_field(env->scounteren, ctr_mask)) { | ||
42 | + return RISCV_EXCP_ILLEGAL_INST; | ||
43 | + } | ||
44 | + | ||
45 | #endif | ||
46 | return RISCV_EXCP_NONE; | ||
47 | } | ||
48 | -- | ||
49 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Andrew Burgess <aburgess@redhat.com> | ||
1 | 2 | ||
3 | While testing some changes to GDB's handling for the RISC-V registers | ||
4 | fcsr, fflags, and frm, I spotted that QEMU includes these registers | ||
5 | twice in the target description it sends to GDB, once in the fpu | ||
6 | feature, and once in the csr feature. | ||
7 | |||
8 | Right now things basically work OK, QEMU maps these registers onto two | ||
9 | different register numbers, e.g. fcsr maps to both 68 and 73, and GDB | ||
10 | can use either of these to access the register. | ||
11 | |||
12 | However, GDB's target descriptions don't really work this way, each | ||
13 | register should appear just once in a target description, mapping the | ||
14 | register name onto the number GDB should use when accessing the | ||
15 | register on the target. Duplicate register names actually result in | ||
16 | duplicate registers on the GDB side, however, as the registers have | ||
17 | the same name, the user can only access one of these registers. | ||
18 | |||
19 | Currently GDB has a hack in place, specifically for RISC-V, to spot | ||
20 | the duplicate copies of these three registers, and hide them from the | ||
21 | user, ensuring the user only ever sees a single copy of each. | ||
22 | |||
23 | In this commit I propose fixing this issue on the QEMU side, and in | ||
24 | the process, simplify the fpu register handling a little. | ||
25 | |||
26 | I think we should, remove fflags, frm, and fcsr from the two (32-bit | ||
27 | and 64-bit) fpu feature xml files. These files will only contain the | ||
28 | 32 core floating point register f0 to f31. The fflags, frm, and fcsr | ||
29 | registers will continue to be advertised in the csr feature as they | ||
30 | currently are. | ||
31 | |||
32 | With that change made, I will simplify riscv_gdb_get_fpu and | ||
33 | riscv_gdb_set_fpu, removing the extra handling for the 3 status | ||
34 | registers. | ||
35 | |||
36 | Signed-off-by: Andrew Burgess <aburgess@redhat.com> | ||
37 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
38 | Message-Id: <0fbf2a5b12e3210ff3867d5cf7022b3f3462c9c8.1661934573.git.aburgess@redhat.com> | ||
39 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
40 | --- | ||
41 | target/riscv/gdbstub.c | 32 ++------------------------------ | ||
42 | gdb-xml/riscv-32bit-fpu.xml | 4 ---- | ||
43 | gdb-xml/riscv-64bit-fpu.xml | 4 ---- | ||
44 | 3 files changed, 2 insertions(+), 38 deletions(-) | ||
45 | |||
46 | diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/riscv/gdbstub.c | ||
49 | +++ b/target/riscv/gdbstub.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) | ||
51 | if (env->misa_ext & RVF) { | ||
52 | return gdb_get_reg32(buf, env->fpr[n]); | ||
53 | } | ||
54 | - /* there is hole between ft11 and fflags in fpu.xml */ | ||
55 | - } else if (n < 36 && n > 32) { | ||
56 | - target_ulong val = 0; | ||
57 | - int result; | ||
58 | - /* | ||
59 | - * CSR_FFLAGS is at index 1 in csr_register, and gdb says it is FP | ||
60 | - * register 33, so we recalculate the map index. | ||
61 | - * This also works for CSR_FRM and CSR_FCSR. | ||
62 | - */ | ||
63 | - result = riscv_csrrw_debug(env, n - 32, &val, | ||
64 | - 0, 0); | ||
65 | - if (result == RISCV_EXCP_NONE) { | ||
66 | - return gdb_get_regl(buf, val); | ||
67 | - } | ||
68 | } | ||
69 | return 0; | ||
70 | } | ||
71 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) | ||
72 | if (n < 32) { | ||
73 | env->fpr[n] = ldq_p(mem_buf); /* always 64-bit */ | ||
74 | return sizeof(uint64_t); | ||
75 | - /* there is hole between ft11 and fflags in fpu.xml */ | ||
76 | - } else if (n < 36 && n > 32) { | ||
77 | - target_ulong val = ldtul_p(mem_buf); | ||
78 | - int result; | ||
79 | - /* | ||
80 | - * CSR_FFLAGS is at index 1 in csr_register, and gdb says it is FP | ||
81 | - * register 33, so we recalculate the map index. | ||
82 | - * This also works for CSR_FRM and CSR_FCSR. | ||
83 | - */ | ||
84 | - result = riscv_csrrw_debug(env, n - 32, NULL, | ||
85 | - val, -1); | ||
86 | - if (result == RISCV_EXCP_NONE) { | ||
87 | - return sizeof(target_ulong); | ||
88 | - } | ||
89 | } | ||
90 | return 0; | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ void riscv_cpu_register_gdb_regs_for_features(CPUState *cs) | ||
93 | CPURISCVState *env = &cpu->env; | ||
94 | if (env->misa_ext & RVD) { | ||
95 | gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, | ||
96 | - 36, "riscv-64bit-fpu.xml", 0); | ||
97 | + 32, "riscv-64bit-fpu.xml", 0); | ||
98 | } else if (env->misa_ext & RVF) { | ||
99 | gdb_register_coprocessor(cs, riscv_gdb_get_fpu, riscv_gdb_set_fpu, | ||
100 | - 36, "riscv-32bit-fpu.xml", 0); | ||
101 | + 32, "riscv-32bit-fpu.xml", 0); | ||
102 | } | ||
103 | if (env->misa_ext & RVV) { | ||
104 | gdb_register_coprocessor(cs, riscv_gdb_get_vector, riscv_gdb_set_vector, | ||
105 | diff --git a/gdb-xml/riscv-32bit-fpu.xml b/gdb-xml/riscv-32bit-fpu.xml | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/gdb-xml/riscv-32bit-fpu.xml | ||
108 | +++ b/gdb-xml/riscv-32bit-fpu.xml | ||
109 | @@ -XXX,XX +XXX,XX @@ | ||
110 | <reg name="ft9" bitsize="32" type="ieee_single"/> | ||
111 | <reg name="ft10" bitsize="32" type="ieee_single"/> | ||
112 | <reg name="ft11" bitsize="32" type="ieee_single"/> | ||
113 | - | ||
114 | - <reg name="fflags" bitsize="32" type="int" regnum="66"/> | ||
115 | - <reg name="frm" bitsize="32" type="int" regnum="67"/> | ||
116 | - <reg name="fcsr" bitsize="32" type="int" regnum="68"/> | ||
117 | </feature> | ||
118 | diff --git a/gdb-xml/riscv-64bit-fpu.xml b/gdb-xml/riscv-64bit-fpu.xml | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/gdb-xml/riscv-64bit-fpu.xml | ||
121 | +++ b/gdb-xml/riscv-64bit-fpu.xml | ||
122 | @@ -XXX,XX +XXX,XX @@ | ||
123 | <reg name="ft9" bitsize="64" type="riscv_double"/> | ||
124 | <reg name="ft10" bitsize="64" type="riscv_double"/> | ||
125 | <reg name="ft11" bitsize="64" type="riscv_double"/> | ||
126 | - | ||
127 | - <reg name="fflags" bitsize="32" type="int" regnum="66"/> | ||
128 | - <reg name="frm" bitsize="32" type="int" regnum="67"/> | ||
129 | - <reg name="fcsr" bitsize="32" type="int" regnum="68"/> | ||
130 | </feature> | ||
131 | -- | ||
132 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Andrew Burgess <aburgess@redhat.com> | ||
1 | 2 | ||
3 | The fixed register numbering in the various GDB feature files for | ||
4 | RISC-V only exists because these files were originally copied from the | ||
5 | GDB source tree. | ||
6 | |||
7 | However, the fixed numbering only exists in the GDB source tree so | ||
8 | that GDB, when it connects to a target that doesn't provide a target | ||
9 | description, will use a specific numbering scheme. | ||
10 | |||
11 | That numbering scheme is designed to be compatible with the first | ||
12 | versions of QEMU (for RISC-V), that didn't send a target description, | ||
13 | and relied on a fixed numbering scheme. | ||
14 | |||
15 | Because of the way that QEMU manages its target descriptions, | ||
16 | recording the number of registers in each feature, and just relying on | ||
17 | GDB's numbering starting from 0, then I propose that we remove all the | ||
18 | fixed numbering from the RISC-V feature xml files, and just rely on | ||
19 | the standard numbering scheme. Plenty of other targets manage their | ||
20 | xml files this way, e.g. ARM, AArch64, Loongarch, m68k, rx, and s390. | ||
21 | |||
22 | Signed-off-by: Andrew Burgess <aburgess@redhat.com> | ||
23 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
24 | Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> | ||
25 | Message-Id: <6069395f90e6fc24dac92197be815fedf42f5974.1661934573.git.aburgess@redhat.com> | ||
26 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
27 | --- | ||
28 | gdb-xml/riscv-32bit-cpu.xml | 6 +----- | ||
29 | gdb-xml/riscv-32bit-fpu.xml | 6 +----- | ||
30 | gdb-xml/riscv-64bit-cpu.xml | 6 +----- | ||
31 | gdb-xml/riscv-64bit-fpu.xml | 6 +----- | ||
32 | 4 files changed, 4 insertions(+), 20 deletions(-) | ||
33 | |||
34 | diff --git a/gdb-xml/riscv-32bit-cpu.xml b/gdb-xml/riscv-32bit-cpu.xml | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/gdb-xml/riscv-32bit-cpu.xml | ||
37 | +++ b/gdb-xml/riscv-32bit-cpu.xml | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | are permitted in any medium without royalty provided the copyright | ||
40 | notice and this notice are preserved. --> | ||
41 | |||
42 | -<!-- Register numbers are hard-coded in order to maintain backward | ||
43 | - compatibility with older versions of tools that didn't use xml | ||
44 | - register descriptions. --> | ||
45 | - | ||
46 | <!DOCTYPE feature SYSTEM "gdb-target.dtd"> | ||
47 | <feature name="org.gnu.gdb.riscv.cpu"> | ||
48 | - <reg name="zero" bitsize="32" type="int" regnum="0"/> | ||
49 | + <reg name="zero" bitsize="32" type="int"/> | ||
50 | <reg name="ra" bitsize="32" type="code_ptr"/> | ||
51 | <reg name="sp" bitsize="32" type="data_ptr"/> | ||
52 | <reg name="gp" bitsize="32" type="data_ptr"/> | ||
53 | diff --git a/gdb-xml/riscv-32bit-fpu.xml b/gdb-xml/riscv-32bit-fpu.xml | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/gdb-xml/riscv-32bit-fpu.xml | ||
56 | +++ b/gdb-xml/riscv-32bit-fpu.xml | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | are permitted in any medium without royalty provided the copyright | ||
59 | notice and this notice are preserved. --> | ||
60 | |||
61 | -<!-- Register numbers are hard-coded in order to maintain backward | ||
62 | - compatibility with older versions of tools that didn't use xml | ||
63 | - register descriptions. --> | ||
64 | - | ||
65 | <!DOCTYPE feature SYSTEM "gdb-target.dtd"> | ||
66 | <feature name="org.gnu.gdb.riscv.fpu"> | ||
67 | - <reg name="ft0" bitsize="32" type="ieee_single" regnum="33"/> | ||
68 | + <reg name="ft0" bitsize="32" type="ieee_single"/> | ||
69 | <reg name="ft1" bitsize="32" type="ieee_single"/> | ||
70 | <reg name="ft2" bitsize="32" type="ieee_single"/> | ||
71 | <reg name="ft3" bitsize="32" type="ieee_single"/> | ||
72 | diff --git a/gdb-xml/riscv-64bit-cpu.xml b/gdb-xml/riscv-64bit-cpu.xml | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/gdb-xml/riscv-64bit-cpu.xml | ||
75 | +++ b/gdb-xml/riscv-64bit-cpu.xml | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | are permitted in any medium without royalty provided the copyright | ||
78 | notice and this notice are preserved. --> | ||
79 | |||
80 | -<!-- Register numbers are hard-coded in order to maintain backward | ||
81 | - compatibility with older versions of tools that didn't use xml | ||
82 | - register descriptions. --> | ||
83 | - | ||
84 | <!DOCTYPE feature SYSTEM "gdb-target.dtd"> | ||
85 | <feature name="org.gnu.gdb.riscv.cpu"> | ||
86 | - <reg name="zero" bitsize="64" type="int" regnum="0"/> | ||
87 | + <reg name="zero" bitsize="64" type="int"/> | ||
88 | <reg name="ra" bitsize="64" type="code_ptr"/> | ||
89 | <reg name="sp" bitsize="64" type="data_ptr"/> | ||
90 | <reg name="gp" bitsize="64" type="data_ptr"/> | ||
91 | diff --git a/gdb-xml/riscv-64bit-fpu.xml b/gdb-xml/riscv-64bit-fpu.xml | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/gdb-xml/riscv-64bit-fpu.xml | ||
94 | +++ b/gdb-xml/riscv-64bit-fpu.xml | ||
95 | @@ -XXX,XX +XXX,XX @@ | ||
96 | are permitted in any medium without royalty provided the copyright | ||
97 | notice and this notice are preserved. --> | ||
98 | |||
99 | -<!-- Register numbers are hard-coded in order to maintain backward | ||
100 | - compatibility with older versions of tools that didn't use xml | ||
101 | - register descriptions. --> | ||
102 | - | ||
103 | <!DOCTYPE feature SYSTEM "gdb-target.dtd"> | ||
104 | <feature name="org.gnu.gdb.riscv.fpu"> | ||
105 | |||
106 | @@ -XXX,XX +XXX,XX @@ | ||
107 | <field name="double" type="ieee_double"/> | ||
108 | </union> | ||
109 | |||
110 | - <reg name="ft0" bitsize="64" type="riscv_double" regnum="33"/> | ||
111 | + <reg name="ft0" bitsize="64" type="riscv_double"/> | ||
112 | <reg name="ft1" bitsize="64" type="riscv_double"/> | ||
113 | <reg name="ft2" bitsize="64" type="riscv_double"/> | ||
114 | <reg name="ft3" bitsize="64" type="riscv_double"/> | ||
115 | -- | ||
116 | 2.37.3 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Alistair Francis <alistair.francis@wdc.com> |
---|---|---|---|
2 | 2 | ||
3 | Once a "One Time Programmable" is programmed, it shouldn't be reset. | 3 | Instead of using our properties to set a config value which then might |
4 | be used to set the resetvec (depending on your timing), let's instead | ||
5 | just set the resetvec directly in the env struct. | ||
4 | 6 | ||
5 | Do not re-initialize the OTP content in the DeviceReset handler, | 7 | This allows us to set the reset vec from the command line with: |
6 | initialize it once in the DeviceRealize one. | 8 | -global driver=riscv.hart_array,property=resetvec,value=0x20000400 |
7 | 9 | ||
8 | Fixes: 9fb45c62ae8 ("riscv: sifive: Implement a model for SiFive FU540 OTP") | 10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
9 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 12 | Message-Id: <20220914101108.82571-2-alistair.francis@wdc.com> |
11 | Message-Id: <20211119104757.331579-1-f4bug@amsat.org> | ||
12 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 13 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
13 | --- | 14 | --- |
14 | hw/misc/sifive_u_otp.c | 13 +++++-------- | 15 | target/riscv/cpu.h | 3 +-- |
15 | 1 file changed, 5 insertions(+), 8 deletions(-) | 16 | target/riscv/cpu.c | 13 +++---------- |
17 | target/riscv/machine.c | 6 +++--- | ||
18 | 3 files changed, 7 insertions(+), 15 deletions(-) | ||
16 | 19 | ||
17 | diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c | 20 | diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/misc/sifive_u_otp.c | 22 | --- a/target/riscv/cpu.h |
20 | +++ b/hw/misc/sifive_u_otp.c | 23 | +++ b/target/riscv/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp) | 24 | @@ -XXX,XX +XXX,XX @@ struct CPUArchState { |
22 | 25 | /* This contains QEMU specific information about the virt state. */ | |
23 | if (blk_pread(s->blk, 0, s->fuse, filesize) != filesize) { | 26 | target_ulong virt; |
24 | error_setg(errp, "failed to read the initial flash content"); | 27 | target_ulong geilen; |
25 | + return; | 28 | - target_ulong resetvec; |
26 | } | 29 | + uint64_t resetvec; |
27 | } | 30 | |
28 | } | 31 | target_ulong mhartid; |
32 | /* | ||
33 | @@ -XXX,XX +XXX,XX @@ struct RISCVCPUConfig { | ||
34 | bool pmp; | ||
35 | bool epmp; | ||
36 | bool debug; | ||
37 | - uint64_t resetvec; | ||
38 | |||
39 | bool short_isa_string; | ||
40 | }; | ||
41 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/riscv/cpu.c | ||
44 | +++ b/target/riscv/cpu.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void set_vext_version(CPURISCVState *env, int vext_ver) | ||
46 | env->vext_ver = vext_ver; | ||
47 | } | ||
48 | |||
49 | -static void set_resetvec(CPURISCVState *env, target_ulong resetvec) | ||
50 | -{ | ||
51 | -#ifndef CONFIG_USER_ONLY | ||
52 | - env->resetvec = resetvec; | ||
53 | -#endif | ||
29 | -} | 54 | -} |
30 | - | 55 | - |
31 | -static void sifive_u_otp_reset(DeviceState *dev) | 56 | static void riscv_any_cpu_init(Object *obj) |
32 | -{ | 57 | { |
33 | - SiFiveUOTPState *s = SIFIVE_U_OTP(dev); | 58 | CPURISCVState *env = &RISCV_CPU(obj)->env; |
34 | 59 | @@ -XXX,XX +XXX,XX @@ static void rv32_imafcu_nommu_cpu_init(Object *obj) | |
35 | /* Initialize all fuses' initial value to 0xFFs */ | 60 | |
36 | memset(s->fuse, 0xff, sizeof(s->fuse)); | 61 | set_misa(env, MXL_RV32, RVI | RVM | RVA | RVF | RVC | RVU); |
37 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_reset(DeviceState *dev) | 62 | set_priv_version(env, PRIV_VERSION_1_10_0); |
38 | serial_data = s->serial; | 63 | - set_resetvec(env, DEFAULT_RSTVEC); |
39 | if (blk_pwrite(s->blk, index * SIFIVE_U_OTP_FUSE_WORD, | 64 | cpu->cfg.mmu = false; |
40 | &serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { | 65 | } |
41 | - error_report("write error index<%d>", index); | 66 | #endif |
42 | + error_setg(errp, "failed to write index<%d>", index); | 67 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) |
43 | + return; | 68 | riscv_set_feature(env, RISCV_FEATURE_DEBUG); |
44 | } | ||
45 | |||
46 | serial_data = ~(s->serial); | ||
47 | if (blk_pwrite(s->blk, (index + 1) * SIFIVE_U_OTP_FUSE_WORD, | ||
48 | &serial_data, SIFIVE_U_OTP_FUSE_WORD, 0) < 0) { | ||
49 | - error_report("write error index<%d>", index + 1); | ||
50 | + error_setg(errp, "failed to write index<%d>", index + 1); | ||
51 | + return; | ||
52 | } | ||
53 | } | 69 | } |
54 | 70 | ||
55 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_class_init(ObjectClass *klass, void *data) | 71 | - set_resetvec(env, cpu->cfg.resetvec); |
56 | 72 | ||
57 | device_class_set_props(dc, sifive_u_otp_properties); | 73 | #ifndef CONFIG_USER_ONLY |
58 | dc->realize = sifive_u_otp_realize; | 74 | if (cpu->cfg.ext_sstc) { |
59 | - dc->reset = sifive_u_otp_reset; | 75 | @@ -XXX,XX +XXX,XX @@ static Property riscv_cpu_properties[] = { |
60 | } | 76 | DEFINE_PROP_UINT64("marchid", RISCVCPU, cfg.marchid, RISCV_CPU_MARCHID), |
61 | 77 | DEFINE_PROP_UINT64("mimpid", RISCVCPU, cfg.mimpid, RISCV_CPU_MIMPID), | |
62 | static const TypeInfo sifive_u_otp_info = { | 78 | |
79 | - DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC), | ||
80 | +#ifndef CONFIG_USER_ONLY | ||
81 | + DEFINE_PROP_UINT64("resetvec", RISCVCPU, env.resetvec, DEFAULT_RSTVEC), | ||
82 | +#endif | ||
83 | |||
84 | DEFINE_PROP_BOOL("short-isa-string", RISCVCPU, cfg.short_isa_string, false), | ||
85 | |||
86 | diff --git a/target/riscv/machine.c b/target/riscv/machine.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/riscv/machine.c | ||
89 | +++ b/target/riscv/machine.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pmu_ctr_state = { | ||
91 | |||
92 | const VMStateDescription vmstate_riscv_cpu = { | ||
93 | .name = "cpu", | ||
94 | - .version_id = 4, | ||
95 | - .minimum_version_id = 4, | ||
96 | + .version_id = 5, | ||
97 | + .minimum_version_id = 5, | ||
98 | .post_load = riscv_cpu_post_load, | ||
99 | .fields = (VMStateField[]) { | ||
100 | VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), | ||
101 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_riscv_cpu = { | ||
102 | VMSTATE_UINT32(env.features, RISCVCPU), | ||
103 | VMSTATE_UINTTL(env.priv, RISCVCPU), | ||
104 | VMSTATE_UINTTL(env.virt, RISCVCPU), | ||
105 | - VMSTATE_UINTTL(env.resetvec, RISCVCPU), | ||
106 | + VMSTATE_UINT64(env.resetvec, RISCVCPU), | ||
107 | VMSTATE_UINTTL(env.mhartid, RISCVCPU), | ||
108 | VMSTATE_UINT64(env.mstatus, RISCVCPU), | ||
109 | VMSTATE_UINT64(env.mip, RISCVCPU), | ||
63 | -- | 110 | -- |
64 | 2.31.1 | 111 | 2.37.3 |
65 | |||
66 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alistair Francis <alistair.francis@wdc.com> | ||
1 | 2 | ||
3 | The resetvec for the OpenTitan machine ended up being set to an out of | ||
4 | date value, so let's fix that and bump it to the correct start address | ||
5 | (after the boot ROM) | ||
6 | |||
7 | Fixes: bf8803c64d75 "hw/riscv: opentitan: bump opentitan version" | ||
8 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Message-Id: <20220914101108.82571-3-alistair.francis@wdc.com> | ||
10 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | --- | ||
12 | hw/riscv/opentitan.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/riscv/opentitan.c | ||
18 | +++ b/hw/riscv/opentitan.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) | ||
20 | &error_abort); | ||
21 | object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus, | ||
22 | &error_abort); | ||
23 | - object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x20000490, | ||
24 | + object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x20000400, | ||
25 | &error_abort); | ||
26 | sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_fatal); | ||
27 | |||
28 | -- | ||
29 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alistair Francis <alistair.francis@wdc.com> | ||
1 | 2 | ||
3 | On the OpenTitan hardware the resetvec is fixed at the start of ROM. In | ||
4 | QEMU we don't run the ROM code and instead just jump to the next stage. | ||
5 | This means we need to be a little more flexible about what the resetvec | ||
6 | is. | ||
7 | |||
8 | This patch allows us to set the resetvec from the command line with | ||
9 | something like this: | ||
10 | -global driver=riscv.lowrisc.ibex.soc,property=resetvec,value=0x20000400 | ||
11 | |||
12 | This way as the next stage changes we can update the resetvec. | ||
13 | |||
14 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Message-Id: <20220914101108.82571-4-alistair.francis@wdc.com> | ||
17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
18 | --- | ||
19 | include/hw/riscv/opentitan.h | 2 ++ | ||
20 | hw/riscv/opentitan.c | 8 +++++++- | ||
21 | 2 files changed, 9 insertions(+), 1 deletion(-) | ||
22 | |||
23 | diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/include/hw/riscv/opentitan.h | ||
26 | +++ b/include/hw/riscv/opentitan.h | ||
27 | @@ -XXX,XX +XXX,XX @@ struct LowRISCIbexSoCState { | ||
28 | IbexTimerState timer; | ||
29 | IbexSPIHostState spi_host[OPENTITAN_NUM_SPI_HOSTS]; | ||
30 | |||
31 | + uint32_t resetvec; | ||
32 | + | ||
33 | MemoryRegion flash_mem; | ||
34 | MemoryRegion rom; | ||
35 | MemoryRegion flash_alias; | ||
36 | diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/hw/riscv/opentitan.c | ||
39 | +++ b/hw/riscv/opentitan.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) | ||
41 | &error_abort); | ||
42 | object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus, | ||
43 | &error_abort); | ||
44 | - object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x20000400, | ||
45 | + object_property_set_int(OBJECT(&s->cpus), "resetvec", s->resetvec, | ||
46 | &error_abort); | ||
47 | sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_fatal); | ||
48 | |||
49 | @@ -XXX,XX +XXX,XX @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) | ||
50 | memmap[IBEX_DEV_PERI].base, memmap[IBEX_DEV_PERI].size); | ||
51 | } | ||
52 | |||
53 | +static Property lowrisc_ibex_soc_props[] = { | ||
54 | + DEFINE_PROP_UINT32("resetvec", LowRISCIbexSoCState, resetvec, 0x20000400), | ||
55 | + DEFINE_PROP_END_OF_LIST() | ||
56 | +}; | ||
57 | + | ||
58 | static void lowrisc_ibex_soc_class_init(ObjectClass *oc, void *data) | ||
59 | { | ||
60 | DeviceClass *dc = DEVICE_CLASS(oc); | ||
61 | |||
62 | + device_class_set_props(dc, lowrisc_ibex_soc_props); | ||
63 | dc->realize = lowrisc_ibex_soc_realize; | ||
64 | /* Reason: Uses serial_hds in realize function, thus can't be used twice */ | ||
65 | dc->user_creatable = false; | ||
66 | -- | ||
67 | 2.37.3 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Frank Chang <frank.chang@sifive.com> | ||
1 | 2 | ||
3 | After RISCVException enum is introduced, riscv_csrrw_debug() returns | ||
4 | RISCV_EXCP_NONE to indicate there's no error. RISC-V vector GDB stub | ||
5 | should check the result against RISCV_EXCP_NONE instead of value 0. | ||
6 | Otherwise, 'E14' packet would be incorrectly reported for vector CSRs | ||
7 | when using "info reg vector" GDB command. | ||
8 | |||
9 | Signed-off-by: Frank Chang <frank.chang@sifive.com> | ||
10 | Reviewed-by: Jim Shu <jim.shu@sifive.com> | ||
11 | Reviewed-by: Tommy Wu <tommy.wu@sifive.com> | ||
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> | ||
14 | Message-Id: <20220918083245.13028-1-frank.chang@sifive.com> | ||
15 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
16 | --- | ||
17 | target/riscv/gdbstub.c | 4 ++-- | ||
18 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
19 | |||
20 | diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/riscv/gdbstub.c | ||
23 | +++ b/target/riscv/gdbstub.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_get_vector(CPURISCVState *env, GByteArray *buf, int n) | ||
25 | target_ulong val = 0; | ||
26 | int result = riscv_csrrw_debug(env, csrno, &val, 0, 0); | ||
27 | |||
28 | - if (result == 0) { | ||
29 | + if (result == RISCV_EXCP_NONE) { | ||
30 | return gdb_get_regl(buf, val); | ||
31 | } | ||
32 | |||
33 | @@ -XXX,XX +XXX,XX @@ static int riscv_gdb_set_vector(CPURISCVState *env, uint8_t *mem_buf, int n) | ||
34 | target_ulong val = ldtul_p(mem_buf); | ||
35 | int result = riscv_csrrw_debug(env, csrno, NULL, val, -1); | ||
36 | |||
37 | - if (result == 0) { | ||
38 | + if (result == RISCV_EXCP_NONE) { | ||
39 | return sizeof(target_ulong); | ||
40 | } | ||
41 | |||
42 | -- | ||
43 | 2.37.3 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Configuring a drive with "if=none" is meant for creation of a backend | 3 | SiFiveEState inherits from SysBusDevice while it's TypeInfo claims it to |
4 | only, it should not get automatically assigned to a device frontend. | 4 | inherit from TYPE_MACHINE. This is an inconsistency which can cause |
5 | Use "if=pflash" for the One-Time-Programmable device instead (like | 5 | undefined behavior such as memory corruption. |
6 | it is e.g. also done for the efuse device in hw/arm/xlnx-zcu102.c). | ||
7 | 6 | ||
8 | Since the old way of configuring the device has already been published | 7 | Change SiFiveEState to inherit from MachineState since it is registered |
9 | with the previous QEMU versions, we cannot remove this immediately, but | 8 | as a machine. |
10 | have to deprecate it and support it for at least two more releases. | ||
11 | 9 | ||
12 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 10 | Fixes: 0869490b1c ("riscv: sifive_e: Manually define the machine") |
13 | Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 11 | |
14 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 12 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> |
15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 13 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
16 | Message-id: 20211119102549.217755-1-thuth@redhat.com | 14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | Message-Id: <20220922075232.33653-1-shentey@gmail.com> | ||
17 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | 16 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
18 | --- | 17 | --- |
19 | docs/about/deprecated.rst | 6 ++++++ | 18 | include/hw/riscv/sifive_e.h | 3 ++- |
20 | hw/misc/sifive_u_otp.c | 9 ++++++++- | 19 | 1 file changed, 2 insertions(+), 1 deletion(-) |
21 | 2 files changed, 14 insertions(+), 1 deletion(-) | ||
22 | 20 | ||
23 | diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst | 21 | diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h |
24 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/docs/about/deprecated.rst | 23 | --- a/include/hw/riscv/sifive_e.h |
26 | +++ b/docs/about/deprecated.rst | 24 | +++ b/include/hw/riscv/sifive_e.h |
27 | @@ -XXX,XX +XXX,XX @@ as short-form boolean values, and passed to plugins as ``arg_name=on``. | 25 | @@ -XXX,XX +XXX,XX @@ |
28 | However, short-form booleans are deprecated and full explicit ``arg_name=on`` | 26 | #include "hw/riscv/riscv_hart.h" |
29 | form is preferred. | 27 | #include "hw/riscv/sifive_cpu.h" |
30 | 28 | #include "hw/gpio/sifive_gpio.h" | |
31 | +``-drive if=none`` for the sifive_u OTP device (since 6.2) | 29 | +#include "hw/boards.h" |
32 | +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | 30 | |
33 | + | 31 | #define TYPE_RISCV_E_SOC "riscv.sifive.e.soc" |
34 | +Using ``-drive if=none`` to configure the OTP device of the sifive_u | 32 | #define RISCV_E_SOC(obj) \ |
35 | +RISC-V machine is deprecated. Use ``-drive if=pflash`` instead. | 33 | @@ -XXX,XX +XXX,XX @@ typedef struct SiFiveESoCState { |
36 | + | 34 | |
37 | 35 | typedef struct SiFiveEState { | |
38 | QEMU Machine Protocol (QMP) commands | 36 | /*< private >*/ |
39 | ------------------------------------ | 37 | - SysBusDevice parent_obj; |
40 | diff --git a/hw/misc/sifive_u_otp.c b/hw/misc/sifive_u_otp.c | 38 | + MachineState parent_obj; |
41 | index XXXXXXX..XXXXXXX 100644 | 39 | |
42 | --- a/hw/misc/sifive_u_otp.c | 40 | /*< public >*/ |
43 | +++ b/hw/misc/sifive_u_otp.c | 41 | SiFiveESoCState soc; |
44 | @@ -XXX,XX +XXX,XX @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp) | ||
45 | TYPE_SIFIVE_U_OTP, SIFIVE_U_OTP_REG_SIZE); | ||
46 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); | ||
47 | |||
48 | - dinfo = drive_get_next(IF_NONE); | ||
49 | + dinfo = drive_get_next(IF_PFLASH); | ||
50 | + if (!dinfo) { | ||
51 | + dinfo = drive_get_next(IF_NONE); | ||
52 | + if (dinfo) { | ||
53 | + warn_report("using \"-drive if=none\" for the OTP is deprecated, " | ||
54 | + "use \"-drive if=pflash\" instead."); | ||
55 | + } | ||
56 | + } | ||
57 | if (dinfo) { | ||
58 | int ret; | ||
59 | uint64_t perm; | ||
60 | -- | 42 | -- |
61 | 2.31.1 | 43 | 2.37.3 |
62 | |||
63 | diff view generated by jsdifflib |