LOADALL

LOADALL is the common name for two different, undocumented machine instructions of Intel 80286 and Intel 80386 processors, which allow access to areas of the internal processor state that are normally outside of the IA-32 API scope, like descriptor cache registers. The LOADALL for 286 processors is encoded 0Fh 05h,[1] while the LOADALL for 386 processors is 0Fh 07h.[2]

Both variants – as the name implies – load all CPU internal registers in one operation. LOADALL had the unique ability to set up the visible part of the segment registers (selector) independently of their corresponding cached part, allowing the programmer to bring the CPU into states not otherwise allowed by the official programming model.

Usage

As an example of the usefulness of these techniques, LOADALL can set up the CPU to allow access to all memory from real mode, without having to switch it into unreal mode (which requires switching into protected mode, accessing memory and finally switching back to real mode). Programs such as the pre-XMS versions of RAMDRIVE.SYS (1985),[3][1][4] SMARTDRV.SYS (1986)[4] as well as HIMEM.SYS (2.03, 1988-08-04; 2.04, 1988-08-17)[4] drivers in MS-DOS, Uniform Software Systems' The Extender (1985) and The Connector (1985) for Lotus 1-2-3, Above Disk (1986)[5] (a LIMulator by Above Software (formerly Tele-Ware West aka Los Angeles Securities Group) that converted hard disk space or extended memory into expanded memory), and OS/2 1.0[3][1] and 1.1[6] used the 286 LOADALL instruction. DOS 3.3 and 4.0 reserved a 102-byte buffer at 0070:0100h (which was normally occupied by DOS BIOS data) so that there was no need to save & restore it for LOADALL. Microsoft's EMM386.EXE special-cases both the 286 and 386 LOADALL instructions in its invalid opcode handler.[7] Examination of the virtual-machine monitor code in Windows/386 2.10 shows that it uses both the 286 and the even less known 386 variant. Microsoft's HIMEM.SYS version 2.06[8] also used LOADALL to quickly copy to and from extended memory on 286 systems.

Another interesting usage of LOADALL, laid out in the book The Design of OS/2,[9] would have been to allow running former real-mode programs in 16-bit protected mode, as utilized by Digital Research's Concurrent DOS 286 since 1985,[10][11][12] as well as FlexOS 286[13] and IBM 4680 OS[14][15] since 1986. Marking all the descriptor caches in the GDT and LDTs "not present" would allow the operating system to trap segment-register reloads, as well as attempts at performing real-mode–specific "segment arithmetic" and emulate the desired behavior by updating the segment descriptors (LOADALL again). This "virtual 8086 mode" for the 80286 was, however, too slow to be practical. The idea had to be mostly discarded, furthermore, due to errata in some early Intel 80286 processors before the E-2 stepping.[10][11][13] As a result, OS/2 1.x – and Windows in "standard" mode as well – had to run DOS programs in real mode. Nevertheless, the idea was not lost; it led Intel to introduce the virtual 8086 mode of the 80386, allowing the implementation of "DOS boxes" at last in a relatively efficient and documented way.

Because LOADALL did not perform any checks on the validity of the data loaded into processor registers, it was possible to load a processor state that could not be normally entered, such as using real mode (PE=0) together with paging (PG=1) on 386-class CPUs.[2]

An in-circuit emulator (ICE) is a tool used for low-level debugging. On Intel 80386, asserting the undocumented pin at location B6 causes the microprocessor to halt execution and enter ICE mode. The microprocessor saves its entire state to an area of memory isolated from normal system memory. The layout of this area is suitable for LOADALL instruction, and this instruction is used by ICE code to return to normal execution.

In later processors, this evolved into System Management Mode. In SMM mode, the RSM instruction is used to load a full CPU state from a memory area. The layout of this memory area is similar to one used by the LOADALL instruction.[16] 386-style LOADALL instruction can be executed on 486 too, but only in SMM mode. In later processors, RSM instruction, with a different encoding, took its role.

Microsoft's Codeview 3.0 and Borland's Turbo Debugger 2.0 correctly decode 286 and 386 LOADALL instructions.[1]

As the two LOADALL instructions were never documented and do not exist on later processors, the opcodes were reused in the AMD64 architecture.[17] The opcode for the 286 LOADALL instruction, 0F05, became the AMD64 instruction SYSCALL; the 386 LOADALL instruction, 0F07, became the SYSRET instruction. These definitions were implemented even on Intel CPUs with the introduction of the Intel 64 implementation of AMD64.[18]

80286

