<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div><div><div><blockquote type="cite"><div>On Nov 7, 2022, at 7:16 PM, Yoshinoya <yoshinoyatoko@163.com> wrote:</div><br class="Apple-interchange-newline"><div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;"><div style="margin: 0;">Hello</div><div style="margin: 0;">Is it possible to access 64bit address space in 32bit mode?</div><div style="margin: 0;"><br></div></div></div></blockquote><div><br></div><div>I assume you are talking about x86?</div><div><br></div><br><blockquote type="cite"><div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;"><div style="margin: 0;">For example, opcode prefix 0x66/67 could let code running in 16bit mode to access 32bit data/address.</div><div style="margin: 0;"><br></div></div></div></blockquote><div><br></div><div>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.  </div><br><blockquote type="cite"><div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;"><div style="margin: 0;">Or, establishing page table is a must requirement for accessing 64bit address space.</div><div style="margin: 0;"><br></div></div></div></blockquote><div><br></div><div><div>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. </div><div><br></div><div>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. </div><div><br></div><div>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]/ </div><div><br></div><div>[1] <a href="https://en.wikipedia.org/wiki/Physical_Address_Extension">https://en.wikipedia.org/wiki/Physical_Address_Extensio</a><a href="https://en.wikipedia.org/wiki/Physical_Address_Extension">n</a></div><div>[2] <a href="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X86Thunk.c">https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X86Thunk.c</a></div><div><div style="display: block;"><div style="-webkit-user-select: all; -webkit-user-drag: element; display: inline-block;" class="apple-rich-link" draggable="true" role="link" data-url="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X64/Thunk16.nasm"><a style="border-radius:10px;font-family:-apple-system, Helvetica, Arial, sans-serif;display:block;-webkit-user-select:none;width:300px;user-select:none;-webkit-user-modify:read-only;user-modify:read-only;overflow:hidden;text-decoration:none;" class="lp-rich-link" rel="nofollow" href="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X64/Thunk16.nasm" dir="ltr" role="button" draggable="false" width="300"><table style="table-layout:fixed;border-collapse:collapse;width:300px;background-color:#E5E6E9;font-family:-apple-system, Helvetica, Arial, sans-serif;" class="lp-rich-link-emailBaseTable" cellpadding="0" cellspacing="0" border="0" width="300"><tbody><tr><td vertical-align="center" align="center"><img style="width:300px;filter:brightness(0.97);height:150px;" width="300" height="150" draggable="false" class="lp-rich-link-mediaImage" alt="edk2.png" src="cid:D8B9B36E-1F42-47E8-8F02-999C2D2F009E"></td></tr><tr><td vertical-align="center"><table bgcolor="#E5E6E9" cellpadding="0" cellspacing="0" width="300" style="font-family:-apple-system, Helvetica, Arial, sans-serif;table-layout:fixed;background-color:rgba(229, 230, 233, 1);" class="lp-rich-link-captionBar"><tbody><tr><td style="padding:8px 0px 8px 0px;" class="lp-rich-link-captionBar-textStackItem"><div style="max-width:100%;margin:0px 16px 0px 16px;overflow:hidden;" class="lp-rich-link-captionBar-textStack"><div style="word-wrap:break-word;font-weight:500;font-size:12px;overflow:hidden;text-overflow:ellipsis;text-align:left;" class="lp-rich-link-captionBar-textStack-topCaption-leading"><a rel="nofollow" href="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X64/Thunk16.nasm" style="text-decoration: none" draggable="false"><font color="#272727" style="color: rgba(0, 0, 0, 0.847059);">edk2/Thunk16.nasm at master · tianocore/edk2</font></a></div><div style="word-wrap:break-word;font-weight:400;font-size:11px;overflow:hidden;text-overflow:ellipsis;text-align:left;" class="lp-rich-link-captionBar-textStack-bottomCaption-leading"><a rel="nofollow" href="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/X64/Thunk16.nasm" style="text-decoration: none" draggable="false"><font color="#808080" style="color: rgba(0, 0, 0, 0.498039);">github.com</font></a></div></div></td></tr></tbody></table></td></tr></tbody></table></a></div></div></div><div><div style="display: block;"><div style="-webkit-user-select: all; -webkit-user-drag: element; display: inline-block;" class="apple-rich-link" draggable="true" role="link" data-url="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm"><a style="border-radius:10px;font-family:-apple-system, Helvetica, Arial, sans-serif;display:block;-webkit-user-select:none;width:300px;user-select:none;-webkit-user-modify:read-only;user-modify:read-only;overflow:hidden;text-decoration:none;" class="lp-rich-link" rel="nofollow" href="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm" dir="ltr" role="button" draggable="false" width="300"><table style="table-layout:fixed;border-collapse:collapse;width:300px;background-color:#E5E6E9;font-family:-apple-system, Helvetica, Arial, sans-serif;" class="lp-rich-link-emailBaseTable" cellpadding="0" cellspacing="0" border="0" width="300"><tbody><tr><td vertical-align="center" align="center"><img style="width:300px;filter:brightness(0.97);height:150px;" width="300" height="150" draggable="false" class="lp-rich-link-mediaImage" alt="edk2.png" src="cid:834BBBD9-5D7E-4C78-B22B-F43194A5F43D"></td></tr><tr><td vertical-align="center"><table bgcolor="#E5E6E9" cellpadding="0" cellspacing="0" width="300" style="font-family:-apple-system, Helvetica, Arial, sans-serif;table-layout:fixed;background-color:rgba(229, 230, 233, 1);" class="lp-rich-link-captionBar"><tbody><tr><td style="padding:8px 0px 8px 0px;" class="lp-rich-link-captionBar-textStackItem"><div style="max-width:100%;margin:0px 16px 0px 16px;overflow:hidden;" class="lp-rich-link-captionBar-textStack"><div style="word-wrap:break-word;font-weight:500;font-size:12px;overflow:hidden;text-overflow:ellipsis;text-align:left;" class="lp-rich-link-captionBar-textStack-topCaption-leading"><a rel="nofollow" href="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm" style="text-decoration: none" draggable="false"><font color="#272727" style="color: rgba(0, 0, 0, 0.847059);">edk2/Thunk16.nasm at master · tianocore/edk2</font></a></div><div style="word-wrap:break-word;font-weight:400;font-size:11px;overflow:hidden;text-overflow:ellipsis;text-align:left;" class="lp-rich-link-captionBar-textStack-bottomCaption-leading"><a rel="nofollow" href="https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/Ia32/Thunk16.nasm" style="text-decoration: none" draggable="false"><font color="#808080" style="color: rgba(0, 0, 0, 0.498039);">github.com</font></a></div></div></td></tr></tbody></table></td></tr></tbody></table></a></div></div></div></div><div><div><br></div><div>Thanks,</div><div><br></div><div>Andrew Fish<br></div><div><br></div></div><br><blockquote type="cite"><div><div style="line-height: 1.7; font-size: 14px; font-family: Arial;"><div style="margin: 0;">Thanks</div><div style="margin: 0;"> </div></div>

  

</div></blockquote></div><br></div></body></html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/96144">View/Reply Online (#96144)</a> |    |  <a target="_blank" href="https://groups.io/mt/94885261/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>