xref: /xnu-10002.81.5/tests/vm_memory_tests_src/mach_vm_tests.h (revision 5e3eaea39dcf651e66cb99ba7d70e32cc4a99587)
1*5e3eaea3SApple OSS Distributions #include <unistd.h>
2*5e3eaea3SApple OSS Distributions #include <spawn.h>
3*5e3eaea3SApple OSS Distributions #include <os/log.h>
4*5e3eaea3SApple OSS Distributions #include <bootstrap_priv.h>
5*5e3eaea3SApple OSS Distributions #include <libproc.h>
6*5e3eaea3SApple OSS Distributions #include <signal.h>
7*5e3eaea3SApple OSS Distributions #include <stdatomic.h>
8*5e3eaea3SApple OSS Distributions #include <os/assumes.h>
9*5e3eaea3SApple OSS Distributions #include <assert.h>
10*5e3eaea3SApple OSS Distributions #include <string.h>
11*5e3eaea3SApple OSS Distributions #include <sys/stat.h>
12*5e3eaea3SApple OSS Distributions #include <darwintest.h>
13*5e3eaea3SApple OSS Distributions #include <darwintest_utils.h>
14*5e3eaea3SApple OSS Distributions 
15*5e3eaea3SApple OSS Distributions #include <mach/mach_time.h>
16*5e3eaea3SApple OSS Distributions #include <mach/message.h>
17*5e3eaea3SApple OSS Distributions #include <mach/mach_traps.h>
18*5e3eaea3SApple OSS Distributions #include <mach/mach_vm.h>
19*5e3eaea3SApple OSS Distributions 
20*5e3eaea3SApple OSS Distributions #define VM_OP_NONE                    (0)
21*5e3eaea3SApple OSS Distributions #define VM_OP_UNMAP                   (1)
22*5e3eaea3SApple OSS Distributions #define VM_OP_EXIT                    (2)
23*5e3eaea3SApple OSS Distributions #define VM_OP_COPY                    (3)
24*5e3eaea3SApple OSS Distributions #define VM_OP_READ                    (4)
25*5e3eaea3SApple OSS Distributions #define VM_OP_MEMENTRY                (5)
26*5e3eaea3SApple OSS Distributions #define VM_OP_REMAP                   (6)
27*5e3eaea3SApple OSS Distributions #define VM_OP_READ_OVERWRITE          (7)
28*5e3eaea3SApple OSS Distributions #define VM_OP_WRITE                   (8)
29*5e3eaea3SApple OSS Distributions #define VM_OP_EXIT_ERROR              (9)
30*5e3eaea3SApple OSS Distributions 
31*5e3eaea3SApple OSS Distributions extern mach_port_t serverPort;
32*5e3eaea3SApple OSS Distributions extern mach_port_t persistentReplyPort;
33*5e3eaea3SApple OSS Distributions extern boolean_t debug;
34*5e3eaea3SApple OSS Distributions 
35*5e3eaea3SApple OSS Distributions struct ipc_message {
36*5e3eaea3SApple OSS Distributions 	mach_msg_header_t header;
37*5e3eaea3SApple OSS Distributions 	mach_msg_body_t body;
38*5e3eaea3SApple OSS Distributions 	mach_msg_port_descriptor_t port_descriptor;
39*5e3eaea3SApple OSS Distributions 	boolean_t                       copy;
40*5e3eaea3SApple OSS Distributions 	int                                     vm_op;
41*5e3eaea3SApple OSS Distributions 	uint64_t                        address;
42*5e3eaea3SApple OSS Distributions 	uint64_t                        pid;
43*5e3eaea3SApple OSS Distributions 	uint64_t                        size;
44*5e3eaea3SApple OSS Distributions 	uint64_t                        misoffset;
45*5e3eaea3SApple OSS Distributions 	char                            value[64];
46*5e3eaea3SApple OSS Distributions };
47*5e3eaea3SApple OSS Distributions typedef struct ipc_message ipc_message_t;
48*5e3eaea3SApple OSS Distributions 
49*5e3eaea3SApple OSS Distributions void mach_vm_client(mach_port_t);
50*5e3eaea3SApple OSS Distributions void mach_server_remap(mach_port_t);
51*5e3eaea3SApple OSS Distributions void mach_server_read(mach_port_t, int);
52*5e3eaea3SApple OSS Distributions void mach_server_make_memory_entry(mach_port_t);
53*5e3eaea3SApple OSS Distributions 
54*5e3eaea3SApple OSS Distributions int mach_server_data_setup(void **);
55*5e3eaea3SApple OSS Distributions void mach_server_data_cleanup(void *, mach_vm_address_t, mach_vm_size_t);
56*5e3eaea3SApple OSS Distributions void mach_server_construct_header(ipc_message_t *, mach_port_t);
57*5e3eaea3SApple OSS Distributions void mach_server_create_allocation(mach_vm_address_t *, mach_vm_size_t, void *);
58*5e3eaea3SApple OSS Distributions void mach_server_contruct_payload(ipc_message_t *, mach_vm_address_t, mach_port_t, mach_vm_size_t, mach_vm_offset_t, boolean_t, int);
59*5e3eaea3SApple OSS Distributions void server_error_out(mach_port_t);
60*5e3eaea3SApple OSS Distributions 
61*5e3eaea3SApple OSS Distributions 
62*5e3eaea3SApple OSS Distributions #define MACH_VM_TEST_SERVICE_NAME  "com.apple.test.xnu.vm.machVMTest"
63*5e3eaea3SApple OSS Distributions #define VM_SPAWN_TOOL "/AppleInternal/Tests/xnu/darwintests/tools/vm_spawn_tool"
64