Skip to content

Commit 09e0cd7

Browse files
committed
Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20200722-1' into staging
This PR contains a few RISC-V fixes. The main fix is the correction of the goldfish RTC time. On top of that some small fixes to the recently added vector extensions have been added (including an assert that fixed a coverity report). There is a change in the SiFive E debug memory size to match hardware. Finally there is a fix for PMP accesses. # gpg: Signature made Wed 22 Jul 2020 17:43:59 BST # gpg: using RSA key F6C4AC46D4934868D3B8CE8F21E10D29DF977054 # gpg: Good signature from "Alistair Francis <[email protected]>" [full] # Primary key fingerprint: F6C4 AC46 D493 4868 D3B8 CE8F 21E1 0D29 DF97 7054 * remotes/alistair/tags/pull-riscv-to-apply-20200722-1: target/riscv: Fix the range of pmpcfg of CSR funcion table hw/riscv: sifive_e: Correct debug block size target/riscv: fix vector index load/store constraints target/riscv: Quiet Coverity complains about vamo* goldfish_rtc: Fix non-atomic read behaviour of TIME_LOW/TIME_HIGH Signed-off-by: Peter Maydell <[email protected]>
2 parents 8ffa52c + 8ba26b0 commit 09e0cd7

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

hw/riscv/sifive_e.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static const struct MemmapEntry {
5454
hwaddr base;
5555
hwaddr size;
5656
} sifive_e_memmap[] = {
57-
[SIFIVE_E_DEBUG] = { 0x0, 0x100 },
57+
[SIFIVE_E_DEBUG] = { 0x0, 0x1000 },
5858
[SIFIVE_E_MROM] = { 0x1000, 0x2000 },
5959
[SIFIVE_E_OTP] = { 0x20000, 0x2000 },
6060
[SIFIVE_E_CLINT] = { 0x2000000, 0x10000 },

hw/rtc/goldfish_rtc.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,22 @@ static uint64_t goldfish_rtc_read(void *opaque, hwaddr offset,
9494
GoldfishRTCState *s = opaque;
9595
uint64_t r = 0;
9696

97+
/*
98+
* From the documentation linked at the top of the file:
99+
*
100+
* To read the value, the kernel must perform an IO_READ(TIME_LOW), which
101+
* returns an unsigned 32-bit value, before an IO_READ(TIME_HIGH), which
102+
* returns a signed 32-bit value, corresponding to the higher half of the
103+
* full value.
104+
*/
97105
switch (offset) {
98106
case RTC_TIME_LOW:
99-
r = goldfish_rtc_get_count(s) & 0xffffffff;
107+
r = goldfish_rtc_get_count(s);
108+
s->time_high = r >> 32;
109+
r &= 0xffffffff;
100110
break;
101111
case RTC_TIME_HIGH:
102-
r = goldfish_rtc_get_count(s) >> 32;
112+
r = s->time_high;
103113
break;
104114
case RTC_ALARM_LOW:
105115
r = s->alarm_next & 0xffffffff;
@@ -216,7 +226,7 @@ static const MemoryRegionOps goldfish_rtc_ops = {
216226

217227
static const VMStateDescription goldfish_rtc_vmstate = {
218228
.name = TYPE_GOLDFISH_RTC,
219-
.version_id = 1,
229+
.version_id = 2,
220230
.pre_save = goldfish_rtc_pre_save,
221231
.post_load = goldfish_rtc_post_load,
222232
.fields = (VMStateField[]) {
@@ -225,6 +235,7 @@ static const VMStateDescription goldfish_rtc_vmstate = {
225235
VMSTATE_UINT32(alarm_running, GoldfishRTCState),
226236
VMSTATE_UINT32(irq_pending, GoldfishRTCState),
227237
VMSTATE_UINT32(irq_enabled, GoldfishRTCState),
238+
VMSTATE_UINT32(time_high, GoldfishRTCState),
228239
VMSTATE_END_OF_LIST()
229240
}
230241
};

include/hw/rtc/goldfish_rtc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef struct GoldfishRTCState {
4141
uint32_t alarm_running;
4242
uint32_t irq_pending;
4343
uint32_t irq_enabled;
44+
uint32_t time_high;
4445
} GoldfishRTCState;
4546

4647
#endif

target/riscv/csr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ static riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = {
13531353
[CSR_MTINST] = { hmode, read_mtinst, write_mtinst },
13541354

13551355
/* Physical Memory Protection */
1356-
[CSR_PMPCFG0 ... CSR_PMPADDR9] = { pmp, read_pmpcfg, write_pmpcfg },
1356+
[CSR_PMPCFG0 ... CSR_PMPCFG3] = { pmp, read_pmpcfg, write_pmpcfg },
13571357
[CSR_PMPADDR0 ... CSR_PMPADDR15] = { pmp, read_pmpaddr, write_pmpaddr },
13581358

13591359
/* Performance Counters */

target/riscv/insn_trans/trans_rvv.inc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,21 @@ static bool ld_index_op(DisasContext *s, arg_rnfvm *a, uint8_t seq)
513513
return ldst_index_trans(a->rd, a->rs1, a->rs2, data, fn, s);
514514
}
515515

516+
/*
517+
* For vector indexed segment loads, the destination vector register
518+
* groups cannot overlap the source vector register group (specified by
519+
* `vs2`), else an illegal instruction exception is raised.
520+
*/
516521
static bool ld_index_check(DisasContext *s, arg_rnfvm* a)
517522
{
518523
return (vext_check_isa_ill(s) &&
519524
vext_check_overlap_mask(s, a->rd, a->vm, false) &&
520525
vext_check_reg(s, a->rd, false) &&
521526
vext_check_reg(s, a->rs2, false) &&
522-
vext_check_nf(s, a->nf));
527+
vext_check_nf(s, a->nf) &&
528+
((a->nf == 1) ||
529+
vext_check_overlap_group(a->rd, a->nf << s->lmul,
530+
a->rs2, 1 << s->lmul)));
523531
}
524532

525533
GEN_VEXT_TRANS(vlxb_v, 0, rnfvm, ld_index_op, ld_index_check)
@@ -733,6 +741,7 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq)
733741
g_assert_not_reached();
734742
#endif
735743
} else {
744+
assert(seq < ARRAY_SIZE(fnsw));
736745
fn = fnsw[seq];
737746
}
738747
}

0 commit comments

Comments
 (0)