From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 139EC2222C232 for ; Sat, 27 Jan 2018 08:11:52 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE57B80F9C; Sat, 27 Jan 2018 16:17:23 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-33.rdu2.redhat.com [10.10.120.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A508A600CC; Sat, 27 Jan 2018 16:17:20 +0000 (UTC) To: Jian J Wang , edk2-devel@lists.01.org Cc: Ruiyu Ni , Jiewen Yao , Eric Dong References: <20180115085433.25008-1-jian.j.wang@intel.com> <20180115085433.25008-2-jian.j.wang@intel.com> From: Laszlo Ersek Message-ID: Date: Sat, 27 Jan 2018 17:17:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180115085433.25008-2-jian.j.wang@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 27 Jan 2018 16:17:23 +0000 (UTC) Subject: Re: [PATCH 1/6] UefiCpuPkg/MpInitLib: split wake up buffer into two parts X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jan 2018 16:11:53 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 > Cc: Ruiyu Ni > Cc: Eric Dong > Cc: Laszlo Ersek > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jian J Wang > --- > 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