summaryrefslogtreecommitdiffstats
path: root/test/qemu-eviction_guest.c
blob: 086fee5c9a6069b89580dc8994b248e209a9ea78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "cachepc/uapi.h"

#include <sys/time.h>
#include <sys/resource.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;

	buf = NULL;
	if (posix_memalign(&buf, L1_LINESIZE * L1_SETS, L1_LINESIZE * L1_SETS))
		err(1, "memalign");
	memset(buf, 0, L1_LINESIZE * L1_SETS);

	setpriority(PRIO_PROCESS, 0, -20);

	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);
	}
}