Commit aeec71c3 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

dist/common: proper volatile declarations in NetEntryReceived

parent 7a798451
...@@ -515,26 +515,28 @@ void NetEntryReceived(struct Peer *peer, uint32_t pos, void *data) ...@@ -515,26 +515,28 @@ void NetEntryReceived(struct Peer *peer, uint32_t pos, void *data)
void *entry = peer->cleanup_base + off; void *entry = peer->cleanup_base + off;
if (peer->is_dev) { if (peer->is_dev) {
struct SimbricksProtoNetD2NDummy *d2n = entry; volatile struct SimbricksProtoNetD2NDummy *d2n = entry;
// first copy data after header // first copy data after header
memcpy(d2n + 1, (uint8_t *) data + sizeof(*d2n), memcpy((void *) (d2n + 1), (uint8_t *) data + sizeof(*d2n),
peer->cleanup_elen - sizeof(*d2n)); peer->cleanup_elen - sizeof(*d2n));
// then copy header except for last byte // then copy header except for last byte
memcpy(entry, data, sizeof(*d2n) - 1); memcpy((void *) d2n, data, sizeof(*d2n) - 1);
// WMB() // WMB()
// now copy last byte // now copy last byte
struct SimbricksProtoNetD2NDummy *src_d2n = data; volatile struct SimbricksProtoNetD2NDummy *src_d2n = data;
asm volatile("sfence" ::: "memory");
d2n->own_type = src_d2n->own_type; d2n->own_type = src_d2n->own_type;
} else { } else {
struct SimbricksProtoNetN2DDummy *n2d = entry; volatile struct SimbricksProtoNetN2DDummy *n2d = entry;
// first copy data after header // first copy data after header
memcpy(n2d + 1, (uint8_t *) data + sizeof(*n2d), memcpy((void *) (n2d + 1), (uint8_t *) data + sizeof(*n2d),
peer->cleanup_elen - sizeof(*n2d)); peer->cleanup_elen - sizeof(*n2d));
// then copy header except for last byte // then copy header except for last byte
memcpy(entry, data, sizeof(*n2d) - 1); memcpy((void *) n2d, data, sizeof(*n2d) - 1);
// WMB() // WMB()
// now copy last byte // now copy last byte
struct SimbricksProtoNetN2DDummy *src_n2d = data; volatile struct SimbricksProtoNetN2DDummy *src_n2d = data;
asm volatile("sfence" ::: "memory");
n2d->own_type = src_n2d->own_type; n2d->own_type = src_n2d->own_type;
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment