[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 40/58] PPC: Fix sync instructions problem in SMP
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH 40/58] PPC: Fix sync instructions problem in SMP |
Date: |
Wed, 14 Sep 2011 10:43:04 +0200 |
From: Elie Richa <address@hidden>
In the current emulation of the load-and-reserve (lwarx) and
store-conditional (stwcx.) instructions, the internal reservation
mechanism is taken into account, however each CPU has its own
reservation information and this information is not synchronized between
CPUs to perform proper synchronization.
The following test case with 2 CPUs shows that the semantics of the
"lwarx" and "stwcx." instructions are not preserved by the emulation.
The test case does the following :
- CPU0: reserve a memory location
- CPU1: reserve the same memory location
- CPU0: perform stwcx. on the location
The last store-conditional operation succeeds while it is supposed to
fail since the reservation was supposed to be lost at the second reserve
operation.
This (one line) patch fixes this problem in a very simple manner by
removing the reservation of a CPU every time it is scheduled (in
cpu_exec()). While this is a harsh workaround, it does not affect the
guest code much because reservations are usually held for a very short
time, that is an lwarx is almost always followed by an stwcx. a few
instructions below. Therefore, in most cases, the reservation will be
taken and consumed before a CPU switch occurs. However in the rare case
where a CPU switch does occur between the lwarx and its corresponding
stwcx. this patch solves a potential erroneous behavior of the
synchronization instructions.
Signed-off-by: Elie Richa <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
cpu-exec.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index aef66f2..a9fa608 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -217,6 +217,7 @@ int cpu_exec(CPUState *env)
#elif defined(TARGET_ARM)
#elif defined(TARGET_UNICORE32)
#elif defined(TARGET_PPC)
+ env->reserve_addr = -1;
#elif defined(TARGET_LM32)
#elif defined(TARGET_MICROBLAZE)
#elif defined(TARGET_MIPS)
--
1.6.0.2
- Re: [Qemu-devel] [Qemu-ppc] [PATCH 28/58] device tree: give dt more size, (continued)
[Qemu-devel] [PATCH 35/58] PPC: SPAPR: Use KVM function for time info, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 14/58] device tree: add nop_node, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 38/58] pseries: interrupt controller should not have a 'reg' property, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 49/58] vscsi: send the CHECK_CONDITION status down together with autosense data, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 20/58] PPC: KVM: Remove kvmppc_read_host_property, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 40/58] PPC: Fix sync instructions problem in SMP,
Alexander Graf <=
[Qemu-devel] [PATCH 18/58] PPC: E500: Remove mpc8544_copy_soc_cell, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 02/58] spapr: prepare for qdevification of irq, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 17/58] PPC: E500: Use generic kvm function for freq, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 48/58] pseries: Implement hcall-bulk hypervisor interface, Alexander Graf, 2011/09/14
[Qemu-devel] [PATCH 50/58] pseries: Update SLOF firmware image, Alexander Graf, 2011/09/14