Re: [edk2] EndOfDxe?

2014-05-02 Thread Tim Lewis
Vincent --

I understand the business problems all too well. But the EDK2 reference 
implementation should be able to comply as it exists today, even if we were to 
put the signal at the last possible point before the connect console and 
Driver processing. We perpetuate this problem on both the x86 side and ARM 
by leaving it out but having EDK2 drivers depend on it.

Tim 

-Original Message-
From: Zimmer, Vincent [mailto:vincent.zim...@intel.com] 
Sent: Wednesday, April 30, 2014 6:36 PM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] EndOfDxe?

Tim:

I agree.  First order business problem is evolving implementations to adhere to 
strictures of PI spec about 3rd party code in volume 2 of the PI Spec from 
uefi.org, viz,

5.1.2.1 End of DXE Event
Prior to invoking any UEFI drivers, applications, or connecting consoles, the 
platform should signal the event EFI_END_OF_DXE_EVENT_GUID.
#define EFI_END_OF_DXE_EVENT_GROUP_GUID \ { 0x2ce967a, 0xdd7e, 0x4ffc, { 0x9e, 
0xe7, 0x81, 0xc, \ 0xf0, 0x47, 0x8, 0x80 } }
>From SEC through the signaling of this event, all of the components 
>should
be under the authority of
the platform manufacturer and not have to worry about interaction or corruption 
by 3rd party extensible modules. As such, PI modules that need to lock or 
protect their resources in anticipation of the invocation of 3rd party 
extensible modules, such as UEFI drivers, should register for notification on 
this event and effect the appropriate protections in their notification handler



Vincent 

-Original Message-
From: Tim Lewis [mailto:tim.le...@insyde.com]
Sent: Wednesday, April 30, 2014 6:19 PM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] EndOfDxe?

Vincent --

Less worried about the exact location, but want it to meet the PI-imposed 
requirements of before console connection or processing DriverOrder or 
BootOrder.

Tim

-Original Message-
From: Zimmer, Vincent [mailto:vincent.zim...@intel.com]
Sent: Wednesday, April 30, 2014 6:06 PM
To: edk2-devel@lists.sourceforge.net
Subject: Re: [edk2] EndOfDxe?

Tim:

I wanted to follow-up a bit on the complexity of doing this.  Maybe relax the ' 
immediately upon calling the BdsEntry() function in BdsDxe.' language in your 
initial message to 'somewhere within BdsEntry() of BdsDxe' if that wasn't 
already your intent.

Why?

Signaling of the EndOfDxe event is a bit tricky since it may need to be done in 
some intermediate portion of the platform Bds logic, not necessarily at the 
top, for a given platform.

Specifically, if you were to simplify logic in 
https://svn.code.sf.net/p/edk2/code/trunk/edk2/IntelFrameworkModulePkg/Unive
rsal/BdsDxe/BdsEntry.c 

You might not signal the event at 

