public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Jian J Wang <jian.j.wang@intel.com>, edk2-devel@lists.01.org
Cc: Ruiyu Ni <ruiyu.ni@intel.com>, Jiewen Yao <jiewen.yao@intel.com>,
	Eric Dong <eric.dong@intel.com>
Subject: Re: [PATCH 1/6] UefiCpuPkg/MpInitLib: split wake up buffer into two parts
Date: Sat, 27 Jan 2018 17:17:19 +0100	[thread overview]
Message-ID: <a45cad7f-a55f-32c0-e284-23a8479dc0a5@redhat.com> (raw)
In-Reply-To: <20180115085433.25008-2-jian.j.wang@intel.com>

Hello Jian,

On 01/15/18 09:54, Jian J Wang wrote:
> If PcdDxeNxMemoryProtectionPolicy is set to enable protection for memory
> of EfiBootServicesCode, EfiConventionalMemory, the BIOS will hang at a page
> fault exception during MP initialization.
> 
> The root cause is that the AP wake up buffer, which is below 1MB and used
> to hold both AP init code and data, is type of EfiConventionalMemory (not
> really allocated because of potential conflict with legacy code), and is
> marked as non-executable. During the transition from real address mode
> to long mode, the AP init code has to enable paging which will then cause
> itself a page fault exception because it's just running in non-executable
> memory.
> 
> The solution is splitting AP wake up buffer into two part: lower part is
> still below 1MB and shared with legacy system, higher part is really
> allocated memory of BootServicesCode type. The init code in the memory
> below 1MB will not enable paging but just switch to protected mode and
> jump to higher memory, in which the init code will enable paging and
> switch to long mode.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
> ---
>  UefiCpuPkg/Library/MpInitLib/DxeMpLib.c        | 34 ++++++++++
>  UefiCpuPkg/Library/MpInitLib/Ia32/MpEqu.inc    |  5 ++
>  UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm | 32 +++++-----
>  UefiCpuPkg/Library/MpInitLib/MpLib.c           | 45 +++++++++++++
>  UefiCpuPkg/Library/MpInitLib/MpLib.h           | 22 +++++++
>  UefiCpuPkg/Library/MpInitLib/PeiMpLib.c        | 23 +++++++
>  UefiCpuPkg/Library/MpInitLib/X64/MpEqu.inc     |  5 +-
>  UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm  | 87 ++++++++++++++++----------
>  8 files changed, 204 insertions(+), 49 deletions(-)

This patch breaks OVMF on KVM. The symptom is that the guest crashes and reboots as follows (infinite reboot loop):

> Loading PEIM at 0x0007FEB0000 EntryPoint=0x0007FEB5C96 CpuMpPei.efi
> AP Loop Mode is 1
> WakeupBufferStart = 9F000, WakeupBufferSize = 1000
> -- crash & reboot here --
> SecCoreStartupWithStack(0xFFFCC000, 0x820000)

Here's the bisection log:

git bisect start
# bad: [06c1f423e17fe5ddef824d688d21c83730238ba6] BeagleBoardPkg: reroute Firmware Vendor Pcd to MdeModulePkg
git bisect bad 06c1f423e17fe5ddef824d688d21c83730238ba6
# good: [018432f0ce1b42541977f61f9c7607257a4bf43a] MdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking
git bisect good 018432f0ce1b42541977f61f9c7607257a4bf43a
# bad: [8ab0bd2397c9d3922e0c7dbb1aa6f7e08799079f] MdePkg/DMAR: Add the definition for DMA_CTRL_PLATFORM_OPT_IN_FLAG bit
git bisect bad 8ab0bd2397c9d3922e0c7dbb1aa6f7e08799079f
# good: [24a105a7d8b4b8312743cf265f869dc049b7ff92] BaseTools: Disable warning varargs in XCODE5 align to CLANG38
git bisect good 24a105a7d8b4b8312743cf265f869dc049b7ff92
# good: [b2725f57c7a1e6feeb176f1563a4f1a8c2eb6c6f] IntelSiliconPkg IntelVTdPmrPei: Get high top by host address width
git bisect good b2725f57c7a1e6feeb176f1563a4f1a8c2eb6c6f
# good: [4f10654e04601fe67a750c9b5a4242efd4141569] UefiCpuPkg/CpuDxe: fix SetMemoryAttributes issue in 32-bit mode
git bisect good 4f10654e04601fe67a750c9b5a4242efd4141569
# bad: [fbe2c4b9be98a5c2b9c1f6976f51e2456467e752] UefiCpuPkg/CpuDxe: clear NX attr for page directory
git bisect bad fbe2c4b9be98a5c2b9c1f6976f51e2456467e752
# bad: [fceafda5185af0445d83f8c819b65417b981c485] UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers
git bisect bad fceafda5185af0445d83f8c819b65417b981c485
# bad: [f32bfe6d061420a15bac6083063d227c567e6388] UefiCpuPkg/MpInitLib: split wake up buffer into two parts
git bisect bad f32bfe6d061420a15bac6083063d227c567e6388
# first bad commit: [f32bfe6d061420a15bac6083063d227c567e6388] UefiCpuPkg/MpInitLib: split wake up buffer into two parts

Thanks
Laszlo


  parent reply	other threads:[~2018-01-27 16:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  8:54 [PATCH 0/6] Fix issues caused by NX memory protection Jian J Wang
2018-01-15  8:54 ` [PATCH 1/6] UefiCpuPkg/MpInitLib: split wake up buffer into two parts Jian J Wang
2018-01-18  6:53   ` Dong, Eric
2018-01-27 16:17   ` Laszlo Ersek [this message]
2018-01-28 21:43     ` Laszlo Ersek
2018-01-29  1:06       ` Wang, Jian J
2018-01-29 15:50         ` Laszlo Ersek
2018-01-15  8:54 ` [PATCH 2/6] UefiCpuPkg/CpuExceptionHandlerLib: alloc code memory for exception handlers Jian J Wang
2018-01-16 14:02   ` Dong, Eric
2018-01-15  8:54 ` [PATCH 3/6] UefiCpuPkg/CpuDxe: clear NX attr for page directory Jian J Wang
2018-01-16 14:02   ` Dong, Eric
2018-01-15  8:54 ` [PATCH 4/6] UefiCpuPkg/PiSmmCpuDxeSmm: Enable NXE if it's supported Jian J Wang
2018-01-16 14:02   ` Dong, Eric
2018-01-28 22:46   ` Laszlo Ersek
2018-01-29  9:02     ` Wang, Jian J
2018-01-29 19:48       ` Laszlo Ersek
2018-01-30 13:09         ` Laszlo Ersek
2018-02-01  1:08         ` Wang, Jian J
2018-01-15  8:54 ` [PATCH 5/6] MdeModulePkg/PiSmmCore: remove NX attr for SMM RAM Jian J Wang
2018-01-15 10:18   ` Zeng, Star
2018-01-15  8:54 ` [PATCH 6/6] MdeModulePkg/BootScriptExecutorDxe: remove NX attr for FfsBuffer Jian J Wang
2018-01-15 10:18   ` Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a45cad7f-a55f-32c0-e284-23a8479dc0a5@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox