]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: prevent code execution from DXE stack
authorLaszlo Ersek <lersek@redhat.com>
Fri, 28 Aug 2015 08:12:51 +0000 (08:12 +0000)
committerlersek <lersek@Edk2>
Fri, 28 Aug 2015 08:12:51 +0000 (08:12 +0000)
SVN rev 18166 ("MdeModulePkg DxeIpl: Add stack NX support") enables
platforms to request non-executable stack for the DXE phase, by setting
PcdSetNxForStack to TRUE.

The PCD defaults to FALSE, because:

(a) A non-executable DXE stack is a new feature and causes changes in
    behavior. Some platform could rely on executing code from the stack.

(b) The code enabling NX in the DXE IPL PEIM enforces the

      PcdSetNxForStack ==> PcdDxeIplBuildPageTables

    implication for "64-bit PEI + 64-bit DXE" platforms, with a new
    ASSERT(). Some platform might not comply with this requirement
    immediately.

Regarding (a), in none of the OVMF builds do we try to execute code from
the stack.

Regarding (b):

- In the OvmfPkgX64.dsc build (which is where (b) applies) we simply
  inherit the PcdDxeIplBuildPageTables|TRUE default from
  "MdeModulePkg/MdeModulePkg.dec". Therefore we can set PcdSetNxForStack
  to TRUE.

- In OvmfPkgIa32X64.dsc, page tables are built by default for DXE. Hence
  we can set PcdSetNxForStack to TRUE.

- In OvmfPkgIa32.dsc, page tables used not to be necessary until now.
  After we set PcdSetNxForStack to TRUE in this patch, the DXE IPL will
  construct page tables even when it is built as part of OvmfPkgIa32.dsc,
  provided the (virtual) hardware supports both PAE mode and the XD bit.

Should this setting cause problems in a GPU (or other device) passthru
scenario, with a UEFI_DRIVER in the PCI option rom attempting to execute
code from the stack, the feature can be dynamically disabled on the QEMU
command line, with "-cpu <MODEL>,-nx".

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: "Zeng, Star" <star.zeng@intel.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18360 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc

index d92a327bf627ee48527870502e6737305b26eddc..685e72a570506ddbcaa65b39e3e068b7220b28ad 100644 (file)
 !endif\r
 \r
 [PcdsFixedAtBuild]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10\r
index 1c39cc7b6281622ea3418b15d3de59d89f836c1a..84cbb7ab4daf21bfb725d843b8fc1392d6eae943 100644 (file)
 !endif\r
 \r
 [PcdsFixedAtBuild]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10\r
index 778ea2892617f101755fec856322e5b38e2b7548..1d023a7527e02b3ff3aee5945d515ab1d25d5116 100644 (file)
 !endif\r
 \r
 [PcdsFixedAtBuild]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumGuidedExtractHandler|0x10\r