1. The exception message maybe printed by DebugLib. Release/Production image 
use NULL DebugLib instance. It may make sense without output on serial port.
2. "Already started" makes sense due to CPU driver has already registered its 
own exception handler.

Your order to unregister with NULL pointer and to register your own exception 
handler is correct. 

I guessed the following happened.
Unregister is successfully, CPU driver unregister its own exception handler and 
restore the original IDT entry (setup in DXE Core before CPU driver dispatched, 
its exception handler provided by CpuExceptionHanderLib to dump exception 
message from serial port).
But register your own exception handler is not successful, so the GP is handled 
by original IDT entry to dump the exception message from serial port.

It seems that there is one bug in Cpu Dxe driver RegisterInterruptHandler () 
implementation.

Jeff
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Sergey 
Tretiyak
Sent: Tuesday, December 29, 2015 4:28 PM
To: Fan, Jeff
Cc: edk2-devel@lists.01.org
Subject: Re: [edk2] Registering custom exception/interrupt handler function.

1. I actually don't get any prints when I do that

2. I get "Already started" error from the RegisterInterruptHandler when I try 
to register my own handler, and again I don't get any prints.

On Tue, Dec 29, 2015 at 3:04 AM, Fan, Jeff <jeff....@intel.com> wrote:

> Got you.
>
>
>
> Could you try the following tests on your system?
>
>
>
> 1.       Not to unregister exception handler with NULL pointer and not to
> register your own exception handler and just to generate one GP fault.
> What’s exception message dumped?
>
> 2.       Not to unregister exception handler with NULL pointer and just
> to register your own exception handler? Then what happened?
>
>
>
> For your case, actually you needn’t to link any library, instead you 
> should consume CPU ARCH protocol only.
>
>
>
> Jeff
>
>
>
> *From:* Sergey Tretiyak [mailto:sergey.treti...@gmail.com]
> *Sent:* Monday, December 28, 2015 7:58 PM
>
> *To:* Fan, Jeff
> *Cc:* edk2-devel@lists.01.org
> *Subject:* Re: [edk2] Registering custom exception/interrupt handler 
> function.
>
>
>
> Yes, here's what I get printed:
>
> !!!! X64 Exception Type - 000000000000000D     CPU Apic ID - 00000000 !!!!
>
> RIP  - 0000000039F37134, CS  - 0000000000000038, RFLAGS - 
> 0000000000010206
>
> ExceptionData - 0000000000000000
>
> RAX  - 0000000000000014, RCX - 000000005DF75000, RDX - 
> 0000000000000000
>
> RBX  - 0000000080000013, RSP - 0000000046AD15E0, RBP - 
> 0000000046AD16B0
>
> RSI  - 0000000000000001, RDI - 000000005DF75000
>
> R8   - 0000000000000000, R9  - 0000000000000000, R10 - 0000000046AD1200
>
> R11  - 0000000000000002, R12 - 000000003A871518, R13 - 
> 0000000000000000
>
> R14  - 0000000000000000, R15 - 000000003A771998
>
> DS   - 0000000000000018, ES  - 0000000000000018, FS  - 0000000000000018
>
> GS   - 0000000000000018, SS  - 0000000000000018
>
> CR0  - 0000000080000013, CR2 - 0000000000000000, CR3 - 
> 00000000468B0000
>
> CR4  - 0000000000002668, CR8 - 0000000000000000
>
> DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 
> 0000000000000000
>
> DR3  - 0000000000000000, DR6 - 00000000FFFE0FF0, DR7 - 
> 0000000000000400
>
> GDTR - 0000000044DEABE0 0000000000000047, LDTR - 0000000000000000
>
> IDTR - 0000000044DEC4A0 0000000000000FFF,   TR - 0000000000000000
>
> FXSAVE_STATE - 0000000046AD1240
>
> !!!! Find PE image (....path to pdb file...) 
> (ImageBase=0000000039F36000,
> EntryPoint=0000000039F362C0) !!!!
>
>
>
> On Mon, Dec 28, 2015 at 9:56 AM, Fan, Jeff <jeff....@intel.com> wrote:
>
> Sorry. I missed this mail last week.
>
>
>
> Are you sure the exception message included the following message?
>
> " (ImageBase=%016lx, EntryPoint=%016lx) !!!!\n",
>
>
>
> Or could you post the whole exception message not only the first line?
>
>
>
> Jeff
>
>
>
> *From:* Sergey Tretiyak [mailto:sergey.treti...@gmail.com]
> *Sent:* Monday, December 21, 2015 8:06 PM
> *To:* Fan, Jeff
> *Cc:* edk2-devel@lists.01.org
> *Subject:* Re: [edk2] Registering custom exception/interrupt handler 
> function.
>
>
>
> It is used, I get the message printed from DumpCpuContent() in 
> ArchExceptionHandler.c, that starts with "!!!! X64 Exception Type - ...
> CPU Apic ID - ... !!!!...".
>
>
>
> On Mon, Dec 21, 2015 at 5:09 AM, Fan, Jeff <jeff....@intel.com> wrote:
>
> Could you post the exception message from serial port? Then we could 
> know if UefiCpuPkg/Library/CpuExceptionHandlerLib is used or not?
>
> Jeff
>
>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of 
> Sergey Tretiyak
> Sent: Sunday, December 20, 2015 6:05 PM
> To: edk2-devel@lists.01.org
> Subject: [edk2] Registering custom exception/interrupt handler function.
>
> Hi to all.
> I'm trying to write some EDK shell app for the latest Intel Skylake 
> CPU, and I need to use a custom GP exception handler during its work.
> I'm trying to locate the EFI_CPU_ARCH_PROTOCOL by using 
> gEfiCpuArchProtocolGuid, then I'm using the RegisterInterruptHandler 
> protocol function (first with NULL to unregister the existing handler, 
> and then with pointer to my handler function), and it returns me 
> EFI_SUCCESS in both calls. But when I actually get a GP, it doesn't 
> reach my custom handler function, and probably continues to use some 
> kind of default exception handler that prints a default exception message on 
> my serial port.
> What I am doing wrong? Perhaps I'm compiling my app with a wrong library?
> Which library should be used for EFI_CPU_ARCH_PROTOCOL to work 
> correctly as expected?
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>
>
>
>
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to