Skip to content

RFC real ll/sc emulation

Nicholas Piggin qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3accel/tcg: Fix TCG TLB coherency race with physical dirty bit clearingaccel/stubs/tcg-stub.c accel/tcg/cputlb.c include/exec/exec-all.h+33 -190 replies
2/3tcg: add a ll/sc protection facilityaccel/tcg/cputlb.c hw/core/cpu-common.c hw/vfio/common.c +8 more+266 -71 reply
3/3target/ppc: Implement reservation protection for larx/stcxtarget/ppc/cpu-param.h target/ppc/cpu_init.c target/ppc/helper.h +2 more+168 -1021 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/3] real ll/sc emulation

I've been toying with how we might do a more faithful ll/sc emulation. Our cmpxchg based one actually had problems on some firmware code we're testing.

The using the dirty memory bitmap to detect stores coming from other CPUs and invalidating active protection / reservations seems to be a possibility. This passes some basic atomic and locking stress tests with mttcg, and boots Linux.

Excuse some of the hacky / ugly / unfinished bits of code, I missed getting into details of vfio, migration, and making it clean. Just wanted to hear thoughts on the general idea at the moment.

The code doesn't seem to be _terribly_ tricky, but there are some tricks around the store-conditional side of it where we have to take a mutex, do the tlb lookup with possible recursion into the code protected by that mutex, verify the protection is still active, and then modify memory.

There is only a single lock now, but if that beomes a problem we *might* be able to split it via physical address hash. But that doesn't help uncontended performance or contention on the same address, which are probably the two most important cases.

(I will submit the TCG TLB coherency fix patch separately, difficulty at the moment is creating a test case for it that does not require subsequent patches!)

Thanks,
Nick

Nicholas Piggin (3):
accel/tcg: Fix TCG TLB coherency race with physical dirty bit clearing
tcg: add a ll/sc protection facility
target/ppc: Implement reservation protection for larx/stcx

 include/exec/cputlb.h    |   7 ++
 include/exec/exec-all.h  |   1 -
 include/exec/ram_addr.h  |  42 ++++++-
 include/exec/ramlist.h   |  10 ++
 include/hw/core/cpu.h    |   5 +
 target/ppc/cpu-param.h   |   4 +
 target/ppc/helper.h      |   2 +
 accel/stubs/tcg-stub.c   |   4 -
 accel/tcg/cputlb.c       | 235 ++++++++++++++++++++++++++++++++++++---
 hw/core/cpu-common.c     |   5 +
 hw/vfio/common.c         |   2 +-
 hw/virtio/vhost.c        |   1 +
 system/memory.c          |   3 +
 system/physmem.c         |   7 ++
 target/ppc/cpu_init.c    |   4 +
 target/ppc/mem_helper.c  | 132 ++++++++++++++++++++++
 target/ppc/translate.c   | 128 +++++----------------
 system/memory_ldst.c.inc |   3 +-
 18 files changed, 467 insertions(+), 128 deletions(-)
Signature · 1 line
2.42.0