Opcode 0F05. The instruction reads data from addresses 00800–00866, whatever the content of the segment registers.

Addressnumber
of bytes
registerregisterregisterregister
008006not used
008062MSW, machine status word
0080814not used
008162TR (task register)
008182flags
0081A2IP (instruction pointer)
0081C2LDTR, local
descriptor table register
0081E4× 2DS (data segment)SS (stack segment)CS (code segment)ES (extra segment)
008264× 2DI (destination index)SI (source index)BP (base pointer)SP (stack pointer)
0082E4× 2BXDXCXAX
008364× 6ES segment descriptorCS segment descriptorSS segment descriptorDS segment descriptor
0084E4× 6GDT,
global descriptor table
LDT,
local descriptor table
IDT,
interrupt descriptor table
TSS,
task state segment

The 80286 LOADALL instruction can not be used to switch from protected back to real mode[19] (it can't clear the PE bit in the MSW). However, use of the LOADALL instruction can avoid the need to switch to protected mode altogether.

80386

Opcode 0F07. The instruction loads data from address ES:EDI. It actually uses ES, not the ES descriptor.

Addressnumber
of bytes
registerregisterregisterregister
ES:EDI+004CR0, control register 0
ES:EDI+044EFLAGS
ES:EDI+084EIP, instruction pointer
ES:EDI+0C4× 4EDI, destination indexESI, source indexEBP, base pointerESP, stack pointer
ES:EDI+1C4× 4EBXEDXECXEAX
ES:EDI+2C2× 4DR6DR7
ES:EDI+344TR, task state selector
ES:EDI+384LDTR,
local descriptor table
ES:EDI+3C4× 2GS, extra segmentnot usedFS, extra segmentnot used
ES:EDI+444× 2DS, data segmentnot usedSS, stack segmentnot used
ES:EDI+4C4× 2CS, code segmentnot usedES, extra segmentnot used
ES:EDI+544× 12TSS descriptor,
task state selector
IDT descriptor,
interrupt descriptor table
GDT descriptor,
global descriptor table
LDT descriptor,
local descriptor table
ES:EDI+844× 12GS segment descriptorFS segment descriptorDS segment descriptorSS segment descriptor
ES:EDI+B42× 12CS segment descriptorES segment descriptor
gollark: And thus hit rate limits.
gollark: It will relay messages out of there constantly, you see.
gollark: Don't. You'll probably cause issues with ABR.
gollark: Apparently just reading that imposed rate limits on me.
gollark: Only 9? Amateurish.

See also

  • Concurrent DOS 286
  • FlexOS 286
  • IBM 4680 OS

References

  1. Schulman, Andrew; Michels, Raymond J.; Kyle, Jim; Paterson, Tim; Maxey, David; Brown, Ralf D. (1990). Undocumented DOS: A programmer's guide to reserved MS-DOS functions and data structures (1 ed.). Addison-Wesley. pp. 14–15. ISBN 978-0-201-57064-9. (xviii+694+viii pages, 2× 5.25"-floppies ) Errata:
  2. Van Gilluwe, Frank (1994). The Undocumented PC (1 ed.). Addison-Wesley. pp. 62–70. ISBN 0-201-62277-7.
  3. Duncan, Ray; Petzold, Charles; Baker, M. Steven; Schulman, Andrew; Davis, Stephen R.; Nelson, Ross P.; Moote, Robert (1990). Extending DOS (1 ed.). Reading, MA, USA: Addison-Wesley Publishing Company, Inc. pp. 100–103. ISBN 0-20155053-9. ISBN 978-0-20155053-5.
  4. Necasek, Michal (2013-10-27). "More on LOADALL and OS/2". OS/2 Museum. Archived from the original on 2018-10-17. Retrieved 2018-10-17.
  5. Collins, Robert R. (October 1991). "The LOADALL Instruction". TECH Specialist - The Journal for Advanced PC Developers. Lawrence, Kansas, USA: R&D Publications, Inc. 2 (10). ISSN 1049-913X. Archived from the original on 2020-02-20. Retrieved 2018-10-17. (NB. The magazine was soon renamed into "The DOS Developers Journal" and eventually into "The Windows/DOS Developer's Journal" (ISSN 1059-2407).)
  6. Necasek, Michal (2011-03-18). "HIMEM.SYS, unreal mode, and LOADALL". OS/2 Museum. Archived from the original on 2017-01-03. Retrieved 2017-01-03.
  7. Schulman, Andrew; Brown, Ralf D.; Maxey, David; Michels, Raymond J.; Kyle, Jim (1994) [November 1993]. Williams, Andrew (ed.). Undocumented DOS: A programmer's guide to reserved MS-DOS functions and data structures - expanded to include MS-DOS 6, Novell DOS and Windows 3.1. The Andrew Schulman Programming Series (1st printing, 2nd ed.). Reading, Massachusetts, USA: Addison Wesley Publishing Company. p. 42. ISBN 0-201-63287-X. ISBN 978-0-201-63287-3. (xviii+856+vi pages, 3.5"-floppy ) Errata:
  8. "Microsoft HIMEM.SYS 2.06 source code".
  9. Deitel, Harvey M.; Kogan, Michael S. (1992). The Design of OS/2. Addison-Wesley. ISBN 0-201-54889-5.
  10. Foster, Edward (1985-05-13). "Super DOS awaits new 80286 – Concurrent DOS 286 – delayed until Intel upgrades chip – offers Xenix's power and IBM PC compatibility". InfoWorld. InfoWorld Media Group. 7 (19): 17–18. ISSN 0199-6649. Archived from the original on 2019-04-21. Retrieved 2019-04-21.
  11. Foster, Edward (1985-08-26). "Intel shows new 80286 chip – Future of DRI's Concurrent DOS 286 still unclear after processor fixed". InfoWorld. InfoWorld Media Group. 7 (34): 21. ISSN 0199-6649. Archived from the original on 2019-04-21. Retrieved 2019-04-21.
  12. "Concurrent DOS 68K 1.2 - Developer Kit for Motorola VME/10 - Disk 2". 1986-08-06 [1986-04-08]. Archived from the original on 2019-04-03. Retrieved 2018-09-13. (NB. This package also includes some header files from Concurrent DOS 286, including STRUCT.H explicitly mentioning LOADALL for "8086 emulation".)
  13. FlexOS Supplement for Intel iAPX 286-based Computers (PDF). 1.3 (1 ed.). Digital Research, Inc. November 1986. Archived (PDF) from the original on 2019-04-21. Retrieved 2018-08-14.
  14. Calvo, Melissa; Forbes, Jim (1986-02-10). "IBM to use a DRI operating system". InfoWorld. InfoWorld Media Group. Archived from the original on 2019-04-21. Retrieved 2011-09-06.
  15. "IBM selects Concurrent DOS-286 for PC AT retail system" (PDF). European Review. Digital Research (18): 1. March 1986. Archived (PDF) from the original on 2019-04-03. Retrieved 2018-09-15.
  16. Collins, Robert R. (January 1997). "Intel's System Management Mode". Archived from the original on 2017-01-03. Retrieved 2017-01-03.
  17. Necasek, Michal (2013-10-18). "LOADALL Strikes Again". OS/2 Museum. Archived from the original on 2017-01-03. Retrieved 2016-01-27.
  18. "Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2B" (PDF). Intel Corporation. December 2015. Archived (PDF) from the original on 2019-04-21. Retrieved 2016-01-27.
  19. Slater, Michael (October 1987). "Secret 286 LOADALL instruction allows access to extended memory in real mode". Microprocessor Report.

Further reading

  • IBM Operating System/2 Technical Reference - Programming Family (PDF). 1 (1st ed.). IBM. September 1987 [1986]. Archived (PDF) from the original on 2017-01-03.
  • Chappell, Geoff (January 1994). Schulman, Andrew; Pedersen, Amorette (eds.). DOS Internals. The Andrew Schulman Programming Series (1st printing, 1st ed.). Addison Wesley Publishing Company. pp. 4, 21, 100–106, 127–129. ISBN 978-0-201-60835-9. ISBN 0-201-60835-9. (xxvi+738+iv pages, 3.5"-floppy ) Errata:
  • Chappell, Geoff (2008-10-03) [1997-03-18]. "Strange Things LINK Knows about 80x86 Processors". Archived from the original on 2019-04-21. Retrieved 2019-04-21.
  • Necasek, Michal (2014-12-13). "Curious Instructions". OS/2 Museum. Archived from the original on 2019-04-21. Retrieved 2019-04-21.
  • Stiller, Andreas (1990). "Bitter für 32-Bitter". c't - magazin für computertechnik (in German). Vol. 1990 no. 8. p. 202.
  • Juffa, Norbert; Siering, Peter (1990). "Wege über die Mauer. Loadall - Extended Memory im Real Mode des 80286". c't - magazin für computertechnik (in German). Vol. 1990 no. 11. pp. 362–366.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.