Changeset 59747 in vbox
- Timestamp:
- Feb 19, 2016 11:18:18 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105617
- Location:
- trunk
- Files:
-
- 1 added
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/intnetinline.h
r58106 r59747 794 794 Assert(RT_ALIGN_32(cbRecv, INTNETRINGBUF_ALIGNMENT) == cbRecv); 795 795 Assert(RT_ALIGN_32(cbSend, INTNETRINGBUF_ALIGNMENT) == cbSend); 796 Assert(ASMMemIs All8(pIntBuf, cbBuf, '\0') == NULL);796 Assert(ASMMemIsZero(pIntBuf, cbBuf)); 797 797 798 798 pIntBuf->u32Magic = INTNETBUF_MAGIC; -
trunk/include/iprt/asm.h
r59533 r59747 3833 3833 3834 3834 /** 3835 * Checks if a memory block is all zeros. 3836 * 3837 * @returns Pointer to the first non-zero byte. 3838 * @returns NULL if all zero. 3839 * 3840 * @param pv Pointer to the memory block. 3841 * @param cb Number of bytes in the block. 3842 * 3843 * @todo Fix name, it is a predicate function but it's not returning boolean! 3844 */ 3845 #if !defined(RT_OS_LINUX) || !defined(__KERNEL__) 3846 DECLASM(void *) ASMMemFirstNonZero(void const *pv, size_t cb); 3847 #else 3848 DECLINLINE(void *) ASMMemFirstNonZero(void const *pv, size_t cb) 3849 { 3850 uint8_t const *pb = (uint8_t const *)pv; 3851 for (; cb; cb--, pb++) 3852 if (RT_LIKELY(*pb == u8)) 3853 { /* likely */ } 3854 else 3855 return (void *)pb; 3856 return NULL; 3857 } 3858 #endif 3859 3860 3861 /** 3862 * Checks if a memory block is all zeros. 3863 * 3864 * @returns true if zero, false if not. 3865 * 3866 * @param pv Pointer to the memory block. 3867 * @param cb Number of bytes in the block. 3868 * 3869 * @sa ASMMemFirstNonZero 3870 */ 3871 DECLINLINE(bool) ASMMemIsZero(void const *pv, size_t cb) 3872 { 3873 return ASMMemFirstNonZero(pv, cb) == NULL; 3874 } 3875 3876 3877 /** 3835 3878 * Checks if a memory page is all zeros. 3836 3879 * … … 3893 3936 3894 3937 /** 3895 * Checks if a memory block is filled with the specified byte. 3896 * 3897 * This is a sort of inverted memchr. 3938 * Checks if a memory block is filled with the specified byte, returning the 3939 * first mismatch. 3940 * 3941 * This is sort of an inverted memchr. 3898 3942 * 3899 3943 * @returns Pointer to the byte which doesn't equal u8. … … 3901 3945 * 3902 3946 * @param pv Pointer to the memory block. 3903 * @param cb Number of bytes in the block. This MUST be aligned on 32-bit!3947 * @param cb Number of bytes in the block. 3904 3948 * @param u8 The value it's supposed to be filled with. 3905 3949 * 3906 * @todo Fix name, it is a predicate function but it's not returning boolean! 3907 */ 3908 DECLINLINE(void *) ASMMemIsAll8(void const *pv, size_t cb, uint8_t u8) 3909 { 3910 /** @todo rewrite this in inline assembly? */ 3950 * @remarks No alignment requirements. 3951 */ 3952 #if !defined(RT_OS_LINUX) || !defined(__KERNEL__) 3953 DECLASM(void *) ASMMemFirstMismatchingU8(void const *pv, size_t cb, uint8_t u8); 3954 #else 3955 DECLINLINE(void *) ASMMemFirstMismatchingU8(void const *pv, size_t cb, uint8_t u8) 3956 { 3911 3957 uint8_t const *pb = (uint8_t const *)pv; 3912 3958 for (; cb; cb--, pb++) … … 3917 3963 return NULL; 3918 3964 } 3965 #endif 3966 3967 3968 /** 3969 * Checks if a memory block is filled with the specified byte. 3970 * 3971 * @returns true if all matching, false if not. 3972 * 3973 * @param pv Pointer to the memory block. 3974 * @param cb Number of bytes in the block. 3975 * @param u8 The value it's supposed to be filled with. 3976 * 3977 * @remarks No alignment requirements. 3978 */ 3979 DECLINLINE(bool) ASMMemIsAllU8(void const *pv, size_t cb, uint8_t u8) 3980 { 3981 return ASMMemFirstMismatchingU8(pv, cb, u8) == NULL; 3982 } 3919 3983 3920 3984 … … 3930 3994 * @param cb Number of bytes in the block. This MUST be aligned on 32-bit! 3931 3995 * @param u32 The value it's supposed to be filled with. 3932 * 3933 * @todo Fix name, it is a predicate function but it's not returning boolean! 3934 */ 3935 DECLINLINE(uint32_t *) ASMMemIsAllU32(void const *pv, size_t cb, uint32_t u32) 3996 */ 3997 DECLINLINE(uint32_t *) ASMMemFirstMismatchingU32(void const *pv, size_t cb, uint32_t u32) 3936 3998 { 3937 3999 /** @todo rewrite this in inline assembly? */ -
trunk/include/iprt/mangling.h
r59689 r59747 265 265 # define ASMMemFill32 RT_MANGLER(ASMMemFill32) 266 266 # define ASMMemFill32_EndProc RT_MANGLER(ASMMemFill32_EndProc) 267 # define ASMMemFirstNonZero RT_MANGLER(ASMMemFirstNonZero) 268 # define ASMMemFirstNonZero_EndProc RT_MANGLER(ASMMemFirstNonZero_EndProc) 269 # define ASMMemFirstMismatchingU8 RT_MANGLER(ASMMemFirstMismatchingU8) 270 # define ASMMemFirstMismatchingU8_EndProc RT_MANGLER(ASMMemFirstMismatchingU8_EndProc) 271 # define ASMMemFirstMismatchingU32 RT_MANGLER(ASMMemFirstMismatchingU32) 272 # define ASMMemFirstMismatchingU32_EndProc RT_MANGLER(ASMMemFirstMismatchingU32_EndProc) 273 # define ASMMemIsZero RT_MANGLER(ASMMemIsZero) 274 # define ASMMemIsZero_EndProc RT_MANGLER(ASMMemIsZero_EndProc) 275 # define ASMMemIsAllU8 RT_MANGLER(ASMMemIsAllU8) 276 # define ASMMemIsAllU8_EndProc RT_MANGLER(ASMMemIsAllU8_EndProc) 267 277 # define ASMMemZero32 RT_MANGLER(ASMMemZero32) 268 278 # define ASMMemZero32_EndProc RT_MANGLER(ASMMemZero32_EndProc) -
trunk/src/VBox/Debugger/DBGPlugInCommonELFTmpl.cpp.h
r56296 r59747 125 125 if (pEhdr->e_shentsize != sizeof(Elf_Shdr)) 126 126 return VERR_BAD_EXE_FORMAT; 127 if ( ASMMemIsAll8(&pEhdr->e_ident[EI_PAD], EI_NIDENT - EI_PAD, 0) != NULL) //??127 if (!ASMMemIsZero(&pEhdr->e_ident[EI_PAD], EI_NIDENT - EI_PAD)) //?? 128 128 return VERR_BAD_EXE_FORMAT; 129 129 -
trunk/src/VBox/Debugger/DBGPlugInSolaris.cpp
r57358 r59747 475 475 || Module.hdr.e_ident[EI_DATA] != ELFDATA2LSB 476 476 || Module.hdr.e_ident[EI_VERSION] != EV_CURRENT 477 || ASMMemIsAll8(&Module.hdr.e_ident[EI_PAD], EI_NIDENT - EI_PAD, 0) != NULL477 || !ASMMemIsZero(&Module.hdr.e_ident[EI_PAD], EI_NIDENT - EI_PAD) 478 478 ) 479 479 return; … … 622 622 || Module.hdr.e_ident[EI_DATA] != ELFDATA2LSB 623 623 || Module.hdr.e_ident[EI_VERSION] != EV_CURRENT 624 || ASMMemIsAll8(&Module.hdr.e_ident[EI_PAD], EI_NIDENT - EI_PAD, 0) != NULL624 || !ASMMemIsZero(&Module.hdr.e_ident[EI_PAD], EI_NIDENT - EI_PAD) 625 625 ) 626 626 return; -
trunk/src/VBox/Devices/BiosCommonCode/MakeAlternativeSource.cpp
r57358 r59747 612 612 " ; Padding %#x bytes at %#x\n", cbPadding, uFlatAddr); 613 613 uint8_t const *pb = &g_pbImg[uFlatAddr - g_uBiosFlatBase]; 614 if ( !ASMMemIsAll8(pb, cbPadding, 0))614 if (ASMMemIsZero(pb, cbPadding)) 615 615 return outputPrintf(" times %u db 0\n", cbPadding); 616 616 … … 955 955 /* Trailing zero padding detection. */ 956 956 if ( *pb == '\0' 957 && ASMMemIs All8(pb, RT_MIN(cb, 8), 0) == NULL)958 { 959 void *pv = ASMMem IsAll8(pb, cb, 0);957 && ASMMemIsZero(pb, RT_MIN(cb, 8))) 958 { 959 void *pv = ASMMemFirstNonZero(pb, cb); 960 960 uint32_t cbZeros = pv ? (uint32_t)((uint8_t const *)pv - pb) : cb; 961 961 if (!outputPrintf(" times %#x db 0\n", cbZeros)) -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-info.cpp
r57358 r59747 1878 1878 if (pSurface->pMipmapLevels[iMipmap].pSurfaceData) 1879 1879 { 1880 if ( ASMMemIsAll8(pSurface->pMipmapLevels[iMipmap].pSurfaceData,1881 pSurface->pMipmapLevels[iMipmap].cbSurface, 0) == NULL)1880 if (ASMMemIsZero(pSurface->pMipmapLevels[iMipmap].pSurfaceData, 1881 pSurface->pMipmapLevels[iMipmap].cbSurface)) 1882 1882 pHlp->pfnPrintf(pHlp, "--- Face #%u, mipmap #%u[%u]: all zeros ---\n", iFace, iLevel, iMipmap); 1883 1883 else -
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
r58374 r59747 1823 1823 * If dynamic linking it screwed up, we may end up here. 1824 1824 */ 1825 if ( ASMMemIsAll8(&g_aSupVerifiedFiles[0], sizeof(g_aSupVerifiedFiles), 0) != NULL1826 || ASMMemIsAll8(&g_aSupVerifiedDirs[0], sizeof(g_aSupVerifiedDirs), 0) != NULL)1825 if ( !ASMMemIsZero(&g_aSupVerifiedFiles[0], sizeof(g_aSupVerifiedFiles)) 1826 || !ASMMemIsZero(&g_aSupVerifiedDirs[0], sizeof(g_aSupVerifiedDirs))) 1827 1827 return VERR_WRONG_ORDER; 1828 1828 -
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r56681 r59747 280 280 if (RT_SUCCESS(rc)) 281 281 { 282 if (ASMMemIs All8(pszzBlock, cbBlock, 0))282 if (ASMMemIsZero(pszzBlock, cbBlock)) 283 283 return VINF_SUCCESS; 284 284 return VERR_TOO_MUCH_DATA; -
trunk/src/VBox/Runtime/Makefile.kmk
r59729 r59747 691 691 common/asm/ASMAtomicUoOrU64.asm \ 692 692 common/asm/ASMAtomicUoOrU32.asm \ 693 common/asm/ASMMemFirstMismatchingU8.asm \ 693 694 common/asm/ASMRdMsrEx.asm \ 694 695 common/asm/ASMWrMsrEx.asm \ … … 709 710 common/asm/ASMAtomicUoOrU64.asm \ 710 711 common/asm/ASMAtomicUoOrU32.asm \ 712 common/asm/ASMMemFirstMismatchingU8.asm \ 711 713 common/asm/ASMRdMsrEx.asm \ 712 714 common/asm/ASMWrMsrEx.asm \ -
trunk/src/VBox/Runtime/common/ldr/ldrPE.cpp
r58729 r59747 2633 2633 * Check that the last table entry has a hash value of zero. 2634 2634 */ 2635 if ( ASMMemIsAll8(pbHashTab + 4, cbHash, 0) != NULL)2635 if (!ASMMemIsZero(pbHashTab + 4, cbHash)) 2636 2636 return RTErrInfoSetF(pErrInfo, VERR_LDRVI_PAGE_HASH_TAB_TOO_LONG, 2637 2637 "Maltform final page hash table entry: #%u %#010x %.*Rhxs", -
trunk/src/VBox/Runtime/common/math/bignum.cpp
r59243 r59747 67 67 Assert(!(a_pBigNum)->fCurScrambled); \ 68 68 Assert( (a_pBigNum)->cUsed == (a_pBigNum)->cAllocated \ 69 || ASMMemIs AllU32(&(a_pBigNum)->pauElements[(a_pBigNum)->cUsed], \70 ((a_pBigNum)->cAllocated - (a_pBigNum)->cUsed) * RTBIGNUM_ELEMENT_SIZE, 0) == NULL); \69 || ASMMemIsZero(&(a_pBigNum)->pauElements[(a_pBigNum)->cUsed], \ 70 ((a_pBigNum)->cAllocated - (a_pBigNum)->cUsed) * RTBIGNUM_ELEMENT_SIZE)); \ 71 71 } while (0) 72 72 #else … … 414 414 #ifdef RT_STRICT 415 415 else if (pBigNum->cUsed != cNewUsed) 416 Assert(ASMMemIsAllU32(&pBigNum->pauElements[pBigNum->cUsed], 417 (cNewUsed - pBigNum->cUsed) * RTBIGNUM_ELEMENT_SIZE, 0) == NULL); 416 Assert(ASMMemIsZero(&pBigNum->pauElements[pBigNum->cUsed], (cNewUsed - pBigNum->cUsed) * RTBIGNUM_ELEMENT_SIZE)); 418 417 #endif 419 418 pBigNum->cUsed = cNewUsed; … … 444 443 #ifdef RT_STRICT 445 444 else if (pBigNum->cUsed != cNewUsed) 446 Assert(ASMMemIsAllU32(&pBigNum->pauElements[pBigNum->cUsed], 447 (cNewUsed - pBigNum->cUsed) * RTBIGNUM_ELEMENT_SIZE, 0) == NULL); 445 Assert(ASMMemIsZero(&pBigNum->pauElements[pBigNum->cUsed], (cNewUsed - pBigNum->cUsed) * RTBIGNUM_ELEMENT_SIZE)); 448 446 #endif 449 447 pBigNum->cUsed = cNewUsed; … … 469 467 { 470 468 Assert( pBigNum->cAllocated == pBigNum->cUsed 471 || ASMMemIs AllU32(&pBigNum->pauElements[pBigNum->cUsed],472 (pBigNum->cAllocated - pBigNum->cUsed) * RTBIGNUM_ELEMENT_SIZE, 0) == NULL);469 || ASMMemIsZero(&pBigNum->pauElements[pBigNum->cUsed], 470 (pBigNum->cAllocated - pBigNum->cUsed) * RTBIGNUM_ELEMENT_SIZE)); 473 471 return VINF_SUCCESS; 474 472 } … … 1768 1766 PRTBIGNUMELEMENT pauDst = pResult->pauElements; 1769 1767 1770 Assert(ASMMemIs AllU32(pauDst, (cBits / RTBIGNUM_ELEMENT_BITS) * RTBIGNUM_ELEMENT_SIZE, 0) == NULL);1768 Assert(ASMMemIsZero(pauDst, (cBits / RTBIGNUM_ELEMENT_BITS) * RTBIGNUM_ELEMENT_SIZE)); 1771 1769 pauDst += cBits / RTBIGNUM_ELEMENT_BITS; 1772 1770 -
trunk/src/VBox/Runtime/common/misc/sg.cpp
r59745 r59747 407 407 } 408 408 409 409 410 RTDECL(bool) RTSgBufIsZero(PRTSGBUF pSgBuf, size_t cbCheck) 410 411 { … … 420 421 if (!cbThisCheck) 421 422 break; 422 423 /** @todo fix this after asm.h gets updated. */ 424 /* Use optimized inline assembler if possible. */ 425 if ( !(cbThisCheck % 4) 426 && cbThisCheck * 8 <= UINT32_MAX) 427 { 428 if (ASMBitFirstSet((volatile void *)pvBuf, (uint32_t)cbThisCheck * 8) != -1) 429 { 430 fIsZero = false; 431 break; 432 } 433 } 434 else 435 { 436 for (size_t i = 0; i < cbThisCheck; i++) 437 { 438 char *pbBuf = (char *)pvBuf; 439 if (*pbBuf) 440 { 441 fIsZero = false; 442 break; 443 } 444 pvBuf = pbBuf + 1; 445 } 446 447 if (!fIsZero) 448 break; 449 } 450 423 fIsZero = ASMMemIsZero(pvBuf, cbThisCheck); 424 if (!fIsZero) 425 break; 451 426 cbLeft -= cbThisCheck; 452 427 } -
trunk/src/VBox/Runtime/common/vfs/vfsmemory.cpp
r59620 r59747 475 475 476 476 /* Skip leading zeros if there is a whole bunch of them. */ 477 uint8_t const *pbSrcNZ = (uint8_t const *)ASMMem IsAll8(pbSrc, cbLeftToWrite, 0);477 uint8_t const *pbSrcNZ = (uint8_t const *)ASMMemFirstNonZero(pbSrc, cbLeftToWrite); 478 478 size_t cbZeros = pbSrcNZ ? pbSrcNZ - pbSrc : cbLeftToWrite; 479 479 if (cbZeros) -
trunk/src/VBox/Runtime/common/zip/tarvfs.cpp
r57368 r59747 622 622 */ 623 623 case RTZIPTARREADERSTATE_ZERO: 624 if ( ASMMemIsAllU32(pHdr, sizeof(*pHdr), 0) != NULL)624 if (!ASMMemIsZero(pHdr, sizeof(*pHdr))) 625 625 return VERR_TAR_ZERO_HEADER; 626 626 pThis->cZeroHdrs++; -
trunk/src/VBox/Runtime/r0drv/alloc-ef-r0drv.cpp
r58278 r59747 672 672 */ 673 673 # ifdef RTR0MEM_EF_IN_FRONT 674 void *pvWrong = ASMMem IsAll8((char *)pv + pBlock->cbUnaligned,675 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbUnaligned,676 RTR0MEM_EF_NOMAN_FILLER);674 void *pvWrong = ASMMemFirstMismatchingU8((char *)pv + pBlock->cbUnaligned, 675 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbUnaligned, 676 RTR0MEM_EF_NOMAN_FILLER); 677 677 # else 678 678 /* Alignment must match allocation alignment in rtMemAlloc(). */ 679 void *pvWrong = ASMMem IsAll8((char *)pv + pBlock->cbUnaligned,680 pBlock->cbAligned - pBlock->cbUnaligned,681 RTR0MEM_EF_NOMAN_FILLER);679 void *pvWrong = ASMMemFirstMismatchingU8((char *)pv + pBlock->cbUnaligned, 680 pBlock->cbAligned - pBlock->cbUnaligned, 681 RTR0MEM_EF_NOMAN_FILLER); 682 682 if (pvWrong) 683 683 RTAssertDoPanic(); 684 pvWrong = ASMMem IsAll8((void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK),685 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbAligned,686 RTR0MEM_EF_NOMAN_FILLER);684 pvWrong = ASMMemFirstMismatchingU8((void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK), 685 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbAligned, 686 RTR0MEM_EF_NOMAN_FILLER); 687 687 # endif 688 688 if (pvWrong) -
trunk/src/VBox/Runtime/r3/alloc-ef.cpp
r57432 r59747 681 681 */ 682 682 # ifdef RTALLOC_EFENCE_IN_FRONT 683 void *pvWrong = ASMMem IsAll8((char *)pv + pBlock->cbUnaligned,684 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbUnaligned,685 RTALLOC_EFENCE_NOMAN_FILLER);683 void *pvWrong = ASMMemFirstMismatchingU8((char *)pv + pBlock->cbUnaligned, 684 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbUnaligned, 685 RTALLOC_EFENCE_NOMAN_FILLER); 686 686 # else 687 687 /* Alignment must match allocation alignment in rtMemAlloc(). */ 688 void *pvWrong = ASMMemIsAll8((char *)pv + pBlock->cbUnaligned,689 pBlock->cbAligned - pBlock->cbUnaligned,690 RTALLOC_EFENCE_NOMAN_FILLER);688 void *pvWrong = ASMMemFirstMismatchingU8((char *)pv + pBlock->cbUnaligned, 689 pBlock->cbAligned - pBlock->cbUnaligned, 690 RTALLOC_EFENCE_NOMAN_FILLER); 691 691 if (pvWrong) 692 692 RTAssertDoPanic(); 693 pvWrong = ASMMem IsAll8((void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK),694 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbAligned,695 RTALLOC_EFENCE_NOMAN_FILLER);693 pvWrong = ASMMemFirstMismatchingU8((void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK), 694 RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbAligned, 695 RTALLOC_EFENCE_NOMAN_FILLER); 696 696 # endif 697 697 if (pvWrong) -
trunk/src/VBox/Runtime/testcase/tstRTInlineAsm.cpp
r59527 r59747 47 47 # include <iprt/time.h> 48 48 #endif 49 #include <iprt/rand.h> 49 50 #include <iprt/stream.h> 50 51 #include <iprt/string.h> … … 1322 1323 RTTESTI_CHECK(!ASMMemIsZeroPage(pvPage2)); 1323 1324 ((uint8_t *)pvPage2)[off] = 0; 1325 } 1326 1327 RTTestSubDone(hTest); 1328 } 1329 1330 1331 void tstASMMemFirstMismatchingU8(RTTEST hTest) 1332 { 1333 RTTestSub(hTest, "ASMMemFirstMismatchingU8"); 1334 1335 uint8_t *pbPage1 = (uint8_t *)RTTestGuardedAllocHead(hTest, PAGE_SIZE); 1336 uint8_t *pbPage2 = (uint8_t *)RTTestGuardedAllocTail(hTest, PAGE_SIZE); 1337 RTTESTI_CHECK_RETV(pbPage1 && pbPage2); 1338 1339 memset(pbPage1, 0, PAGE_SIZE); 1340 memset(pbPage2, 0, PAGE_SIZE); 1341 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, PAGE_SIZE, 0) == NULL); 1342 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, PAGE_SIZE, 0) == NULL); 1343 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, PAGE_SIZE, 1) == pbPage1); 1344 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, PAGE_SIZE, 1) == pbPage2); 1345 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, PAGE_SIZE, 0x87) == pbPage1); 1346 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, PAGE_SIZE, 0x87) == pbPage2); 1347 RTTESTI_CHECK(ASMMemIsZero(pbPage1, PAGE_SIZE)); 1348 RTTESTI_CHECK(ASMMemIsZero(pbPage2, PAGE_SIZE)); 1349 RTTESTI_CHECK(ASMMemIsAllU8(pbPage1, PAGE_SIZE, 0)); 1350 RTTESTI_CHECK(ASMMemIsAllU8(pbPage2, PAGE_SIZE, 0)); 1351 RTTESTI_CHECK(!ASMMemIsAllU8(pbPage1, PAGE_SIZE, 0x34)); 1352 RTTESTI_CHECK(!ASMMemIsAllU8(pbPage2, PAGE_SIZE, 0x88)); 1353 unsigned cbSub = 32; 1354 while (cbSub-- > 0) 1355 { 1356 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage1[PAGE_SIZE - cbSub], cbSub, 0) == NULL); 1357 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage2[PAGE_SIZE - cbSub], cbSub, 0) == NULL); 1358 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, cbSub, 0) == NULL); 1359 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, cbSub, 0) == NULL); 1360 1361 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage1[PAGE_SIZE - cbSub], cbSub, 0x34) == &pbPage1[PAGE_SIZE - cbSub] || !cbSub); 1362 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage2[PAGE_SIZE - cbSub], cbSub, 0x99) == &pbPage2[PAGE_SIZE - cbSub] || !cbSub); 1363 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, cbSub, 0x42) == pbPage1 || !cbSub); 1364 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, cbSub, 0x88) == pbPage2 || !cbSub); 1365 } 1366 1367 memset(pbPage1, 0xff, PAGE_SIZE); 1368 memset(pbPage2, 0xff, PAGE_SIZE); 1369 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, PAGE_SIZE, 0xff) == NULL); 1370 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, PAGE_SIZE, 0xff) == NULL); 1371 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, PAGE_SIZE, 0xfe) == pbPage1); 1372 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, PAGE_SIZE, 0xfe) == pbPage2); 1373 RTTESTI_CHECK(!ASMMemIsZero(pbPage1, PAGE_SIZE)); 1374 RTTESTI_CHECK(!ASMMemIsZero(pbPage2, PAGE_SIZE)); 1375 RTTESTI_CHECK(ASMMemIsAllU8(pbPage1, PAGE_SIZE, 0xff)); 1376 RTTESTI_CHECK(ASMMemIsAllU8(pbPage2, PAGE_SIZE, 0xff)); 1377 RTTESTI_CHECK(!ASMMemIsAllU8(pbPage1, PAGE_SIZE, 0)); 1378 RTTESTI_CHECK(!ASMMemIsAllU8(pbPage2, PAGE_SIZE, 0)); 1379 cbSub = 32; 1380 while (cbSub-- > 0) 1381 { 1382 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage1[PAGE_SIZE - cbSub], cbSub, 0xff) == NULL); 1383 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage2[PAGE_SIZE - cbSub], cbSub, 0xff) == NULL); 1384 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, cbSub, 0xff) == NULL); 1385 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, cbSub, 0xff) == NULL); 1386 1387 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage1[PAGE_SIZE - cbSub], cbSub, 0xfe) == &pbPage1[PAGE_SIZE - cbSub] || !cbSub); 1388 RTTESTI_CHECK(ASMMemFirstMismatchingU8(&pbPage2[PAGE_SIZE - cbSub], cbSub, 0xfe) == &pbPage2[PAGE_SIZE - cbSub] || !cbSub); 1389 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage1, cbSub, 0xfe) == pbPage1 || !cbSub); 1390 RTTESTI_CHECK(ASMMemFirstMismatchingU8(pbPage2, cbSub, 0xfe) == pbPage2 || !cbSub); 1391 } 1392 1393 1394 /* 1395 * Various alignments and sizes. 1396 */ 1397 uint8_t const bFiller1 = 0x00; 1398 uint8_t const bFiller2 = 0xf6; 1399 size_t const cbBuf = 128; 1400 uint8_t *pbBuf1 = pbPage1; 1401 uint8_t *pbBuf2 = &pbPage2[PAGE_SIZE - cbBuf]; /* Put it up against the tail guard */ 1402 memset(pbPage1, ~bFiller1, PAGE_SIZE); 1403 memset(pbPage2, ~bFiller2, PAGE_SIZE); 1404 memset(pbBuf1, bFiller1, cbBuf); 1405 memset(pbBuf2, bFiller2, cbBuf); 1406 for (size_t offNonZero = 0; offNonZero < cbBuf; offNonZero++) 1407 { 1408 uint8_t bRand = (uint8_t)RTRandU32(); 1409 pbBuf1[offNonZero] = bRand | 1; 1410 pbBuf2[offNonZero] = (0x80 | bRand) ^ 0xf6; 1411 1412 for (size_t offStart = 0; offStart < 32; offStart++) 1413 { 1414 size_t const cbMax = cbBuf - offStart; 1415 for (size_t cb = 0; cb < cbMax; cb++) 1416 { 1417 size_t const offEnd = offStart + cb; 1418 uint8_t bSaved1, bSaved2; 1419 if (offEnd < PAGE_SIZE) 1420 { 1421 bSaved1 = pbBuf1[offEnd]; 1422 bSaved2 = pbBuf2[offEnd]; 1423 pbBuf1[offEnd] = 0xff; 1424 pbBuf2[offEnd] = 0xff; 1425 } 1426 1427 uint8_t *pbRet = (uint8_t *)ASMMemFirstMismatchingU8(pbBuf1 + offStart, cb, bFiller1); 1428 RTTESTI_CHECK(offNonZero - offStart < cb ? pbRet == &pbBuf1[offNonZero] : pbRet == NULL); 1429 1430 pbRet = (uint8_t *)ASMMemFirstMismatchingU8(pbBuf2 + offStart, cb, bFiller2); 1431 if (!(offNonZero - offStart < cb ? pbRet == &pbBuf2[offNonZero] : pbRet == NULL)) 1432 __debugbreak(); 1433 RTTESTI_CHECK(offNonZero - offStart < cb ? pbRet == &pbBuf2[offNonZero] : pbRet == NULL); 1434 1435 if (offEnd < PAGE_SIZE) 1436 { 1437 pbBuf1[offEnd] = bSaved1; 1438 pbBuf2[offEnd] = bSaved2; 1439 } 1440 } 1441 } 1442 1443 pbBuf1[offNonZero] = 0; 1444 pbBuf2[offNonZero] = 0xf6; 1324 1445 } 1325 1446 … … 1791 1912 tstASMMemZeroPage(); 1792 1913 tstASMMemIsZeroPage(g_hTest); 1914 tstASMMemFirstMismatchingU8(g_hTest); 1793 1915 tstASMMemZero32(); 1794 1916 tstASMMemFill32(); -
trunk/src/VBox/Runtime/testcase/tstRTMemCache.cpp
r57358 r59747 133 133 { 134 134 RTTESTI_CHECK(hMemCache == g_hMemCache); 135 RTTESTI_CHECK(ASMMemIs All8(pvObj, 256, 0) == NULL);135 RTTESTI_CHECK(ASMMemIsZero(pvObj, 256)); 136 136 137 137 if (*(bool *)pvUser) -
trunk/src/VBox/Runtime/testcase/tstRTMemPool.cpp
r57358 r59747 68 68 { 69 69 RTTESTI_CHECK_RETV(pv = RTMemPoolAllocZ(hMemPool, 1024)); 70 RTTESTI_CHECK(ASMMem IsAllU32(pv, 1024, 0) == NULL);70 RTTESTI_CHECK(ASMMemFirstMismatchingU32(pv, 1024, 0) == NULL); 71 71 memset(pv, 'a', 1024); 72 72 RTTESTI_CHECK_RETV(RTMemPoolRefCount(pv) == 1); … … 88 88 RTTESTI_CHECK_RETV(pv = RTMemPoolDupEx(hMemPool, szTest, sizeof(szTest), cb)); 89 89 RTTESTI_CHECK(memcmp(pv, szTest, sizeof(szTest)) == 0); 90 RTTESTI_CHECK(ASMMemIs All8((uint8_t *)pv + sizeof(szTest), cb, 0) == NULL);90 RTTESTI_CHECK(ASMMemIsZero((uint8_t *)pv + sizeof(szTest), cb)); 91 91 memset(pv, 'b', sizeof(szTest) + cb); 92 92 RTTESTI_CHECK_RETV(RTMemPoolRefCount(pv) == 1); … … 118 118 RTTESTI_CHECK(RTMemPoolRefCount(pv) == 1); 119 119 memset(pv, 'a', i); 120 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv,(uintptr_t)pv2 - (uintptr_t)pv));120 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv,(uintptr_t)pv2 - (uintptr_t)pv)); 121 121 RTTESTI_CHECK(RTMemPoolRetain(pv) == 2); 122 122 RTTESTI_CHECK(RTMemPoolRefCount(pv) == 2); … … 125 125 RTTESTI_CHECK(RTMemPoolRetain(pv) == 4); 126 126 RTTESTI_CHECK(RTMemPoolRefCount(pv) == 4); 127 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv));127 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv)); 128 128 RTTESTI_CHECK(RTMemPoolRelease(hMemPool, pv) == 3); 129 129 RTTESTI_CHECK(RTMemPoolRefCount(pv) == 3); 130 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv));130 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv)); 131 131 RTTESTI_CHECK(RTMemPoolRetain(pv) == 4); 132 132 RTTESTI_CHECK(RTMemPoolRefCount(pv) == 4); … … 137 137 RTTESTI_CHECK(RTMemPoolRelease(NIL_RTMEMPOOL, pv) == 5); 138 138 RTTESTI_CHECK(RTMemPoolRelease(NIL_RTMEMPOOL, pv) == 4); 139 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv));139 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv)); 140 140 141 141 for (uint32_t cRefs = 3;; cRefs--) … … 145 145 break; 146 146 RTTESTI_CHECK(RTMemPoolRefCount(pv) == cRefs); 147 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x cRefs=%d\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv, cRefs));147 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x cRefs=%d\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv, cRefs)); 148 148 for (uint32_t j = 0; j < 42; j++) 149 149 { … … 152 152 memset(pv2, 'f', i); 153 153 RTTESTI_CHECK(RTMemPoolRelease(hMemPool, pv2) == 0); 154 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x cRefs=%d\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv, cRefs));154 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(pv, i, 'a')) == NULL, ("i=%#x pv=%p off=%#x cRefs=%d\n", i, pv, (uintptr_t)pv2 - (uintptr_t)pv, cRefs)); 155 155 } 156 156 } -
trunk/src/VBox/Runtime/testcase/tstRTMemSafer.cpp
r57358 r59747 129 129 RTTESTI_CHECK_RC_OK_RETV(RTMemSaferReallocZEx(cbAlloc, pvBuf, cbNew, &pvBuf, 0)); 130 130 131 RTTESTI_CHECK(ASMMemIsAll 8(pvBuf, RT_MIN(cbAlloc, cbNew), chFiller) == NULL);131 RTTESTI_CHECK(ASMMemIsAllU8(pvBuf, RT_MIN(cbAlloc, cbNew), chFiller)); 132 132 133 133 chFiller += 0x31; -
trunk/src/VBox/Runtime/testcase/tstRTStrAlloc.cpp
r57358 r59747 96 96 RTTESTI_CHECK(!psz[127]); 97 97 RTTESTI_CHECK(!psz[159]); 98 RTTESTI_CHECK(ASMMemIsAll 8(psz, 127, 'a') == NULL);98 RTTESTI_CHECK(ASMMemIsAllU8(psz, 127, 'a')); 99 99 memset(psz, 'b', 159); 100 100 … … 103 103 { 104 104 RTTESTI_CHECK(!psz[78]); 105 RTTESTI_CHECK(ASMMemIsAll 8(psz, 78, 'b') == NULL);105 RTTESTI_CHECK(ASMMemIsAllU8(psz, 78, 'b')); 106 106 107 107 RTTESTI_CHECK_RC(rc = RTStrRealloc(&psz, 0), VINF_SUCCESS); -
trunk/src/VBox/Runtime/testcase/tstRTStrCache.cpp
r57358 r59747 175 175 void *pv2; 176 176 RTTESTI_CHECK_RETV(psz = RTStrCacheEnterN(hStrCache, szTest, i)); 177 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz));177 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz)); 178 178 RTTESTI_CHECK(RTStrCacheRetain(psz) == 2); 179 179 RTTESTI_CHECK(RTStrCacheRetain(psz) == 3); 180 180 RTTESTI_CHECK(RTStrCacheRetain(psz) == 4); 181 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz));181 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz)); 182 182 RTTESTI_CHECK(RTStrCacheRelease(hStrCache, psz) == 3); 183 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz));183 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz)); 184 184 RTTESTI_CHECK(RTStrCacheRetain(psz) == 4); 185 185 RTTESTI_CHECK(RTStrCacheRetain(psz) == 5); … … 187 187 RTTESTI_CHECK(RTStrCacheRelease(hStrCache, psz) == 5); 188 188 RTTESTI_CHECK(RTStrCacheRelease(hStrCache, psz) == 4); 189 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz));189 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz)); 190 190 191 191 for (uint32_t cRefs = 3;; cRefs--) … … 194 194 if (cRefs == 0) 195 195 break; 196 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x cRefs=%d\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz, cRefs));196 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x cRefs=%d\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz, cRefs)); 197 197 for (uint32_t j = 0; j < 42; j++) 198 198 { … … 201 201 RTTESTI_CHECK_RETV(psz2 != psz); 202 202 RTTESTI_CHECK(RTStrCacheRelease(hStrCache, psz2) == 0); 203 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMem IsAll8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x cRefs=%d\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz, cRefs));203 RTTESTI_CHECK_MSG_RETV((pv2 = ASMMemFirstMismatchingU8(psz, i, 'a')) == NULL && !psz[i], ("i=%#x psz=%p off=%#x cRefs=%d\n", i, psz, (uintptr_t)pv2 - (uintptr_t)psz, cRefs)); 204 204 } 205 205 } -
trunk/src/VBox/VMM/VMMAll/MMAllHyper.cpp
r58122 r59747 1190 1190 } 1191 1191 1192 uint32_t *pu32Bad = ASMMem IsAllU32((uint8_t *)pu32End - cbFence, cbFence - sizeof(uint32_t), MMHYPER_HEAP_STRICT_FENCE_U32);1192 uint32_t *pu32Bad = ASMMemFirstMismatchingU32((uint8_t *)pu32End - cbFence, cbFence - sizeof(uint32_t), MMHYPER_HEAP_STRICT_FENCE_U32); 1193 1193 if (RT_UNLIKELY(pu32Bad)) 1194 1194 { -
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r58833 r59747 2655 2655 * Enumerate the VMs and add the ones visible to the statistics. 2656 2656 */ 2657 if ( ASMMemIsAll8(&pStats->SchedSum, sizeof(pStats->SchedSum), 0))2657 if (!ASMMemIsZero(&pStats->SchedSum, sizeof(pStats->SchedSum))) 2658 2658 { 2659 2659 for (unsigned i = pGVMM->iUsedHead; -
trunk/src/VBox/VMM/VMMR3/PGMDbg.cpp
r58126 r59747 677 677 } 678 678 679 const bool fAllZero = ASMMemIs All8(pabNeedle, cbNeedle, 0) == NULL;679 const bool fAllZero = ASMMemIsZero(pabNeedle, cbNeedle); 680 680 const uint32_t cIncPages = GCPhysAlign <= PAGE_SIZE 681 681 ? 1 … … 850 850 * Search the memory - ignore MMIO, zero and not-present pages. 851 851 */ 852 const bool fAllZero = ASMMemIs All8(pabNeedle, cbNeedle, 0) == NULL;852 const bool fAllZero = ASMMemIsZero(pabNeedle, cbNeedle); 853 853 RTGCPTR GCPtrMask = PGMMODE_IS_LONG_MODE(enmMode) ? UINT64_MAX : UINT32_MAX; 854 854 uint8_t abPrev[MAX_NEEDLE_SIZE]; -
trunk/src/VBox/VMM/testcase/tstCompressionBenchmark.cpp
r57358 r59747 610 610 for (size_t iPage = 0; iPage < g_cPages; iPage++) 611 611 { 612 if ( !ASMMemIsAllU32(&g_pabSrc[iPage * PAGE_SIZE], PAGE_SIZE, 0))612 if (ASMMemIsZeroPage(&g_pabSrc[iPage * PAGE_SIZE])) 613 613 cZeroPages++; 614 614 } -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r59527 r59747 119 119 ../../../Runtime/common/asm/ASMBitLastSetU32.asm \ 120 120 ../../../Runtime/common/asm/ASMBitLastSetU64.asm \ 121 ../../../Runtime/common/asm/ASMMemFirstMismatchingU8.asm \ 121 122 ../../../Runtime/common/asm/ASMSerializeInstruction-cpuid.asm \ 122 123 ../../../Runtime/common/asm/ASMSerializeInstruction-iret.asm \
Note:
See TracChangeset
for help on using the changeset viewer.