On Aug 8, 2014, at 5:02 PM, Bill Paul <[email protected]> wrote: > Of all the gin joints in all the towns in all the world, Andrew Fish had to > walk into mine at 16:46:15 on Friday 08 August 2014 and say: > >> I’m still working on porting the CpuExceptionHandlerLib to clang, but I hit >> some code I don’t understand? I have mods in the assembly code but….. >> >> I’m running in QEMU and I’m taking the 1st timer tick and >> CommonExceptionHandler() gets called and ExceptionType is 0x68. But >> ExceptionType is used to index into an array that only has 32 entries? > > Vectors 0 to 31 are reserved for internal CPU exception vector values when > running in protected mode or long mode. Vectors 32 through 255 are available > for software defined interrupts. (In 16-bit real mode, only vectors 0 through > 7 are reserved, which requires you to fiddle with the 8259 PICs a bit when > you > enter protected mode to avoid a conflict in the unlikely event that you > choose > to use the legacy PICs for interrupt handling.) >
Yes I agree. > So the exception count is correct, and I guess CommonExceptionHandler() is > assuming that the ExceptionType argument will only ever be an internal > exception value. Presumably there's some other code somewhere that branches > off the handling of vectors 32 to 255 to a different handler (for IRQ > dispatching). > Well it seems in PEI it might only be the fixed 32 vectors for the exceptions. But on the DXE side there are functions called InitializeCpuInterruptHandlers() and RegisterCpuInterruptHandler(), so it is exceptions + interrupts. https://svn.code.sf.net/p/edk2/code/trunk/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeException.c https://svn.code.sf.net/p/edk2/code/trunk/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c I would also point out CommonExceptionHandler() is checking to see if ExceptionType is an exception or interrupt after performing the buffer overflow read of the array I mentioned in my other mail. https://svn.code.sf.net/p/edk2/code/trunk/edk2/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeSmmCpuException.c } else if (ExceptionType < CPU_EXCEPTION_NUM) { So it looks more like unfortunate names. Maybe it started as exception only and the interrupt support got added, and the names did not get changed? Or maybe some on grabbed the code initially from a debugger that only hooked exceptions. > The question is where is the value 0x68 coming from? I think it is coming from: UefiCpuPkg/CpuDxe/CpuDxe.c:259: return RegisterCpuInterruptHandler (InterruptType, InterruptHandler); This library function is produced by the CpuExceptionHandlerLib. And the Timer driver is going to call the CPU Architectural Protocol produced by the CpuDxe driver to register the timer tick. 0x68 is the timer interrupt in OVFM. Thanks, Andrew Fish
------------------------------------------------------------------------------
_______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
