Skip to contentSkip to conversation

riscv: sifive_test: Allow 16-bit writes to memory region

PATCH Applied Nathan Chancellor 4 participants 10 messages Sep 1, 2020 – Sep 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: sifive_test: Allow 16-bit writes to memory region

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75

Signature · 1 line
2.28.0
#1 lore raw
Quoted 51 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +0 -0
index 0c78fb2c93..8c70dd69df 100644

hw/riscv/sifive_test.c static const MemoryRegionOps sifive_test_ops = { · line 60

Quoted 2 lines
hw/riscv/sifive_test.c +0 -0
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,

Apropos, why is this native endian?
The write handler seems to ignore target endian-ness, looks like a bug ...

Quoted 10 lines
hw/riscv/sifive_test.c +1 -1
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75

Signature · 1 line
2.28.0
#2 lore raw
Quoted 47 lines · Michael S. Tsirkin
Quoted 46 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

hw/riscv/sifive_test.c static const MemoryRegionOps sifive_test_ops = { · line 60

Quoted 7 lines
hw/riscv/sifive_test.c +0 -0
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,

Apropos, why is this native endian?
The write handler seems to ignore target endian-ness, looks like a bug ...

patch itself looks fine

Quoted 10 lines
Quoted 10 lines
hw/riscv/sifive_test.c +1 -1
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75

Signature · 1 line
2.28.0
Reviewed-by on v1 1/1
#3 lore raw
In reply to Nathan Chancellor
Quoted 35 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Quoted 4 lines
Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

Alistair

Quoted 27 lines

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75 --
2.28.0

#4 lore raw
In reply to Nathan Chancellor
Quoted 35 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Quoted 4 lines
Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 27 lines

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75 --
2.28.0

#5 lore raw

Quoting Alistair Francis (2020-09-01 18:59:29)

Quoted 37 lines
Quoted 35 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Quoted 8 lines
Quoted 4 lines
Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

Thanks!

Applied to riscv-to-apply.next

FYI, I'm hoping to pull this patch into the upcoming 5.0.1 stable release. The freeze is scheduled for 2020-09-20, I will apply this if it hits master before then.

Quoted 31 lines

Alistair

Quoted 27 lines

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75 --
2.28.0

#6 lore raw
Quoted 44 lines · Michael Roth

Quoting Alistair Francis (2020-09-01 18:59:29)

Quoted 42 lines
Quoted 39 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")
Quoted 7 lines
Quoted 3 lines

Thanks!

Applied to riscv-to-apply.next

FYI, I'm hoping to pull this patch into the upcoming 5.0.1 stable release. The freeze is scheduled for 2020-09-20, I will apply this if it hits master before then.

I just sent a PR with this patch. Is this still on track to make it into 5.0.1?

Alistair

Quoted 32 lines
Quoted 32 lines

Alistair

Quoted 27 lines

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75 --
2.28.0

#7 lore raw

Quoting Alistair Francis (2020-09-10 13:10:43)

Quoted 47 lines · Michael Roth
Quoted 46 lines

Quoting Alistair Francis (2020-09-01 18:59:29)

Quoted 44 lines
Quoted 35 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Quoted 4 lines
Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

Thanks!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Applied to riscv-to-apply.next

FYI, I'm hoping to pull this patch into the upcoming 5.0.1 stable release. The freeze is scheduled for 2020-09-20, I will apply this if it hits master before then.

I just sent a PR with this patch. Is this still on track to make it into 5.0.1?

Since it's not likely to invalidate any testing on my end outside of the ones built into QEMU I can probably still slip it in if it hits master by Monday, or maybe just grab it from your tree.

Quoted 35 lines

Alistair

Quoted 32 lines
Quoted 32 lines

Alistair

Quoted 27 lines

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75 --
2.28.0

#8 lore raw
Quoted 55 lines · Michael Roth

Quoting Alistair Francis (2020-09-10 13:10:43)

Quoted 53 lines · Michael Roth
Quoted 51 lines

Quoting Alistair Francis (2020-09-01 18:59:29)

Quoted 37 lines
Quoted 35 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Quoted 8 lines
Quoted 4 lines
Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

Thanks!

Applied to riscv-to-apply.next

FYI, I'm hoping to pull this patch into the upcoming 5.0.1 stable release. The freeze is scheduled for 2020-09-20, I will apply this if it hits master before then.

Quoted 5 lines
Quoted 1 line

I just sent a PR with this patch. Is this still on track to make it into 5.0.1?

Since it's not likely to invalidate any testing on my end outside of the ones built into QEMU I can probably still slip it in if it hits master by Monday, or maybe just grab it from your tree.

This is in master now, I hope that's enough time to make it in.

Let me know if you want me to do anything else.

Alistair

Quoted 36 lines
Quoted 36 lines

Alistair

Quoted 32 lines
Quoted 32 lines

Alistair

Quoted 27 lines

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75 --
2.28.0

#9 lore raw

Quoting Alistair Francis (2020-09-14 11:07:26)

Quoted 56 lines · Michael Roth
Quoted 55 lines

Quoting Alistair Francis (2020-09-10 13:10:43)

Quoted 53 lines · Michael Roth
Quoted 51 lines

Quoting Alistair Francis (2020-09-01 18:59:29)

Quoted 37 lines
Quoted 35 lines · Nathan Chancellor

When shutting down the machine running a mainline Linux kernel, the following error happens:

$ build/riscv64-softmmu/qemu-system-riscv64 -bios default -M virt \
    -display none -initrd rootfs.cpio -kernel Image -m 512m \
    -nodefaults -serial mon:stdio
...
Requesting system poweroff
[    4.999630] reboot: Power down
sbi_trap_error: hart0: trap handler failed (error -2)
sbi_trap_error: hart0: mcause=0x0000000000000007 mtval=0x0000000000100000
sbi_trap_error: hart0: mepc=0x000000008000d4cc mstatus=0x0000000000001822
sbi_trap_error: hart0: ra=0x000000008000999e sp=0x0000000080015c78
sbi_trap_error: hart0: gp=0xffffffe000e76610 tp=0xffffffe0081b89c0
sbi_trap_error: hart0: s0=0x0000000080015c88 s1=0x0000000000000040
sbi_trap_error: hart0: a0=0x0000000000000000 a1=0x0000000080004024
sbi_trap_error: hart0: a2=0x0000000080004024 a3=0x0000000080004024
sbi_trap_error: hart0: a4=0x0000000000100000 a5=0x0000000000005555
sbi_trap_error: hart0: a6=0x0000000000004024 a7=0x0000000080011158
sbi_trap_error: hart0: s2=0x0000000000000000 s3=0x0000000080016000
sbi_trap_error: hart0: s4=0x0000000000000000 s5=0x0000000000000000
sbi_trap_error: hart0: s6=0x0000000000000001 s7=0x0000000000000000
sbi_trap_error: hart0: s8=0x0000000000000000 s9=0x0000000000000000
sbi_trap_error: hart0: s10=0x0000000000000000 s11=0x0000000000000008
sbi_trap_error: hart0: t0=0x0000000000000000 t1=0x0000000000000000
sbi_trap_error: hart0: t2=0x0000000000000000 t3=0x0000000000000000
sbi_trap_error: hart0: t4=0x0000000000000000 t5=0x0000000000000000
sbi_trap_error: hart0: t6=0x0000000000000000

The kernel does a 16-bit write when powering off the machine, which was allowed before commit 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid""). Make min_access_size match reality so that the machine can shut down properly now.

Quoted 8 lines
Quoted 4 lines
Fixes 88a07990fa ("SiFive RISC-V Test Finisher")
Fixes 5d971f9e67 ("memory: Revert "memory: accept mismatching sizes in memory_region_access_valid"")

Thanks!

Applied to riscv-to-apply.next

FYI, I'm hoping to pull this patch into the upcoming 5.0.1 stable release. The freeze is scheduled for 2020-09-20, I will apply this if it hits master before then.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I just sent a PR with this patch. Is this still on track to make it into 5.0.1?

Since it's not likely to invalidate any testing on my end outside of the ones built into QEMU I can probably still slip it in if it hits master by Monday, or maybe just grab it from your tree.

This is in master now, I hope that's enough time to make it in.

Yes I pulled it in yesterday:

https://github.com/mdroth/qemu/commits/stable-5.0-staging

Quoted 2 lines

Let me know if you want me to do anything else.

Thanks!

Quoted 39 lines

Alistair

Quoted 36 lines
Quoted 36 lines

Alistair

Quoted 32 lines
Quoted 32 lines

Alistair

Quoted 27 lines

---

Please let me know if the tags are wrong or inappropriate, this is my first QEMU patch.

 hw/riscv/sifive_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/riscv/sifive_test.c +1 -1
index 0c78fb2c93..8c70dd69df 100644
@@ -59,7 +59,7 @@ static const MemoryRegionOps sifive_test_ops = {
     .write = sifive_test_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
     .valid = {
-        .min_access_size = 4,
+        .min_access_size = 2,
         .max_access_size = 4
     }
 };

base-commit: 2f4c51c0f384d7888a04b4815861e6d5fd244d75 --
2.28.0