Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | tools/testing/selftests/ia64/aliasing-test.c |
static int read_rom(char *path) {
int fd, rc;
size_t size = 0;
fd = open(path, O_RDWR);
if (fd == -1) {
perror(path);
return -1;
}
rc = write(fd, "1", 2);
if (rc <= 0) {
close(fd);
perror("write");
return -1;
}
do {
rc = read(fd, buf, sizeof(buf));
if (rc > 0)
siz... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/ipc/msgque.c |
int restore_queue(struct msgque_data *msgque) {
int fd, ret, id, i;
char buf[32];
fd = open("/proc/sys/kernel/msg_next_id", O_WRONLY);
if (fd == -1) {
printf("Failed to open /proc/sys/kernel/msg_next_id\n");
return -errno;
}
sprintf(buf, "%d", msgque->msq_id);
ret = write(fd, buf, strlen(buf));... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/ipc/msgque.c |
int check_and_destroy_queue(struct msgque_data *msgque) {
struct msg1 message;
int cnt = 0, ret;
while (1) {
ret = msgrcv(msgque->msq_id, &message.mtype, MAX_MSG_SIZE, 0, IPC_NOWAIT);
if (ret < 0) {
if (errno == ENOMSG)
break;
printf("Failed to read IPC message: %m\n");
ret = -... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/ipc/msgque.c |
int dump_queue(struct msgque_data *msgque) {
struct msqid_ds ds;
int kern_id;
int i, ret;
for (kern_id = 0; kern_id < 256; kern_id++) {
ret = msgctl(kern_id, MSG_STAT, &ds);
if (ret < 0) {
if (errno == EINVAL)
continue;
printf("Failed to get stats for IPC queue with id %d\n", kern_... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/ipc/msgque.c |
int fill_msgque(struct msgque_data *msgque) {
struct msg1 msgbuf;
msgbuf.mtype = MSG_TYPE;
memcpy(msgbuf.mtext, TEST_STRING, sizeof(TEST_STRING));
if (msgsnd(msgque->msq_id, &msgbuf.mtype, sizeof(TEST_STRING), IPC_NOWAIT) !=
0) {
printf("First message send failed (%m)\n");
return -errno;
}
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/ir/ir_loopback.c |
int lirc_open(const char *rc) {
struct dirent *dent;
char buf[SYSFS_PATH_MAX + DNAME_PATH_MAX];
DIR *d;
int fd;
snprintf(buf, sizeof(buf), "/sys/class/rc/%s", rc);
d = opendir(buf);
if (!d)
ksft_exit_fail_msg("cannot open %s: %m\n", buf);
while ((dent = readdir(d)) != NULL) {
if (!strncmp(de... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h |
static inline void ksft_inc_pass_cnt(void) { ksft_cnt.ksft_pass++; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h | static inline void ksft_inc_fail_cnt(void) { ksft_cnt.ksft_fail++; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h | static inline int ksft_get_fail_cnt(void) { return ksft_cnt.ksft_fail; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h | static inline int ksft_get_xskip_cnt(void) { return ksft_cnt.ksft_xskip; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h | static inline int ksft_get_error_cnt(void) { return ksft_cnt.ksft_error; } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h |
static inline void ksft_print_cnts(void) {
if (ksft_plan != ksft_test_num())
printf("# Planned tests != run tests (%u != %u)\n", ksft_plan,
ksft_test_num());
printf("# Totals: pass:%d fail:%d xfail:%d xpass:%d skip:%d error:%d\n",
ksft_cnt.ksft_pass, ksft_cnt.ksft_fail, ksft_cnt.ksft_xfail,... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h |
static inline void ksft_print_msg(const char *msg, ...) {
int saved_errno = errno;
va_list args;
va_start(args, msg);
printf("# ");
errno = saved_errno;
vprintf(msg, args);
va_end(args);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kselftest.h |
static inline int ksft_exit_xfail(void) {
ksft_print_cnts();
exit(KSFT_XFAIL);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c |
static void test_guest_raz(struct kvm_vcpu *vcpu) {
struct ucall uc;
vcpu_run(vcpu);
switch (get_ucall(vcpu, &uc)) {
case UCALL_ABORT:
REPORT_GUEST_ASSERT(uc);
break;
case UCALL_DONE:
break;
default:
TEST_FAIL("Unexpected ucall: %lu", uc.cmd);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c |
static void test_user_raz_invariant(struct kvm_vcpu *vcpu) {
int i, r;
for (i = 0; i < ARRAY_SIZE(raz_invariant_reg_ids); i++) {
uint64_t reg_id = raz_invariant_reg_ids[i];
uint64_t val;
vcpu_get_reg(vcpu, reg_id, &val);
ASSERT_EQ(val, 0);
r = __vcpu_set_reg(vcpu, reg_id, BAD_ID_REG_VAL);
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/arch_timer.c |
static void guest_irq_handler(struct ex_regs *regs) {
unsigned int intid = gic_get_and_ack_irq();
uint32_t cpu = guest_get_vcpuid();
struct test_vcpu_shared_data *shared_data = &vcpu_shared_data[cpu];
guest_validate_irq(intid, shared_data);
WRITE_ONCE(shared_data->nr_iter, shared_data->nr_iter + 1);
gic... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/arch_timer.c | static void guest_run_stage(struct test_vcpu_shared_data *shared_data,
enum guest_stage stage) {
uint32_t irq_iter, config_iter;
shared_data->guest_stage = stage;
shared_data->nr_iter = 0;
for (config_iter = 0; config_iter < test_args.nr_iter; config_iter++) {
guest_configure_... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/arch_timer.c | static void *test_vcpu_run(void *arg) {
unsigned int vcpu_idx = (unsigned long)arg;
struct ucall uc;
struct kvm_vcpu *vcpu = vcpus[vcpu_idx];
struct kvm_vm *vm = vcpu->vm;
struct test_vcpu_shared_data *shared_data = &vcpu_shared_data[vcpu_idx];
vcpu_run(vcpu);
pthread_mutex_lock(&vcpu_done_map_lock);
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/arch_timer.c | static uint32_t test_get_pcpu(void) {
uint32_t pcpu;
unsigned int nproc_conf;
cpu_set_t online_cpuset;
nproc_conf = get_nprocs_conf();
sched_getaffinity(0, sizeof(cpu_set_t), &online_cpuset);
do {
pcpu = rand() % nproc_conf;
} while (!CPU_ISSET(pcpu, &online_cpuset));
return pcpu;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/arch_timer.c | static int test_migrate_vcpu(unsigned int vcpu_idx) {
int ret;
cpu_set_t cpuset;
uint32_t new_pcpu = test_get_pcpu();
CPU_ZERO(&cpuset);
CPU_SET(new_pcpu, &cpuset);
pr_debug("Migrating vCPU: %u to pCPU: %u\n", vcpu_idx, new_pcpu);
ret = pthread_setaffinity_np(pt_vcpu_run[vcpu_idx], sizeof(cpuset), &cpu... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/arch_timer.c |
static void *test_vcpu_migration(void *arg) {
unsigned int i, n_done;
bool vcpu_done;
do {
usleep(msecs_to_usecs(test_args.migration_freq_ms));
for (n_done = 0, i = 0; i < test_args.nr_vcpus; i++) {
pthread_mutex_lock(&vcpu_done_map_lock);
vcpu_done = test_bit(i, vcpu_done_map);
pthre... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/arch_timer.c |
static void test_print_help(char *name) {
pr_info("Usage: %s [-h] [-n nr_vcpus] [-i iterations] [-p timer_period_ms]\n",
name);
pr_info("\t-n: Number of vCPUs to configure (default: %u; max: %u)\n",
NR_VCPUS_DEF, KVM_MAX_VCPUS);
pr_info("\t-i: Number of iterations per stage (default: %u)\n",
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/debug-exceptions.c |
static void guest_wp_handler(struct ex_regs *regs) {
wp_data_addr = read_sysreg(far_el1);
wp_addr = regs->pc;
regs->pstate |= SPSR_D;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/debug-exceptions.c | static void guest_code_ss(int test_cnt) {
uint64_t i;
uint64_t bvr, wvr, w_bvr, w_wvr;
for (i = 0; i < test_cnt; i++) {
w_bvr = i << 2;
w_wvr = i << 2;
/* Enable Single Step execution */
GUEST_SYNC(SINGLE_STEP_ENABLE);
/*
* The userspace will veriry that the pc is as expected during
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/debug-exceptions.c |
static int debug_version(struct kvm_vcpu *vcpu) {
uint64_t id_aa64dfr0;
vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64DFR0_EL1), &id_aa64dfr0);
return id_aa64dfr0 & 0xf;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/debug-exceptions.c |
static void test_guest_debug_exceptions(void) {
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
struct ucall uc;
int stage;
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
ucall_init(vm, NULL);
vm_init_descriptor_tables(vm);
vcpu_init_descriptor_tables(vcpu);
vm_install_sync_handler(vm, VECTOR_SYNC_CUR... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/get-reg-list.c |
static const char *str_with_index(const char *template, __u64 index) {
char *str, *p;
int n;
str = strdup(template);
p = strstr(str, "##");
n = sprintf(p, "%lld", index);
strcat(p + n, strstr(template, "##") + 2);
return (const char *)str;
}
#define REG_MASK ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/get-reg-list.c |
static void prepare_vcpu_init(struct vcpu_config *c,
struct kvm_vcpu_init *init) {
struct reg_sublist *s;
for_each_sublist(c, s) if (s->capability) init->features[s->feature / 32] |=
1 << (s->feature % 32);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/get-reg-list.c |
static void check_supported(struct vcpu_config *c) {
struct reg_sublist *s;
for_each_sublist(c, s) {
if (!s->capability)
continue;
__TEST_REQUIRE(kvm_has_cap(s->capability),
"%s: %s not available, skipping tests\n", config_name(c),
s->name);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/hypercalls.c |
static void guest_test_hvc(const struct test_hvc_info *hc_info) {
unsigned int i;
struct arm_smccc_res res;
unsigned int hvc_info_arr_sz;
hvc_info_arr_sz =
hc_info == hvc_info ? ARRAY_SIZE(hvc_info) : ARRAY_SIZE(false_hvc_info);
for (i = 0; i < hvc_info_arr_sz; i++, hc_info++) {
memset(&res, 0, s... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/hypercalls.c | static void test_fw_regs_before_vm_start(struct kvm_vcpu *vcpu) {
uint64_t val;
unsigned int i;
int ret;
for (i = 0; i < ARRAY_SIZE(fw_reg_info); i++) {
const struct kvm_fw_reg_info *reg_info = &fw_reg_info[i];
vcpu_get_reg(vcpu, reg_info->reg, &val);
TEST_ASSERT(val == FW_REG_ULIMIT_VAL(reg_info-... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/hypercalls.c | static void test_fw_regs_after_vm_start(struct kvm_vcpu *vcpu) {
uint64_t val;
unsigned int i;
int ret;
for (i = 0; i < ARRAY_SIZE(fw_reg_info); i++) {
const struct kvm_fw_reg_info *reg_info = &fw_reg_info[i];
vcpu_get_reg(vcpu, reg_info->reg, &val);
TEST_ASSERT(val == 0,
"Expected... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/hypercalls.c |
static struct kvm_vm *test_vm_create(struct kvm_vcpu **vcpu) {
struct kvm_vm *vm;
vm = vm_create_with_one_vcpu(vcpu, guest_code);
ucall_init(vm, NULL);
steal_time_init(*vcpu);
return vm;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/hypercalls.c |
static void test_run(void) {
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
struct ucall uc;
bool guest_done = false;
vm = test_vm_create(&vcpu);
test_fw_regs_before_vm_start(vcpu);
while (!guest_done) {
vcpu_run(vcpu);
switch (get_ucall(vcpu, &uc)) {
case UCALL_SYNC:
test_guest_stage(&v... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/psci_test.c |
static uint64_t psci_affinity_info(uint64_t target_affinity,
uint64_t lowest_affinity_level) {
struct arm_smccc_res res;
smccc_hvc(PSCI_0_2_FN64_AFFINITY_INFO, target_affinity, lowest_affinity_level,
0, 0, 0, 0, 0, &res);
return res.a0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/psci_test.c |
static uint64_t psci_features(uint32_t func_id) {
struct arm_smccc_res res;
smccc_hvc(PSCI_1_0_FN_PSCI_FEATURES, func_id, 0, 0, 0, 0, 0, 0, &res);
return res.a0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/vcpu_width_config.c | int main(void) {
struct kvm_vcpu_init init0, init1;
struct kvm_vm *vm;
int ret;
TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_EL1_32BIT));
vm = vm_create_barebones();
vm_ioctl(vm, KVM_ARM_PREFERRED_TARGET, &init0);
kvm_vm_free(vm);
init1 = init0;
/* Test with 64bit vCPUs */
ret = add_init_2vcpus(&init0, &... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/vgic_init.c |
static struct vm_gic vm_gic_create_with_vcpus(uint32_t gic_dev_type,
uint32_t nr_vcpus,
struct kvm_vcpu *vcpus[]) {
struct vm_gic v;
v.gic_dev_type = gic_dev_type;
v.vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus)... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/vgic_init.c | static void test_vgic_then_vcpus(uint32_t gic_dev_type) {
struct kvm_vcpu *vcpus[NR_VCPUS];
struct vm_gic v;
int ret, i;
v = vm_gic_create_with_vcpus(gic_dev_type, 1, vcpus);
subtest_dist_rdist(&v);
for (i = 1; i < NR_VCPUS; ++i)
vcpus[i] = vm_vcpu_add(v.vm, i, guest_code);
ret = run_vcpu(vcpus[3]... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/vgic_init.c | int test_kvm_device(uint32_t gic_dev_type) {
struct kvm_vcpu *vcpus[NR_VCPUS];
struct vm_gic v;
uint32_t other;
int ret;
v.vm = vm_create_with_vcpus(NR_VCPUS, guest_code, vcpus);
ret = __kvm_test_create_device(v.vm, 0);
TEST_ASSERT(ret && errno == ENODEV, "unsupported device");
/* trial mode */
ret... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/vgic_irq.c | static void guest_restore_active(struct test_args *args, uint32_t first_intid,
uint32_t num, kvm_inject_cmd cmd) {
uint32_t prio, intid, ap1r;
int i;
for (i = 0, prio = (num - 1) * 8; i < num; i++, prio -= 8) {
GUEST_ASSERT(prio >= 0);
intid = i + first_intid;
gic_set... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/vgic_irq.c | static void test_preemption(struct test_args *args, struct kvm_inject_desc *f) {
if (f->sgi)
test_inject_preemption(args, MIN_SGI, 4, f->cmd);
if (f->ppi)
test_inject_preemption(args, MIN_PPI, 4, f->cmd);
if (f->spi)
test_inject_preemption(args, MIN_SPI, 4, f->cmd);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/aarch64/vgic_irq.c | static void run_guest_cmd(struct kvm_vcpu *vcpu, int gic_fd,
struct kvm_inject_args *inject_args,
struct test_args *test_args) {
kvm_inject_cmd cmd = inject_args->cmd;
uint32_t intid = inject_args->first_intid;
uint32_t num = inject_args->num;
int level = inje... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/access_tracking_perf_test.c |
static uint64_t lookup_pfn(int pagemap_fd, struct kvm_vm *vm, uint64_t gva) {
uint64_t hva = (uint64_t)addr_gva2hva(vm, gva);
uint64_t entry;
uint64_t pfn;
entry = pread_uint64(pagemap_fd, "pagemap", hva / getpagesize());
if (!(entry & PAGEMAP_PRESENT))
return 0;
pfn = entry & PAGEMAP_PFN_MASK;
__T... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/access_tracking_perf_test.c |
static bool spin_wait_for_next_iteration(int *current_iteration) {
int last_iteration = *current_iteration;
do {
if (READ_ONCE(done))
return false;
*current_iteration = READ_ONCE(iteration);
} while (last_iteration == *current_iteration);
return true;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/access_tracking_perf_test.c |
static void vcpu_thread_main(struct perf_test_vcpu_args *vcpu_args) {
struct kvm_vcpu *vcpu = vcpu_args->vcpu;
struct kvm_vm *vm = perf_test_args.vm;
int vcpu_idx = vcpu_args->vcpu_idx;
int current_iteration = 0;
while (spin_wait_for_next_iteration(¤t_iteration)) {
switch (READ_ONCE(iteration_work... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/access_tracking_perf_test.c | static void mark_memory_idle(struct kvm_vm *vm, int nr_vcpus) {
pr_debug("Marking VM memory idle (slow)...\n");
iteration_work = ITERATION_MARK_IDLE;
run_iteration(vm, nr_vcpus, "Mark memory idle");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/access_tracking_perf_test.c |
int main(int argc, char *argv[]) {
struct test_params params = {
.backing_src = DEFAULT_VM_MEM_SRC,
.vcpu_memory_bytes = DEFAULT_PER_VCPU_MEM_SIZE,
.nr_vcpus = 1,
};
int page_idle_fd;
int opt;
guest_modes_append_default();
while ((opt = getopt(argc, argv, "hm:b:v:os:")) != -1) {
swi... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/demand_paging_test.c |
static int handle_uffd_page_request(int uffd_mode, int uffd, uint64_t addr) {
pid_t tid = syscall(__NR_gettid);
struct timespec start;
struct timespec ts_diff;
int r;
clock_gettime(CLOCK_MONOTONIC, &start);
if (uffd_mode == UFFDIO_REGISTER_MODE_MISSING) {
struct uffdio_copy copy;
copy.src = (uin... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/demand_paging_test.c |
int main(int argc, char *argv[]) {
int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
struct test_params p = {
.src_type = DEFAULT_VM_MEM_SRC,
.partition_vcpu_memory_access = true,
};
int opt;
guest_modes_append_default();
while ((opt = getopt(argc, argv, "hm:u:d:b:s:v:o")) != -1) {
switch... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/demand_paging_test.c | int main(void) {
print_skip("__NR_userfaultfd must be present for userfaultfd test");
return KSFT_SKIP;
}
#endif | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_perf_test.c | static void arch_cleanup_vm(struct kvm_vm *vm) {
if (gic_fd > 0)
close(gic_fd);
}
#else | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_perf_test.c |
static void toggle_dirty_logging(struct kvm_vm *vm, int slots, bool enable) {
int i;
for (i = 0; i < slots; i++) {
int slot = PERF_TEST_MEM_SLOT_INDEX + i;
int flags = enable ? KVM_MEM_LOG_DIRTY_PAGES : 0;
vm_mem_region_set_flags(vm, slot, flags);
}
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_perf_test.c |
static unsigned long **alloc_bitmaps(int slots, uint64_t pages_per_slot) {
unsigned long **bitmaps;
int i;
bitmaps = malloc(slots * sizeof(bitmaps[0]));
TEST_ASSERT(bitmaps, "Failed to allocate bitmaps array.");
for (i = 0; i < slots; i++) {
bitmaps[i] = bitmap_zalloc(pages_per_slot);
TEST_ASSERT(b... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_test.c | static void guest_code(void) {
uint64_t addr;
int i;
for (i = 0; i < guest_num_pages; i++) {
addr = guest_test_virt_mem + i * guest_page_size;
*(uint64_t *)addr = READ_ONCE(iteration);
}
while (true) {
for (i = 0; i < TEST_PAGES_PER_LOOP; i++) {
addr = guest_test_virt_mem;
addr += (R... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_test.c |
static void clear_log_create_vm_done(struct kvm_vm *vm) {
u64 manual_caps;
manual_caps = kvm_check_cap(KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
TEST_ASSERT(manual_caps, "MANUAL_CAPS is zero!");
manual_caps &=
(KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | KVM_DIRTY_LOG_INITIALLY_SET);
vm_enable_cap(vm, KVM_CAP_MAN... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_test.c |
static bool dirty_ring_supported(void) {
return (kvm_has_cap(KVM_CAP_DIRTY_LOG_RING) ||
kvm_has_cap(KVM_CAP_DIRTY_LOG_RING_ACQ_REL));
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_test.c |
static inline bool dirty_gfn_is_dirtied(struct kvm_dirty_gfn *gfn) {
return smp_load_acquire(&gfn->flags) == KVM_DIRTY_GFN_F_DIRTY;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_test.c |
static void log_mode_create_vm_done(struct kvm_vm *vm) {
struct log_mode *mode = &log_modes[host_log_mode];
if (mode->create_vm_done)
mode->create_vm_done(vm);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/dirty_log_test.c | static void *vcpu_worker(void *data) {
int ret;
struct kvm_vcpu *vcpu = data;
struct kvm_vm *vm = vcpu->vm;
uint64_t *guest_array;
uint64_t pages_count = 0;
struct kvm_signal_mask *sigmask =
alloca(offsetof(struct kvm_signal_mask, sigset) + sizeof(sigset_t));
sigset_t *sigset = (sigset_t *)&sigmask-... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/hardware_disable_test.c | static void guest_code(void) {
for (;;)
;
printf("Should not be reached.\n");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/hardware_disable_test.c |
static inline void check_set_affinity(pthread_t thread, cpu_set_t *cpu_set) {
int r;
r = pthread_setaffinity_np(thread, sizeof(cpu_set_t), cpu_set);
TEST_ASSERT(r == 0, "%s: failed set affinity", __func__);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/hardware_disable_test.c | int main(int argc, char **argv) {
uint32_t i;
int s, r;
pid_t pid;
sem = sem_open("vm_sem", O_CREAT | O_EXCL, 0644, 0);
sem_unlink("vm_sem");
for (i = 0; i < FORK_NUM; ++i) {
pid = fork();
TEST_ASSERT(pid >= 0, "%s: unable to fork", __func__);
if (pid == 0)
run_test(i);
pr_debug("%s... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/aarch64/arch_timer.h | static inline uint64_t timer_get_cntct(enum arch_timer timer) {
isb();
switch (timer) {
case VIRTUAL:
return read_sysreg(cntvct_el0);
case PHYSICAL:
return read_sysreg(cntpct_el0);
default:
GUEST_ASSERT_1(0, timer);
}
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/aarch64/arch_timer.h |
static inline void timer_set_ctl(enum arch_timer timer, uint32_t ctl) {
switch (timer) {
case VIRTUAL:
write_sysreg(ctl, cntv_ctl_el0);
break;
case PHYSICAL:
write_sysreg(ctl, cntp_ctl_el0);
break;
default:
GUEST_ASSERT_1(0, timer);
}
isb();
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/aarch64/arch_timer.h | static inline uint32_t timer_get_ctl(enum arch_timer timer) {
switch (timer) {
case VIRTUAL:
return read_sysreg(cntv_ctl_el0);
case PHYSICAL:
return read_sysreg(cntp_ctl_el0);
default:
GUEST_ASSERT_1(0, timer);
}
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/aarch64/processor.h | static inline void cpu_relax(void) { asm volatile("yield" ::: "memory"); }
#define isb() asm volatile("isb" : : : "memory")
#define dsb(opt) asm volatile("dsb " #opt : : : "memory")
#define dmb(opt) asm volatile("dmb " #opt : : : "memory")
#define dma_wmb() dmb(oshst)
#define __iowmb() dma_wmb()
#define dma_rmb() dm... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static __always_inline void static_assert_is_vm(struct kvm_vm *vm) {}
#define __vm_ioctl(vm, cmd, arg) \
({ \
static_assert_is_vm(vm); \
k... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static __always_inline void static_assert_is_vcpu(struct kvm_vcpu *vcpu) {}
#define __vcpu_ioctl(vcpu, cmd, arg) \
({ \
static_assert_is_vcpu(vcpu); ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline void kvm_vm_get_dirty_log(struct kvm_vm *vm, int slot,
void *log) {
struct kvm_dirty_log args = {.dirty_bitmap = log, .slot = slot};
vm_ioctl(vm, KVM_GET_DIRTY_LOG, &args);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline void kvm_vm_clear_dirty_log(struct kvm_vm *vm, int slot,
void *log, uint64_t first_page,
uint32_t num_pages) {
struct kvm_clear_dirty_log args = {.dirty_bitmap = log,
.slot = slot,
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h | static inline ssize_t
get_stats_descriptor_size(struct kvm_stats_header *header) {
return sizeof(struct kvm_stats_desc) + header->name_size;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline void vcpu_regs_set(struct kvm_vcpu *vcpu, struct kvm_regs *regs) {
vcpu_ioctl(vcpu, KVM_SET_REGS, regs);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline int __vcpu_get_reg(struct kvm_vcpu *vcpu, uint64_t id,
void *addr) {
struct kvm_one_reg reg = {.id = id, .addr = (uint64_t)addr};
return __vcpu_ioctl(vcpu, KVM_GET_ONE_REG, ®);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h | static inline void vcpu_events_get(struct kvm_vcpu *vcpu,
struct kvm_vcpu_events *events) {
vcpu_ioctl(vcpu, KVM_GET_VCPU_EVENTS, events);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h | static inline int __vcpu_nested_state_set(struct kvm_vcpu *vcpu,
struct kvm_nested_state *state) {
return __vcpu_ioctl(vcpu, KVM_SET_NESTED_STATE, state);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline void kvm_device_attr_set(int dev_fd, uint32_t group,
uint64_t attr, void *val) {
int ret = __kvm_device_attr_set(dev_fd, group, attr, val);
TEST_ASSERT(!ret, KVM_IOCTL_ERROR(KVM_SET_DEVICE_ATTR, ret));
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline int __vcpu_device_attr_get(struct kvm_vcpu *vcpu, uint32_t group,
uint64_t attr, void *val) {
return __kvm_device_attr_get(vcpu->fd, group, attr, val);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline void vcpu_dump(FILE *stream, struct kvm_vcpu *vcpu,
uint8_t indent) {
vcpu_arch_dump(stream, vcpu, indent);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/kvm_util_base.h |
static inline void virt_dump(FILE *stream, struct kvm_vm *vm, uint8_t indent) {
virt_arch_dump(stream, vm, indent);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/apic.h |
static inline void x2apic_write_reg(unsigned int reg, uint64_t value) {
wrmsr(APIC_BASE_MSR + (reg >> 4), value);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h | static inline uint16_t inw(uint16_t port) {
uint16_t tmp;
__asm__ __volatile__("in %%dx, %%ax" : "=a"(tmp) : /* input */ "d"(port));
return tmp;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h | static inline uint16_t get_cs(void) {
uint16_t cs;
__asm__ __volatile__("mov %%cs, %[cs]" : [cs] "=rm"(cs));
return cs;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h | static inline uint16_t get_gs(void) {
uint16_t gs;
__asm__ __volatile__("mov %%gs, %[gs]" : [gs] "=rm"(gs));
return gs;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h | static inline uint64_t get_cr3(void) {
uint64_t cr3;
__asm__ __volatile__("mov %%cr3, %[cr3]" : [cr3] "=r"(cr3));
return cr3;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h | static inline uint64_t get_cr4(void) {
uint64_t cr4;
__asm__ __volatile__("mov %%cr4, %[cr4]" : [cr4] "=r"(cr4));
return cr4;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h | static inline void vcpu_debugregs_set(struct kvm_vcpu *vcpu,
struct kvm_debugregs *debugregs) {
vcpu_ioctl(vcpu, KVM_SET_DEBUGREGS, debugregs);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h |
static inline bool kvm_cpu_has(struct kvm_x86_cpu_feature feature) {
return kvm_cpuid_has(kvm_get_supported_cpuid(), feature);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h |
static inline struct kvm_cpuid_entry2 *
__vcpu_get_cpuid_entry(struct kvm_vcpu *vcpu, uint32_t function,
uint32_t index) {
return (struct kvm_cpuid_entry2 *)get_cpuid_entry(vcpu->cpuid, function,
index);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h |
static inline void vcpu_set_cpuid_feature(struct kvm_vcpu *vcpu,
struct kvm_x86_cpu_feature feature) {
vcpu_set_or_clear_cpuid_feature(vcpu, feature, true);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h |
static inline void
vcpu_clear_cpuid_feature(struct kvm_vcpu *vcpu,
struct kvm_x86_cpu_feature feature) {
vcpu_set_or_clear_cpuid_feature(vcpu, feature, false);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h |
static inline void vcpu_set_msr(struct kvm_vcpu *vcpu, uint64_t msr_index,
uint64_t msr_value) {
int r = _vcpu_set_msr(vcpu, msr_index, msr_value);
TEST_ASSERT(r == 1, KVM_IOCTL_ERROR(KVM_SET_MSRS, r));
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/processor.h |
static inline uint32_t kvm_get_cpuid_max_extended(void) {
return kvm_get_supported_cpuid_entry(0x80000000)->eax;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/vmx.h | static inline void vmcall(void) {
__asm__ __volatile__("push %%rbp; vmcall; pop %%rbp"
:
:
: "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "r8", "r9",
"r10", "r11", "r12", "r13", "r14", "r15");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/include/x86_64/vmx.h |
static inline uint32_t vmcs_revision(void) { return rdmsr(MSR_IA32_VMX_BASIC); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/kvm_binary_stats_test.c |
static void vm_stats_test(struct kvm_vm *vm) {
int stats_fd = vm_get_stats_fd(vm);
stats_test(stats_fd);
close(stats_fd);
TEST_ASSERT(fcntl(stats_fd, F_GETFD) == -1, "Stats fd not freed");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/kvm/kvm_binary_stats_test.c | int main(int argc, char *argv[]) {
int i, j;
struct kvm_vcpu **vcpus;
struct kvm_vm **vms;
int max_vm = DEFAULT_NUM_VM;
int max_vcpu = DEFAULT_NUM_VCPU;
if (argc > 1) {
max_vm = strtol(argv[1], NULL, 0);
if (max_vm <= 0)
max_vm = DEFAULT_NUM_VM;
}
if (argc > 2) {
max_vcpu = strtol(arg... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/kvm_page_table_test.c |
static void help(char *name) {
puts("");
printf("usage: %s [-h] [-p offset] [-m mode] "
"[-b mem-size] [-v vcpus] [-s mem-type]\n",
name);
puts("");
printf(
" -p: specify guest physical test memory offset\n"
" Warning: a low offset can conflict with the loaded test code.\n");
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/kvm/kvm_page_table_test.c |
int main(int argc, char *argv[]) {
int max_vcpus = kvm_check_cap(KVM_CAP_MAX_VCPUS);
struct test_params p = {
.test_mem_size = DEFAULT_TEST_MEM_SIZE,
.src_type = DEFAULT_VM_MEM_SRC,
};
int opt;
guest_modes_append_default();
while ((opt = getopt(argc, argv, "hp:m:b:v:s:")) != -1) {
switch ... | [
1,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.