summaryrefslogtreecommitdiff
path: root/usr/src/test/bhyve-tests/tests/common/in_guest.h
blob: fdacd6f54061a5bc0b52fa047737cc5210d81d88 (plain)
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
/*
 * 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 2022 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_flags(const char *, uint64_t);
void test_cleanup(bool);
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);

int test_setup_vcpu(struct vmctx *, int, 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,
	/* Test specific logic must handle exit data */
	VEK_UNHANDLED,
};

enum vm_exit_kind test_run_vcpu(struct vmctx *, int, 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_ */