github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/vmexit_io.h (about) 1 /* 2 * Copyright (c) 2013 Intel Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 */ 14 15 #ifndef _VMEXIT_IO_H_ 16 #define _VMEXIT_IO_H_ 17 18 19 // define this structure to resolve the conflict below: 20 // an IO port is monitored by uVMM internally, as well as TMSL/Handler 21 // status -- not enabled yet. 22 typedef enum { 23 NO_IO_OWNER = 0x00, 24 IO_OWNED_BY_UVMM = 0x01, // used by uVMM internally. 25 IO_OWNED_BY_TMSL = 0x02, // used by APIs for TMSL IB/Handler 26 IO_OWNED_BY_UVMM_TMSL = IO_OWNED_BY_UVMM | IO_OWNED_BY_TMSL, 27 } IO_PORT_OWNER; 28 29 typedef BOOLEAN (*IO_ACCESS_HANDLER)(GUEST_CPU_HANDLE gcpu, 30 UINT16 port_id, unsigned port_size, // 1, 2, 4 31 RW_ACCESS access, BOOLEAN string_intr, // ins/outs 32 BOOLEAN rep_prefix, // rep 33 UINT32 rep_count, 34 //IO_PORT_OWNER port_owner 35 void *p_value, //gva for string I/O; otherwise hva. 36 void *handler_context); 37 38 // FUNCTION : io_vmexit_setup() 39 // PURPOSE : Allocate and initialize IO VMEXITs related data structures, 40 // : common for all guests 41 // ARGUMENTS: GUEST_ID num_of_guests 42 // RETURNS : void 43 void io_vmexit_initialize(void); 44 45 46 // FUNCTION : io_vmexit_guest_setup() 47 // PURPOSE : Allocate and initialize IO VMEXITs related data structures for 48 // : specific guest 49 // ARGUMENTS: GUEST_ID guest_id 50 // RETURNS : void 51 void io_vmexit_guest_initialize(GUEST_ID guest_id); 52 53 // FUNCTION : io_vmexit_activate() 54 // PURPOSE : enables in HW IO VMEXITs for specific guest on given CPU 55 // : called during initialization 56 // ARGUMENTS: GUEST_CPU_HANDLE gcpu 57 // RETURNS : void 58 void io_vmexit_activate(GUEST_CPU_HANDLE gcpu); 59 60 // FUNCTION : io_vmexit_handler_register() 61 // PURPOSE : Register/update IO handler for spec port/guest pair. 62 // ARGUMENTS: GUEST_ID guest_id 63 // : IO_PORT_ID port_id 64 // : IO_ACCESS_HANDLER handler 65 // : void* handler_context - passed as it to the handler 66 // RETURNS : status 67 VMM_STATUS io_vmexit_handler_register( GUEST_ID guest_id, 68 IO_PORT_ID port_id, IO_ACCESS_HANDLER handler, 69 void *handler_context); 70 71 // FUNCTION : io_vmexit_handler_unregister() 72 // PURPOSE : Unregister IO handler for spec port/guest pair. 73 // ARGUMENTS: GUEST_ID guest_id 74 // : IO_PORT_ID port_id 75 // RETURNS : status 76 VMM_STATUS io_vmexit_handler_unregister( GUEST_ID guest_id, 77 IO_PORT_ID port_id); 78 79 // FUNCTION : io_vmexit_block_port() 80 // PURPOSE : Enable VMEXIT on port without installing handler. 81 // : Blocking_handler will be used for such cases. 82 // ARGUMENTS: GUEST_ID guest_id 83 // : IO_PORT_ID port_from 84 // : IO_PORT_ID port_to 85 // RETURNS : void 86 void io_vmexit_block_port( GUEST_ID guest_id, IO_PORT_ID port_from, 87 IO_PORT_ID port_to); 88 89 // FUNCTION : io_vmexit_transparent_handler() 90 // PURPOSE : Called to facilitate IO handlers to pass IO requests to HW, if needed 91 // ARGUMENTS: GUEST_ID guest_id 92 // : IO_PORT_ID port_from 93 // : IO_PORT_ID port_to 94 void io_vmexit_transparent_handler( GUEST_CPU_HANDLE gcpu, 95 UINT16 port_id, unsigned port_size, // 1, 2, 4 96 RW_ACCESS access, void *p_value, 97 void *context); // not used 98 99 #endif // _VMEXIT_IO_H_ 100