File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,24 @@ static void vm_setup_cpu_cx(struct vm *vm)
110
110
111
111
}
112
112
113
+ static inline void init_cx_port (struct vm * vm )
114
+ {
115
+ uint8_t cx_idx ;
116
+
117
+ for (cx_idx = 2 ; cx_idx <= vm -> pm .cx_cnt ; cx_idx ++ ) {
118
+ struct cpu_cx_data * cx_data = vm -> pm .cx_data + cx_idx ;
119
+
120
+ if (cx_data -> cx_reg .space_id == SPACE_SYSTEM_IO ) {
121
+ uint16_t port = (uint16_t )cx_data -> cx_reg .address ;
122
+
123
+ allow_guest_io_access (vm , port , 1 );
124
+ }
125
+ }
126
+ }
127
+
113
128
void vm_setup_cpu_state (struct vm * vm )
114
129
{
115
130
vm_setup_cpu_px (vm );
116
131
vm_setup_cpu_cx (vm );
132
+ init_cx_port (vm );
117
133
}
Original file line number Diff line number Diff line change @@ -190,6 +190,22 @@ void free_io_emulation_resource(struct vm *vm)
190
190
free (vm -> arch_vm .iobitmap [1 ]);
191
191
}
192
192
193
+ void allow_guest_io_access (struct vm * vm , uint32_t address , uint32_t nbytes )
194
+ {
195
+ uint32_t * b ;
196
+ uint32_t i ;
197
+ uint32_t a ;
198
+
199
+ b = vm -> arch_vm .iobitmap [0 ];
200
+ for (i = 0 ; i < nbytes ; i ++ ) {
201
+ if (address & 0x8000 )
202
+ b = vm -> arch_vm .iobitmap [1 ];
203
+ a = address & 0x7fff ;
204
+ b [a >> 5 ] &= ~(1 << (a & 0x1f ));
205
+ address ++ ;
206
+ }
207
+ }
208
+
193
209
static void deny_guest_io_access (struct vm * vm , uint32_t address , uint32_t nbytes )
194
210
{
195
211
uint32_t * b ;
Original file line number Diff line number Diff line change @@ -170,6 +170,7 @@ struct vm_io_handler {
170
170
int io_instr_vmexit_handler (struct vcpu * vcpu );
171
171
void setup_io_bitmap (struct vm * vm );
172
172
void free_io_emulation_resource (struct vm * vm );
173
+ void allow_guest_io_access (struct vm * vm , uint32_t address , uint32_t nbytes );
173
174
void register_io_emulation_handler (struct vm * vm , struct vm_io_range * range ,
174
175
io_read_fn_t io_read_fn_ptr ,
175
176
io_write_fn_t io_write_fn_ptr );
You can’t perform that action at this time.
0 commit comments