VirtualBox

Changeset 420 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 29, 2007 6:17:06 PM (18 years ago)
Author:
vboxsync
Message:

Don't trust the compiler to give us the right return address address for interrupt dispatching. (Hope this doesn't break on x86.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r397 r420  
    447447                case VINF_EM_RAW_INTERRUPT:
    448448                case VINF_EM_RAW_INTERRUPT_HYPER:
     449                {
    449450#ifdef VBOX_WITHOUT_IDT_PATCHING
    450451                    TRPMR0DispatchHostInterrupt(pVM);
    451 #else
    452                     TRPMR0SetupInterruptDispatcherFrame(pVM, (char*)&pVM - sizeof(pVM));
    453 #endif
     452#else /* !VBOX_WITHOUT_IDT_PATCHING */
     453                    /*
     454                     * Don't trust the compiler to get this right.
     455                     * gcc -fomit-frame-pointer screws up big time here. This works fine in 64-bit
     456                     * mode too because we push the arguments on the stack in the IDT patch code.
     457                     */
     458# if defined(__GNUC__)
     459                    void *pvRet = (uint8_t *)__builtin_frame_address(0) + sizeof(void *);
     460# elif defined(_MSC_VER) && defined(__AMD64__) /** @todo check this with with VC7! */
     461#  pragma intrinsic(_AddressOfReturnAddress)
     462                    void *pvRet = (uint8_t *)_AddressOfReturnAddress;
     463# elif defined(__X86__)
     464                    void *pvRet = (uint8_t *)&pVM - sizeof(pVM);
     465# else
     466#  error "huh?"
     467# endif
     468                    if (    ((uintptr_t *)pvRet)[1] == (uintptr_t)pVM
     469                        &&  ((uintptr_t *)pvRet)[2] == (uintptr_t)uOperation
     470                        &&  ((uintptr_t *)pvRet)[3] == (uintptr_t)pvArg)
     471                        TRPMR0SetupInterruptDispatcherFrame(pVM, pvRet);
     472                    else
     473                    {
     474# if defined(DEBUG) || defined(LOG_ENABLED)
     475                        static bool  s_fHaveWarned = false;
     476                        if (!s_fHaveWarned)
     477                        {
     478                             s_fHaveWarned = true;
     479                             //RTLogPrintf("VMMR0.r0: The compiler can't find the stack frame!\n"); -- @todo export me!
     480                             RTLogComPrintf("VMMR0.r0: The compiler can't find the stack frame!\n");
     481                        }
     482# endif
     483                        TRPMR0DispatchHostInterrupt(pVM);
     484                    }
     485#endif /* !VBOX_WITHOUT_IDT_PATCHING */
    454486                    return rc;
     487                }
    455488            }
    456489            /* Won't get here! */
Note: See TracChangeset for help on using the changeset viewer.

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