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 2023 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_reinitialize(struct vmctx *, uint64_t); 24 void test_cleanup(bool); 25 void test_fail(void); 26 void test_fail_errno(int err, const char *msg); 27 void test_fail_msg(const char *fmt, ...); 28 void test_fail_vmexit(const struct vm_exit *vexit); 29 void test_pass(void); 30 const char *test_msg_get(struct vmctx *); 31 void test_msg_print(struct vmctx *); 32 33 int test_setup_vcpu(struct vcpu *, uint64_t, uint64_t); 34 35 enum vm_exit_kind { 36 /* Otherwise empty vmexit which should result in immediate re-entry */ 37 VEK_REENTR, 38 /* Write to IOP_TEST_RESULT port with success value (0) */ 39 VEK_TEST_PASS, 40 /* Write to IOP_TEST_RESULT port with failure value (non-zero) */ 41 VEK_TEST_FAIL, 42 /* Payload emitted a message via IOP_TEST_MSG port */ 43 VEK_TEST_MSG, 44 /* Test specific logic must handle exit data */ 45 VEK_UNHANDLED, 46 }; 47 48 enum vm_exit_kind test_run_vcpu(struct vcpu *, struct vm_entry *, 49 struct vm_exit *); 50 51 void ventry_fulfill_inout(const struct vm_exit *, struct vm_entry *, uint32_t); 52 void ventry_fulfill_mmio(const struct vm_exit *, struct vm_entry *, uint64_t); 53 54 bool vexit_match_inout(const struct vm_exit *, bool, uint16_t, uint_t, 55 uint32_t *); 56 bool vexit_match_mmio(const struct vm_exit *, bool, uint64_t, uint_t, 57 uint64_t *); 58 59 #endif /* _IN_GUEST_H_ */ 60