Главная » Просмотр файлов » Volume 3 General-Purpose and System Instructions

Volume 3 General-Purpose and System Instructions (794097), страница 53

Файл №794097 Volume 3 General-Purpose and System Instructions (Intel and AMD manuals) 53 страницаVolume 3 General-Purpose and System Instructions (794097) страница 532019-04-28СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 53)

System software must explicitlysave that information.An invalid-opcode exception occurs if this instruction is used in long mode. Software should use theSYSCALL (and SYSRET) instructions in long mode. If SYSENTER is used in real mode, a #GP israised.For additional information on this instruction, see “SYSENTER and SYSEXIT (Legacy Mode Only)”in Volume 2.MnemonicSYSENTEROpcode0F 34DescriptionCall operating system.Related InstructionsSYSCALL, SYSEXIT, SYSRETInstruction ReferenceSYSENTER315AMD64 Technology24594—Rev. 3.13—July 2007rFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDF021201918IFTFSFZFAFPFCF876420017161413–1211109Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to one or zero is M (modified).

Unaffected flags are blank.Undefined flags are U.ExceptionsExceptionInvalid opcode, #UDGeneral protection, #GP316RealVirtual8086ProtectedCause of ExceptionXXXThe SYSENTER and SYSEXIT instructions are notsupported, as indicated by EDX bit 11 returned byCPUID function 0000_0001h.XThis instruction is not recognized in long mode.XThis instruction is not recognized in real mode.XXMSR_SYSENTER_CS was a null selector.SYSENTERInstruction Reference24594—Rev. 3.13—July 2007AMD64 TechnologySYSEXITSystem ReturnReturns from the operating system to an application. It is a low-latency system return instructiondesigned for use by system and application software implementing a flat-segment memory model.This is a privileged instruction. The current privilege level must be zero to execute this instruction.

Aninvalid-opcode exception occurs if this instruction is used in long mode. Software should use theSYSRET (and SYSCALL) instructions when running in long mode.When a system procedure performs a SYSEXIT back to application software, the CS selector isupdated to point to the second descriptor entry after the SYSENTER CS value (MSRSYSENTER_CS+16). The SS selector is updated to point to the third descriptor entry after theSYSENTER CS value (MSR SYSENTER_CS+24). The CPL is forced to 3, as are the descriptorprivilege levels.The hidden portions of the CS and SS segment registers are not loaded from the descriptor table as theywould be using a legacy x86 RET instruction. Instead, the hidden portions are forced by the processorto the following values:••••The CS and SS base values are forced to 0.The CS and SS limit values are forced to 4 Gbytes.The CS segment attributes are set to 32-bit read/execute at CPL 3.The SS segment attributes are set to read/write and expand-up with a 32-bit stack referenced byESP.System software must create corresponding descriptor-table entries referenced by the new CS and SSselectors that match the values described above.The following additional actions result from executing SYSEXIT:••EIP is loaded from EDX.ESP is loaded from ECX.System software must explicitly load the return address and application software-stack pointer into theEDX and ECX registers prior to executing SYSEXIT.For additional information on this instruction, see “SYSENTER and SYSEXIT (Legacy Mode Only)”in Volume 2.MnemonicOpcodeSYSEXIT0F 35DescriptionReturn from operating system to application.Related InstructionsSYSCALL, SYSENTER, SYSRETInstruction ReferenceSYSEXIT317AMD64 Technology24594—Rev.

3.13—July 2007rFLAGS AffectedIDVIPVIFACVMRFNTIOPLOFDFIFTFSFZFAFPFCF1413–12111098764200212019181716Note: Bits 31–22, 15, 5, 3, and 1 are reserved. A flag set to one or cleared to zero is M (modified). Unaffected flagsare blank.ExceptionsExceptionInvalid opcode, #UDRealVirtual8086ProtectedXXXThe SYSENTER and SYSEXIT instructions are notsupported, as indicated by EDX bit 11 returned byCPUID function 0000_0001h.XThis instruction is not recognized in long mode.XGeneral protection, #GP318Cause of ExceptionThis instruction is only recognized in protectedmode.XXCPL was not 0.XMSR_SYSENTER_CS was a null selector.SYSEXITInstruction Reference24594—Rev.

3.13—July 2007AMD64 TechnologySYSRETFast System ReturnReturns from the operating system to an application. It is a low-latency system return instructiondesigned for use by system and application software implementing a flat segmentation memory model.The SYSCALL and SYSRET instructions are low-latency system call and return control-transferinstructions that assume that the operating system implements a flat-segment memory model. Byeliminating unneeded checks, and by loading pre-determined values into the CS and SS segmentregisters (both visible and hidden portions), calls to and returns from the operating system are greatlysimplified.

These instructions can be used in protected mode and are particularly well-suited for use in64-bit mode, which requires implementation of a paged, flat-segment memory model.This instruction has been optimized by reducing the number of checks and memory references that arenormally made so that a call or return takes substantially fewer internal clock cycles when compared tothe CALL/RET instruction method.It is assumed that the base, limit, and attributes of the Code Segment will remain flat for all processesand for the operating system, and that only the current privilege level for the selector of the callingprocess should be changed from a current privilege level of 0 to a new privilege level of 3.

