Главная » Просмотр файлов » Volume 2 System Programming

Volume 2 System Programming (794096), страница 31

Файл №794096 Volume 2 System Programming (Intel and AMD manuals) 31 страницаVolume 2 System Programming (794096) страница 312019-04-28СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

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

Each type of model is described in the following sections.4.3.1 Multi-Segmented ModelIn the multi-segmented memory model, each segment register can reference a unique base addresswith a unique segment size. Segments can be as small as a single byte or as large as 4 Gbytes.

Whenpage translation is used, multiple segments can be mapped to a single page and multiple pages can bemapped to a single segment. Figure 1-1 on page 6 shows an example of the multi-segmented model.64Segmented Virtual Memory24593—Rev. 3.13—July 2007AMD64 TechnologyThe multi-segmented memory model provides the greatest level of flexibility for system softwareusing the segmentation mechanism.Compatibility mode allows the multi-segmented model to be used in support of legacy software.However, in compatibility mode, the multi-segmented memory model is restricted to the first 4 Gbytesof virtual-memory space.

Access to virtual memory above 4 Gbytes requires the use of 64-bit mode,which does not support segmentation.4.3.2 Flat-Memory ModelThe flat-memory model is the simplest form of segmentation to implement. Although segmentationcannot be disabled, the flat-memory model allows system software to bypass most of the segmentationmechanism. In the flat-memory model, all segment-base addresses have a value of 0 and the segmentlimits are fixed at 4 Gbytes. Clearing the segment-base value to 0 effectively disables segmenttranslation, resulting in a single segment spanning the entire virtual-address space.

All segmentdescriptors reference this single, flat segment. Figure 1-2 on page 7 shows an example of the flatmemory model.4.3.3 Segmentation in 64-Bit ModeIn 64-bit mode, segmentation is disabled. The segment-base value is ignored and treated as 0 by thesegmentation hardware. Likewise, segment limits and most attributes are ignored. There are a fewexceptions. The CS-segment DPL, D, and L attributes are used (respectively) to establish the privilegelevel for a program, the default operand size, and whether the program is running in 64-bit mode orcompatibility mode. The FS and GS segments can be used as additional base registers in addresscalculations, and those segments can have non-zero base-address values.

This facilitates addressingthread-local data and certain system-software data structures. See “FS and GS Registers in 64-BitMode” on page 70 for details about the FS and GS segments in 64-bit mode. The system-segmentregisters are always used in 64-bit mode.4.4Segmentation Data Structures and RegistersFigure 4-1 on page 66 shows the following data structures used by the segmentation mechanism:•••Segment Descriptors—As the name implies, a segment descriptor describes a segment, includingits location in virtual-address space, its size, protection characteristics, and other attributes.Descriptor Tables—Segment descriptors are stored in memory in one of three tables.

The globaldescriptor table (GDT) holds segment descriptors that can be shared among all tasks. Multiplelocal-descriptor tables (LDT) can be defined to hold descriptors that are used by specific tasks andare not shared globally. The interrupt-descriptor table (IDT) holds gate descriptors that are used toaccess the segments where interrupt handlers are located.Task-State Segment—A task-state segment (TSS) is a special type of system segment that containstask-state information and data structures for each task. For example, a TSS holds a copy of theGPRs and EFLAGS register when a task is suspended. A TSS also holds the pointers to privileged-Segmented Virtual Memory65AMD64 Technology•24593—Rev. 3.13—July 2007software stacks.

The TSS and task-switch mechanism are described in Chapter 12, “TaskManagement.”Segment Selectors—Descriptors are selected for use from the descriptor tables using a segmentselector. A segment selector contains an index into either the GDT or LDT. The IDT is indexedusing an interrupt vector, as described in “Legacy Protected-Mode Interrupt Control Transfers” onpage 229, and in “Long-Mode Interrupt Control Transfers” on page 239.Global-Descriptor Table (GDT)DescriptorDescriptor...Segment DescriptorsDescriptorCodeSegment SelectorsSelector 1Local-Descriptor Table (LDT)StackDescriptorSelector 2...DataDescriptor...GateDescriptorTask-State SegmentSelector nInterrupt-Descriptor Table (IDT)Gate DescriptorLocal-Descriptor TableGate Descriptor...Gate Descriptor513-263.epsFigure 4-1.

