From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web10.9742.1609947429602730828 for ; Wed, 06 Jan 2021 07:37:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XGOv+Pro; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609947428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ywJawWE3kfTL7AWgfvd4YREL9kkX5HuTXhZLCbHzRYo=; b=XGOv+ProP3lKPveOvjAsXQrfvi7MUaQkPVCgRCpvxdh3FsdWVdUlCsYEW4YnOWUGiGe1xR rs+m8Oop72g7NfGG6D2RNCU0sQ2Y/gc6s1aFp9Zh4V+u5ZJ9+SE9SfHa/T36NiySHSdSfr +V3z6W+QO0ETpUuQuvxJtcv+5l0YpJ8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-cjhNBboDPC6kYDboBAsR0g-1; Wed, 06 Jan 2021 10:37:04 -0500 X-MC-Unique: cjhNBboDPC6kYDboBAsR0g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 436AF100C660; Wed, 6 Jan 2021 15:37:03 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-198.ams2.redhat.com [10.36.113.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0CB85D6A1; Wed, 6 Jan 2021 15:37:01 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg/CpuDxe: Fix boot error To: "Kinney, Michael D" , "Dong, Guo" , "devel@edk2.groups.io" Cc: "Dong, Eric" , "Ni, Ray" , "Kumar, Rahul1" References: <20201224200420.15692-1-guo.dong@intel.com> From: "Laszlo Ersek" Message-ID: Date: Wed, 6 Jan 2021 16:37:00 +0100 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 01/06/21 03:00, Kinney, Michael D wrote: > Hi Guo, > > Could be the port from MASM to NASM did not check to see if NASM supported the instruction. I agree: ad8ae98d2fa2 ("OvmfPkg LoadLinuxLib: Convert X64/JumpToKernel.asm to NASM", 2014-10-31). I seem to remember that Jordan implemented that large MASM->NASM conversion series mostly mechanically (which was the right approach, of course, given the number of assembly files, and the regression risks). > You can verify the NASM disassembly to make sure it matches the DB bytes. Thanks! Laszlo > > Mike > >> -----Original Message----- >> From: Dong, Guo >> Sent: Tuesday, January 5, 2021 4:51 PM >> To: Kinney, Michael D ; devel@edk2.groups.io >> Cc: Dong, Eric ; Ni, Ray ; lersek@redhat.com; Kumar, Rahul1 >> >> Subject: RE: [edk2-devel] [PATCH] UefiCpuPkg/CpuDxe: Fix boot error >> >> >> Hi Mike, >> >> Thanks for the comments. I will remove DB and submit a new patch. >> I used DB because retfq is used in EDK2 only in OvmfPkg\Library\LoadLinuxLib\X64\JumpToKernel.nasm and it used DB. >> Not sure if there is any BKM why they use it. >> >> Thanks, >> Guo >> >>> -----Original Message----- >>> From: Kinney, Michael D >>> Sent: Monday, January 4, 2021 9:31 PM >>> To: devel@edk2.groups.io; Dong, Guo ; Kinney, Michael >>> D >>> Cc: Dong, Eric ; Ni, Ray ; >>> lersek@redhat.com; Kumar, Rahul1 >>> Subject: RE: [edk2-devel] [PATCH] UefiCpuPkg/CpuDxe: Fix boot error >>> >>> Hi Guo, >>> >>> NASM has good support for instructions. Can the DB be removed and replaced >>> with the equivalent instruction? >>> >>> Thanks, >>> >>> Mike >>> >>>> -----Original Message----- >>>> From: devel@edk2.groups.io On Behalf Of Guo Dong >>>> Sent: Thursday, December 24, 2020 12:04 PM >>>> To: devel@edk2.groups.io >>>> Cc: Dong, Eric ; Ni, Ray ; >>> lersek@redhat.com; Kumar, Rahul1 >>>> >>>> Subject: [edk2-devel] [PATCH] UefiCpuPkg/CpuDxe: Fix boot error >>>> >>>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3084 >>>> >>>> When DXE drivers are dispatched above 4GB memory in 64bit >>>> mode, the address setCodeSelectorLongJump in stack will >>>> be override by parameter. Jump to Qword is not supported >>>> by some processors. So use retfq instead. >>>> >>>> Signed-off-by: Guo Dong >>>> --- >>>> UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm | 8 +++----- >>>> 1 file changed, 3 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm >>> b/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm >>>> index c3489bcc3e..e33ddb2784 100644 >>>> --- a/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm >>>> +++ b/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm >>>> @@ -20,13 +20,11 @@ >>>> ;------------------------------------------------------------------------------ >>>> global ASM_PFX(SetCodeSelector) >>>> ASM_PFX(SetCodeSelector): >>>> - sub rsp, 0x10 >>>> + push rcx, >>>> lea rax, [setCodeSelectorLongJump] >>>> - mov [rsp], rax >>>> - mov [rsp+4], cx >>>> - jmp dword far [rsp] >>>> + push rax >>>> + DB 0x48, 0xcb ; retfq >>>> setCodeSelectorLongJump: >>>> - add rsp, 0x10 >>>> ret >>>> >>>> ;------------------------------------------------------------------------------ >>>> -- >>>> 2.16.2.windows.1 >>>> >>>> >>>> >>>> >>>> >