[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/39] KVM: dirty ring: add missing memory barrier
From: |
Paolo Bonzini |
Subject: |
[PULL 10/39] KVM: dirty ring: add missing memory barrier |
Date: |
Thu, 1 Sep 2022 20:24:00 +0200 |
The KVM_DIRTY_GFN_F_DIRTY flag ensures that the entry is valid. If
the read of the fields are not ordered after the read of the flag,
QEMU might see stale values.
Cc: Gavin Shan <gshan@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
accel/kvm/kvm-all.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 8d81ab74de..136c8eaed3 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -719,7 +719,11 @@ static void kvm_dirty_ring_mark_page(KVMState *s, uint32_t
as_id,
static bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn)
{
- return gfn->flags == KVM_DIRTY_GFN_F_DIRTY;
+ /*
+ * Read the flags before the value. Pairs with barrier in
+ * KVM's kvm_dirty_ring_push() function.
+ */
+ return qatomic_load_acquire(&gfn->flags) == KVM_DIRTY_GFN_F_DIRTY;
}
static void dirty_gfn_set_collected(struct kvm_dirty_gfn *gfn)
--
2.37.2
- [PULL 00/39] i386, SCSI, build system changes for 2022-09-01, Paolo Bonzini, 2022/09/01
- [PULL 01/39] esp: Handle CMD_BUSRESET by resetting the SCSI bus, Paolo Bonzini, 2022/09/01
- [PULL 03/39] scsi: Reject commands if the CDB length exceeds buf_len, Paolo Bonzini, 2022/09/01
- [PULL 04/39] i386: reset KVM nested state upon CPU reset, Paolo Bonzini, 2022/09/01
- [PULL 02/39] scsi: Add buf_len parameter to scsi_req_new(), Paolo Bonzini, 2022/09/01
- [PULL 06/39] configure: improve error for ucontext coroutine backend, Paolo Bonzini, 2022/09/01
- [PULL 05/39] i386: do kvm_put_msr_feature_control() first thing when vCPU is reset, Paolo Bonzini, 2022/09/01
- [PULL 07/39] meson: be strict for boolean options, Paolo Bonzini, 2022/09/01
- [PULL 08/39] meson: remove dead code, Paolo Bonzini, 2022/09/01
- [PULL 11/39] tests/tcg: x86_64: improve consistency with i386, Paolo Bonzini, 2022/09/01
- [PULL 10/39] KVM: dirty ring: add missing memory barrier,
Paolo Bonzini <=
- [PULL 09/39] meson: remove dead assignments, Paolo Bonzini, 2022/09/01
- [PULL 14/39] target/i386: DPPS rounding fix, Paolo Bonzini, 2022/09/01
- [PULL 12/39] tests/tcg: i386: extend BMI test, Paolo Bonzini, 2022/09/01
- [PULL 13/39] target/i386: fix PHSUB* instructions with dest=src, Paolo Bonzini, 2022/09/01
- [PULL 17/39] target/i386: formatting fixes, Paolo Bonzini, 2022/09/01
- [PULL 16/39] target/i386: do not use MOVL to move data between SSE registers, Paolo Bonzini, 2022/09/01
- [PULL 15/39] tests/tcg: i386: add SSE tests, Paolo Bonzini, 2022/09/01
- [PULL 19/39] target/i386: Rework sse_op_table1, Paolo Bonzini, 2022/09/01
- [PULL 21/39] target/i386: Move 3DNOW decoder, Paolo Bonzini, 2022/09/01
- [PULL 20/39] target/i386: Rework sse_op_table6/7, Paolo Bonzini, 2022/09/01