tools/testing/selftests/kvm/arm64/idreg-idst.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/arm64/idreg-idst.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/kvm/arm64/idreg-idst.c
Extension
.c
Size
2273 bytes
Lines
118
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (get_ucall(vcpu, &uc)) {
		case UCALL_ABORT:
			REPORT_GUEST_ASSERT(uc);
			break;
		case UCALL_PRINTF:
			printf("%s", uc.buffer);
			break;
		case UCALL_DONE:
			break;
		default:
			TEST_FAIL("Unknown ucall %lu", uc.cmd);
		}
	} while (uc.cmd != UCALL_DONE);
}

static void test_guest_feat_idst(void)
{
	struct kvm_vcpu *vcpu;
	struct kvm_vm *vm;

	/* This VM has no MTE, no SME, no CCIDX */
	vm = vm_create_with_one_vcpu(&vcpu, guest_code);

	vm_init_descriptor_tables(vm);
	vcpu_init_descriptor_tables(vcpu);

	vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
				ESR_ELx_EC_SYS64, guest_sys64_handler);
	vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT,
				ESR_ELx_EC_UNKNOWN, guest_undef_handler);

	test_run_vcpu(vcpu);

	kvm_vm_free(vm);
}

int main(int argc, char *argv[])
{
	struct kvm_vcpu *vcpu;
	struct kvm_vm *vm;
	u64 mmfr2;

	test_disable_default_vgic();

	vm = vm_create_with_one_vcpu(&vcpu, NULL);
	mmfr2 = vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64MMFR2_EL1));
	__TEST_REQUIRE(FIELD_GET(ID_AA64MMFR2_EL1_IDS, mmfr2) > 0,
		       "FEAT_IDST not supported");
	kvm_vm_free(vm);

	test_guest_feat_idst();

	return 0;
}

Annotation

Implementation Notes