| 61 |
#define SW_SREG_FS_BIT (1 << 4) |
#define SW_SREG_FS_BIT (1 << 4) |
| 62 |
#define SW_SREG_GS_BIT (1 << 5) |
#define SW_SREG_GS_BIT (1 << 5) |
| 63 |
|
|
| 64 |
/* 0f 01 c1 vmcall */ |
#define ASM_VMCALL "vmcall" |
|
#ifdef AS_DOESNT_SUPPORT_VMX |
|
|
# define ASM_VMCALL ".byte 0x0F, 0x01, 0xC1" |
|
|
#else |
|
|
# define ASM_VMCALL "vmcall" |
|
|
#endif |
|
| 65 |
|
|
| 66 |
asmlinkage int asm_vmlaunch_regs_32 (struct vt_vmentry_regs *p); |
asmlinkage int asm_vmlaunch_regs_32 (struct vt_vmentry_regs *p); |
| 67 |
asmlinkage int asm_vmresume_regs_32 (struct vt_vmentry_regs *p); |
asmlinkage int asm_vmresume_regs_32 (struct vt_vmentry_regs *p); |
| 221 |
static inline void |
static inline void |
| 222 |
asm_vmxon (void *vmxon_region) |
asm_vmxon (void *vmxon_region) |
| 223 |
{ |
{ |
|
#ifdef AS_DOESNT_SUPPORT_VMX |
|
|
asm volatile (".byte 0xf3, 0x0f, 0xc7, 0x33" |
|
|
: |
|
|
: "b" (vmxon_region) |
|
|
: "cc", "memory"); |
|
|
#else |
|
| 224 |
asm volatile ("vmxon %0" |
asm volatile ("vmxon %0" |
| 225 |
: |
: |
| 226 |
: "m" (*(ulong *)vmxon_region) |
: "m" (*(ulong *)vmxon_region) |
| 227 |
: "cc", "memory"); |
: "cc", "memory"); |
|
#endif |
|
| 228 |
} |
} |
| 229 |
|
|
| 230 |
/* 0f 01 c4 vmxoff */ |
/* 0f 01 c4 vmxoff */ |
| 231 |
static inline void |
static inline void |
| 232 |
asm_vmxoff (void) |
asm_vmxoff (void) |
| 233 |
{ |
{ |
|
#ifdef AS_DOESNT_SUPPORT_VMX |
|
|
asm volatile (".byte 0x0f, 0x01, 0xc4" |
|
|
: |
|
|
: |
|
|
: "cc"); |
|
|
#else |
|
| 234 |
asm volatile ("vmxoff" |
asm volatile ("vmxoff" |
| 235 |
: |
: |
| 236 |
: |
: |
| 237 |
: "cc"); |
: "cc"); |
|
#endif |
|
| 238 |
} |
} |
| 239 |
|
|
| 240 |
/* 66 0f c7 33 vmclear (%ebx) */ |
/* 66 0f c7 33 vmclear (%ebx) */ |
| 258 |
static inline void |
static inline void |
| 259 |
asm_vmptrld (void *p) |
asm_vmptrld (void *p) |
| 260 |
{ |
{ |
|
#ifdef AS_DOESNT_SUPPORT_VMX |
|
|
asm volatile (".byte 0x0f, 0xc7, 0x33" |
|
|
: |
|
|
: "b" (p) |
|
|
: "cc", "memory"); |
|
|
#else |
|
| 261 |
asm volatile ("vmptrld %0" |
asm volatile ("vmptrld %0" |
| 262 |
: |
: |
| 263 |
: "m" (*(ulong *)p) |
: "m" (*(ulong *)p) |
| 264 |
: "cc", "memory"); |
: "cc", "memory"); |
|
#endif |
|
| 265 |
} |
} |
| 266 |
|
|
| 267 |
/* 0f c7 3b vmptrst (%ebx) */ |
/* 0f c7 3b vmptrst (%ebx) */ |
| 268 |
static inline void |
static inline void |
| 269 |
asm_vmptrst (void *p) |
asm_vmptrst (void *p) |
| 270 |
{ |
{ |
|
#ifdef AS_DOESNT_SUPPORT_VMX |
|
|
asm volatile (".byte 0x0f, 0xc7, 0x3b" |
|
|
: |
|
|
: "b" (p) |
|
|
: "cc", "memory"); |
|
|
#else |
|
| 271 |
asm volatile ("vmptrst %0" |
asm volatile ("vmptrst %0" |
| 272 |
: |
: |
| 273 |
: "m" (*(ulong *)p) |
: "m" (*(ulong *)p) |
| 274 |
: "cc", "memory"); |
: "cc", "memory"); |
|
#endif |
|
| 275 |
} |
} |
| 276 |
|
|
| 277 |
/* 0f 79 c2 vmwrite %edx,%eax */ |
/* 0f 79 c2 vmwrite %edx,%eax */ |
| 292 |
} |
} |
| 293 |
|
|
| 294 |
static inline void |
static inline void |
| 295 |
|
asm_vmwrite32(ulong index, u32 val) |
| 296 |
|
{ |
| 297 |
|
ulong ulong_val = val; |
| 298 |
|
asm volatile ("vmwrite %1,%0" |
| 299 |
|
: |
| 300 |
|
: "r" (index), "rm" (ulong_val) |
| 301 |
|
: "cc"); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
static inline void |
| 305 |
asm_vmwrite64(ulong index, u64 val) |
asm_vmwrite64(ulong index, u64 val) |
| 306 |
{ |
{ |
| 307 |
#ifdef __x86_64__ |
#ifdef __x86_64__ |
| 308 |
asm_vmwrite(index, (ulong)val); |
asm volatile ("vmwrite %1,%0" |
| 309 |
|
: |
| 310 |
|
: "r" (index), "rm" (val) |
| 311 |
|
: "cc"); |
| 312 |
#else |
#else |
| 313 |
ulong low, high; |
ulong low, high; |
| 314 |
low = val; |
low = val; |
| 344 |
static inline void |
static inline void |
| 345 |
asm_vmread (ulong index, ulong *val) |
asm_vmread (ulong index, ulong *val) |
| 346 |
{ |
{ |
|
#ifdef AS_DOESNT_SUPPORT_VMX |
|
|
asm volatile (".byte 0x0f, 0x78, 0xc2" |
|
|
: "=d" (*val) |
|
|
: "a" (index) |
|
|
: "cc"); |
|
|
#else |
|
| 347 |
asm volatile ("vmread %1,%0" |
asm volatile ("vmread %1,%0" |
| 348 |
: "=rm" (*val) |
: "=rm" (*val) |
| 349 |
: "r" (index) |
: "r" (index) |
| 350 |
: "cc"); |
: "cc"); |
|
#endif |
|
| 351 |
} |
} |
| 352 |
|
|
| 353 |
static inline void |
static inline void |
| 354 |
asm_vmread64(ulong index, u64 *val) |
asm_vmread32(ulong index, u32 *val) |
| 355 |
{ |
{ |
|
#ifdef __x86_64__ |
|
| 356 |
ulong ulong_val; |
ulong ulong_val; |
| 357 |
asm_vmread(index, &ulong_val); |
asm volatile ("vmread %1,%0" |
| 358 |
|
: "=rm" (ulong_val) |
| 359 |
|
: "r" (index) |
| 360 |
|
: "cc"); |
| 361 |
*val = ulong_val; |
*val = ulong_val; |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
static inline void |
| 365 |
|
asm_vmread64(ulong index, u64 *val) |
| 366 |
|
{ |
| 367 |
|
#ifdef __x86_64__ |
| 368 |
|
asm volatile ("vmread %1,%0" |
| 369 |
|
: "=rm" (*val) |
| 370 |
|
: "r" (index) |
| 371 |
|
: "cc"); |
| 372 |
#else |
#else |
| 373 |
ulong low, high; |
ulong low, high; |
| 374 |
asm_vmread(index, &low); |
asm_vmread(index, &low); |