diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-02-06 11:30:27 -0600 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-02-06 11:30:27 -0600 |
| commit | 8d018c17170a3b623f48de5282955b817a6284f3 (patch) | |
| tree | 70c44cfe471771ef2a42933118846c6ab869df11 /test/qemu-targetstep_guest.c | |
| parent | 4dd9fe04e1399e8629ab2a98b54db6a7dcdb0076 (diff) | |
| download | cachepc-8d018c17170a3b623f48de5282955b817a6284f3.tar.gz cachepc-8d018c17170a3b623f48de5282955b817a6284f3.zip | |
qemu-targetstep: Attempt to track guest process gfn when running in userspace
Seems like single-stepping the guest with LAPIC influences the guest scheduler behaviour, since just a single step inside the target gfn (to determine if its running in userspace), is enough to for us to never reach the GUEST_STOP_TRACK event. FWICT the single-stepping is not frequent and does not take long enough to justify never reaching the stop event.
Diffstat (limited to 'test/qemu-targetstep_guest.c')
| -rw-r--r-- | test/qemu-targetstep_guest.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/qemu-targetstep_guest.c b/test/qemu-targetstep_guest.c new file mode 100644 index 0000000..9ef36e1 --- /dev/null +++ b/test/qemu-targetstep_guest.c @@ -0,0 +1,50 @@ +#include "cachepc/uapi.h" + +#include <sys/time.h> +#include <sys/resource.h> +#include <errno.h> +#include <err.h> +#include <unistd.h> +#include <stdint.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +int +main(int argc, const char **argv) +{ + void *buf; + int ret; + + buf = NULL; + if (posix_memalign(&buf, L1_LINESIZE * L1_SETS, L1_LINESIZE * L1_SETS)) + err(1, "memalign"); + memset(buf, 0, L1_LINESIZE * L1_SETS); + + errno = 0; + ret = setpriority(PRIO_PROCESS, 0, -20); + if (errno) err(1, "setpriority"); + printf("NICE %i\n", ret); + + while (1) { + printf("LOOP\n"); + CPC_DO_VMMCALL(KVM_HC_CPC_VMMCALL_SIGNAL, + CPC_GUEST_START_TRACK, 0); + *(uint8_t *)(buf + L1_LINESIZE * 9) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 10) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 11) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 12) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 13) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 14) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 15) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 9) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 10) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 11) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 12) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 13) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 14) = 1; + *(uint8_t *)(buf + L1_LINESIZE * 15) = 1; + CPC_DO_VMMCALL(KVM_HC_CPC_VMMCALL_SIGNAL, + CPC_GUEST_STOP_TRACK, 0); + } +} |
