儲存庫 vbox 的更動 103156
- 時間撮記:
- 2024-2-1 上午10:23:11 (13 月 以前)
- svn:sync-xref-src-repo-rev:
- 161409
- 位置:
- trunk/src/VBox/ValidationKit
- 檔案:
-
- 修改 3 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/ValidationKit/common/constants/tbreq.py
r98103 r103156 86 86 SIGNON_PARAM_HAS_IOMMU = 'HAS_IOMMU'; 87 87 SIGNON_PARAM_WITH_RAW_MODE = 'WITH_RAW_MODE'; 88 SIGNON_PARAM_HAS_NATIVE_API = 'HAS_NATIVE_API'; 88 89 SIGNON_PARAM_MEM_SIZE = 'MEM_SIZE'; 89 90 SIGNON_PARAM_SCRATCH_SIZE = 'SCRATCH_SIZE'; -
trunk/src/VBox/ValidationKit/testboxscript/TestBoxHelper.cpp
r101672 r103156 63 63 # include <sys/types.h> 64 64 # include <sys/sysctl.h> 65 #elif defined(RT_OS_WINDOWS) 66 # include <iprt/nt/nt-and-windows.h> 67 # include <iprt/ldr.h> 68 69 extern "C" HRESULT WINAPI 70 WHvGetCapability(UINT32 CapabilityCode, VOID *CapabilityBuffer, UINT32 CapabilityBufferSizeInBytes, UINT32 *WrittenSizeInBytes); 71 #elif defined(RT_OS_LINUX) 72 # include <sys/stat.h> 73 # include <fcntl.h> 74 # include <unistd.h> 65 75 #endif 66 76 … … 470 480 } 471 481 482 483 static bool isNativeApiSupported(void) 484 { 485 bool fSupported = false; 486 487 #if defined(RT_OS_DARWIN) 488 /* 489 * The kern.hv_support parameter indicates support for the hypervisor API 490 * in the kernel. 491 */ 492 int32_t fHvSupport = 0; 493 size_t cbOld = sizeof(fHvSupport); 494 if (sysctlbyname("kern.hv_support", &fHvSupport, &cbOld, NULL, 0) == 0) 495 { 496 if (fHvSupport != 0) 497 fSupported = true; 498 } 499 500 #elif defined(RT_OS_WINDOWS) 501 /* 502 * Check whether we can load WinHvPlatform.dll and whether the Hypervisor 503 * capability is present. 504 */ 505 RTLDRMOD hLdrMod; 506 int rc = RTLdrLoadSystem("WinHvPlatform.dll", false /*fNoUnload*/, &hLdrMod); 507 if (RT_SUCCESS(rc)) 508 { 509 decltype(WHvGetCapability) *pfnWHvGetCapability; 510 511 rc = RTLdrGetSymbol(hLdrMod, "WHvGetCapability", (void **)&pfnWHvGetCapability); 512 if (RT_SUCCESS(rc)) 513 { 514 BOOL fHypervisorPresent = FALSE; 515 SetLastError(0); 516 HRESULT hrc = pfnWHvGetCapability(0 /*WHvCapabilityCodeHypervisorPresent*/, 517 &fHypervisorPresent, 518 sizeof(fHypervisorPresent), 519 NULL); 520 if ( SUCCEEDED(hrc) 521 && fHypervisorPresent) 522 fSupported = true; 523 } 524 525 RTLdrClose(hLdrMod); 526 } 527 528 #elif defined(RT_OS_LINUX) 529 /* Check by opening /dev/kvm. */ 530 int fdKvm = open("/dev/kvm", O_RDWR | O_CLOEXEC); 531 if (fdKvm >= 0) 532 { 533 close(fdKvm); 534 fSupported = true; 535 } 536 #endif 537 538 return fSupported; 539 } 540 541 /** Print the 'true' if native API virtualization is supported, 'false' if not and 542 * 'dunno' if we cannot tell. */ 543 static RTEXITCODE handlerNativeApi(int argc, char **argv) 544 { 545 NOREF(argc); NOREF(argv); 546 547 int cch = RTPrintf(isNativeApiSupported() ? "true\n" : "false\n"); 548 return cch > 0 ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 549 } 550 551 472 552 typedef enum { HWVIRTTYPE_NONE, HWVIRTTYPE_VTX, HWVIRTTYPE_AMDV, HVIRTTYPE_ARMV8 } HWVIRTTYPE; 473 553 static HWVIRTTYPE isHwVirtSupported(void) 474 554 { 475 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 555 /* No native virtualization supported on macOS anymore (for the VBox versions we care about). */ 556 #if !defined RT_OS_DARWIN 557 # if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 476 558 uint32_t uEax, uEbx, uEcx, uEdx; 477 559 … … 493 575 return HWVIRTTYPE_AMDV; 494 576 } 495 #elif defined(RT_ARCH_ARM64)496 # if defined(RT_OS_DARWIN)497 /*498 * The kern.hv_support parameter indicates support for the hypervisor API in the499 * kernel, which is the only way for virtualization on macOS on Apple Silicon.500 */501 int32_t fHvSupport = 0;502 size_t cbOld = sizeof(fHvSupport);503 if (sysctlbyname("kern.hv_support", &fHvSupport, &cbOld, NULL, 0) == 0)504 {505 if (fHvSupport != 0)506 return HVIRTTYPE_ARMV8;507 }508 577 # endif 509 578 #endif … … 529 598 530 599 HWVIRTTYPE enmHwVirt = isHwVirtSupported(); 600 if (enmHwVirt == HWVIRTTYPE_NONE) 601 fSupported = 0; 531 602 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 532 if (enmHwVirt == HWVIRTTYPE_AMDV)603 else if (enmHwVirt == HWVIRTTYPE_AMDV) 533 604 { 534 605 uint32_t uEax, uEbx, uEcx, uEdx; … … 589 660 } 590 661 } 591 # elif defined(RT_OS_DARWIN)592 else if (enmHwVirt == HWVIRTTYPE_VTX)593 {594 /*595 * The kern.hv_support parameter indicates support for the hypervisor API in the596 * kernel, which in turn is documented require nested paging and unrestricted597 * guest mode. So, if it's there and set we've got nested paging. Howeber, if598 * it's there and clear we have not definite answer as it might be due to lack599 * of unrestricted guest mode support.600 */601 int32_t fHvSupport = 0;602 size_t cbOld = sizeof(fHvSupport);603 if (sysctlbyname("kern.hv_support", &fHvSupport, &cbOld, NULL, 0) == 0)604 {605 if (fHvSupport != 0)606 fSupported = true;607 }608 }609 662 # endif 610 #elif defined(RT_ARCH_ARM64)611 /* On ARM nested paging is always supported if virtualization is there. */612 if (enmHwVirt == HVIRTTYPE_ARMV8)613 fSupported = 1;614 663 #endif 615 664 … … 625 674 NOREF(argc); NOREF(argv); 626 675 HWVIRTTYPE enmHwVirt = isHwVirtSupported(); 676 bool fNativeApi = isNativeApiSupported(); 627 677 int fSupported = 0; 628 678 629 if (enmHwVirt != HWVIRTTYPE_NONE) 679 if ( enmHwVirt != HWVIRTTYPE_NONE 680 || fNativeApi) 630 681 { 631 682 #if defined(RT_ARCH_AMD64) … … 767 818 { "nestedpaging", handlerCpuNestedPaging, true }, 768 819 { "longmode", handlerCpuLongMode, true }, 820 { "nativeapi", handlerNativeApi, true }, 769 821 { "memsize", handlerMemSize, true }, 770 822 { "report", handlerReport, true }, -
trunk/src/VBox/ValidationKit/testboxscript/testboxscript_real.py
r98651 r103156 184 184 constants.tbreq.SIGNON_PARAM_HAS_64_BIT_GUEST: { self.VALUE: self._can64BitGuest(), self.FN: None }, 185 185 constants.tbreq.SIGNON_PARAM_HAS_IOMMU: { self.VALUE: self._hasHostIoMmu(), self.FN: None }, 186 constants.tbreq.SIGNON_PARAM_HAS_NATIVE_API: { self.VALUE: self._hasHostNativeApi(), self.FN: None }, 186 187 #constants.tbreq.SIGNON_PARAM_WITH_RAW_MODE: { self.VALUE: self._withRawModeSupport(), self.FN: None }, 187 188 constants.tbreq.SIGNON_PARAM_SCRIPT_REV: { self.VALUE: self._getScriptRev(), self.FN: None }, … … 559 560 self._oOptions.fHasIoMmu = False; 560 561 return self._oOptions.fHasIoMmu; 562 563 def _hasHostNativeApi(self): 564 """ 565 Check if the host supports the native API/NEM mode. 566 """ 567 if self._oOptions.fHasNativeApi is None: 568 self._oOptions.fHasNativeApi = self._getHelperOutput('nativeapi'); 569 return self._oOptions.fHasNativeApi; 561 570 562 571 def _withRawModeSupport(self): … … 1005 1014 dest="fCan64BitGuest", action="store_false", default=None, 1006 1015 help="Host cannot execute 64-bit guests"); 1016 parser.add_option("--native-api", 1017 dest="fHasNativeApi", action="store_true", default=None, 1018 help="Native API virtualization is available"); 1019 parser.add_option("--no-native-api", 1020 dest="fHasNativeApi", action="store_false", default=None, 1021 help="Native API virtualization is not available"); 1007 1022 parser.add_option("--io-mmu", 1008 1023 dest="fHasIoMmu", action="store_true", default=None,
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器