Xen Test Framework
Data Structures | Macros | Functions | Variables
desc.h File Reference

x86 segment descriptor infrastructure. More...

#include <xtf/types.h>
#include <xtf/compiler.h>
#include <arch/x86-gate.h>
#include <arch/x86-tss.h>
#include <arch/segment.h>
+ Include dependency graph for desc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  seg_desc32
 8 byte user segment descriptor (GDT/LDT entries with .s = 1) More...
 
struct  desc_ptr64
 Long mode lgdt/lidt table pointer. More...
 
struct  far_ptr64
 Long mode lcall/ljmp memory operand. More...
 
struct  desc_ptr32
 Protected mode lgdt/lidt table pointer. More...
 
struct  far_ptr32
 Protected mode lcall/ljmp memory operand. More...
 

Macros

#define SEG_ATTR_G   0x8000
 Granularity of limit (0 = 1, 1 = 4K) More...
 
#define SEG_ATTR_AVL   0x1000
 Available for software use. More...
 
#define SEG_ATTR_P   0x0080
 Present? More...
 
#define SEG_ATTR_S   0x0010
 !System desc (0 = system, 1 = user) More...
 
#define SEG_ATTR_A   0x0001
 Accessed? (set by hardware) More...
 
#define SEG_ATTR_COMMON   0x8091
 Commonly set bits (G P S A) More...
 
#define SEG_ATTR_DPL0   0x0000
 Descriptor privilege level 0. More...
 
#define SEG_ATTR_DPL1   0x0020
 Descriptor privilege level 1. More...
 
#define SEG_ATTR_DPL2   0x0040
 Descriptor privilege level 2. More...
 
#define SEG_ATTR_DPL3   0x0060
 Descriptor privilege level 3. More...
 
#define SEG_ATTR_CODE   0x0008
 Type (0 = data, 1 = code)
More...
 
#define SEG_ATTR_DATA   0x0000
 Type (0 = data, 1 = code)
More...
 
#define SEG_ATTR_D   0x4000
 Default operand size (0 = 16bit, 1 = 32bit) More...
 
#define SEG_ATTR_L   0x2000
 Long segment? (1 = 64bit) More...
 
#define SEG_ATTR_C   0x0004
 Conforming? (0 = non, 1 = conforming) More...
 
#define SEG_ATTR_R   0x0002
 Readable? (0 = XO seg, 1 = RX seg) More...
 
#define SEG_ATTR_B   0x4000
 'Big' flag. More...
 
#define SEG_ATTR_E   0x0004
 Expand-down? (0 = normal, 1 = expand-down) More...
 
#define SEG_ATTR_W   0x0002
 Writable? (0 = RO seg, 1 = RW seg) More...
 
#define INIT_GDTE(base, limit, attr)
 Initialiser for an LDT/GDT entry using a raw attribute number. More...
 
#define GDTE(base, limit, attr)   ((user_desc)INIT_GDTE(base, limit, attr))
 As INIT_GDTE(), but creates a user_desc object. More...
 

Functions

static unsigned long user_desc_base (const user_desc *d)
 
static unsigned int user_desc_limit (const user_desc *d)
 
static void pack_tss_desc (user_desc *d, const env_tss *t)
 
static void pack_ldt_desc (user_desc *d, const user_desc *ldt, unsigned int limit)
 

Variables

user_desc gdt [NR_GDT_ENTRIES]
 
desc_ptr gdt_ptr
 

Detailed Description

x86 segment descriptor infrastructure.

Definition in file desc.h.

Macro Definition Documentation

◆ SEG_ATTR_G

#define SEG_ATTR_G   0x8000

Granularity of limit (0 = 1, 1 = 4K)

Definition at line 65 of file desc.h.

◆ SEG_ATTR_AVL

#define SEG_ATTR_AVL   0x1000

Available for software use.

Definition at line 66 of file desc.h.

◆ SEG_ATTR_P

#define SEG_ATTR_P   0x0080

Present?

Definition at line 67 of file desc.h.

◆ SEG_ATTR_S

#define SEG_ATTR_S   0x0010

!System desc (0 = system, 1 = user)

Definition at line 68 of file desc.h.

◆ SEG_ATTR_A

#define SEG_ATTR_A   0x0001

Accessed? (set by hardware)

