[Qemu-commits] [qemu/qemu] bbdcc8: target/riscv/kvm: change KVM_REG_RISCV_FP_F to u32

2024-05-13 Thread Alex Bennée via Qemu-commits
  Branch: refs/heads/stable-8.2
  Home:   https://github.com/qemu/qemu
  Commit: bbdcc89678daa5cb131ef22a6cd41a5f7f9dcea9
  
https://github.com/qemu/qemu/commit/bbdcc89678daa5cb131ef22a6cd41a5f7f9dcea9
  Author: Daniel Henrique Barboza 
  Date:   2024-04-27 (Sat, 27 Apr 2024)

  Changed paths:
M target/riscv/kvm/kvm-cpu.c

  Log Message:
  ---
  target/riscv/kvm: change KVM_REG_RISCV_FP_F to u32

KVM_REG_RISCV_FP_F regs have u32 size according to the API, but by using
kvm_riscv_reg_id() in RISCV_FP_F_REG() we're returning u64 sizes when
running with TARGET_RISCV64. The most likely reason why no one noticed
this is because we're not implementing kvm_cpu_synchronize_state() in
RISC-V yet.

Create a new helper that returns a KVM ID with u32 size and use it in
RISCV_FP_F_REG().

Reported-by: Andrew Jones 
Signed-off-by: Daniel Henrique Barboza 
Reviewed-by: Andrew Jones 
Message-ID: <20231208183835.2411523-2-dbarb...@ventanamicro.com>
Signed-off-by: Alistair Francis 
(cherry picked from commit 49c211ffca00fdf7c0c29072c224e88527a14838)
Signed-off-by: Michael Tokarev 


  Commit: 125b95d79e746cbab6b72683b3382dd372e38c61
  
https://github.com/qemu/qemu/commit/125b95d79e746cbab6b72683b3382dd372e38c61
  Author: Daniel Henrique Barboza 
  Date:   2024-04-27 (Sat, 27 Apr 2024)

  Changed paths:
M target/riscv/kvm/kvm-cpu.c

  Log Message:
  ---
  target/riscv/kvm: change KVM_REG_RISCV_FP_D to u64

KVM_REG_RISCV_FP_D regs are always u64 size. Using kvm_riscv_reg_id() in
RISCV_FP_D_REG() ends up encoding the wrong size if we're running with
TARGET_RISCV32.

Create a new helper that returns a KVM ID with u64 size and use it with
RISCV_FP_D_REG().

Reported-by: Andrew Jones 
Signed-off-by: Daniel Henrique Barboza 
Reviewed-by: Andrew Jones 
Message-ID: <20231208183835.2411523-3-dbarb...@ventanamicro.com>
Signed-off-by: Alistair Francis 
(cherry picked from commit 450bd6618fda3d2e2ab02b2fce1c79efd5b66084)
Signed-off-by: Michael Tokarev 


  Commit: cbae1080988e0f1af0fb4c816205f7647f6de16f
  
https://github.com/qemu/qemu/commit/cbae1080988e0f1af0fb4c816205f7647f6de16f
  Author: Daniel Henrique Barboza 
  Date:   2024-04-27 (Sat, 27 Apr 2024)

  Changed paths:
M target/riscv/kvm/kvm-cpu.c

  Log Message:
  ---
  target/riscv/kvm: change timer regs size to u64

KVM_REG_RISCV_TIMER regs are always u64 according to the KVM API, but at
this moment we'll return u32 regs if we're running a RISCV32 target.

Use the kvm_riscv_reg_id_u64() helper in RISCV_TIMER_REG() to fix it.

Reported-by: Andrew Jones 
Signed-off-by: Daniel Henrique Barboza 
Reviewed-by: Andrew Jones 
Message-ID: <20231208183835.2411523-4-dbarb...@ventanamicro.com>
Signed-off-by: Alistair Francis 
(cherry picked from commit 10f86d1b845087d14b58d65dd2a6e3411d1b6529)
Signed-off-by: Michael Tokarev 


  Commit: 55b88e61edcd472ad8e1222acacaf7ded0f18c20
  
https://github.com/qemu/qemu/commit/55b88e61edcd472ad8e1222acacaf7ded0f18c20
  Author: Li Zhijian 
  Date:   2024-04-28 (Sun, 28 Apr 2024)

  Changed paths:
M migration/colo.c

  Log Message:
  ---
  migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion 
