Changeset 46253 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- May 24, 2013 9:25:35 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevLsiLogicSCSI.cpp
r45970 r46253 67 67 #define LSILOGIC_MAX_ALLOC_TOO_MUCH 20 68 68 69 /** Maximum size of the memory regions (prevents teh guest from DOSing the host by 70 * allocating loadds of memory). */ 71 #define LSILOGIC_MEMORY_REGIONS_MAX (_1M) 72 69 73 /******************************************************************************* 70 74 * Structures and Typedefs * … … 337 341 /** Current address to read from or write to in the diagnostic memory region. */ 338 342 uint32_t u32DiagMemAddr; 339 343 /** Current size of the memory regions. */ 344 uint32_t cbMemRegns; 345 346 #if HC_ARCH_BITS ==32 340 347 uint32_t u32Padding3; 348 #endif 341 349 342 350 union … … 786 794 RTMemFree(pIt); 787 795 } 796 pThis->cbMemRegns = 0; 788 797 } 789 798 … … 878 887 uint32_t cRegionSizeOld = (pRegion->u32AddrEnd - pRegion->u32AddrStart) / 4 + 1; 879 888 uint32_t cRegionSizeNew = cRegionSizeOld + 512; 880 PLSILOGICMEMREGN pRegionNew = (PLSILOGICMEMREGN)RTMemRealloc(pRegion, RT_OFFSETOF(LSILOGICMEMREGN, au32Data[cRegionSizeNew])); 881 882 if (pRegionNew) 889 890 if (pThis->cbMemRegns + 512 * sizeof(uint32_t) < LSILOGIC_MEMORY_REGIONS_MAX) 883 891 { 884 pRegion = pRegionNew; 885 memset(&pRegion->au32Data[cRegionSizeOld], 0, 512 * sizeof(uint32_t)); 886 pRegion->au32Data[cRegionSizeOld] = u32Data; 887 pRegion->u32AddrEnd = pRegion->u32AddrStart + (cRegionSizeNew - 1) * sizeof(uint32_t); 888 } 889 /* else: Silently fail, there is nothing we can do here and the guest might work nevertheless. */ 890 891 lsilogicR3MemRegionInsert(pThis, pRegion); 892 } 893 else 894 { 895 /* Create completely new. */ 896 pRegion = (PLSILOGICMEMREGN)RTMemAllocZ(RT_OFFSETOF(LSILOGICMEMREGN, au32Data[512])); 897 if (pRegion) 898 { 899 pRegion->u32AddrStart = pThis->u32DiagMemAddr; 900 pRegion->u32AddrEnd = pRegion->u32AddrStart + (512 - 1) * sizeof(uint32_t); 901 pRegion->au32Data[0] = u32Data; 892 PLSILOGICMEMREGN pRegionNew = (PLSILOGICMEMREGN)RTMemRealloc(pRegion, RT_OFFSETOF(LSILOGICMEMREGN, au32Data[cRegionSizeNew])); 893 894 if (pRegionNew) 895 { 896 pRegion = pRegionNew; 897 memset(&pRegion->au32Data[cRegionSizeOld], 0, 512 * sizeof(uint32_t)); 898 pRegion->au32Data[cRegionSizeOld] = u32Data; 899 pRegion->u32AddrEnd = pRegion->u32AddrStart + (cRegionSizeNew - 1) * sizeof(uint32_t); 900 pThis->cbMemRegns += 512 * sizeof(uint32_t); 901 } 902 /* else: Silently fail, there is nothing we can do here and the guest might work nevertheless. */ 902 903 903 904 lsilogicR3MemRegionInsert(pThis, pRegion); 904 905 } 905 /* else: Silently fail, there is nothing we can do here and the guest might work nevertheless. */ 906 } 907 else 908 { 909 if (pThis->cbMemRegns + 512 * sizeof(uint32_t) < LSILOGIC_MEMORY_REGIONS_MAX) 910 { 911 /* Create completely new. */ 912 pRegion = (PLSILOGICMEMREGN)RTMemAllocZ(RT_OFFSETOF(LSILOGICMEMREGN, au32Data[512])); 913 if (pRegion) 914 { 915 pRegion->u32AddrStart = pThis->u32DiagMemAddr; 916 pRegion->u32AddrEnd = pRegion->u32AddrStart + (512 - 1) * sizeof(uint32_t); 917 pRegion->au32Data[0] = u32Data; 918 pThis->cbMemRegns += 512 * sizeof(uint32_t); 919 920 lsilogicR3MemRegionInsert(pThis, pRegion); 921 } 922 /* else: Silently fail, there is nothing we can do here and the guest might work nevertheless. */ 923 } 906 924 } 907 925 … … 4639 4657 SSMR3GetMem(pSSM, &pRegion->au32Data[0], cRegion * sizeof(uint32_t)); 4640 4658 lsilogicR3MemRegionInsert(pThis, pRegion); 4659 pThis->cbMemRegns += cRegion * sizeof(uint32_t); 4641 4660 } 4642 4661 else
Note:
See TracChangeset
for help on using the changeset viewer.