It is alsoassumed (but not checked) that the RPL of the SYSCALL and SYSRET target selectors are set to 0and 3, respectively.SYSRET sets the CPL to 3, regardless of the values of bits 49–48 of the star register. SYSRET canonly be executed in protected mode at CPL 0. SYSCALL and SYSRET must be enabled by settingEFER.SCE to 1.It is the responsibility of the operating system to keep the descriptors in memory that correspond to theCS and SS selectors loaded by the SYSCALL and SYSRET instructions consistent with the segmentbase, limit, and attribute values forced by these instructions.When a system procedure performs a SYSRET back to application software, the CS selector isupdated from bits 63–50 of the STAR register (STAR.SYSRET_CS) as follows:••If the return is to 32-bit mode (legacy or compatibility), CS is updated with the value ofSTAR.SYSRET_CS.If the return is to 64-bit mode, CS is updated with the value of STAR.SYSRET_CS + 16.In both cases, the CPL is forced to 3, effectively ignoring STAR bits 49–48.

The SS selector is updatedto point to the next descriptor-table entry after the CS descriptor (STAR.SYSRET_CS + 8), and itsRPL is not forced to 3.The hidden portions of the CS and SS segment registers are not loaded from the descriptor table as theywould be using a legacy x86 RET instruction. Instead, the hidden portions are forced by the processorto the following values:••The CS base value is forced to 0.The CS limit value is forced to 4 Gbytes.Instruction ReferenceSYSRET319AMD64 Technology••24594—Rev.

3.13—July 2007The CS segment attributes are set to execute-read 32 bits or 64 bits (see below).The SS segment base, limit, and attributes are not modified.When SYSCALLed system software is running in 64-bit mode, it has been entered from either 64-bitmode or compatibility mode. The corresponding SYSRET needs to know the mode to which it mustreturn. Executing SYSRET in non-64-bit mode or with a 16- or 32-bit operand size returns to 32-bitmode with a 32-bit stack pointer.

Executing SYSRET in 64-bit mode with a 64-bit operand size returnsto 64-bit mode with a 64-bit stack pointer.The instruction pointer is updated with the return address based on the operating mode in whichSYSRET is executed:••If returning to 64-bit mode, SYSRET loads RIP with the value of RCX.If returning to 32-bit mode, SYSRET loads EIP with the value of ECX.How SYSRET handles RFLAGS depends on the processor’s operating mode:••If executed in 64-bit mode, SYSRET loads the lower-32 RFLAGS bits from R11[31:0] and clearsthe upper 32 RFLAGS bits.If executed in legacy mode or compatibility mode, SYSRET sets EFLAGS.IF.For further details on the SYSCALL and SYSRET instructions and their associated MSR registers(STAR, LSTAR, and CSTAR), see “Fast System Call and Return” in Volume 2.MnemonicOpcodeSYSRET0F 07DescriptionReturn from operating system.Action// See “Pseudocode Definitions” on page 41.SYSRET_START:IF (MSR_EFER.SCE = 0)EXCEPTION [#UD]// Check if syscall/sysret are enabled.IF ((!PROTECTED_MODE) || (CPL != 0))EXCEPTION [#GP(0)]// SYSRET requires protected mode, cpl0IF (64BIT_MODE)SYSRET_64BIT_MODEELSE // (!64BIT_MODE)SYSRET_NON_64BIT_MODESYSRET_64BIT_MODE:IF (OPERAND_SIZE = 64){320// Return to 64-bit mode.SYSRETInstruction Reference24594—Rev.

3.13—July 2007CS.selCS.baseCS.limitCS.attr====AMD64 Technology(MSR_STAR.SYSRET_CS + 16) OR 30x000000000xFFFFFFFF64-bit code,dpl3temp_RIP.q = RCX}ELSE{// Return to 32-bit compatibility mode.CS.selCS.baseCS.limitCS.attr====MSR_STAR.SYSRET_CS OR 30x000000000xFFFFFFFF32-bit code,dpl3temp_RIP.d = RCX}SS.sel = MSR_STAR.SYSRET_CS + 8RFLAGS.q = R11CPL = 3// SS selector is changed,// SS base, limit, attributes unchanged.// RF=0,VM=0RIP = temp_RIPEXITSYSRET_NON_64BIT_MODE:CS.selCS.baseCS.limitCS.attr====MSR_STAR.SYSRET_CS OR 3 // Return to 32-bit legacy protected mode.0x000000000xFFFFFFFF32-bit code,dpl3temp_RIP.d = RCXSS.sel = MSR_STAR.SYSRET_CS + 8// SS selector is changed.// SS base, limit, attributes unchanged.RFLAGS.IF = 1CPL = 3RIP = temp_RIPEXITRelated InstructionsSYSCALL, SYSENTER, SYSEXITInstruction ReferenceSYSRET321AMD64 Technology24594—Rev. 3.13—July 2007rFLAGS AffectedIDVIPVIFACMMMM21201918VMRFNTIOPLOFDFIFTFSFZFAFPFCF0MMMMMMMMMMM161413–121110987642017Note: Bits 31–22, 15, 5, 3, and 1 are reserved.

Характеристики

Тип файла
PDF-файл
Размер
1,98 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
Почему делать на заказ в разы дороже, чем купить готовую учебную работу на СтудИзбе? Наши учебные работы продаются каждый год, тогда как большинство заказов выполняются с нуля. Найдите подходящий учебный материал на СтудИзбе!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6417
Авторов
на СтудИзбе
307
Средний доход
с одного платного файла
Обучение Подробнее