summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Lawrence <allawr@microsoft.com>2017-04-26 12:14:11 +0100
committerJan Kotas <jkotas@microsoft.com>2017-04-26 04:14:11 -0700
commite02c014a97e2a1c44fa5c7d10355031e310ea66f (patch)
tree2aa1b4314dee70396fe53a419c6e27b0827af495
parent3011ab330532cbd6f82da9b8ae5d1d28c324cc06 (diff)
downloadcoreclr-e02c014a97e2a1c44fa5c7d10355031e310ea66f.tar.gz
coreclr-e02c014a97e2a1c44fa5c7d10355031e310ea66f.tar.bz2
coreclr-e02c014a97e2a1c44fa5c7d10355031e310ea66f.zip
Comment explaining use of FlushProcessWriteBuffers in StompWriteBarrier. (#10924)
-rw-r--r--src/vm/gcenv.ee.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp
index 54c7991ee9..63c4ffea10 100644
--- a/src/vm/gcenv.ee.cpp
+++ b/src/vm/gcenv.ee.cpp
@@ -1275,9 +1275,17 @@ void GCToEEInterface::StompWriteBarrier(WriteBarrierParameters* args)
// We need to make sure that other threads executing checked write barriers
// will see the g_card_table update before g_lowest/highest_address updates.
// Otherwise, the checked write barrier may AV accessing the old card table
- // with address that it does not cover. Write barriers access card table
- // without memory barriers for performance reasons, so we need to flush
- // the store buffers here.
+ // with address that it does not cover.
+ //
+ // Even x86's total store ordering is insufficient here because threads reading
+ // g_card_table do so via the instruction cache, whereas g_lowest/highest_address
+ // are read via the data cache.
+ //
+ // The g_card_table update is covered by section 8.1.3 of the Intel Software
+ // Development Manual, Volume 3A (System Programming Guide, Part 1), about
+ // "cross-modifying code": We need all _executing_ threads to invalidate
+ // their instruction cache, which FlushProcessWriteBuffers achieves by sending
+ // an IPI (inter-process interrupt).
FlushProcessWriteBuffers();
g_lowest_address = args->lowest_address;