Changeset 87456 in vbox
- Timestamp:
- Jan 28, 2021 12:11:20 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asmdefs.mac
r85460 r87456 101 101 %define RT_CONCAT4(a_1,a_2,a_3,a_4) a_1 %+ a_2 %+ a_3 %+ a_4 102 102 103 ;; 104 ; Trick for using RT_CONCAT and the like on %define names. 105 ; @param 1 The name (expression. 106 ; @param 2 The value. 107 %macro RT_DEFINE_EX 2 108 %error 1=%1 2=%2 109 %define %1 %2 110 %endmacro 111 112 ;; 113 ; Trick for using RT_CONCAT and the like on %xdefine names. 114 ; @param 1 The name (expression. 115 ; @param 2 The value. 116 %macro RT_XDEFINE_EX 2 117 %xdefine %1 %2 118 %endmacro 119 120 ;; 121 ; Trick for using RT_CONCAT and the like on %undef names. 122 ; @param 1 The name (expression. 123 %macro RT_UNDEF_EX 1 124 %error 1=%1 125 %undef %1 126 %endmacro 127 103 128 104 129 ;; Define ASM_FORMAT_PE64 if applicable. … … 117 142 %endif 118 143 144 %ifdef RT_ASM_WITH_SEH64_ALT 145 %ifdef ASM_FORMAT_PE64 146 ;; @name Register numbers. Used with RT_CONCAT to convert macro inputs to numbers. 147 ;; @{ 148 %define SEH64_PE_GREG_rax 0 149 %define SEH64_PE_GREG_xAX 0 150 %define SEH64_PE_GREG_rcx 1 151 %define SEH64_PE_GREG_xCX 1 152 %define SEH64_PE_GREG_rdx 2 153 %define SEH64_PE_GREG_xDX 2 154 %define SEH64_PE_GREG_rbx 3 155 %define SEH64_PE_GREG_xBX 3 156 %define SEH64_PE_GREG_rsp 4 157 %define SEH64_PE_GREG_xSP 4 158 %define SEH64_PE_GREG_rbp 5 159 %define SEH64_PE_GREG_xBP 5 160 %define SEH64_PE_GREG_rsi 6 161 %define SEH64_PE_GREG_xSI 6 162 %define SEH64_PE_GREG_rdi 7 163 %define SEH64_PE_GREG_xDI 7 164 %define SEH64_PE_GREG_r8 8 165 %define SEH64_PE_GREG_r9 9 166 %define SEH64_PE_GREG_r10 10 167 %define SEH64_PE_GREG_r11 11 168 %define SEH64_PE_GREG_r12 12 169 %define SEH64_PE_GREG_r13 13 170 %define SEH64_PE_GREG_r14 14 171 %define SEH64_PE_GREG_r15 15 172 ;; @} 173 174 ;; @name PE unwind operations. 175 ;; @{ 176 %define SEH64_PE_PUSH_NONVOL 0 177 %define SEH64_PE_ALLOC_LARGE 1 178 %define SEH64_PE_ALLOC_SMALL 2 179 %define SEH64_PE_SET_FPREG 3 180 %define SEH64_PE_SAVE_NONVOL 4 181 %define SEH64_PE_SAVE_NONVOL_FAR 5 182 %define SEH64_PE_SAVE_XMM128 8 183 %define SEH64_PE_SAVE_XMM128_FAR 9 184 ;; @} 185 186 ;; 187 ; Starts the unwind info for the manual SEH64 info generation. 188 ; @param 1 Function name. 189 %macro SEH64_ALT_START_UNWIND_INFO 1 190 %assign seh64_idxOps 0 191 %assign seh64_FrameReg SEH64_PE_GREG_rsp 192 %assign seh64_offFrame 0 193 %define asm_seh64_proc %1 194 %undef seh64_slot_bytes 195 %endmacro 196 197 ;; We keep the unwind bytes in the seh64_slot_bytes (x)define, in reverse order as per spec. 198 %macro SEH64_APPEND_SLOT_PAIR 2 199 %ifdef seh64_slot_bytes 200 %xdefine seh64_slot_bytes %1, %2, seh64_slot_bytes 201 %else 202 %xdefine seh64_slot_bytes %1, %2 203 %endif 204 %endmacro 205 206 ;; For multi-slot unwind info. 207 %macro SEH64_APPEND_SLOT_BYTES 2+ 208 %rep %0 209 %rotate -1 210 %ifdef seh64_slot_bytes 211 %xdefine seh64_slot_bytes %1, seh64_slot_bytes 212 %else 213 %xdefine seh64_slot_bytes %1 214 %endif 215 %endrep 216 %endmacro 217 218 %else 219 %undef RT_ASM_WITH_SEH64_ALT 220 %endif 221 %endif 222 119 223 ;; 120 224 ; Records a xBP push. 121 225 %macro SEH64_PUSH_xBP 0 122 226 %ifdef RT_ASM_WITH_SEH64 123 [pushreg rbp] 227 [pushreg rbp] 228 229 %elifdef RT_ASM_WITH_SEH64_ALT 230 RT_CONCAT(.seh64_op_label_,seh64_idxOps): 231 %ifdef ASM_FORMAT_PE64 232 SEH64_APPEND_SLOT_PAIR RT_CONCAT(.seh64_op_label_,seh64_idxOps) - .start_of_prologue, \ 233 SEH64_PE_PUSH_NONVOL | (SEH64_PE_GREG_rbp << 4) 234 %endif 235 %assign seh64_idxOps seh64_idxOps + 1 124 236 %endif 125 237 %endmacro … … 130 242 %macro SEH64_PUSH_GREG 1 131 243 %ifdef RT_ASM_WITH_SEH64 132 [pushreg %1] 244 [pushreg %1] 245 246 %elifdef RT_ASM_WITH_SEH64_ALT 247 RT_CONCAT(.seh64_op_label_,seh64_idxOps): 248 %ifdef ASM_FORMAT_PE64 249 SEH64_APPEND_SLOT_PAIR RT_CONCAT(.seh64_op_label_,seh64_idxOps) - .start_of_prologue, \ 250 SEH64_PE_PUSH_NONVOL | (RT_CONCAT(SEH64_PE_GREG_,%1) << 4) 251 %endif 252 %assign seh64_idxOps seh64_idxOps + 1 133 253 %endif 134 254 %endmacro … … 139 259 %ifdef RT_ASM_WITH_SEH64 140 260 [setframe rbp, %1] 261 262 %elifdef RT_ASM_WITH_SEH64_ALT 263 RT_CONCAT(.seh64_op_label_,seh64_idxOps): 264 %ifdef ASM_FORMAT_PE64 265 SEH64_APPEND_SLOT_PAIR RT_CONCAT(.seh64_op_label_,seh64_idxOps) - .start_of_prologue, \ 266 SEH64_PE_SET_FPREG | 0 ; vs2019 seems to put the offset in the info field 267 %assign seh64_FrameReg SEH64_PE_GREG_rbp 268 %assign seh64_offFrame %1 269 %endif 270 %assign seh64_idxOps seh64_idxOps + 1 141 271 %endif 142 272 %endmacro … … 146 276 %macro SEH64_ALLOCATE_STACK 1 147 277 %ifdef RT_ASM_WITH_SEH64 148 [allocstack %1] 149 %endif 278 [allocstack %1] 279 280 %elifdef RT_ASM_WITH_SEH64_ALT 281 RT_CONCAT(.seh64_op_label_,seh64_idxOps): 282 %ifdef ASM_FORMAT_PE64 283 %if (%1) & 7 284 %error "SEH64_ALLOCATE_STACK must be a multiple of 8" 285 %endif 286 %if (%1) < 8 287 %error "SEH64_ALLOCATE_STACK must have an argument that's 8 or higher." 288 %elif (%1) <= 128 289 SEH64_APPEND_SLOT_PAIR RT_CONCAT(.seh64_op_label_,seh64_idxOps) - .start_of_prologue, \ 290 SEH64_PE_ALLOC_SMALL | ((((%1) / 8) - 1) << 4) 291 %elif (%1) < 512 292 SEH64_APPEND_SLOT_BYTES RT_CONCAT(.seh64_op_label_,seh64_idxOps) - .start_of_prologue, \ 293 SEH64_PE_ALLOC_LARGE | 0, \ 294 ((%1) / 8) & 0xff, ((%1) / 8) >> 8 295 %else 296 SEH64_APPEND_SLOT_BYTES RT_CONCAT(.seh64_op_label_,seh64_idxOps) - .start_of_prologue, \ 297 SEH64_PE_ALLOC_LARGE | 1, \ 298 (%1) & 0xff, ((%1) >> 8) & 0xff, ((%1) >> 16) & 0xff, ((%1) >> 24) & 0xff 299 %endif 300 %endif 301 %assign seh64_idxOps seh64_idxOps + 1 302 %endif 303 %endmacro 304 305 %macro SEH64_INFO_HELPER 1 306 %if defined(%1) 307 dw %1 308 %endif 150 309 %endmacro 151 310 … … 153 312 ; Ends the prologue. 154 313 %macro SEH64_END_PROLOGUE 0 314 .end_of_prologue: 155 315 %ifdef RT_ASM_WITH_SEH64 156 [endprolog] 316 [endprolog] 317 318 %elifdef RT_ASM_WITH_SEH64_ALT 319 %ifdef ASM_FORMAT_PE 320 ; Emit the unwind info now. 321 %ifndef ASM_DEFINED_XDATA_SECTION 322 %define ASM_DEFINED_XDATA_SECTION 323 section .xdata rdata align=4 324 %else 325 section .xdata 326 align 4, db 0 327 %endif 328 .unwind_info: 329 db 1 ; version 1 (3 bit), no flags (5 bits) 330 db .end_of_prologue - .start_of_prologue 331 332 db (.unwind_info_array_end - .unwind_info_array) / 2 333 db seh64_FrameReg | (seh64_offFrame & 0xf0) ; framereg and offset/16. 334 .unwind_info_array: 335 %ifdef seh64_slot_bytes 336 db seh64_slot_bytes 337 %undef seh64_slot_bytes 338 %endif 339 .unwind_info_array_end: 340 341 ; Reset the segment 342 BEGINCODE 343 %endif 157 344 %endif 158 345 %endmacro … … 320 507 ; Begins a C callable procedure. 321 508 %macro BEGINPROC 1 509 %ifdef RT_ASM_WITH_SEH64_ALT 510 SEH64_ALT_START_UNWIND_INFO %1 511 %endif 322 512 %ifdef RT_ASM_WITH_SEH64 323 513 global NAME(%1):function … … 326 516 GLOBALNAME_EX %1, function hidden 327 517 %endif 518 .start_of_prologue: 328 519 %endmacro 329 520 … … 331 522 ; Begins a C callable exported procedure. 332 523 %macro BEGINPROC_EXPORTED 1 524 %ifdef RT_ASM_WITH_SEH64_ALT 525 SEH64_ALT_START_UNWIND_INFO %1 526 %endif 333 527 %ifdef RT_ASM_WITH_SEH64 334 528 %ifdef ASM_FORMAT_PE … … 340 534 EXPORTEDNAME_EX %1, function 341 535 %endif 536 .start_of_prologue: 342 537 %endmacro 343 538 … … 356 551 %endif 357 552 db 0xCC, 0xCC, 0xCC, 0xCC 553 554 %ifdef RT_ASM_WITH_SEH64_ALT 555 %ifdef ASM_FORMAT_PE 556 ; Emit the RUNTIME_FUNCTION entry. The linker is picky here, no label. 557 %ifndef ASM_DEFINED_PDATA_SECTION 558 %define ASM_DEFINED_PDATA_SECTION 559 section .pdata rdata align=4 560 %else 561 section .pdata 562 %endif 563 dd NAME(%1) wrt ..imagebase 564 dd NAME(%1 %+ _EndProc) wrt ..imagebase 565 dd NAME(%1 %+ .unwind_info) wrt ..imagebase 566 567 ; Restore code section. 568 BEGINCODE 569 %endif 570 %endif 358 571 %endmacro 359 572 -
trunk/src/VBox/VMM/VMMR0/HMR0A.asm
r87451 r87456 20 20 ;********************************************************************************************************************************* 21 21 ;%define RT_ASM_WITH_SEH64 - trouble with SEH, alignment and (probably) 2nd pass optimizations. 22 %define RT_ASM_WITH_SEH64_ALT ; Use asmdefs.mac hackery for manually emitting unwind info. 22 23 %include "VBox/asmdefs.mac" 23 24 %include "VBox/err.mac" … … 761 762 %endif 762 763 %assign cbBaseFrame cbFrame 763 sub rsp, cbFrame - 8 764 sub rsp, cbFrame - 8h 765 SEH64_ALLOCATE_STACK cbFrame 764 766 765 767 ; Save all general purpose host registers. -
trunk/src/VBox/VMM/VMMR0/VMMR0JmpA-amd64.asm
r82968 r87456 19 19 ;* Header Files * 20 20 ;******************************************************************************* 21 %define RT_ASM_WITH_SEH64 21 %define RT_ASM_WITH_SEH64_ALT 22 22 %include "VBox/asmdefs.mac" 23 23 %include "VMMInternal.mac" … … 56 56 ; @param pvUser2 msc:r9 gcc:rcx x86:[esp+0x10] The argument of that function. 57 57 ; 58 BEGINPROC vmmR0CallRing3SetJmp59 58 GLOBALNAME vmmR0CallRing3SetJmp2 60 59 GLOBALNAME vmmR0CallRing3SetJmpEx 60 BEGINPROC vmmR0CallRing3SetJmp 61 61 ; 62 62 ; Save the registers.
Note:
See TracChangeset
for help on using the changeset viewer.