Changeset 22885 in vbox for trunk/src/VBox/VMM/testcase
- Timestamp:
- Sep 9, 2009 9:58:49 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM/testcase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/tstHelp.h
r20374 r22885 70 70 do \ 71 71 { \ 72 if ( 72 if (RT_OFFSETOF(strct, member) & ((align) - 1) ) \ 73 73 { \ 74 printf("%s::%s offset=%#x expected alignment %x, meaning %#x off\n", #strct, #member, (unsigned)RT_OFFSETOF(strct, member), \ 75 (unsigned)(align), (unsigned)(RT_OFFSETOF(strct, member) & ((align) - 1))); \ 74 printf("%s::%s offset=%#x (%u) expected alignment %x, meaning %#x (%u) off\n", \ 75 #strct, #member, \ 76 (unsigned)RT_OFFSETOF(strct, member), \ 77 (unsigned)RT_OFFSETOF(strct, member), \ 78 (unsigned)(align), \ 79 (unsigned)((align) - RT_OFFSETOF(strct, member) & ((align) - 1)), \ 80 (unsigned)((align) - RT_OFFSETOF(strct, member) & ((align) - 1)) ); \ 76 81 rc++; \ 77 82 } \ … … 85 90 if (RT_ALIGN_Z(sizeof(type), (align)) != sizeof(type)) \ 86 91 { \ 87 printf("%s size=%#x, align=%#x %#x bytes off\n", #type, (int)sizeof(type), \ 88 (align), (int)RT_ALIGN_Z(sizeof(type), align) - (int)sizeof(type)); \ 92 printf("%s size=%#x (%u), align=%#x %#x (%u) bytes off\n", \ 93 #type, \ 94 (unsigned)sizeof(type), \ 95 (unsigned)sizeof(type), \ 96 (align), \ 97 (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type), \ 98 (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type)); \ 89 99 rc++; \ 90 100 } \ … … 94 104 * Checks that a internal struct padding is big enough. 95 105 */ 96 #define CHECK_PADDING(strct, member ) \106 #define CHECK_PADDING(strct, member, align) \ 97 107 do \ 98 108 { \ … … 101 111 { \ 102 112 printf("padding of %s::%s is too small, padding=%d struct=%d correct=%d\n", #strct, #member, \ 103 (int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), 64)); \ 113 (int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \ 114 rc++; \ 115 } \ 116 else if (RT_ALIGN_Z(sizeof(p->member.padding), (align)) != sizeof(p->member.padding)) \ 117 { \ 118 printf("padding of %s::%s is misaligned, padding=%d correct=%d\n", #strct, #member, \ 119 (int)sizeof(p->member.padding), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \ 104 120 rc++; \ 105 121 } \ -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r21989 r22885 73 73 printf("struct VM: %d bytes\n", (int)sizeof(VM)); 74 74 75 #define CHECK_PADDING_VM( member) \75 #define CHECK_PADDING_VM(align, member) \ 76 76 do \ 77 77 { \ 78 CHECK_PADDING(VM, member); \ 79 CHECK_MEMBER_ALIGNMENT(VM, member, 32); \ 78 CHECK_PADDING(VM, member, align); \ 79 CHECK_MEMBER_ALIGNMENT(VM, member, align); \ 80 VM *p; \ 81 if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \ 82 printf("warning: VM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \ 83 #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \ 84 (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \ 85 (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \ 80 86 } while (0) 81 87 82 88 83 #define CHECK_PADDING_VMCPU( member) \89 #define CHECK_PADDING_VMCPU(align, member) \ 84 90 do \ 85 91 { \ 86 CHECK_PADDING(VMCPU, member); \ 87 CHECK_MEMBER_ALIGNMENT(VMCPU, member, 32); \ 92 CHECK_PADDING(VMCPU, member, align); \ 93 CHECK_MEMBER_ALIGNMENT(VMCPU, member, align); \ 94 VMCPU *p; \ 95 if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \ 96 printf("warning: VMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \ 97 #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \ 98 (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \ 99 (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \ 88 100 } while (0) 89 101 … … 137 149 CHECK_SIZE(X86PML4, PAGE_SIZE); 138 150 139 CHECK_PADDING_VM(cfgm); 140 CHECK_PADDING_VM(cpum); 141 CHECK_PADDING_VM(dbgf); 142 CHECK_PADDING_VM(em); 143 CHECK_PADDING_VM(iom); 144 CHECK_PADDING_VM(mm); 145 CHECK_PADDING_VM(pdm); 146 CHECK_PADDING_VM(pgm); 147 CHECK_PADDING_VM(selm); 148 CHECK_PADDING_VM(tm); 149 CHECK_PADDING_VM(trpm); 150 CHECK_PADDING_VM(vm); 151 CHECK_PADDING_VM(vmm); 152 CHECK_PADDING_VM(ssm); 153 CHECK_PADDING_VM(rem); 154 CHECK_PADDING_VM(hwaccm); 155 CHECK_PADDING_VM(patm); 156 CHECK_PADDING_VM(csam); 157 158 CHECK_PADDING_VMCPU(cpum); 159 CHECK_PADDING_VMCPU(pgm); 160 CHECK_PADDING_VMCPU(em); 161 CHECK_PADDING_VMCPU(hwaccm); 162 CHECK_PADDING_VMCPU(trpm); 163 CHECK_PADDING_VMCPU(tm); 164 CHECK_PADDING_VMCPU(vmm); 151 CHECK_PADDING_VM(64, cpum); 152 CHECK_PADDING_VM(64, vmm); 153 CHECK_PADDING_VM(64, pgm); 154 CHECK_PADDING_VM(64, hwaccm); 155 CHECK_PADDING_VM(64, trpm); 156 CHECK_PADDING_VM(64, selm); 157 CHECK_PADDING_VM(64, mm); 158 CHECK_PADDING_VM(64, pdm); 159 CHECK_PADDING_VM(64, iom); 160 CHECK_PADDING_VM(64, patm); 161 CHECK_PADDING_VM(64, csam); 162 CHECK_PADDING_VM(64, em); 163 CHECK_PADDING_VM(64, tm); 164 CHECK_PADDING_VM(64, dbgf); 165 CHECK_PADDING_VM(64, ssm); 166 CHECK_PADDING_VM(64, rem); 167 CHECK_PADDING_VM(8, vm); 168 #ifdef VBOX_WITH_VMI 169 CHECK_PADDING_VM(8, parav); 170 #endif 171 CHECK_PADDING_VM(8, cfgm); 172 173 CHECK_PADDING_VMCPU(64, cpum); 174 CHECK_PADDING_VMCPU(64, pgm); 175 CHECK_PADDING_VMCPU(64, hwaccm); 176 CHECK_PADDING_VMCPU(64, em); 177 CHECK_PADDING_VMCPU(64, trpm); 178 CHECK_PADDING_VMCPU(64, tm); 179 CHECK_PADDING_VMCPU(64, vmm); 180 CHECK_PADDING_VMCPU(64, pdm); 181 CHECK_PADDING_VMCPU(64, iom); 182 CHECK_PADDING_VMCPU(64, dbgf); 165 183 166 184 CHECK_MEMBER_ALIGNMENT(VM, selm.s.Tss, 16); … … 207 225 CHECK_MEMBER_ALIGNMENT(VM, rem.s.StatsInQEMU, 8); 208 226 CHECK_MEMBER_ALIGNMENT(VM, rem.s.Env, 32); 209 CHECK_MEMBER_ALIGNMENT(VM, aCpus, 64); 210 211 /* vmcpu */ 212 CHECK_MEMBER_ALIGNMENT(VMCPU, cpum, 64); 213 CHECK_MEMBER_ALIGNMENT(VMCPU, vmm, 32); 214 CHECK_MEMBER_ALIGNMENT(VMCPU, pgm, 32); 215 CHECK_MEMBER_ALIGNMENT(VMCPU, em, 32); 216 CHECK_MEMBER_ALIGNMENT(VMCPU, hwaccm, 32); 217 CHECK_MEMBER_ALIGNMENT(VMCPU, tm, 32); 218 CHECK_SIZE_ALIGNMENT(VMCPU, 32); 227 228 /* the VMCPUs are page aligned TLB hit reassons. */ 229 CHECK_MEMBER_ALIGNMENT(VM, aCpus, 4096); 230 CHECK_SIZE_ALIGNMENT(VMCPU, 4096); 219 231 220 232 /* cpumctx */ … … 268 280 /* pdm */ 269 281 CHECK_MEMBER_ALIGNMENT(PDMDEVINS, achInstanceData, 64); 270 CHECK_PADDING(PDMDEVINS, Internal );282 CHECK_PADDING(PDMDEVINS, Internal, 1); 271 283 CHECK_MEMBER_ALIGNMENT(PDMUSBINS, achInstanceData, 16); 272 CHECK_PADDING(PDMUSBINS, Internal );284 CHECK_PADDING(PDMUSBINS, Internal, 1); 273 285 CHECK_MEMBER_ALIGNMENT(PDMDRVINS, achInstanceData, 16); 274 CHECK_PADDING(PDMDRVINS, Internal );286 CHECK_PADDING(PDMDRVINS, Internal, 1); 275 287 CHECK_PADDING2(PDMCRITSECT); 276 288 CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, idx, sizeof(uint16_t));
Note:
See TracChangeset
for help on using the changeset viewer.