vmcs.c (245678) | vmcs.c (249879) |
---|---|
1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/amd64/vmm/intel/vmcs.c 245678 2013-01-20 03:42:49Z neel $ | 26 * $FreeBSD: head/sys/amd64/vmm/intel/vmcs.c 249879 2013-04-25 04:56:43Z grehan $ |
27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/cdefs.h> | 27 */ 28 29#include "opt_ddb.h" 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/amd64/vmm/intel/vmcs.c 245678 2013-01-20 03:42:49Z neel $"); | 32__FBSDID("$FreeBSD: head/sys/amd64/vmm/intel/vmcs.c 249879 2013-04-25 04:56:43Z grehan $"); |
33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/pcpu.h> 37 38#include <vm/vm.h> 39#include <vm/pmap.h> 40 --- 128 unchanged lines hidden (view full) --- 169 default: 170 return (EINVAL); 171 } 172 173 return (0); 174} 175 176int | 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/pcpu.h> 37 38#include <vm/vm.h> 39#include <vm/pmap.h> 40 --- 128 unchanged lines hidden (view full) --- 169 default: 170 return (EINVAL); 171 } 172 173 return (0); 174} 175 176int |
177vmcs_getreg(struct vmcs *vmcs, int ident, uint64_t *retval) | 177vmcs_getreg(struct vmcs *vmcs, int running, int ident, uint64_t *retval) |
178{ 179 int error; 180 uint32_t encoding; 181 182 /* 183 * If we need to get at vmx-specific state in the VMCS we can bypass 184 * the translation of 'ident' to 'encoding' by simply setting the 185 * sign bit. As it so happens the upper 16 bits are reserved (i.e 186 * set to 0) in the encodings for the VMCS so we are free to use the 187 * sign bit. 188 */ 189 if (ident < 0) 190 encoding = ident & 0x7fffffff; 191 else 192 encoding = vmcs_field_encoding(ident); 193 194 if (encoding == (uint32_t)-1) 195 return (EINVAL); 196 | 178{ 179 int error; 180 uint32_t encoding; 181 182 /* 183 * If we need to get at vmx-specific state in the VMCS we can bypass 184 * the translation of 'ident' to 'encoding' by simply setting the 185 * sign bit. As it so happens the upper 16 bits are reserved (i.e 186 * set to 0) in the encodings for the VMCS so we are free to use the 187 * sign bit. 188 */ 189 if (ident < 0) 190 encoding = ident & 0x7fffffff; 191 else 192 encoding = vmcs_field_encoding(ident); 193 194 if (encoding == (uint32_t)-1) 195 return (EINVAL); 196 |
197 VMPTRLD(vmcs); | 197 if (!running) 198 VMPTRLD(vmcs); 199 |
198 error = vmread(encoding, retval); | 200 error = vmread(encoding, retval); |
199 VMCLEAR(vmcs); | 201 202 if (!running) 203 VMCLEAR(vmcs); 204 |
200 return (error); 201} 202 203int | 205 return (error); 206} 207 208int |
204vmcs_setreg(struct vmcs *vmcs, int ident, uint64_t val) | 209vmcs_setreg(struct vmcs *vmcs, int running, int ident, uint64_t val) |
205{ 206 int error; 207 uint32_t encoding; 208 209 if (ident < 0) 210 encoding = ident & 0x7fffffff; 211 else 212 encoding = vmcs_field_encoding(ident); 213 214 if (encoding == (uint32_t)-1) 215 return (EINVAL); 216 217 val = vmcs_fix_regval(encoding, val); 218 | 210{ 211 int error; 212 uint32_t encoding; 213 214 if (ident < 0) 215 encoding = ident & 0x7fffffff; 216 else 217 encoding = vmcs_field_encoding(ident); 218 219 if (encoding == (uint32_t)-1) 220 return (EINVAL); 221 222 val = vmcs_fix_regval(encoding, val); 223 |
219 VMPTRLD(vmcs); | 224 if (!running) 225 VMPTRLD(vmcs); 226 |
220 error = vmwrite(encoding, val); | 227 error = vmwrite(encoding, val); |
221 VMCLEAR(vmcs); | 228 229 if (!running) 230 VMCLEAR(vmcs); 231 |
222 return (error); 223} 224 225int 226vmcs_setdesc(struct vmcs *vmcs, int seg, struct seg_desc *desc) 227{ 228 int error; 229 uint32_t base, limit, access; --- 322 unchanged lines hidden --- | 232 return (error); 233} 234 235int 236vmcs_setdesc(struct vmcs *vmcs, int seg, struct seg_desc *desc) 237{ 238 int error; 239 uint32_t base, limit, access; --- 322 unchanged lines hidden --- |