Yes you are right that VariableSmm.c doesn't need the conversion.
But it is not because the mEnableLocking is FALSE.
You can find there is another place (VariableSmm.c:664) calling the function 
VariableServiceSetVariable() and the mEnableLocking is TRUE at that moment.

The real reason that we do not need the conversion is SMM driver is running in 
its own context so using its own 1:1 page table, not like the Runtime driver 
which is using the OS page table.

Thanks,
Ray

-----Original Message-----
From: Laszlo Ersek [mailto:ler...@redhat.com] 
Sent: Sunday, June 09, 2013 7:57 AM
To: Ni, Ruiyu
Cc: edk2-devel@lists.sourceforge.net
Subject: Re: SVN r14372 breaks Windows boot on OVMF

On 06/08/13 07:41, Ni, Ruiyu wrote:
> Laszlo,
> Even though your OVMF includes a SeaBios image, the two Windows you
> used are UEFI OS right?

OS        CSM in OVMF.fd  UEFI boot  crashes
--------  --------------  ---------  -------
win8      no              yes        yes
win2k8r2  yes             yes        yes


> If that's true, can you try to boot the Windows again after removing
> the code change in BdsEntry.c?
>
> I am afraid I forgot to do some pointers conversion in the variable
> driver.

I was confused by the term "pointer conversion" and thought maybe you
had meant some EFIAPI declarations going lost.

However I started debugging the code you added in r14372, and the crash
happens in VariableServiceSetVariable()
[MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c], when you
initialize Link with GetFirstNode():

  if (mEndOfDxe && mEnableLocking) {
    //
    // Treat the variables listed in the forbidden variable list as read-only 
after leaving DXE phase.
    //
    for ( Link = GetFirstNode (&mLockedVariableList)  // <--------------- here
        ; !IsNull (&mLockedVariableList, Link)
        ; Link = GetNextNode (&mLockedVariableList, Link)
        ) {
      Entry = BASE_CR (Link, VARIABLE_ENTRY, Link);
      if (CompareGuid (&Entry->Guid, VendorGuid) && (StrCmp (Entry->Name, 
VariableName) == 0)) {
        Status = EFI_WRITE_PROTECTED;
        DEBUG ((EFI_D_INFO, "[Variable]: Changing readonly variable after 
leaving DXE phase - %g:%s\n", VendorGuid, Va
        goto Done;
      }
    }
  }

I started logging accesses to forward and backward links in
mLockedVariableList, printing even &mLockedVariableList itself, and then
I realized what you meant by "pointer conversion" :)

I'll post the patch to the list in a minute that fixes the problem for
me.

... There are three INF files in this directory.

                           has definition of    extends                      
traverses
                           mLockedVariableList  mLockedVariableList          
mLockedVariableList
                           (ie. links with      via                          via
                           Variable.c)          VariableLockRequestToLock()  
VariableServiceSetVariable()
                           -------------------  ---------------------------  
----------------------------
VariableRuntimeDxe.inf     yes                  yes                          yes
VariableSmm.inf            yes                  yes                          no 
(*)
VariableSmmRuntimeDxe.inf  no                   n/a                          n/a

(*) see "mEnableLocking" in SmmVariableSetVariable().

Therefore I think it's not necessary to convert the pointers in
VariableSmm.c.

However we probably need to replicate the fix to SecurityPkg (SVN
r14378); I included that in the patch (and tested it) too.

Thanks,
Laszlo

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to