Segmentation Data StructuresFigure 4-2 on page 67 shows the registers used by the segmentation mechanism. The registers have thefollowing relationship to the data structures:•••66Segment Registers—The six segment registers (CS, DS, ES, FS, GS, and SS) are used to point tothe user segments. A segment selector selects a descriptor when it is loaded into one of the segmentregisters.

This causes the processor to automatically load the selected descriptor into a softwareinvisible portion of the segment register.Descriptor-Table Registers—The three descriptor-table registers (GDTR, LDTR, and IDTR) areused to point to the system segments. The descriptor-table registers identify the virtual-memorylocation and size of the descriptor tables.Task Register (TR)—Describes the location and limit of the current task state segment (TSS).Segmented Virtual Memory24593—Rev. 3.13—July 2007AMD64 TechnologyCode Segment RegisterGlobal-Descriptor-Table RegisterCSGDTRData Segment RegistersInterrupt-Descriptor-Table RegisterDSIDTRESLocal-Descriptor-Table RegisterFSLDTRGSTask RegisterStack Segment RegisterTRSS513-264.epsFigure 4-2.

Segment and Descriptor-Table RegistersA fourth system-segment register, the TR, points to the TSS. The data structures and registersassociated with task-state segments are described in “Task-Management Resources” on page 306.4.5Segment Selectors and Registers4.5.1 Segment SelectorsSegment selectors are pointers to specific entries in the global and local descriptor tables. Figure 4-3on page 67 shows the segment selector format.153SI21TIRPLBits Mnemonic Description15-3 SISelector Index2TITable Indicator1-0RPLRequestor Privilege Level0R/WR/WR/WR/WFigure 4-3. Segment SelectorSegmented Virtual Memory67AMD64 Technology24593—Rev.

3.13—July 2007The selector format consists of the following fields:Selector Index Field. Bits 15–3. The selector-index field specifies an entry in the descriptor table.Descriptor-table entries are eight bytes long, so the selector index is scaled by 8 to form a byte offsetinto the descriptor table. The offset is then added to either the global or local descriptor-table baseaddress (as indicated by the table-index bit) to form the descriptor-entry address in virtual-addressspace.Some descriptor entries in long mode are 16 bytes long rather than 8 bytes (see “Legacy SegmentDescriptors” on page 77 for more information on long-mode descriptor-table entries).

These expandeddescriptors consume two entries in the descriptor table. Long mode, however, continues to scale theselector index by eight to form the descriptor-table offset. It is the responsibility of system software toassign selectors such that they correctly point to the start of an expanded entry.Table Indicator (TI) Bit. Bit 2. The TI bit indicates which table holds the descriptor referenced by theselector index. When TI=0 the GDT is used and when TI=1 the LDT is used. The descriptor-table baseaddress is read from the appropriate descriptor-table register and added to the scaled selector index asdescribed above.Requestor Privilege-Level (RPL) Field.

Bits 1–0. The RPL represents the privilege level (CPL) theprocessor is operating under at the time the selector is created.RPL is used in segment privilege-checks to prevent software running at lesser privilege levels fromaccessing privileged data. See “Data-Access Privilege Checks” on page 95 and “Control-TransferPrivilege Checks” on page 98 for more information on segment privilege-checks.Null Selector. Null selectors have a selector index of 0 and TI=0, corresponding to the first entry inthe GDT.

However, null selectors do not reference the first GDT entry but are instead used to invalidateunused segment registers. A general-protection exception (#GP) occurs if a reference is made to use asegment register containing a null selector in non-64-bit mode. By initializing unused segmentregisters with null selectors software can trap references to unused segments.Null selectors can only be loaded into the DS, ES, FS and GS data-segment registers, and into theLDTR descriptor-table register.

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

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

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

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