|
root / base / usr / src / test / bhyve-tests / tests / common / in_guest.h
in_guest.h C 61 lines 1.9 KB
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2024 Oxide Computer Company
 */

#ifndef _IN_GUEST_H_
#define	_IN_GUEST_H_

#include "payload_common.h"

struct vmctx *test_initialize(const char *);
struct vmctx *test_initialize_plain(const char *);
struct vmctx *test_initialize_flags(const char *, uint64_t);
void test_reinitialize(struct vmctx *, uint64_t);
void test_cleanup(bool);
void test_fail(void);
void test_fail_errno(int err, const char *msg);
void test_fail_msg(const char *fmt, ...);
void test_fail_vmexit(const struct vm_exit *vexit);
void test_pass(void);
const char *test_msg_get(struct vmctx *);
void test_msg_print(struct vmctx *);

int test_setup_vcpu(struct vcpu *, uint64_t, uint64_t);

enum vm_exit_kind {
	/* Otherwise empty vmexit which should result in immediate re-entry */
	VEK_REENTR,
	/* Write to IOP_TEST_RESULT port with success value (0) */
	VEK_TEST_PASS,
	/* Write to IOP_TEST_RESULT port with failure value (non-zero) */
	VEK_TEST_FAIL,
	/* Payload emitted a message via IOP_TEST_MSG port */
	VEK_TEST_MSG,
	/* Test specific logic must handle exit data */
	VEK_UNHANDLED,
};

enum vm_exit_kind test_run_vcpu(struct vcpu *, struct vm_entry *,
    struct vm_exit *);

void ventry_fulfill_inout(const struct vm_exit *, struct vm_entry *, uint32_t);
void ventry_fulfill_mmio(const struct vm_exit *, struct vm_entry *, uint64_t);

bool vexit_match_inout(const struct vm_exit *, bool, uint16_t, uint_t,
    uint32_t *);
bool vexit_match_mmio(const struct vm_exit *, bool, uint64_t, uint_t,
    uint64_t *);

#endif /* _IN_GUEST_H_ */