VOID
EFIAPI
BdsEntry (
  IN EFI_BDS_ARCH_PROTOCOL  *This
  )
{
  LIST_ENTRY  DriverOptionList;
  LIST_ENTRY  BootOptionList;
  UINTN   BootNextSize;
  CHAR16  *FirmwareVendor;
  EFI_STATUS  Status;
  UINT16  BootTimeOut;
  UINTN   Index;
  EDKII_VARIABLE_LOCK_PROTOCOL*VariableLock;

 SignalEndOfDxe here

But instead perhaps later in the code, prior to the code block:

  //
  // Set up the device list based on EFI 1.1 variables
  // process Driver and Load the driver's in the
  // driver option list
  //
  BdsLibBuildOptionFromVar (&DriverOptionList, L"DriverOrder");
  if (!IsListEmpty (&DriverOptionList)) {
BdsLibLoadDrivers (&DriverOptionList);
  }
  //
  // Check if we have the boot next option
  //
  mBootNext = BdsLibGetVariableAndSize (
L"BootNext",
&gEfiGlobalVariableGuid,
&BootNextSize
);

  //
  // Setup some platform policy here
  //
  PlatformBdsPolicyBehavior (&DriverOptionList, &BootOptionList, 
BdsProcessCapsules, BdsMemoryTest);
  PERF_END (NULL, "PlatformBds", "BDS", 0);

  //
  // BDS select the boot device to load OS
  //
  BdsBootDeviceSelect ();


Why?

Prior to loading drivers and doing connects, you may want the platform to be 
open (assuming an EndOfDxe handler locks flash, for example).

Other examples in platform Bds's not in our open source one includes capsule 
processing.

Perhaps the Bds logic there



BdsEntry()
{
Process capsule

If there exists a valid capsule, connect just my integrated gfx driver so that 
I can provide output while processing capsules

Signal end of Dxe to lock flash

Load and run 3rd party drivers

Connect rest of consoles

etc
}

So I agree w/ need, but maybe each package owner needs to do the analysis on 
where in their Bds to put this logic.  

So this isn't so much a question of 'if' we should do it, which we all agree is 
good, but perhaps 'where' in the respective Bds driver?

Thanks,

Vincent

-Original Message-
From: Andrew Fish [mailto:af...@apple.com]
Sent: Wednesday, April 30, 2014 10:39 AM
To: edk2-devel@lists.sourceforge.net
S

[edk2] SouceLevelDebug w/WinDbg and DuetPkgX64

2014-05-02 Thread Joe Thomas
Seems like this is an ongoing question without any definitive answer...

I have a hardware driver I'm trying to debug using DuetPkgX64 (need to access 
real HW and platforms we have access to don't support SourceLevelDebug...)

After some missteps, I can at least connect to the debug agent running WInDbg.  
The problem is that the target keeps reporting an Access Violation in the 
TimerInterruptHandler.
This is without my driver being loaded yet.

Before I decide if this is something I can tackle, has anyone encountered 
this/know how to resolve?

Thanks!





Kernel Debugger connection established
Debugger data list address is NULL
Connected to eXDI Device 0 x64 target at (Fri May  2 08:42:43.683 2014 
(GMT-5)), ptr64 TRUE
Symbol search path is: *** Invalid ***

* Symbol loading may be unreliable without a symbol search path.   *
* Use .symfix to have the debugger choose a symbol path.   *
* After setting your symbol path, use .reload to refresh symbol locations. *

Executable search path is:
eXDI Device Kernel Version 0 UP Free x64
Machine Name:
Primary image base = 0x` Loaded module list = 
0x`
System Uptime: not available
The call to LoadLibrary(kdexts) failed, Win32 error 0n2
"The system cannot find the file specified."
Please check your debugger configuration and/or network access.
Access violation - code c005 (first/second chance not available)
`bf52e988 0fae07  fxsave  [rdi]
0: kd> .sympath C:  
\UEFI\EDK2\BUILD\DUETPKGX64\DEBUG_VS2005\X64\MDEMODULEPKG\CORE\DXE\DXEMAIN\DEBUG\
Symbol search path is: C:  
\UEFI\EDK2\BUILD\DUETPKGX64\DEBUG_VS2005\X64\MDEMODULEPKG\CORE\DXE\DXEMAIN\DEBUG\
Expanded Symbol search path is: c:  
\uefi\edk2\build\duetpkgx64\debug_vs2005\x64\mdemodulepkg\core\dxe\dxemain\debug\
0: kd> .reload /f DXECORE=0x0`BF503000
0: kd> .load C:\Program Files (x86)\Intel\Intel(R) UEFI Development Kit 
Debugger Tool\UdkExtension.dll
0: kd> g
Access violation - code c005 (first/second chance not available)
DXECORE!TimerInterruptHandle+0xf8:
`bf52e988 0fae07  fxsave  [rdi]
0: kd> .echo Target encountered an exception: Vector = 13, Error Code = 
Target encountered an exception: Vector = 13, Error Code = 



0: kd> r
rax= rbx=0002 rcx=0008
rdx= rsi=00022110 rdi=bf4d1a38
rip=bf52e988 rsp=bf4d1a38 rbp=bf4d1d88
r8=  r9= r10=
r11= r12= r13=
r14= r15=
iopl=0 nv up di pl nz na pe nc
cs=0038  ss=0018  ds=0018  es=0018  fs=  gs=f000 efl=00010002
DXECORE!TimerInterruptHandle+0xf8:
`bf52e988 0fae07  fxsave  [rdi]ds:0018:`bf4d1a38=00


`bf52e961 0f23f8  mov dr7,rax
`bf52e964 0f21f0  mov rax,dr6
`bf52e967 50  pushrax
`bf52e968 4833c0  xor rax,rax
`bf52e96b 0f23f0  mov dr6,rax
`bf52e96e 0f21d8  mov rax,dr3
`bf52e971 50  pushrax
`bf52e972 0f21d0  mov rax,dr2
`bf52e975 50  pushrax
`bf52e976 0f21c8  mov rax,dr1
`bf52e979 50  pushrax
`bf52e97a 0f21c0  mov rax,dr0
`bf52e97d 50  pushrax
`bf52e97e 4881ec0002  sub rsp,200h
`bf52e985 488bfc  mov rdi,rsp
`bf52e988 0fae07  fxsave  [rdi]ds:0018:`bf4d1a38=00
`bf52e98b ff7510  pushqword ptr [rbp+10h]
`bf52e98e fc  cld
`bf52e98f 488bd4  mov rdx,rsp
`bf52e992 4c8bf9  mov r15,rcx
`bf52e995 4883ec28sub rsp,28h
`bf52e999 e83e9e  callDXECORE!InterruptProcess 
(`bf5287dc)
`bf52e99e 4883c428add rsp,28h
`bf52e9a2 4883c408add rsp,8
`bf52e9a6 488bf4  mov rsi,rsp
`bf52e9a9 0fae0e  fxrstor [rsi]
`bf52e9ac 4881c40002  add rsp,200h
`bf52e9b3 58  pop rax
`bf52e9b4 0f23c0  mov dr0,rax
`bf52e9b7 58  pop rax



Console output:

Enter DxeIpl ...
Handoff:
Handoff.BfvBase = BF549000, BfvLength = 15
Handoff.DxeIplImageBase = BF53C000, DxeIplImageSize = D000
Handoff.DxeCoreImageBase = BF502000, DxeCoreImageSize = 3A000
Prepare Cpu HOB information ...
Prepare BFV HOB information ...
Prepare Memory HOB information ...
Prepare NV Storage information ...
NV Storage Base = BF4D2000
Stack Top=0xBF4D2000, Stack Bottom=0xBF4B2000
Prepare DxeCore