`!qemu_in_coroutine()' failed.

bdrv_activate_all() should not be called from the coroutine context, move
it to the QEMU thread colo_process_incoming_thread() with the bql_lock
protected.

The backtrace is as follows:
 #4  0x561af7948362 in bdrv_graph_rdlock_main_loop () at 
../block/graph-lock.c:260
 #5  0x561af7907a68 in graph_lockable_auto_lock_mainloop (x=0x7fd29810be7b) 
at /patch/to/qemu/include/block/graph-lock.h:259
 #6  0x561af79167d1 in bdrv_activate_all (errp=0x7fd29810bed0) at 
../block.c:6906
 #7  0x561af762b4af in colo_incoming_co () at ../migration/colo.c:935
 #8  0x561af7607e57 in process_incoming_migration_co (opaque=0x0) at 
../migration/migration.c:793
 #9  0x561af7adbeeb in coroutine_trampoline (i0=-106876144, i1=22042) at 
../util/coroutine-ucontext.c:175
 #10 0x7fd2a5cf21c0 in  () at /lib64/libc.so.6

Cc: qemu-sta...@nongnu.org
Cc: Fabiano Rosas 
Closes: https://gitlab.com/qemu-project/qemu/-/issues/2277
Fixes: 2b3912f135 ("block: Mark bdrv_first_blk() and bdrv_is_root_node() 
GRAPH_RDLOCK")
Signed-off-by: Li Zhijian 
Reviewed-by: Zhang Chen 
Tested-by: Zhang Chen 
Reviewed-by: Fabiano Rosas 
Link: https://lore.kernel.org/r/20240417025634.1014582-1-lizhij...@fujitsu.com
Signed-off-by: Peter Xu 
(cherry picked from commit 2cc637f1ea08d2a1b19fc5b1a30bc609f948de93)
Signed-off-by: Michael Tokarev 
(Mjt: fixup bql_lock() => qemu_mutex_lock_iothread() for 
v8.2.0-444-g195801d700c0
 "system/cpus: rename qemu_mutex_lock_iothread() to bql_lock()")


  Commit: 6fee9efc2e9e3e32c080462b02e9f69f7060316d
  
https://github.com/qemu/qemu/commit/6fee9efc2e9e3e32c080462b02e9f69f7060316d
  Author: Michael Tokarev 
  Date:   2024-04-28 (Sun, 28 Apr 2024)

  Changed paths:
M linux-user/syscall.c

  Log Message:
  ---
  linux-user: do_setsockopt: fix 

[Qemu-commits] [qemu/qemu] bbdcc8: target/riscv/kvm: change KVM_REG_RISCV_FP_F to u32

2024-04-28 Thread Eric Blake via Qemu-commits
  Branch: refs/heads/staging-8.2
  Home:   https://github.com/qemu/qemu
  Commit: bbdcc89678daa5cb131ef22a6cd41a5f7f9dcea9
  
https://github.com/qemu/qemu/commit/bbdcc89678daa5cb131ef22a6cd41a5f7f9dcea9
  Author: Daniel Henrique Barboza 
  Date:   2024-04-27 (Sat, 27 Apr 2024)

  Changed paths:
M target/riscv/kvm/kvm-cpu.c

  Log Message:
  ---
  target/riscv/kvm: change KVM_REG_RISCV_FP_F to u32

KVM_REG_RISCV_FP_F regs have u32 size according to the API, but by using
kvm_riscv_reg_id() in RISCV_FP_F_REG() we're returning u64 sizes when
running with TARGET_RISCV64. The most likely reason why no one noticed
this is because we're not implementing kvm_cpu_synchronize_state() in
RISC-V yet.

Create a new helper that returns a KVM ID with u32 size and use it in
RISCV_FP_F_REG().

Reported-by: Andrew Jones 
Signed-off-by: Daniel Henrique Barboza 
Reviewed-by: Andrew Jones 
Message-ID: <20231208183835.2411523-2-dbarb...@ventanamicro.com>
Signed-off-by: Alistair Francis 
(cherry picked from commit 49c211ffca00fdf7c0c29072c224e88527a14838)
Signed-off-by: Michael Tokarev 


  Commit: 125b95d79e746cbab6b72683b3382dd372e38c61
  
https://github.com/qemu/qemu/commit/125b95d79e746cbab6b72683b3382dd372e38c61
  Author: Daniel Henrique Barboza 
  Date:   2024-04-27 (Sat, 27 Apr 2024)

  Changed paths:
M target/riscv/kvm/kvm-cpu.c

  Log Message:
  ---
  target/riscv/kvm: change KVM_REG_RISCV_FP_D to u64

KVM_REG_RISCV_FP_D regs are always u64 size. Using kvm_riscv_reg_id() in
RISCV_FP_D_REG() ends up encoding the wrong size if we're running with
TARGET_RISCV32.

Create a new helper that returns a KVM ID with u64 size and use it with
RISCV_FP_D_REG().

Reported-by: Andrew Jones 
Signed-off-by: Daniel Henrique Barboza 
Reviewed-by: Andrew Jones 
Message-ID: <20231208183835.2411523-3-dbarb...@ventanamicro.com>
Signed-off-by: Alistair Francis 
(cherry picked from commit 450bd6618fda3d2e2ab02b2fce1c79efd5b66084)
Signed-off-by: Michael Tokarev 


  Commit: cbae1080988e0f1af0fb4c816205f7647f6de16f
  
https://github.com/qemu/qemu/commit/cbae1080988e0f1af0fb4c816205f7647f6de16f
  Author: Daniel Henrique Barboza 
  Date:   2024-04-27 (Sat, 27 Apr 2024)

  Changed paths:
M target/riscv/kvm/kvm-cpu.c

  Log Message:
  ---
  target/riscv/kvm: change timer regs size to u64

KVM_REG_RISCV_TIMER regs are always u64 according to the KVM API, but at
this moment we'll return u32 regs if we're running a RISCV32 target.

Use the kvm_riscv_reg_id_u64() helper in RISCV_TIMER_REG() to fix it.

Reported-by: Andrew Jones 
Signed-off-by: Daniel Henrique Barboza 
Reviewed-by: Andrew Jones 
Message-ID: <20231208183835.2411523-4-dbarb...@ventanamicro.com>
Signed-off-by: Alistair Francis 
(cherry picked from commit 10f86d1b845087d14b58d65dd2a6e3411d1b6529)
Signed-off-by: Michael Tokarev 


  Commit: 55b88e61edcd472ad8e1222acacaf7ded0f18c20
  
https://github.com/qemu/qemu/commit/55b88e61edcd472ad8e1222acacaf7ded0f18c20
  Author: Li Zhijian 
  Date:   2024-04-28 (Sun, 28 Apr 2024)

  Changed paths:
M migration/colo.c

  Log Message:
  ---
  migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion 
`!qemu_in_coroutine()' failed.

