mirror of
https://github.com/torvalds/linux.git
synced 2026-04-21 08:13:56 -04:00
This test tries to setup routes which have address + offset combinations which cross a page. Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Tested-by: Matthew Rosato <mjrosato@linux.ibm.com> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* IRQ routing offset tests.
|
|
*
|
|
* Copyright IBM Corp. 2026
|
|
*
|
|
* Authors:
|
|
* Janosch Frank <frankja@linux.ibm.com>
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
#include "test_util.h"
|
|
#include "kvm_util.h"
|
|
#include "kselftest.h"
|
|
#include "ucall_common.h"
|
|
|
|
extern char guest_code[];
|
|
asm("guest_code:\n"
|
|
"diag %r0,%r0,0\n"
|
|
"j .\n");
|
|
|
|
static void test(void)
|
|
{
|
|
struct kvm_irq_routing *routing;
|
|
struct kvm_vcpu *vcpu;
|
|
struct kvm_vm *vm;
|
|
vm_paddr_t mem;
|
|
int ret;
|
|
|
|
struct kvm_irq_routing_entry ue = {
|
|
.type = KVM_IRQ_ROUTING_S390_ADAPTER,
|
|
.gsi = 1,
|
|
};
|
|
|
|
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
|
|
mem = vm_phy_pages_alloc(vm, 2, 4096 * 42, 0);
|
|
|
|
routing = kvm_gsi_routing_create();
|
|
routing->nr = 1;
|
|
routing->entries[0] = ue;
|
|
routing->entries[0].u.adapter.summary_addr = (uintptr_t)mem;
|
|
routing->entries[0].u.adapter.ind_addr = (uintptr_t)mem;
|
|
|
|
routing->entries[0].u.adapter.summary_offset = 4096 * 8;
|
|
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
|
|
ksft_test_result(ret == -1 && errno == EINVAL, "summary offset outside of page\n");
|
|
|
|
routing->entries[0].u.adapter.summary_offset -= 4;
|
|
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
|
|
ksft_test_result(ret == 0, "summary offset inside of page\n");
|
|
|
|
routing->entries[0].u.adapter.ind_offset = 4096 * 8;
|
|
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
|
|
ksft_test_result(ret == -1 && errno == EINVAL, "ind offset outside of page\n");
|
|
|
|
routing->entries[0].u.adapter.ind_offset -= 4;
|
|
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
|
|
ksft_test_result(ret == 0, "ind offset inside of page\n");
|
|
|
|
kvm_vm_free(vm);
|
|
}
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
TEST_REQUIRE(kvm_has_cap(KVM_CAP_IRQ_ROUTING));
|
|
|
|
ksft_print_header();
|
|
ksft_set_plan(4);
|
|
test();
|
|
|
|
ksft_finished(); /* Print results and exit() accordingly */
|
|
}
|