public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "vincent zimmer" <vincent.zimmer@gmail.com>
To: devel@edk2.groups.io, afish@apple.com
Cc: yoshinoyatoko@163.com
Subject: Re: [edk2-devel] Access 64bit address space in 32bit mode
Date: Wed, 9 Nov 2022 10:58:40 -0800	[thread overview]
Message-ID: <CAKhbih5yWAqHjn7TPjAHN_61rpYO3YkyOi9nv8+0e8238yTZUQ@mail.gmail.com> (raw)
In-Reply-To: <CC64DA9B-0378-44B0-8BA3-2237636B9891@apple.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 3364 bytes --]

we have the challenge of 32-bit PEI needing to access 64-bit addresses to
support 64-bit DXE/UEFI OS's in the capsule use-case scenario.  This is
described in
https://raw.githubusercontent.com/tianocore-docs/Docs/master/White_Papers/A_Tour_Beyond_BIOS_Capsule_Update_and_Recovery_in_EDK_II.pdf
page 22 with code
https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Universal/CapsulePei

On Wed, Nov 9, 2022 at 9:21 AM Andrew Fish via groups.io <afish=
apple.com@groups.io> wrote:

>
> On Nov 7, 2022, at 7:16 PM, Yoshinoya <yoshinoyatoko@163.com> wrote:
>
> Hello
> Is it possible to access 64bit address space in 32bit mode?
>
>
> I assume you are talking about x86?
>
>
> For example, opcode prefix 0x66/67 could let code running in 16bit mode to
> access 32bit data/address.
>
>
> This is more complex than just instruction prefix. You need the CPU to be
> setup in big real mode via the GDT, so you basically have a 32-bit
> environment setup via GDT etc. Also the prefix opcodes have different
> meaning in different modes. I don’t think there is a way to make 32-bit
> code access 64-bit data via instruction prefix even if a 64-bit GDT was
> setup with paging enabled.
>
> Or, establishing page table is a must requirement for accessing 64bit
> address space.
>
>
> For x86 you have to have 64-bit versions of the IDT, GDT, and you need to
> enable paging to enter 64-bit Long Mode.
>
> In a 32-bit x86 world you can access up to 64 GB of physical memory via
> using 32-bit page table using PAE [1]. PAE is a 32-bit virtual address
> space, but with support for a 36-bit physical address. I think in the olden
> days of 32-bit x86 EFI servers would have custom EFI code that enabled
> paging in 32-bit and carved out a chunk of the 32-bit memory space that
> could be mapped to 36-bit physical addresses. I think this was platform
> specific code and I don’t know of any open source version. The 32-bit Long
> Mode EFI does not have paging enabled, so adding PAE means enabling paging
> yourself.
>
> The edk2 has the opposite version of this code so you can call 16-bit
> really mode (Legacy BIOS) from 32-bit Protected mode, or 64-bit Long Mode.
> This is the code to Thunk for 32-bit/64-bit mode to 16-bit code [2]/
>
> [1] https://en.wikipedia.org/wiki/Physical_Address_Extensio
> <https://en.wikipedia.org/wiki/Physical_Address_Extension>n
> <https://en.wikipedia.org/wiki/Physical_Address_Extension>
> [2]
> https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X86Thunk.c
> [image: edk2.png]
>
> edk2/Thunk16.nasm at master · tianocore/edk2
> <https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X64/Thunk16.nasm>
> github.com
> <https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X64/Thunk16.nasm>
>
> <https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X64/Thunk16.nasm>
> [image: edk2.png]
>
> edk2/Thunk16.nasm at master · tianocore/edk2
> <https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm>
> github.com
> <https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm>
>
> <https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm>
>
> Thanks,
>
> Andrew Fish
>
>
> Thanks
>
>
>
> 
>
>

[-- Attachment #1.1.2: Type: text/html, Size: 8039 bytes --]

[-- Attachment #1.2: edk2.png --]
[-- Type: image/png, Size: 70276 bytes --]

[-- Attachment #2: edk2.png --]
[-- Type: image/png, Size: 70276 bytes --]

  reply	other threads:[~2022-11-09 18:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 11:32 [edk2-devel] Python368.efi failed to run in shell environment Yoshinoya
2022-10-05 16:28 ` Michael D Kinney
2022-10-11 10:20   ` Yoshinoya
2022-10-18  9:04     ` Jayaprakash, N
2022-10-19  8:30       ` Yoshinoya
2022-10-19 13:16         ` Jayaprakash, N
2022-10-20  3:06           ` Yoshinoya
2022-10-20  3:18             ` Jayaprakash, N
2022-11-08  3:16 ` [edk2-devel] Access 64bit address space in 32bit mode Yoshinoya
2022-11-09 17:20   ` Andrew Fish
2022-11-09 18:58     ` vincent zimmer [this message]
2022-11-09 20:14       ` Andrew Fish
2023-02-18  0:55         ` [edk2-devel] PciBus scan: Does it support scan from EndBusNum to StartBusNum? Yoshinoya
2023-02-20  4:28           ` Yoshinoya
2023-02-21  1:27           ` Yoshinoya
2023-02-21  2:47             ` Yoshinoya
2023-02-21 19:18           ` Pedro Falcato
2023-02-22  1:10             ` Tiger Liu(BJ-RD)
2023-02-22  1:22               ` Pedro Falcato
2023-05-23  9:55           ` [edk2-devel] PciHostBridge: dynamic pcie bus limit assignment Yoshinoya
2022-11-09 20:40     ` [edk2-devel] Access 64bit address space in 32bit mode Brian J. Johnson
2023-01-03  9:04       ` [edk2-devel] PciBus driver: support pcie 4.0 bus/device enumeration ? Yoshinoya

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=CAKhbih5yWAqHjn7TPjAHN_61rpYO3YkyOi9nv8+0e8238yTZUQ@mail.gmail.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