1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2022 Oxide Computer Company 14 */ 15 16 #ifndef _IN_GUEST_H_ 17 #define _IN_GUEST_H_ 18 19 #include "payload_common.h" 20 21 struct vmctx *test_initialize(const char *); 22 struct vmctx *test_initialize_flags(const char *, uint64_t); 23 void test_cleanup(bool); 24 void test_fail_errno(int err, const char *msg); 25 void test_fail_msg(const char *fmt, ...); 26 void test_fail_vmexit(const struct vm_exit *vexit); 27 void test_pass(void); 28 29 int test_setup_vcpu(struct vmctx *, int, uint64_t, uint64_t); 30 31 enum vm_exit_kind { 32 /* Otherwise empty vmexit which should result in immediate re-entry */ 33 VEK_REENTR, 34 /* Write to IOP_TEST_RESULT port with success value (0) */ 35 VEK_TEST_PASS, 36 /* Write to IOP_TEST_RESULT port with failure value (non-zero) */ 37 VEK_TEST_FAIL, 38 /* Test specific logic must handle exit data */ 39 VEK_UNHANDLED, 40 }; 41 42 enum vm_exit_kind test_run_vcpu(struct vmctx *, int, struct vm_entry *, 43 struct vm_exit *); 44 45 void ventry_fulfill_inout(const struct vm_exit *, struct vm_entry *, uint32_t); 46 void ventry_fulfill_mmio(const struct vm_exit *, struct vm_entry *, uint64_t); 47 48 bool vexit_match_inout(const struct vm_exit *, bool, uint16_t, uint_t, 49 uint32_t *); 50 bool vexit_match_mmio(const struct vm_exit *, bool, uint64_t, uint_t, 51 uint64_t *); 52 53 #endif /* _IN_GUEST_H_ */ 54