Changeset 80112 in vbox for trunk/include/VBox/vmm
- Timestamp:
- Aug 2, 2019 2:47:35 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/hmvmxinline.h
r80110 r80112 251 251 * @param HCPhysVmxOn Physical address of VMXON structure. 252 252 */ 253 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS)253 #if RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS 254 254 DECLASM(int) VMXEnable(RTHCPHYS HCPhysVmxOn); 255 255 #else 256 256 DECLINLINE(int) VMXEnable(RTHCPHYS HCPhysVmxOn) 257 257 { 258 # if RT_INLINE_ASM_GNU_STYLE 259 int rc = VINF_SUCCESS; 258 # if VMX_USE_MSC_INTRINSICS 259 unsigned char rcMsc = __vmx_on(&HCPhysVmxOn); 260 if (RT_LIKELY(rcMsc == 0)) 261 return VINF_SUCCESS; 262 return rcMsc == 2 ? VERR_VMX_INVALID_VMXON_PTR : VERR_VMX_VMXON_FAILED; 263 264 # elif RT_INLINE_ASM_GNU_STYLE 265 # ifdef RT_ARCH_AMD64 266 int rc; 267 __asm__ __volatile__ ( 268 "pushq %2 \n\t" 269 ".byte 0xf3, 0x0f, 0xc7, 0x34, 0x24 # VMXON [esp] \n\t" 270 "ja 2f \n\t" 271 "je 1f \n\t" 272 "movl $" RT_XSTR(VERR_VMX_INVALID_VMXON_PTR)", %0 \n\t" 273 "jmp 2f \n\t" 274 "1: \n\t" 275 "movl $" RT_XSTR(VERR_VMX_VMXON_FAILED)", %0 \n\t" 276 "2: \n\t" 277 "add $8, %%rsp \n\t" 278 :"=rm"(rc) 279 :"0"(VINF_SUCCESS), 280 "ir"(HCPhysVmxOn) /* don't allow direct memory reference here, */ 281 /* this would not work with -fomit-frame-pointer */ 282 :"memory" 283 ); 284 return rc; 285 # else 286 int rc; 260 287 __asm__ __volatile__ ( 261 288 "push %3 \n\t" … … 277 304 ); 278 305 return rc; 279 280 # elif VMX_USE_MSC_INTRINSICS 281 unsigned char rcMsc = __vmx_on(&HCPhysVmxOn); 282 if (RT_LIKELY(rcMsc == 0)) 283 return VINF_SUCCESS; 284 return rcMsc == 2 ? VERR_VMX_INVALID_VMXON_PTR : VERR_VMX_VMXON_FAILED; 285 286 # else 306 # endif 307 308 # elif defined(RT_ARCH_X86) 287 309 int rc = VINF_SUCCESS; 288 310 __asm … … 306 328 } 307 329 return rc; 308 # endif 309 } 330 331 # else 332 # error "Shouldn't be here..." 333 # endif 334 } 335 #endif 336 337 338 #if 0 339 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS) 340 DECLASM(int) VMXEnable(RTHCPHYS HCPhysVmxOn); 341 #else 342 DECLINLINE(int) VMXEnable(RTHCPHYS HCPhysVmxOn) 343 { 344 # if RT_INLINE_ASM_GNU_STYLE 345 int rc = VINF_SUCCESS; 346 __asm__ __volatile__ ( 347 "push %3 \n\t" 348 "push %2 \n\t" 349 ".byte 0xf3, 0x0f, 0xc7, 0x34, 0x24 # VMXON [esp] \n\t" 350 "ja 2f \n\t" 351 "je 1f \n\t" 352 "movl $" RT_XSTR(VERR_VMX_INVALID_VMXON_PTR)", %0 \n\t" 353 "jmp 2f \n\t" 354 "1: \n\t" 355 "movl $" RT_XSTR(VERR_VMX_VMXON_FAILED)", %0 \n\t" 356 "2: \n\t" 357 "add $8, %%esp \n\t" 358 :"=rm"(rc) 359 :"0"(VINF_SUCCESS), 360 "ir"((uint32_t)HCPhysVmxOn), /* don't allow direct memory reference here, */ 361 "ir"((uint32_t)(HCPhysVmxOn >> 32)) /* this would not work with -fomit-frame-pointer */ 362 :"memory" 363 ); 364 return rc; 365 366 # elif VMX_USE_MSC_INTRINSICS 367 unsigned char rcMsc = __vmx_on(&HCPhysVmxOn); 368 if (RT_LIKELY(rcMsc == 0)) 369 return VINF_SUCCESS; 370 return rcMsc == 2 ? VERR_VMX_INVALID_VMXON_PTR : VERR_VMX_VMXON_FAILED; 371 372 # else 373 int rc = VINF_SUCCESS; 374 __asm 375 { 376 push dword ptr [HCPhysVmxOn + 4] 377 push dword ptr [HCPhysVmxOn] 378 _emit 0xf3 379 _emit 0x0f 380 _emit 0xc7 381 _emit 0x34 382 _emit 0x24 /* VMXON [esp] */ 383 jnc vmxon_good 384 mov dword ptr [rc], VERR_VMX_INVALID_VMXON_PTR 385 jmp the_end 386 387 vmxon_good: 388 jnz the_end 389 mov dword ptr [rc], VERR_VMX_VMXON_FAILED 390 the_end: 391 add esp, 8 392 } 393 return rc; 394 # endif 395 } 396 #endif 310 397 #endif 311 398 … … 314 401 * Executes VMXOFF. 315 402 */ 316 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS)403 #if RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS 317 404 DECLASM(void) VMXDisable(void); 318 405 #else 319 406 DECLINLINE(void) VMXDisable(void) 320 407 { 321 # if RT_INLINE_ASM_GNU_STYLE 408 # if VMX_USE_MSC_INTRINSICS 409 __vmx_off(); 410 411 # elif RT_INLINE_ASM_GNU_STYLE 322 412 __asm__ __volatile__ ( 323 413 ".byte 0x0f, 0x01, 0xc4 # VMXOFF \n\t" 324 414 ); 325 415 326 # elif VMX_USE_MSC_INTRINSICS 327 __vmx_off(); 328 329 # else 416 # elif defined(RT_ARCH_X86) 330 417 __asm 331 418 { … … 334 421 _emit 0xc4 /* VMXOFF */ 335 422 } 336 # endif 337 } 423 424 # else 425 # error "Shouldn't be here..." 426 # endif 427 } 428 #endif 429 430 431 #if 0 432 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS) 433 DECLASM(void) VMXDisable(void); 434 #else 435 DECLINLINE(void) VMXDisable(void) 436 { 437 # if RT_INLINE_ASM_GNU_STYLE 438 __asm__ __volatile__ ( 439 ".byte 0x0f, 0x01, 0xc4 # VMXOFF \n\t" 440 ); 441 442 # elif VMX_USE_MSC_INTRINSICS 443 __vmx_off(); 444 445 # else 446 __asm 447 { 448 _emit 0x0f 449 _emit 0x01 450 _emit 0xc4 /* VMXOFF */ 451 } 452 # endif 453 } 454 #endif 338 455 #endif 339 456 … … 345 462 * @param HCPhysVmcs Physical address of VM control structure. 346 463 */ 464 #if RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS 465 DECLASM(int) VMXClearVmcs(RTHCPHYS HCPhysVmcs); 466 #else 467 DECLINLINE(int) VMXClearVmcs(RTHCPHYS HCPhysVmcs) 468 { 469 # if VMX_USE_MSC_INTRINSICS 470 unsigned char rcMsc = __vmx_vmclear(&HCPhysVmcs); 471 if (RT_LIKELY(rcMsc == 0)) 472 return VINF_SUCCESS; 473 return VERR_VMX_INVALID_VMCS_PTR; 474 475 # elif RT_INLINE_ASM_GNU_STYLE 476 # ifdef RT_ARCH_AMD64 477 int rc; 478 __asm__ __volatile__ ( 479 "pushq %2 \n\t" 480 ".byte 0x66, 0x0f, 0xc7, 0x34, 0x24 # VMCLEAR [esp] \n\t" 481 "jnc 1f \n\t" 482 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 483 "1: \n\t" 484 "add $8, %%rsp \n\t" 485 :"=rm"(rc) 486 :"0"(VINF_SUCCESS), 487 "ir"(HCPhysVmcs) /* don't allow direct memory reference here, */ 488 /* this would not work with -fomit-frame-pointer */ 489 :"memory" 490 ); 491 return rc; 492 # else 493 int rc; 494 __asm__ __volatile__ ( 495 "push %3 \n\t" 496 "push %2 \n\t" 497 ".byte 0x66, 0x0f, 0xc7, 0x34, 0x24 # VMCLEAR [esp] \n\t" 498 "jnc 1f \n\t" 499 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 500 "1: \n\t" 501 "add $8, %%esp \n\t" 502 :"=rm"(rc) 503 :"0"(VINF_SUCCESS), 504 "ir"((uint32_t)HCPhysVmcs), /* don't allow direct memory reference here, */ 505 "ir"((uint32_t)(HCPhysVmcs >> 32)) /* this would not work with -fomit-frame-pointer */ 506 :"memory" 507 ); 508 return rc; 509 # endif 510 511 # elif defined(RT_ARCH_X86) 512 int rc = VINF_SUCCESS; 513 __asm 514 { 515 push dword ptr [HCPhysVmcs + 4] 516 push dword ptr [HCPhysVmcs] 517 _emit 0x66 518 _emit 0x0f 519 _emit 0xc7 520 _emit 0x34 521 _emit 0x24 /* VMCLEAR [esp] */ 522 jnc success 523 mov dword ptr [rc], VERR_VMX_INVALID_VMCS_PTR 524 success: 525 add esp, 8 526 } 527 return rc; 528 529 # else 530 # error "Shouldn't be here..." 531 # endif 532 } 533 #endif 534 535 536 #if 0 347 537 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS) 348 538 DECLASM(int) VMXClearVmcs(RTHCPHYS HCPhysVmcs); … … 394 584 } 395 585 #endif 586 #endif 396 587 397 588 … … 402 593 * @param HCPhysVmcs Physical address of VMCS structure. 403 594 */ 595 #if RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS 596 DECLASM(int) VMXLoadVmcs(RTHCPHYS HCPhysVmcs); 597 #else 598 DECLINLINE(int) VMXLoadVmcs(RTHCPHYS HCPhysVmcs) 599 { 600 # if VMX_USE_MSC_INTRINSICS 601 unsigned char rcMsc = __vmx_vmptrld(&HCPhysVmcs); 602 if (RT_LIKELY(rcMsc == 0)) 603 return VINF_SUCCESS; 604 return VERR_VMX_INVALID_VMCS_PTR; 605 606 # elif RT_INLINE_ASM_GNU_STYLE 607 # ifdef RT_ARCH_AMD64 608 int rc; 609 __asm__ __volatile__ ( 610 "pushq %2 \n\t" 611 ".byte 0x0f, 0xc7, 0x34, 0x24 # VMPTRLD [esp] \n\t" 612 "jnc 1f \n\t" 613 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 614 "1: \n\t" 615 "add $8, %%rsp \n\t" 616 :"=rm"(rc) 617 :"0"(VINF_SUCCESS), 618 "ir"(HCPhysVmcs) /* don't allow direct memory reference here, */ 619 /* this will not work with -fomit-frame-pointer */ 620 :"memory" 621 ); 622 return rc; 623 # else 624 int rc; 625 __asm__ __volatile__ ( 626 "push %3 \n\t" 627 "push %2 \n\t" 628 ".byte 0x0f, 0xc7, 0x34, 0x24 # VMPTRLD [esp] \n\t" 629 "jnc 1f \n\t" 630 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 631 "1: \n\t" 632 "add $8, %%esp \n\t" 633 :"=rm"(rc) 634 :"0"(VINF_SUCCESS), 635 "ir"((uint32_t)HCPhysVmcs), /* don't allow direct memory reference here, */ 636 "ir"((uint32_t)(HCPhysVmcs >> 32)) /* this will not work with -fomit-frame-pointer */ 637 :"memory" 638 ); 639 return rc; 640 # endif 641 642 # elif defined(RT_ARCH_X86) 643 int rc = VINF_SUCCESS; 644 __asm 645 { 646 push dword ptr [HCPhysVmcs + 4] 647 push dword ptr [HCPhysVmcs] 648 _emit 0x0f 649 _emit 0xc7 650 _emit 0x34 651 _emit 0x24 /* VMPTRLD [esp] */ 652 jnc success 653 mov dword ptr [rc], VERR_VMX_INVALID_VMCS_PTR 654 success: 655 add esp, 8 656 } 657 return rc; 658 659 # else 660 # error "Shouldn't be here..." 661 # endif 662 } 663 #endif 664 665 #if 0 404 666 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS) 405 667 DECLASM(int) VMXLoadVmcs(RTHCPHYS HCPhysVmcs); … … 450 712 } 451 713 #endif 714 #endif 452 715 453 716 … … 476 739 * will be VERR_VMX_INVALID_VMCS_PTR. 477 740 */ 478 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS)741 #if RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS 479 742 DECLASM(int) VMXWriteVmcs32(uint32_t uFieldEnc, uint32_t u32Val); 480 743 #else 481 744 DECLINLINE(int) VMXWriteVmcs32(uint32_t uFieldEnc, uint32_t u32Val) 482 745 { 483 # if RT_INLINE_ASM_GNU_STYLE 484 int rc = VINF_SUCCESS; 746 # if VMX_USE_MSC_INTRINSICS 747 unsigned char rcMsc = __vmx_vmwrite(uFieldEnc, u32Val); 748 if (RT_LIKELY(rcMsc == 0)) 749 return VINF_SUCCESS; 750 return rcMsc == 2 ? VERR_VMX_INVALID_VMCS_PTR : VERR_VMX_INVALID_VMCS_FIELD; 751 752 # elif RT_INLINE_ASM_GNU_STYLE 753 int rc; 485 754 __asm__ __volatile__ ( 486 755 ".byte 0x0f, 0x79, 0xc2 # VMWRITE eax, edx \n\t" … … 499 768 return rc; 500 769 501 # elif VMX_USE_MSC_INTRINSICS 502 unsigned char rcMsc = __vmx_vmwrite(uFieldEnc, u32Val); 503 if (RT_LIKELY(rcMsc == 0)) 504 return VINF_SUCCESS; 505 return rcMsc == 2 ? VERR_VMX_INVALID_VMCS_PTR : VERR_VMX_INVALID_VMCS_FIELD; 506 507 #else 770 # elif defined(RT_ARCH_X86) 508 771 int rc = VINF_SUCCESS; 509 772 __asm … … 518 781 mov dword ptr [rc], VERR_VMX_INVALID_VMCS_PTR 519 782 jmp the_end 520 521 783 valid_vmcs: 522 784 jnz the_end … … 526 788 } 527 789 return rc; 528 # endif 529 } 790 791 # else 792 # error "Shouldn't be here..." 793 # endif 794 } 795 #endif 796 797 798 #if 0 799 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS) 800 DECLASM(int) VMXWriteVmcs32(uint32_t uFieldEnc, uint32_t u32Val); 801 #else 802 DECLINLINE(int) VMXWriteVmcs32(uint32_t uFieldEnc, uint32_t u32Val) 803 { 804 # if RT_INLINE_ASM_GNU_STYLE 805 int rc = VINF_SUCCESS; 806 __asm__ __volatile__ ( 807 ".byte 0x0f, 0x79, 0xc2 # VMWRITE eax, edx \n\t" 808 "ja 2f \n\t" 809 "je 1f \n\t" 810 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 811 "jmp 2f \n\t" 812 "1: \n\t" 813 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_FIELD)", %0 \n\t" 814 "2: \n\t" 815 :"=rm"(rc) 816 :"0"(VINF_SUCCESS), 817 "a"(uFieldEnc), 818 "d"(u32Val) 819 ); 820 return rc; 821 822 # elif VMX_USE_MSC_INTRINSICS 823 unsigned char rcMsc = __vmx_vmwrite(uFieldEnc, u32Val); 824 if (RT_LIKELY(rcMsc == 0)) 825 return VINF_SUCCESS; 826 return rcMsc == 2 ? VERR_VMX_INVALID_VMCS_PTR : VERR_VMX_INVALID_VMCS_FIELD; 827 828 #else 829 int rc = VINF_SUCCESS; 830 __asm 831 { 832 push dword ptr [u32Val] 833 mov eax, [uFieldEnc] 834 _emit 0x0f 835 _emit 0x79 836 _emit 0x04 837 _emit 0x24 /* VMWRITE eax, [esp] */ 838 jnc valid_vmcs 839 mov dword ptr [rc], VERR_VMX_INVALID_VMCS_PTR 840 jmp the_end 841 842 valid_vmcs: 843 jnz the_end 844 mov dword ptr [rc], VERR_VMX_INVALID_VMCS_FIELD 845 the_end: 846 add esp, 4 847 } 848 return rc; 849 # endif 850 } 851 #endif 530 852 #endif 531 853 … … 545 867 * will be VERR_VMX_INVALID_VMCS_PTR. 546 868 */ 547 #if (defined(RT_ARCH_AMD64) && VMX_USE_MSC_INTRINSICS) 869 #if defined(RT_ARCH_X86) || (RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS) 870 DECLASM(int) VMXWriteVmcs64(uint32_t uFieldEnc, uint64_t u64Val); 871 #else 548 872 DECLINLINE(int) VMXWriteVmcs64(uint32_t uFieldEnc, uint64_t u64Val) 549 873 { 874 # if VMX_USE_MSC_INTRINSICS 550 875 unsigned char rcMsc = __vmx_vmwrite(uFieldEnc, u64Val); 551 876 if (RT_LIKELY(rcMsc == 0)) 552 877 return VINF_SUCCESS; 553 878 return rcMsc == 2 ? VERR_VMX_INVALID_VMCS_PTR : VERR_VMX_INVALID_VMCS_FIELD; 879 880 # elif RT_INLINE_ASM_GNU_STYLE 881 int rc; 882 __asm__ __volatile__ ( 883 ".byte 0x0f, 0x79, 0xc2 # VMWRITE eax, edx \n\t" 884 "ja 2f \n\t" 885 "je 1f \n\t" 886 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 887 "jmp 2f \n\t" 888 "1: \n\t" 889 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_FIELD)", %0 \n\t" 890 "2: \n\t" 891 :"=rm"(rc) 892 :"0"(VINF_SUCCESS), 893 "a"(uFieldEnc), 894 "d"(u64Val) 895 ); 896 return rc; 897 898 # else 899 # error "Shouldn't be here..." 900 # endif 901 } 902 #endif 903 904 905 #if 0 906 #if (defined(RT_ARCH_AMD64) && VMX_USE_MSC_INTRINSICS) 907 DECLINLINE(int) VMXWriteVmcs64(uint32_t uFieldEnc, uint64_t u64Val) 908 { 909 unsigned char rcMsc = __vmx_vmwrite(uFieldEnc, u64Val); 910 if (RT_LIKELY(rcMsc == 0)) 911 return VINF_SUCCESS; 912 return rcMsc == 2 ? VERR_VMX_INVALID_VMCS_PTR : VERR_VMX_INVALID_VMCS_FIELD; 554 913 } 555 914 #else 556 915 DECLASM(int) VMXWriteVmcs64(uint32_t uFieldEnc, uint64_t u64Val); 916 #endif 557 917 #endif 558 918 … … 623 983 * will be VERR_VMX_INVALID_VMCS_PTR. 624 984 */ 625 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS)985 #if RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS 626 986 DECLASM(int) VMXReadVmcs32(uint32_t uFieldEnc, uint32_t *pData); 627 987 #else 628 988 DECLINLINE(int) VMXReadVmcs32(uint32_t uFieldEnc, uint32_t *pData) 629 989 { 630 # if RT_INLINE_ASM_GNU_STYLE 631 int rc = VINF_SUCCESS; 990 # if VMX_USE_MSC_INTRINSICS 991 unsigned char rcMsc; 992 uint64_t u64Tmp; 993 rcMsc = __vmx_vmread(uFieldEnc, &u64Tmp); 994 *pData = (uint32_t)u64Tmp; 995 if (RT_LIKELY(rcMsc == 0)) 996 return VINF_SUCCESS; 997 return rcMsc == 2 ? VERR_VMX_INVALID_VMCS_PTR : VERR_VMX_INVALID_VMCS_FIELD; 998 999 # elif RT_INLINE_ASM_GNU_STYLE 1000 int rc; 632 1001 __asm__ __volatile__ ( 633 1002 "movl $" RT_XSTR(VINF_SUCCESS)", %0 \n\t" … … 647 1016 return rc; 648 1017 1018 # elif defined(RT_ARCH_X86) 1019 int rc = VINF_SUCCESS; 1020 __asm 1021 { 1022 sub esp, 4 1023 mov dword ptr [esp], 0 1024 mov eax, [uFieldEnc] 1025 _emit 0x0f 1026 _emit 0x78 1027 _emit 0x04 1028 _emit 0x24 /* VMREAD eax, [esp] */ 1029 mov edx, pData 1030 pop dword ptr [edx] 1031 jnc valid_vmcs 1032 mov dword ptr [rc], VERR_VMX_INVALID_VMCS_PTR 1033 jmp the_end 1034 valid_vmcs: 1035 jnz the_end 1036 mov dword ptr [rc], VERR_VMX_INVALID_VMCS_FIELD 1037 the_end: 1038 } 1039 return rc; 1040 1041 # else 1042 # error "Shouldn't be here..." 1043 # endif 1044 } 1045 #endif 1046 1047 #if 0 1048 #if ((RT_INLINE_ASM_EXTERNAL || !defined(RT_ARCH_X86)) && !VMX_USE_MSC_INTRINSICS) 1049 DECLASM(int) VMXReadVmcs32(uint32_t uFieldEnc, uint32_t *pData); 1050 #else 1051 DECLINLINE(int) VMXReadVmcs32(uint32_t uFieldEnc, uint32_t *pData) 1052 { 1053 # if RT_INLINE_ASM_GNU_STYLE 1054 int rc = VINF_SUCCESS; 1055 __asm__ __volatile__ ( 1056 "movl $" RT_XSTR(VINF_SUCCESS)", %0 \n\t" 1057 ".byte 0x0f, 0x78, 0xc2 # VMREAD eax, edx \n\t" 1058 "ja 2f \n\t" 1059 "je 1f \n\t" 1060 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 1061 "jmp 2f \n\t" 1062 "1: \n\t" 1063 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_FIELD)", %0 \n\t" 1064 "2: \n\t" 1065 :"=&r"(rc), 1066 "=d"(*pData) 1067 :"a"(uFieldEnc), 1068 "d"(0) 1069 ); 1070 return rc; 1071 649 1072 # elif VMX_USE_MSC_INTRINSICS 650 1073 unsigned char rcMsc; … … 686 1109 } 687 1110 #endif 1111 #endif 688 1112 689 1113 … … 702 1126 * will be VERR_VMX_INVALID_VMCS_PTR. 703 1127 */ 1128 #if defined(RT_ARCH_X86) || (RT_INLINE_ASM_EXTERNAL && !VMX_USE_MSC_INTRINSICS) 1129 DECLASM(int) VMXReadVmcs64(uint32_t uFieldEnc, uint64_t *pData); 1130 #else 1131 DECLINLINE(int) VMXReadVmcs64(uint32_t uFieldEnc, uint64_t *pData) 1132 { 1133 # if VMX_USE_MSC_INTRINSICS 1134 unsigned char rcMsc; 1135 rcMsc = __vmx_vmread(uFieldEnc, pData); 1136 if (RT_LIKELY(rcMsc == 0)) 1137 return VINF_SUCCESS; 1138 return rcMsc == 2 ? VERR_VMX_INVALID_VMCS_PTR : VERR_VMX_INVALID_VMCS_FIELD; 1139 1140 # elif RT_INLINE_ASM_GNU_STYLE 1141 int rc; 1142 __asm__ __volatile__ ( 1143 "movl $" RT_XSTR(VINF_SUCCESS)", %0 \n\t" 1144 ".byte 0x0f, 0x78, 0xc2 # VMREAD eax, edx \n\t" 1145 "ja 2f \n\t" 1146 "je 1f \n\t" 1147 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_PTR)", %0 \n\t" 1148 "jmp 2f \n\t" 1149 "1: \n\t" 1150 "movl $" RT_XSTR(VERR_VMX_INVALID_VMCS_FIELD)", %0 \n\t" 1151 "2: \n\t" 1152 :"=&r"(rc), 1153 "=d"(*pData) 1154 :"a"(uFieldEnc), 1155 "d"(0) 1156 ); 1157 return rc; 1158 1159 # else 1160 # error "Shouldn't be here..." 1161 # endif 1162 } 1163 #endif 1164 1165 1166 #if 0 704 1167 #if (!defined(RT_ARCH_X86) && !VMX_USE_MSC_INTRINSICS) 705 1168 DECLASM(int) VMXReadVmcs64(uint32_t uFieldEnc, uint64_t *pData); … … 736 1199 } 737 1200 #endif 1201 #endif 738 1202 739 1203
Note:
See TracChangeset
for help on using the changeset viewer.