bdrv_activate_all() should not be called from the coroutine context, move
it to the QEMU thread colo_process_incoming_thread() with the bql_lock
protected.

The backtrace is as follows:
 #4  0x561af7948362 in bdrv_graph_rdlock_main_loop () at 
../block/graph-lock.c:260
 #5  0x561af7907a68 in graph_lockable_auto_lock_mainloop (x=0x7fd29810be7b) 
at /patch/to/qemu/include/block/graph-lock.h:259
 #6  0x561af79167d1 in bdrv_activate_all (errp=0x7fd29810bed0) at 
../block.c:6906
 #7  0x561af762b4af in colo_incoming_co () at ../migration/colo.c:935
 #8  0x561af7607e57 in process_incoming_migration_co (opaque=0x0) at 
../migration/migration.c:793
 #9  0x561af7adbeeb in coroutine_trampoline (i0=-106876144, i1=22042) at 
../util/coroutine-ucontext.c:175
 #10 0x7fd2a5cf21c0 in  () at /lib64/libc.so.6

Cc: qemu-sta...@nongnu.org
Cc: Fabiano Rosas 
Closes: https://gitlab.com/qemu-project/qemu/-/issues/2277
Fixes: 2b3912f135 ("block: Mark bdrv_first_blk() and bdrv_is_root_node() 
GRAPH_RDLOCK")
Signed-off-by: Li Zhijian 
Reviewed-by: Zhang Chen 
Tested-by: Zhang Chen 
Reviewed-by: Fabiano Rosas 
Link: https://lore.kernel.org/r/20240417025634.1014582-1-lizhij...@fujitsu.com
Signed-off-by: Peter Xu 
(cherry picked from commit 2cc637f1ea08d2a1b19fc5b1a30bc609f948de93)
Signed-off-by: Michael Tokarev 
(Mjt: fixup bql_lock() => qemu_mutex_lock_iothread() for 
v8.2.0-444-g195801d700c0
 "system/cpus: rename qemu_mutex_lock_iothread() to bql_lock()")


  Commit: 6fee9efc2e9e3e32c080462b02e9f69f7060316d
  
https://github.com/qemu/qemu/commit/6fee9efc2e9e3e32c080462b02e9f69f7060316d
  Author: Michael Tokarev 
  Date:   2024-04-28 (Sun, 28 Apr 2024)

  Changed paths:
M linux-user/syscall.c

  Log Message:
  ---
  linux-user: do_setsockopt: fix