iPXE
librm_mgmt.c
Go to the documentation of this file.
1 /*
2  * librm: a library for interfacing to real-mode code
3  *
4  * Michael Brown <mbrown@fensystems.co.uk>
5  *
6  */
7 
8 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
9 
10 #include <stdint.h>
11 #include <strings.h>
12 #include <assert.h>
13 #include <ipxe/profile.h>
14 #include <realmode.h>
15 #include <pic8259.h>
16 #include <ipxe/shell.h>
17 #include <ipxe/cpuid.h>
18 
19 /*
20  * This file provides functions for managing librm.
21  *
22  */
23 
24 /** The interrupt wrapper */
25 extern char interrupt_wrapper[];
26 
27 /** The interrupt vectors */
29 
30 /** The 32-bit interrupt descriptor table */
32 idt32[NUM_INT] __attribute__ (( aligned ( 16 ) ));
33 
34 /** The 32-bit interrupt descriptor table register */
35 struct idtr32 idtr32 = {
36  .limit = ( sizeof ( idt32 ) - 1 ),
37 };
38 
39 /** The 64-bit interrupt descriptor table */
41 idt64[NUM_INT] __attribute__ (( aligned ( 16 ) ));
42 
43 /** The interrupt descriptor table register */
44 struct idtr64 idtr64 = {
45  .limit = ( sizeof ( idt64 ) - 1 ),
46 };
47 
48 /** Startup IPI register state */
50 
51 /** Length of stack dump */
52 #define STACK_DUMP_LEN 128
53 
54 /** Timer interrupt profiler */
55 static struct profiler timer_irq_profiler __profiler = { .name = "irq.timer" };
56 
57 /** Other interrupt profiler */
58 static struct profiler other_irq_profiler __profiler = { .name = "irq.other" };
59 
60 /**
61  * Allocate space on the real-mode stack and copy data there from a
62  * user buffer
63  *
64  * @v data User buffer
65  * @v size Size of stack data
66  * @ret sp New value of real-mode stack pointer
67  */
69  userptr_t rm_stack;
70  rm_sp -= size;
71  rm_stack = real_to_user ( rm_ss, rm_sp );
72  memcpy_user ( rm_stack, 0, data, 0, size );
73  return rm_sp;
74 };
75 
76 /**
77  * Deallocate space on the real-mode stack, optionally copying back
78  * data to a user buffer.
79  *
80  * @v data User buffer
81  * @v size Size of stack data
82  */
84  if ( data ) {
85  userptr_t rm_stack = real_to_user ( rm_ss, rm_sp );
86  memcpy_user ( rm_stack, 0, data, 0, size );
87  }
88  rm_sp += size;
89 };
90 
91 /**
92  * Set interrupt vector
93  *
94  * @v intr Interrupt number
95  * @v vector Interrupt vector, or NULL to disable
96  */
97 void set_interrupt_vector ( unsigned int intr, void *vector ) {
98  struct interrupt32_descriptor *idte32;
99  struct interrupt64_descriptor *idte64;
100  intptr_t addr = ( ( intptr_t ) vector );
101 
102  /* Populate 32-bit interrupt descriptor */
103  idte32 = &idt32[intr];
104  idte32->segment = VIRTUAL_CS;
105  idte32->attr = ( vector ? ( IDTE_PRESENT | IDTE_TYPE_IRQ32 ) : 0 );
106  idte32->low = ( addr >> 0 );
107  idte32->high = ( addr >> 16 );
108 
109  /* Populate 64-bit interrupt descriptor, if applicable */
110  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {
111  idte64 = &idt64[intr];
112  idte64->segment = LONG_CS;
113  idte64->attr = ( vector ?
114  ( IDTE_PRESENT | IDTE_TYPE_IRQ64 ) : 0 );
115  idte64->low = ( addr >> 0 );
116  idte64->mid = ( addr >> 16 );
117  idte64->high = ( ( ( uint64_t ) addr ) >> 32 );
118  }
119 }
120 
121 /**
122  * Initialise interrupt descriptor table
123  *
124  */
125 __asmcall void init_idt ( void ) {
126  struct interrupt_vector *vec;
127  unsigned int intr;
128 
129  /* Initialise the interrupt descriptor table and interrupt vectors */
130  for ( intr = 0 ; intr < NUM_INT ; intr++ ) {
131  vec = &intr_vec[intr];
132  vec->push = PUSH_INSN;
133  vec->movb = MOVB_INSN;
134  vec->intr = intr;
135  vec->jmp = JMP_INSN;
136  vec->offset = ( ( intptr_t ) interrupt_wrapper -
137  ( intptr_t ) vec->next );
138  set_interrupt_vector ( intr, vec );
139  }
140  DBGC ( &intr_vec[0], "INTn vector at %p+%zxn (phys %#lx+%zxn)\n",
141  intr_vec, sizeof ( intr_vec[0] ),
142  virt_to_phys ( intr_vec ), sizeof ( intr_vec[0] ) );
143 
144  /* Initialise the 32-bit interrupt descriptor table register */
146 
147  /* Initialise the 64-bit interrupt descriptor table register,
148  * if applicable.
149  */
150  if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) )
152 }
153 
154 /**
155  * Determine interrupt profiler (for debugging)
156  *
157  * @v intr Interrupt number
158  * @ret profiler Profiler
159  */
160 static struct profiler * interrupt_profiler ( int intr ) {
161 
162  switch ( intr ) {
163  case IRQ_INT ( 0 ) :
164  return &timer_irq_profiler;
165  default:
166  return &other_irq_profiler;
167  }
168 }
169 
170 /**
171  * Display interrupt stack dump (for debugging)
172  *
173  * @v intr Interrupt number
174  * @v frame32 32-bit interrupt wrapper stack frame (or NULL)
175  * @v frame64 64-bit interrupt wrapper stack frame (or NULL)
176  */
177 static __attribute__ (( unused )) void
178 interrupt_dump ( int intr, struct interrupt_frame32 *frame32,
179  struct interrupt_frame64 *frame64 ) {
180  unsigned long sp;
181  void *stack;
182 
183  /* Do nothing unless debugging is enabled */
184  if ( ! DBG_LOG )
185  return;
186 
187  /* Print register dump */
188  if ( ( sizeof ( physaddr_t ) <= sizeof ( uint32_t ) ) || frame32 ) {
189  sp = ( frame32->esp + sizeof ( *frame32 ) -
190  offsetof ( typeof ( *frame32 ), esp ) );
191  DBGC ( &intr, "INT%d at %04x:%08x (stack %04x:%08lx):\n",
192  intr, frame32->cs, frame32->eip, frame32->ss, sp );
193  DBGC ( &intr, "cs = %04x ds = %04x es = %04x fs = %04x "
194  "gs = %04x ss = %04x\n", frame32->cs, frame32->ds,
195  frame32->es, frame32->fs, frame32->gs, frame32->ss );
196  DBGC ( &intr, "eax = %08x ebx = %08x ecx = %08x "
197  "edx = %08x flg = %08x\n", frame32->eax, frame32->ebx,
198  frame32->ecx, frame32->edx, frame32->eflags );
199  DBGC ( &intr, "esi = %08x edi = %08x ebp = %08x "
200  "esp = %08lx eip = %08x\n", frame32->esi, frame32->edi,
201  frame32->ebp, sp, frame32->eip );
202  stack = ( ( ( void * ) frame32 ) + sizeof ( *frame32 ) );
203  } else {
204  DBGC ( &intr, "INT%d at %04llx:%016llx (stack "
205  "%04llx:%016llx):\n", intr,
206  ( ( unsigned long long ) frame64->cs ),
207  ( ( unsigned long long ) frame64->rip ),
208  ( ( unsigned long long ) frame64->ss ),
209  ( ( unsigned long long ) frame64->rsp ) );
210  DBGC ( &intr, "rax = %016llx rbx = %016llx rcx = %016llx\n",
211  ( ( unsigned long long ) frame64->rax ),
212  ( ( unsigned long long ) frame64->rbx ),
213  ( ( unsigned long long ) frame64->rcx ) );
214  DBGC ( &intr, "rdx = %016llx rsi = %016llx rdi = %016llx\n",
215  ( ( unsigned long long ) frame64->rdx ),
216  ( ( unsigned long long ) frame64->rsi ),
217  ( ( unsigned long long ) frame64->rdi ) );
218  DBGC ( &intr, "rbp = %016llx rsp = %016llx flg = %016llx\n",
219  ( ( unsigned long long ) frame64->rbp ),
220  ( ( unsigned long long ) frame64->rsp ),
221  ( ( unsigned long long ) frame64->rflags ) );
222  DBGC ( &intr, "r8 = %016llx r9 = %016llx r10 = %016llx\n",
223  ( ( unsigned long long ) frame64->r8 ),
224  ( ( unsigned long long ) frame64->r9 ),
225  ( ( unsigned long long ) frame64->r10 ) );
226  DBGC ( &intr, "r11 = %016llx r12 = %016llx r13 = %016llx\n",
227  ( ( unsigned long long ) frame64->r11 ),
228  ( ( unsigned long long ) frame64->r12 ),
229  ( ( unsigned long long ) frame64->r13 ) );
230  DBGC ( &intr, "r14 = %016llx r15 = %016llx\n",
231  ( ( unsigned long long ) frame64->r14 ),
232  ( ( unsigned long long ) frame64->r15 ) );
233  sp = frame64->rsp;
234  stack = phys_to_virt ( sp );
235  }
236 
237  /* Print stack dump */
238  DBGC_HDA ( &intr, sp, stack, STACK_DUMP_LEN );
239 }
240 
241 /**
242  * Interrupt handler
243  *
244  * @v intr Interrupt number
245  * @v frame32 32-bit interrupt wrapper stack frame (or NULL)
246  * @v frame64 64-bit interrupt wrapper stack frame (or NULL)
247  * @v frame Interrupt wrapper stack frame
248  */
249 void __attribute__ (( regparm ( 3 ) ))
250 interrupt ( int intr, struct interrupt_frame32 *frame32,
251  struct interrupt_frame64 *frame64 ) {
253  uint32_t discard_eax;
254 
255  /* Trap CPU exceptions if debugging is enabled. Note that we
256  * cannot treat INT8+ as exceptions, since we are not
257  * permitted to rebase the PIC.
258  */
259  if ( DBG_LOG && ( intr < IRQ_INT ( 0 ) ) ) {
260  interrupt_dump ( intr, frame32, frame64 );
261  DBG ( "CPU exception: dropping to emergency shell\n" );
262  shell();
263  }
264 
265  /* Reissue interrupt in real mode */
267  __asm__ __volatile__ ( REAL_CODE ( "movb %%al, %%cs:(1f + 1)\n\t"
268  "\n1:\n\t"
269  "int $0x00\n\t" )
270  : "=a" ( discard_eax ) : "0" ( intr ) );
273 }
274 
275 /**
276  * Map pages for I/O
277  *
278  * @v bus_addr Bus address
279  * @v len Length of region
280  * @ret io_addr I/O address
281  */
282 static void * ioremap_pages ( unsigned long bus_addr, size_t len ) {
283  unsigned long start;
284  unsigned int count;
285  unsigned int stride;
286  unsigned int first;
287  unsigned int i;
288  size_t offset;
289  void *io_addr;
290 
291  DBGC ( &io_pages, "IO mapping %08lx+%zx\n", bus_addr, len );
292 
293  /* Sanity check */
294  if ( ! len )
295  return NULL;
296 
297  /* Round down start address to a page boundary */
298  start = ( bus_addr & ~( IO_PAGE_SIZE - 1 ) );
299  offset = ( bus_addr - start );
300  assert ( offset < IO_PAGE_SIZE );
301 
302  /* Calculate number of pages required */
303  count = ( ( offset + len + IO_PAGE_SIZE - 1 ) / IO_PAGE_SIZE );
304  assert ( count != 0 );
305  assert ( count < ( sizeof ( io_pages.page ) /
306  sizeof ( io_pages.page[0] ) ) );
307 
308  /* Round up number of pages to a power of two */
309  stride = ( 1 << ( fls ( count ) - 1 ) );
310  assert ( count <= stride );
311 
312  /* Allocate pages */
313  for ( first = 0 ; first < ( sizeof ( io_pages.page ) /
314  sizeof ( io_pages.page[0] ) ) ;
315  first += stride ) {
316 
317  /* Calculate I/O address */
318  io_addr = ( IO_BASE + ( first * IO_PAGE_SIZE ) + offset );
319 
320  /* Check that page table entries are available */
321  for ( i = first ; i < ( first + count ) ; i++ ) {
322  if ( io_pages.page[i] & PAGE_P ) {
323  io_addr = NULL;
324  break;
325  }
326  }
327  if ( ! io_addr )
328  continue;
329 
330  /* Create page table entries */
331  for ( i = first ; i < ( first + count ) ; i++ ) {
332  io_pages.page[i] = ( start | PAGE_P | PAGE_RW |
334  PAGE_PS );
335  start += IO_PAGE_SIZE;
336  }
337 
338  /* Mark last page as being the last in this allocation */
339  io_pages.page[ i - 1 ] |= PAGE_LAST;
340 
341  /* Return I/O address */
342  DBGC ( &io_pages, "IO mapped %08lx+%zx to %p using PTEs "
343  "[%d-%d]\n", bus_addr, len, io_addr, first,
344  ( first + count - 1 ) );
345  return io_addr;
346  }
347 
348  DBGC ( &io_pages, "IO could not map %08lx+%zx\n", bus_addr, len );
349  return NULL;
350 }
351 
352 /**
353  * Unmap pages for I/O
354  *
355  * @v io_addr I/O address
356  */
357 static void iounmap_pages ( volatile const void *io_addr ) {
358  volatile const void *invalidate = io_addr;
359  unsigned int first;
360  unsigned int i;
361  int is_last;
362 
363  DBGC ( &io_pages, "IO unmapping %p\n", io_addr );
364 
365  /* Calculate first page table entry */
366  first = ( ( io_addr - IO_BASE ) / IO_PAGE_SIZE );
367 
368  /* Clear page table entries */
369  for ( i = first ; ; i++ ) {
370 
371  /* Sanity check */
372  assert ( io_pages.page[i] & PAGE_P );
373 
374  /* Check if this is the last page in this allocation */
375  is_last = ( io_pages.page[i] & PAGE_LAST );
376 
377  /* Clear page table entry */
378  io_pages.page[i] = 0;
379 
380  /* Invalidate TLB for this page */
381  __asm__ __volatile__ ( "invlpg (%0)" : : "r" ( invalidate ) );
382  invalidate += IO_PAGE_SIZE;
383 
384  /* Terminate if this was the last page */
385  if ( is_last )
386  break;
387  }
388 
389  DBGC ( &io_pages, "IO unmapped %p using PTEs [%d-%d]\n",
390  io_addr, first, i );
391 }
392 
393 /**
394  * Check for FXSAVE/FXRSTOR instruction support
395  *
396  */
398  struct x86_features features;
399 
400  /* Check for FXSR bit */
401  x86_features ( &features );
402  if ( ! ( features.intel.edx & CPUID_FEATURES_INTEL_EDX_FXSR ) )
403  regs->flags |= CF;
404  DBGC ( &features, "FXSAVE/FXRSTOR is%s supported\n",
405  ( ( regs->flags & CF ) ? " not" : "" ) );
406 }
407 
408 /**
409  * Set up startup IPI handler
410  *
411  * @v vector Startup IPI vector
412  * @v handler Protected-mode startup IPI handler physical address
413  * @v regs Initial register state
414  */
415 void setup_sipi ( unsigned int vector, uint32_t handler,
416  struct i386_regs *regs ) {
417 
418  /* Record protected-mode handler */
419  sipi_handler = handler;
420 
421  /* Update copy of rm_ds */
422  sipi_ds = rm_ds;
423 
424  /* Save register state */
425  memcpy ( &sipi_regs, regs, sizeof ( sipi_regs ) );
426 
427  /* Copy real-mode handler */
428  copy_to_real ( ( vector << 8 ), 0, sipi, ( ( size_t ) sipi_len ) );
429 }
430 
#define IO_PAGE_SIZE
I/O page size.
Definition: librm.h:468
uint32_t cs
Definition: librm.h:402
#define __attribute__(x)
Definition: compiler.h:10
uint64_t rsp
Definition: librm.h:426
unsigned short uint16_t
Definition: stdint.h:11
#define CF
Definition: registers.h:181
Minimal command shell.
uint32_t esp
Definition: librm.h:249
uint64_t r14
Definition: librm.h:409
uint16_t mid
Middle 16 bits of address.
Definition: librm.h:338
uint8_t next[0]
Next instruction after jump.
Definition: librm.h:374
uint64_t r12
Definition: librm.h:411
uint32_t vector
MSI-X vector.
Definition: ena.h:20
uint8_t intr
Interrupt number.
Definition: librm.h:368
off_t memchr_user(userptr_t userptr, off_t offset, int c, size_t len)
Find character in user buffer.
#define IDTE_TYPE_IRQ32
Interrupt descriptor 32-bit interrupt gate type.
Definition: librm.h:349
uint32_t sipi_handler
Startup IPI protected-mode handler (physical address)
struct i386_regs sipi_regs
Startup IPI register state.
Definition: librm_mgmt.c:49
PROVIDE_UACCESS_INLINE(librm, phys_to_user)
uint32_t es
Definition: librm.h:392
uint64_t rsi
Definition: librm.h:418
uint16_t high
High 16 bits of address.
Definition: librm.h:324
Page-level write-through.
Definition: librm.h:447
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
#define sipi_ds
Definition: librm.h:486
PROVIDE_IOMAP(pages, ioremap, ioremap_pages)
#define DBGC(...)
Definition: compiler.h:505
#define LONG_CS
Definition: librm.h:17
uint8_t attr
Type and attributes.
Definition: librm.h:322
unsigned long long uint64_t
Definition: stdint.h:13
void x86_features(struct x86_features *features)
Get x86 CPU features.
Definition: cpuid.c:163
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
int shell(void)
Start command shell.
Definition: shell.c:84
uint64_t r10
Definition: librm.h:413
uint32_t eax
Definition: librm.h:400
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
x86 CPU features
Definition: cpuid.h:23
A data structure for storing profiling information.
Definition: profile.h:26
unsigned long io_to_bus(volatile const void *io_addr)
Convert I/O address to bus address (for debug only)
#define rm_ds
Definition: libkir.h:39
unsigned long intptr_t
Definition: stdint.h:21
static void iounmap_pages(volatile const void *io_addr)
Unmap pages for I/O.
Definition: librm_mgmt.c:357
static void interrupt_dump(int intr, struct interrupt_frame32 *frame32, struct interrupt_frame64 *frame64)
Display interrupt stack dump (for debugging)
Definition: librm_mgmt.c:178
static void profile_stop(struct profiler *profiler)
Stop profiling.
Definition: profile.h:171
uint32_t high
High 32 bits of address.
Definition: librm.h:340
A full register dump.
Definition: registers.h:174
Page-level cache disable.
Definition: librm.h:449
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Definition: uaccess.h:287
uint64_t r13
Definition: librm.h:410
uint64_t ss
Definition: librm.h:427
uint32_t start
Starting offset.
Definition: netvsc.h:12
#define IDTE_TYPE_IRQ64
Interrupt descriptor 64-bit interrupt gate type.
Definition: librm.h:352
uint64_t rcx
Definition: librm.h:420
uint32_t ds
Definition: librm.h:393
static __always_inline void * phys_to_virt(unsigned long phys_addr)
Convert physical address to a virtual address.
Definition: uaccess.h:299
uint64_t r8
Definition: librm.h:415
A 32-bit interrupt descriptor table entry.
Definition: librm.h:314
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
userptr_t userptr_add(userptr_t userptr, off_t offset)
Add offset to user pointer.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
const char * name
Name.
Definition: profile.h:28
uint16_t copy_user_to_rm_stack(userptr_t data, size_t size)
Allocate space on the real-mode stack and copy data there from a user buffer.
Definition: librm_mgmt.c:68
#define __asmcall
Declare a function with standard calling conventions.
Definition: compiler.h:15
uint32_t edx
Definition: librm.h:397
uint64_t rax
Definition: librm.h:422
Assertions.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint8_t intr
Interrupts enabled.
Definition: ena.h:14
#define IO_BASE
I/O page base address.
Definition: librm.h:475
#define DBGC_HDA(...)
Definition: compiler.h:506
uint32_t fs
Definition: librm.h:391
uint64_t r9
Definition: librm.h:414
A 16-bit general register.
Definition: registers.h:24
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
uint8_t movb
"movb" instruction
Definition: librm.h:366
Page is the last page in an allocation.
Definition: librm.h:457
uint32_t ecx
Definition: librm.h:398
static struct interrupt_vector intr_vec[NUM_INT]
The interrupt vectors.
Definition: librm_mgmt.c:28
uint32_t eip
Definition: librm.h:401
Page is a large page.
Definition: librm.h:451
static void profile_start(struct profiler *profiler)
Start profiling.
Definition: profile.h:158
__asmcall void init_idt(void)
Initialise interrupt descriptor table.
Definition: librm_mgmt.c:125
Profiling.
uint32_t edi
Definition: librm.h:395
#define CPUID_FEATURES_INTEL_EDX_FXSR
FXSAVE and FXRSTOR are supported.
Definition: cpuid.h:52
#define PUSH_INSN
"push %eax" instruction
Definition: librm.h:378
uint16_t low
Low 16 bits of address.
Definition: librm.h:316
uint32_t esp
Definition: librm.h:388
uint64_t rdx
Definition: librm.h:419
uint64_t r15
Definition: librm.h:408
x86 CPU feature detection
uint16_t limit
Limit.
Definition: librm.h:300
#define copy_to_real
Definition: libkir.h:78
uint32_t features
Supported features.
Definition: ena.h:16
uint16_t rm_ss
An interrupt vector.
Definition: librm.h:362
uint32_t ebp
Definition: librm.h:394
uint32_t eflags
Definition: librm.h:403
#define IRQ_INT(irq)
Definition: pic8259.h:60
#define VIRTUAL_CS
Definition: librm.h:10
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A 32-bit interrupt descriptor table register.
Definition: librm.h:298
u32 addr
Definition: sky2.h:8
uint8_t push
"push" instruction
Definition: librm.h:364
uint16_t low
Low 16 bits of address.
Definition: librm.h:330
static struct profiler timer_irq_profiler __profiler
Timer interrupt profiler.
Definition: librm_mgmt.c:55
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
unsigned int uint32_t
Definition: stdint.h:12
char sipi_len[]
Length of startup IPI real-mode handler.
#define STACK_DUMP_LEN
Length of stack dump.
Definition: librm_mgmt.c:52
A 64-bit interrupt descriptor table entry.
Definition: librm.h:328
struct i386_regs regs
Definition: registers.h:15
uint64_t rbp
Definition: librm.h:416
void setup_sipi(unsigned int vector, uint32_t handler, struct i386_regs *regs)
Set up startup IPI handler.
Definition: librm_mgmt.c:415
#define MOVB_INSN
"movb" instruction
Definition: librm.h:381
A 32-bit general register dump.
Definition: registers.h:62
uint32_t ss
Definition: librm.h:389
unsigned long physaddr_t
Definition: stdint.h:20
size_t strlen_user(userptr_t userptr, off_t offset)
Find length of NUL-terminated string in user buffer.
uint64_t rflags
Definition: librm.h:425
32-bit interrupt wrapper stack frame
Definition: librm.h:387
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
#define IDTE_PRESENT
Interrupt descriptor is present.
Definition: librm.h:346
uint32_t esi
Definition: librm.h:396
uint32_t len
Length.
Definition: ena.h:14
uint64_t base
Base.
Definition: librm.h:310
uint8_t unused[32]
Unused.
Definition: eltorito.h:15
void set_interrupt_vector(unsigned int intr, void *vector)
Set interrupt vector.
Definition: librm_mgmt.c:97
uint32_t gs
Definition: librm.h:390
uint32_t ebx
Definition: librm.h:399
uint16_t count
Number of entries.
Definition: ena.h:22
uint64_t cs
Definition: librm.h:424
uint16_t segment
Code segment.
Definition: librm.h:332
uint16_t limit
Limit.
Definition: librm.h:308
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
Page is writable.
Definition: librm.h:443
struct page_table io_pages
The I/O space page table.
void * user_to_virt(userptr_t userptr, off_t offset)
Convert user pointer to virtual address.
uint64_t rbx
Definition: librm.h:421
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
void iounmap(volatile const void *io_addr)
Unmap I/O address.
#define JMP_INSN
"jmp" instruction
Definition: librm.h:384
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint32_t base
Base.
Definition: librm.h:302
uint16_t rm_sp
char interrupt_wrapper[]
The interrupt wrapper.
uint32_t offset
Interrupt wrapper address offset.
Definition: librm.h:372
static void * ioremap_pages(unsigned long bus_addr, size_t len)
Map pages for I/O.
Definition: librm_mgmt.c:282
void memmove_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers, allowing for overlap.
static __always_inline userptr_t real_to_user(unsigned int segment, unsigned int offset)
Convert segment:offset address to user buffer.
Definition: realmode.h:75
Page is accessible by user code.
Definition: librm.h:445
void remove_user_from_rm_stack(userptr_t data, size_t size)
Deallocate space on the real-mode stack, optionally copying back data to a user buffer.
Definition: librm_mgmt.c:83
static struct profiler * interrupt_profiler(int intr)
Determine interrupt profiler (for debugging)
Definition: librm_mgmt.c:160
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
#define NUM_INT
Number of interrupts.
Definition: librm.h:295
#define sipi
Definition: librm.h:479
uint64_t page[512]
Page address and flags.
Definition: librm.h:435
static void profile_exclude(struct profiler *profiler)
Exclude time from other ongoing profiling results.
Definition: profile.h:184
uint64_t rip
Definition: librm.h:423
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
uint8_t jmp
"jmp" instruction
Definition: librm.h:370
void * ioremap(unsigned long bus_addr, size_t len)
Map bus address as an I/O address.
static struct interrupt64_descriptor idt64[NUM_INT]
The 64-bit interrupt descriptor table.
Definition: librm_mgmt.c:40
#define fls(x)
Find last (i.e.
Definition: strings.h:166
static __always_inline void unsigned long bus_addr
Definition: ecam_io.h:135
__asmcall void check_fxsr(struct i386_all_regs *regs)
Check for FXSAVE/FXRSTOR instruction support.
Definition: librm_mgmt.c:397
#define DBG_LOG
Definition: compiler.h:317
uint64_t r11
Definition: librm.h:412
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void interrupt(int intr, struct interrupt_frame32 *frame32, struct interrupt_frame64 *frame64)
Interrupt handler.
Definition: librm_mgmt.c:250
uint8_t attr
Type and attributes.
Definition: librm.h:336
64-bit interrupt wrapper stack frame
Definition: librm.h:407
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23
A 64-bit interrupt descriptor table register.
Definition: librm.h:306
PROVIDE_IOMAP_INLINE(pages, io_to_bus)
uint16_t sp
Definition: registers.h:27
uint64_t rdi
Definition: librm.h:417
void memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
uint16_t segment
Code segment.
Definition: librm.h:318
String functions.
static struct interrupt32_descriptor idt32[NUM_INT]
The 32-bit interrupt descriptor table.
Definition: librm_mgmt.c:31
Page is present.
Definition: librm.h:441