/* * To generate a bus lock, carve out a buffer that precisely occupies two cache * lines and perform an atomic access that splits the two lines.
*/ static u8 buffer[CACHE_LINE_SIZE * 2] __aligned(CACHE_LINE_SIZE); static atomic_t *val = (void *)&buffer[CACHE_LINE_SIZE - (sizeof(*val) / 2)];
staticvoid guest_generate_buslocks(void)
{ for (int i = 0; i < NR_BUS_LOCKS_PER_LEVEL; i++)
atomic_inc(val);
}
/* * Verify the counter is actually getting incremented, e.g. that * KVM isn't skipping the instruction. On Intel, the exit is * trap-like, i.e. the counter should already have been * incremented. On AMD, it's fault-like, i.e. the counter will * be incremented when the guest re-executes the instruction.
*/
sync_global_from_guest(vm, *val);
TEST_ASSERT_EQ(atomic_read(val), bus_locks + host_cpu_is_intel);
bus_locks++;
}
TEST_FAIL("Didn't receive UCALL_DONE, took %u bus lock exits\n", bus_locks);
done:
TEST_ASSERT_EQ(i, bus_locks);
kvm_vm_free(vm); return 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.