Definition at line 69 of file desc.h.

◆ SEG_ATTR_COMMON

#define SEG_ATTR_COMMON   0x8091

Commonly set bits (G P S A)

Definition at line 71 of file desc.h.

◆ SEG_ATTR_DPL0

#define SEG_ATTR_DPL0   0x0000

Descriptor privilege level 0.

Definition at line 73 of file desc.h.

◆ SEG_ATTR_DPL1

#define SEG_ATTR_DPL1   0x0020

Descriptor privilege level 1.

Definition at line 74 of file desc.h.

◆ SEG_ATTR_DPL2

#define SEG_ATTR_DPL2   0x0040

Descriptor privilege level 2.

Definition at line 75 of file desc.h.

◆ SEG_ATTR_DPL3

#define SEG_ATTR_DPL3   0x0060

Descriptor privilege level 3.

Definition at line 76 of file desc.h.

◆ SEG_ATTR_CODE

#define SEG_ATTR_CODE   0x0008

Type (0 = data, 1 = code)

Definition at line 77 of file desc.h.

◆ SEG_ATTR_DATA

#define SEG_ATTR_DATA   0x0000

Type (0 = data, 1 = code)

Definition at line 78 of file desc.h.

◆ SEG_ATTR_D

#define SEG_ATTR_D   0x4000

Default operand size (0 = 16bit, 1 = 32bit)

Definition at line 81 of file desc.h.

◆ SEG_ATTR_L

#define SEG_ATTR_L   0x2000

Long segment? (1 = 64bit)

Definition at line 82 of file desc.h.

◆ SEG_ATTR_C

#define SEG_ATTR_C   0x0004

Conforming? (0 = non, 1 = conforming)

Definition at line 83 of file desc.h.

◆ SEG_ATTR_R

#define SEG_ATTR_R   0x0002

Readable? (0 = XO seg, 1 = RX seg)

Definition at line 84 of file desc.h.

◆ SEG_ATTR_B

#define SEG_ATTR_B   0x4000

'Big' flag.

  • For ss, default operand size.
  • For expand-down segment, sets upper bound.

Definition at line 89 of file desc.h.

◆ SEG_ATTR_E

#define SEG_ATTR_E   0x0004

Expand-down? (0 = normal, 1 = expand-down)

Definition at line 90 of file desc.h.

◆ SEG_ATTR_W

#define SEG_ATTR_W   0x0002

Writable? (0 = RO seg, 1 = RW seg)

Definition at line 91 of file desc.h.

◆ INIT_GDTE

#define INIT_GDTE (   base,
  limit,
  attr 
)
Value:
{ { { \
.lo = (((base) & 0xffff) << 16) | ((limit) & 0xffff), \
.hi = ((base) & 0xff000000) | ((limit) & 0xf0000) | \
(((attr) & 0xf0ff) << 8) | (((base) & 0xff0000) >> 16) \
} } }

Initialiser for an LDT/GDT entry using a raw attribute number.

Parameters
baseSegment base.
limitSegment limit.
attrSegment attributes.

Definition at line 100 of file desc.h.

◆ GDTE

#define GDTE (   base,
  limit,
  attr 
)    ((user_desc)INIT_GDTE(base, limit, attr))

As INIT_GDTE(), but creates a user_desc object.

Definition at line 109 of file desc.h.

Function Documentation

◆ user_desc_base()

static unsigned long user_desc_base ( const user_desc *  d)
inlinestatic

Definition at line 177 of file desc.h.

+ Here is the caller graph for this function:

◆ user_desc_limit()

static unsigned int user_desc_limit ( const user_desc *  d)
inlinestatic

Definition at line 191 of file desc.h.

◆ pack_tss_desc()

static void pack_tss_desc ( user_desc *  d,
const env_tss *  t 
)
inlinestatic

Definition at line 201 of file desc.h.

+ Here is the caller graph for this function:

◆ pack_ldt_desc()

static void pack_ldt_desc ( user_desc *  d,
const user_desc *  ldt,
unsigned int  limit 
)
inlinestatic

Definition at line 212 of file desc.h.

+ Here is the caller graph for this function:

Variable Documentation

◆ gdt

user_desc gdt[NR_GDT_ENTRIES]
extern

◆ gdt_ptr

desc_ptr gdt_ptr
extern