From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=17.151.62.66; helo=nwk-aaemail-lapp01.apple.com; envelope-from=afish@apple.com; receiver=edk2-devel@lists.01.org Received: from nwk-aaemail-lapp01.apple.com (nwk-aaemail-lapp01.apple.com [17.151.62.66]) (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 2E612211D6743 for ; Thu, 7 Mar 2019 21:02:31 -0800 (PST) Received: from pps.filterd (nwk-aaemail-lapp01.apple.com [127.0.0.1]) by nwk-aaemail-lapp01.apple.com (8.16.0.27/8.16.0.27) with SMTP id x284l67i004099 for ; Thu, 7 Mar 2019 21:02:31 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=mime-version : content-type : sender : from : subject : date : references : to : in-reply-to : message-id; s=20180706; bh=EG1IN6KkPk2RLITyqvnteE+QZkDDVM8lrsUonbxSJUk=; b=MGWxqxhsdWdoKPkouMomlPyqKqblJvazu+fe+xRapMWiTe90J8Tks8llmnNUTUGiXSWZ /BJAE/WvB238YwSqPuC4HMTwW7c94D3fVulSV0rOSrZ6rMOdrwO1o6UWSfqBBytKvrwm 4Z0xlSIjaaXG+q3Q65NA5UJz1Yg2SdcCwL3Q1gMgUKnCwG/dYebTmcowNQKCk/OyI6iG Gi0NtqLvBoD3BBGe1sCeV/5Cln1jChDcEtXiZMRL/h3Ndp4+NljeAn/qQjdBedrx786L 4ZmeLL4Nzo1DzI0+s3NwWVSio0dnWYWMNq1P925lGex4rljOsy9n/Lci5D4IvXGSwrT6 dw== Received: from ma1-mtap-s03.corp.apple.com (ma1-mtap-s03.corp.apple.com [17.40.76.7]) by nwk-aaemail-lapp01.apple.com with ESMTP id 2qysn9qukg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Thu, 07 Mar 2019 21:02:30 -0800 MIME-version: 1.0 Received: from ma1-mmpp-sz11.apple.com (ma1-mmpp-sz11.apple.com [17.171.128.33]) by ma1-mtap-s03.corp.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) with ESMTPS id <0PO100E7L7C6AS80@ma1-mtap-s03.corp.apple.com> for edk2-devel@lists.01.org; Thu, 07 Mar 2019 21:02:30 -0800 (PST) Received: from process_milters-daemon.ma1-mmpp-sz11.apple.com by ma1-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) id <0PO100K005WVGA00@ma1-mmpp-sz11.apple.com> for edk2-devel@lists.01.org; Thu, 07 Mar 2019 21:02:30 -0800 (PST) X-Va-A: X-Va-T-CD: 3b266a2f6a8b2663ff6662a8ca2180b2 X-Va-E-CD: ef0835f8b81af2f365e293bd4ee93e87 X-Va-R-CD: 3b31e3aba99771dd19eeb1baf94641f6 X-Va-CD: 0 X-Va-ID: e33f7d88-686e-47b4-bd18-2584fe999276 X-V-A: X-V-T-CD: 3b266a2f6a8b2663ff6662a8ca2180b2 X-V-E-CD: ef0835f8b81af2f365e293bd4ee93e87 X-V-R-CD: 3b31e3aba99771dd19eeb1baf94641f6 X-V-CD: 0 X-V-ID: d67375b2-1f8e-4f0e-9291-ede8d0a679c2 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-08_04:,, signatures=0 Received: from [17.234.199.80] (unknown [17.234.199.80]) by ma1-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.2.3.20181024 64bit (built Oct 24 2018)) with ESMTPSA id <0PO100KL47C30L20@ma1-mmpp-sz11.apple.com> for edk2-devel@lists.01.org; Thu, 07 Mar 2019 21:02:30 -0800 (PST) Sender: afish@apple.com From: Andrew Fish Date: Thu, 07 Mar 2019 21:02:24 -0800 References: <96DCE1C9-B02B-4520-A483-F72BBAAAB3B8@apple.com> To: edk2-devel In-reply-to: <96DCE1C9-B02B-4520-A483-F72BBAAAB3B8@apple.com> Message-id: <5E739A5E-6BC3-44E8-8577-3A55BCEAD164@apple.com> X-Mailer: Apple Mail (2.3445.6.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-08_04:, , signatures=0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: UefiCpuPkg CpuDxe GDT init question? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Mar 2019 05:02:32 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT Actually it looks like the the CpuDxe driver is coded to only run if it it is loaded under 4 GB? Is that following the spec? Is that intentional? I noticed that SetCodeSelector is coded to use a far jump and that is a 32-bit absolute value? Note [rsp+4] https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/CpuDxe/X64/CpuAsm.nasm#L28 ASM_PFX(SetCodeSelector): sub rsp, 0x10 lea rax, [setCodeSelectorLongJump] mov [rsp], rax mov [rsp+4], cx jmp dword far [rsp] setCodeSelectorLongJump: add rsp, 0x10 ret Thanks, Andrew Fish > On Mar 7, 2019, at 2:37 PM, Andrew Fish wrote: > > I'm trying to understand why gdtPtr.Base is casting to (UINT32)? > 1) gdtPtr.Base is a a UINTN > 2) It is legal for AllocateRuntimePool() to return an address > 4GB > > It seems like the code should just cast to (UINTN)? > > > https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/CpuDxe/CpuGdt.c#L151 > > > > VOID > InitGlobalDescriptorTable ( > VOID > ) > { > GDT_ENTRIES *gdt; > IA32_DESCRIPTOR gdtPtr; > > // > // Allocate Runtime Data for the GDT > // > gdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8); > ASSERT (gdt != NULL); > gdt = ALIGN_POINTER (gdt, 8); > > // > // Initialize all GDT entries > // > CopyMem (gdt, &GdtTemplate, sizeof (GdtTemplate)); > > // > // Write GDT register > // > gdtPtr.Base = (UINT32)(UINTN)(VOID*) gdt; > gdtPtr.Limit = (UINT16) (sizeof (GdtTemplate) - 1); > AsmWriteGdtr (&gdtPtr); > > Thanks, > > Andrew Fish