VirtualBox

Changeset 108658 in vbox


Ignore:
Timestamp:
Mar 20, 2025 3:33:39 PM (8 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168071
Message:

HostDrivers/Support/testcase/tstLow.cpp: Make it work for hosts where we don't know the host page size when building, bugref:10391

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/testcase/tstLow.cpp

    r106061 r108658  
    4545#include <iprt/stream.h>
    4646#include <iprt/string.h>
     47#include <iprt/system.h>
    4748
    4849
     
    5859    if (RT_SUCCESS(rc))
    5960    {
     61        uint32_t  const cbPage      = RTSystemGetPageSize();
     62        uintptr_t const offPageMask = RTSystemGetPageOffsetMask();
     63
    6064        /*
    6165         * Allocate a bit of contiguous memory.
     
    7781                }
    7882                if (    aPages0[iPage].Phys >= _4G
    79                     ||  (aPages0[iPage].Phys & PAGE_OFFSET_MASK))
     83                    ||  (aPages0[iPage].Phys & offPageMask))
    8084                {
    8185                    rcRet++;
     
    8690            {
    8791                for (unsigned iPage = 0; iPage < RT_ELEMENTS(aPages0); iPage++)
    88                     memset((char *)pvPages0 + iPage * PAGE_SIZE, iPage, PAGE_SIZE);
     92                    memset((char *)pvPages0 + iPage * cbPage, iPage, cbPage);
    8993                for (unsigned iPage = 0; iPage < RT_ELEMENTS(aPages0); iPage++)
    90                     for (uint8_t *pu8 = (uint8_t *)pvPages0 + iPage * PAGE_SIZE, *pu8End = pu8 + PAGE_SIZE; pu8 < pu8End; pu8++)
     94                    for (uint8_t *pu8 = (uint8_t *)pvPages0 + iPage * cbPage, *pu8End = pu8 + cbPage; pu8 < pu8End; pu8++)
    9195                        if (*pu8 != (uint8_t)iPage)
    9296                        {
    9397                            RTPrintf("tstLow: error: invalid page content %02x != %02x. iPage=%u off=%#x\n",
    94                                      *pu8, (uint8_t)iPage, iPage, (uintptr_t)pu8 & PAGE_OFFSET_MASK);
     98                                     *pu8, (uint8_t)iPage, iPage, (uintptr_t)pu8 & offPageMask);
    9599                            rcRet++;
    96100                        }
     
    125129                    }
    126130                    if (    aPages1[iPage].Phys >= _4G
    127                         ||  (aPages1[iPage].Phys & PAGE_OFFSET_MASK))
     131                        ||  (aPages1[iPage].Phys & offPageMask))
    128132                    {
    129133                        rcRet++;
     
    134138                {
    135139                    for (unsigned iPage = 0; iPage < cPages; iPage++)
    136                         memset((char *)pvPages1 + iPage * PAGE_SIZE, iPage, PAGE_SIZE);
     140                        memset((char *)pvPages1 + iPage * cbPage, iPage, cbPage);
    137141                    for (unsigned iPage = 0; iPage < cPages; iPage++)
    138                         for (uint8_t *pu8 = (uint8_t *)pvPages1 + iPage * PAGE_SIZE, *pu8End = pu8 + PAGE_SIZE; pu8 < pu8End; pu8++)
     142                        for (uint8_t *pu8 = (uint8_t *)pvPages1 + iPage * cbPage, *pu8End = pu8 + cbPage; pu8 < pu8End; pu8++)
    139143                            if (*pu8 != (uint8_t)iPage)
    140144                            {
    141145                                RTPrintf("tstLow: error: invalid page content %02x != %02x. iPage=%p off=%#x\n",
    142                                          *pu8, (uint8_t)iPage, iPage, (uintptr_t)pu8 & PAGE_OFFSET_MASK);
     146                                         *pu8, (uint8_t)iPage, iPage, (uintptr_t)pu8 & offPageMask);
    143147                                rcRet++;
    144148                            }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette