diff options
Diffstat (limited to 'include/asm-x86')
| -rw-r--r-- | include/asm-x86/Kbuild | 3 | ||||
| -rw-r--r-- | include/asm-x86/bootparam.h | 108 | ||||
| -rw-r--r-- | include/asm-x86/e820.h | 28 | ||||
| -rw-r--r-- | include/asm-x86/e820_32.h | 21 | ||||
| -rw-r--r-- | include/asm-x86/e820_64.h | 20 | ||||
| -rw-r--r-- | include/asm-x86/ist.h | 12 | ||||
| -rw-r--r-- | include/asm-x86/lguest.h | 86 | ||||
| -rw-r--r-- | include/asm-x86/lguest_hcall.h | 71 |
8 files changed, 248 insertions, 101 deletions
diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild index 559830ece755..5e3539c129b9 100644 --- a/include/asm-x86/Kbuild +++ b/include/asm-x86/Kbuild | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | include include/asm-generic/Kbuild.asm | 1 | include include/asm-generic/Kbuild.asm |
| 2 | 2 | ||
| 3 | header-y += boot.h | 3 | header-y += boot.h |
| 4 | header-y += bootparam.h | ||
| 4 | header-y += debugreg.h | 5 | header-y += debugreg.h |
| 5 | header-y += ldt.h | 6 | header-y += ldt.h |
| 6 | header-y += msr-index.h | 7 | header-y += msr-index.h |
| @@ -14,8 +15,10 @@ unifdef-y += a.out_32.h | |||
| 14 | unifdef-y += a.out_64.h | 15 | unifdef-y += a.out_64.h |
| 15 | unifdef-y += byteorder_32.h | 16 | unifdef-y += byteorder_32.h |
| 16 | unifdef-y += byteorder_64.h | 17 | unifdef-y += byteorder_64.h |
| 18 | unifdef-y += e820.h | ||
| 17 | unifdef-y += elf_32.h | 19 | unifdef-y += elf_32.h |
| 18 | unifdef-y += elf_64.h | 20 | unifdef-y += elf_64.h |
| 21 | unifdef-y += ist.h | ||
| 19 | unifdef-y += mce.h | 22 | unifdef-y += mce.h |
| 20 | unifdef-y += msgbuf_32.h | 23 | unifdef-y += msgbuf_32.h |
| 21 | unifdef-y += msgbuf_64.h | 24 | unifdef-y += msgbuf_64.h |
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h index dc031cf44633..19f3ddf2df4b 100644 --- a/include/asm-x86/bootparam.h +++ b/include/asm-x86/bootparam.h | |||
| @@ -10,85 +10,85 @@ | |||
| 10 | #include <video/edid.h> | 10 | #include <video/edid.h> |
| 11 | 11 | ||
| 12 | struct setup_header { | 12 | struct setup_header { |
| 13 | u8 setup_sects; | 13 | __u8 setup_sects; |
| 14 | u16 root_flags; | 14 | __u16 root_flags; |
| 15 | u32 syssize; | 15 | __u32 syssize; |
| 16 | u16 ram_size; | 16 | __u16 ram_size; |
| 17 | #define RAMDISK_IMAGE_START_MASK 0x07FF | 17 | #define RAMDISK_IMAGE_START_MASK 0x07FF |
| 18 | #define RAMDISK_PROMPT_FLAG 0x8000 | 18 | #define RAMDISK_PROMPT_FLAG 0x8000 |
| 19 | #define RAMDISK_LOAD_FLAG 0x4000 | 19 | #define RAMDISK_LOAD_FLAG 0x4000 |
| 20 | u16 vid_mode; | 20 | __u16 vid_mode; |
| 21 | u16 root_dev; | 21 | __u16 root_dev; |
| 22 | u16 boot_flag; | 22 | __u16 boot_flag; |
| 23 | u16 jump; | 23 | __u16 jump; |
| 24 | u32 header; | 24 | __u32 header; |
| 25 | u16 version; | 25 | __u16 version; |
| 26 | u32 realmode_swtch; | 26 | __u32 realmode_swtch; |
| 27 | u16 start_sys; | 27 | __u16 start_sys; |
| 28 | u16 kernel_version; | 28 | __u16 kernel_version; |
| 29 | u8 type_of_loader; | 29 | __u8 type_of_loader; |
| 30 | u8 loadflags; | 30 | __u8 loadflags; |
| 31 | #define LOADED_HIGH (1<<0) | 31 | #define LOADED_HIGH (1<<0) |
| 32 | #define KEEP_SEGMENTS (1<<6) | 32 | #define KEEP_SEGMENTS (1<<6) |
| 33 | #define CAN_USE_HEAP (1<<7) | 33 | #define CAN_USE_HEAP (1<<7) |
| 34 | u16 setup_move_size; | 34 | __u16 setup_move_size; |
| 35 | u32 code32_start; | 35 | __u32 code32_start; |
| 36 | u32 ramdisk_image; | 36 | __u32 ramdisk_image; |
| 37 | u32 ramdisk_size; | 37 | __u32 ramdisk_size; |
| 38 | u32 bootsect_kludge; | 38 | __u32 bootsect_kludge; |
| 39 | u16 heap_end_ptr; | 39 | __u16 heap_end_ptr; |
| 40 | u16 _pad1; | 40 | __u16 _pad1; |
| 41 | u32 cmd_line_ptr; | 41 | __u32 cmd_line_ptr; |
| 42 | u32 initrd_addr_max; | 42 | __u32 initrd_addr_max; |
| 43 | u32 kernel_alignment; | 43 | __u32 kernel_alignment; |
| 44 | u8 relocatable_kernel; | 44 | __u8 relocatable_kernel; |
| 45 | u8 _pad2[3]; | 45 | __u8 _pad2[3]; |
| 46 | u32 cmdline_size; | 46 | __u32 cmdline_size; |
| 47 | u32 hardware_subarch; | 47 | __u32 hardware_subarch; |
| 48 | u64 hardware_subarch_data; | 48 | __u64 hardware_subarch_data; |
| 49 | } __attribute__((packed)); | 49 | } __attribute__((packed)); |
| 50 | 50 | ||
| 51 | struct sys_desc_table { | 51 | struct sys_desc_table { |
| 52 | u16 length; | 52 | __u16 length; |
| 53 | u8 table[14]; | 53 | __u8 table[14]; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | struct efi_info { | 56 | struct efi_info { |
| 57 | u32 _pad1; | 57 | __u32 _pad1; |
| 58 | u32 efi_systab; | 58 | __u32 efi_systab; |
| 59 | u32 efi_memdesc_size; | 59 | __u32 efi_memdesc_size; |
| 60 | u32 efi_memdesc_version; | 60 | __u32 efi_memdesc_version; |
| 61 | u32 efi_memmap; | 61 | __u32 efi_memmap; |
| 62 | u32 efi_memmap_size; | 62 | __u32 efi_memmap_size; |
| 63 | u32 _pad2[2]; | 63 | __u32 _pad2[2]; |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | /* The so-called "zeropage" */ | 66 | /* The so-called "zeropage" */ |
| 67 | struct boot_params { | 67 | struct boot_params { |
| 68 | struct screen_info screen_info; /* 0x000 */ | 68 | struct screen_info screen_info; /* 0x000 */ |
| 69 | struct apm_bios_info apm_bios_info; /* 0x040 */ | 69 | struct apm_bios_info apm_bios_info; /* 0x040 */ |
| 70 | u8 _pad2[12]; /* 0x054 */ | 70 | __u8 _pad2[12]; /* 0x054 */ |
| 71 | struct ist_info ist_info; /* 0x060 */ | 71 | struct ist_info ist_info; /* 0x060 */ |
| 72 | u8 _pad3[16]; /* 0x070 */ | 72 | __u8 _pad3[16]; /* 0x070 */ |
| 73 | u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ | 73 | __u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ |
| 74 | u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ | 74 | __u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ |
| 75 | struct sys_desc_table sys_desc_table; /* 0x0a0 */ | 75 | struct sys_desc_table sys_desc_table; /* 0x0a0 */ |
| 76 | u8 _pad4[144]; /* 0x0b0 */ | 76 | __u8 _pad4[144]; /* 0x0b0 */ |
| 77 | struct edid_info edid_info; /* 0x140 */ | 77 | struct edid_info edid_info; /* 0x140 */ |
| 78 | struct efi_info efi_info; /* 0x1c0 */ | 78 | struct efi_info efi_info; /* 0x1c0 */ |
| 79 | u32 alt_mem_k; /* 0x1e0 */ | 79 | __u32 alt_mem_k; /* 0x1e0 */ |
| 80 | u32 scratch; /* Scratch field! */ /* 0x1e4 */ | 80 | __u32 scratch; /* Scratch field! */ /* 0x1e4 */ |
| 81 | u8 e820_entries; /* 0x1e8 */ | 81 | __u8 e820_entries; /* 0x1e8 */ |
| 82 | u8 eddbuf_entries; /* 0x1e9 */ | 82 | __u8 eddbuf_entries; /* 0x1e9 */ |
| 83 | u8 edd_mbr_sig_buf_entries; /* 0x1ea */ | 83 | __u8 edd_mbr_sig_buf_entries; /* 0x1ea */ |
| 84 | u8 _pad6[6]; /* 0x1eb */ | 84 | __u8 _pad6[6]; /* 0x1eb */ |
| 85 | struct setup_header hdr; /* setup header */ /* 0x1f1 */ | 85 | struct setup_header hdr; /* setup header */ /* 0x1f1 */ |
| 86 | u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; | 86 | __u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; |
| 87 | u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */ | 87 | __u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */ |
| 88 | struct e820entry e820_map[E820MAX]; /* 0x2d0 */ | 88 | struct e820entry e820_map[E820MAX]; /* 0x2d0 */ |
| 89 | u8 _pad8[48]; /* 0xcd0 */ | 89 | __u8 _pad8[48]; /* 0xcd0 */ |
| 90 | struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */ | 90 | struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */ |
| 91 | u8 _pad9[276]; /* 0xeec */ | 91 | __u8 _pad9[276]; /* 0xeec */ |
| 92 | } __attribute__((packed)); | 92 | } __attribute__((packed)); |
| 93 | 93 | ||
| 94 | #endif /* _ASM_BOOTPARAM_H */ | 94 | #endif /* _ASM_BOOTPARAM_H */ |
diff --git a/include/asm-x86/e820.h b/include/asm-x86/e820.h index 5d4d2183e5db..3e214f39fad3 100644 --- a/include/asm-x86/e820.h +++ b/include/asm-x86/e820.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | #ifndef __ASM_E820_H | ||
| 2 | #define __ASM_E820_H | ||
| 3 | #define E820MAP 0x2d0 /* our map */ | ||
| 4 | #define E820MAX 128 /* number of entries in E820MAP */ | ||
| 5 | #define E820NR 0x1e8 /* # entries in E820MAP */ | ||
| 6 | |||
| 7 | #define E820_RAM 1 | ||
| 8 | #define E820_RESERVED 2 | ||
| 9 | #define E820_ACPI 3 | ||
| 10 | #define E820_NVS 4 | ||
| 11 | |||
| 12 | #ifndef __ASSEMBLY__ | ||
| 13 | struct e820entry { | ||
| 14 | __u64 addr; /* start of memory segment */ | ||
| 15 | __u64 size; /* size of memory segment */ | ||
| 16 | __u32 type; /* type of memory segment */ | ||
| 17 | } __attribute__((packed)); | ||
| 18 | |||
| 19 | struct e820map { | ||
| 20 | __u32 nr_map; | ||
| 21 | struct e820entry map[E820MAX]; | ||
| 22 | }; | ||
| 23 | #endif /* __ASSEMBLY__ */ | ||
| 24 | |||
| 25 | #ifdef __KERNEL__ | ||
| 1 | #ifdef CONFIG_X86_32 | 26 | #ifdef CONFIG_X86_32 |
| 2 | # include "e820_32.h" | 27 | # include "e820_32.h" |
| 3 | #else | 28 | #else |
| 4 | # include "e820_64.h" | 29 | # include "e820_64.h" |
| 5 | #endif | 30 | #endif |
| 31 | #endif /* __KERNEL__ */ | ||
| 32 | |||
| 33 | #endif /* __ASM_E820_H */ | ||
diff --git a/include/asm-x86/e820_32.h b/include/asm-x86/e820_32.h index cf67dbb1db79..03f60c690c8a 100644 --- a/include/asm-x86/e820_32.h +++ b/include/asm-x86/e820_32.h | |||
| @@ -12,30 +12,10 @@ | |||
| 12 | #ifndef __E820_HEADER | 12 | #ifndef __E820_HEADER |
| 13 | #define __E820_HEADER | 13 | #define __E820_HEADER |
| 14 | 14 | ||
| 15 | #define E820MAP 0x2d0 /* our map */ | ||
| 16 | #define E820MAX 128 /* number of entries in E820MAP */ | ||
| 17 | #define E820NR 0x1e8 /* # entries in E820MAP */ | ||
| 18 | |||
| 19 | #define E820_RAM 1 | ||
| 20 | #define E820_RESERVED 2 | ||
| 21 | #define E820_ACPI 3 | ||
| 22 | #define E820_NVS 4 | ||
| 23 | |||
| 24 | #define HIGH_MEMORY (1024*1024) | 15 | #define HIGH_MEMORY (1024*1024) |
| 25 | 16 | ||
| 26 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
| 27 | 18 | ||
| 28 | struct e820entry { | ||
| 29 | u64 addr; /* start of memory segment */ | ||
| 30 | u64 size; /* size of memory segment */ | ||
| 31 | u32 type; /* type of memory segment */ | ||
| 32 | } __attribute__((packed)); | ||
| 33 | |||
| 34 | struct e820map { | ||
| 35 | u32 nr_map; | ||
| 36 | struct e820entry map[E820MAX]; | ||
| 37 | }; | ||
| 38 | |||
| 39 | extern struct e820map e820; | 19 | extern struct e820map e820; |
| 40 | 20 | ||
| 41 | extern int e820_all_mapped(unsigned long start, unsigned long end, | 21 | extern int e820_all_mapped(unsigned long start, unsigned long end, |
| @@ -56,5 +36,4 @@ static inline void e820_mark_nosave_regions(void) | |||
| 56 | #endif | 36 | #endif |
| 57 | 37 | ||
| 58 | #endif/*!__ASSEMBLY__*/ | 38 | #endif/*!__ASSEMBLY__*/ |
| 59 | |||
| 60 | #endif/*__E820_HEADER*/ | 39 | #endif/*__E820_HEADER*/ |
diff --git a/include/asm-x86/e820_64.h b/include/asm-x86/e820_64.h index 3486e701bd86..0bd4787a5d57 100644 --- a/include/asm-x86/e820_64.h +++ b/include/asm-x86/e820_64.h | |||
| @@ -11,27 +11,7 @@ | |||
| 11 | #ifndef __E820_HEADER | 11 | #ifndef __E820_HEADER |
| 12 | #define __E820_HEADER | 12 | #define __E820_HEADER |
| 13 | 13 | ||
| 14 | #define E820MAP 0x2d0 /* our map */ | ||
| 15 | #define E820MAX 128 /* number of entries in E820MAP */ | ||
| 16 | #define E820NR 0x1e8 /* # entries in E820MAP */ | ||
| 17 | |||
| 18 | #define E820_RAM 1 | ||
| 19 | #define E820_RESERVED 2 | ||
| 20 | #define E820_ACPI 3 | ||
| 21 | #define E820_NVS 4 | ||
| 22 | |||
| 23 | #ifndef __ASSEMBLY__ | 14 | #ifndef __ASSEMBLY__ |
| 24 | struct e820entry { | ||
| 25 | u64 addr; /* start of memory segment */ | ||
| 26 | u64 size; /* size of memory segment */ | ||
| 27 | u32 type; /* type of memory segment */ | ||
| 28 | } __attribute__((packed)); | ||
| 29 | |||
| 30 | struct e820map { | ||
| 31 | u32 nr_map; | ||
| 32 | struct e820entry map[E820MAX]; | ||
| 33 | }; | ||
| 34 | |||
| 35 | extern unsigned long find_e820_area(unsigned long start, unsigned long end, | 15 | extern unsigned long find_e820_area(unsigned long start, unsigned long end, |
| 36 | unsigned size); | 16 | unsigned size); |
| 37 | extern void add_memory_region(unsigned long start, unsigned long size, | 17 | extern void add_memory_region(unsigned long start, unsigned long size, |
diff --git a/include/asm-x86/ist.h b/include/asm-x86/ist.h index ef2003ebc6f9..6ec6ceed95a7 100644 --- a/include/asm-x86/ist.h +++ b/include/asm-x86/ist.h | |||
| @@ -17,17 +17,17 @@ | |||
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | #ifdef __KERNEL__ | ||
| 21 | |||
| 22 | #include <linux/types.h> | 20 | #include <linux/types.h> |
| 23 | 21 | ||
| 24 | struct ist_info { | 22 | struct ist_info { |
| 25 | u32 signature; | 23 | __u32 signature; |
| 26 | u32 command; | 24 | __u32 command; |
| 27 | u32 event; | 25 | __u32 event; |
| 28 | u32 perf_level; | 26 | __u32 perf_level; |
| 29 | }; | 27 | }; |
| 30 | 28 | ||
| 29 | #ifdef __KERNEL__ | ||
| 30 | |||
| 31 | extern struct ist_info ist_info; | 31 | extern struct ist_info ist_info; |
| 32 | 32 | ||
| 33 | #endif /* __KERNEL__ */ | 33 | #endif /* __KERNEL__ */ |
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h new file mode 100644 index 000000000000..ccd338460811 --- /dev/null +++ b/include/asm-x86/lguest.h | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | #ifndef _X86_LGUEST_H | ||
| 2 | #define _X86_LGUEST_H | ||
| 3 | |||
| 4 | #define GDT_ENTRY_LGUEST_CS 10 | ||
| 5 | #define GDT_ENTRY_LGUEST_DS 11 | ||
| 6 | #define LGUEST_CS (GDT_ENTRY_LGUEST_CS * 8) | ||
| 7 | #define LGUEST_DS (GDT_ENTRY_LGUEST_DS * 8) | ||
| 8 | |||
| 9 | #ifndef __ASSEMBLY__ | ||
| 10 | #include <asm/desc.h> | ||
| 11 | |||
| 12 | #define GUEST_PL 1 | ||
| 13 | |||
| 14 | /* Every guest maps the core switcher code. */ | ||
| 15 | #define SHARED_SWITCHER_PAGES \ | ||
| 16 | DIV_ROUND_UP(end_switcher_text - start_switcher_text, PAGE_SIZE) | ||
| 17 | /* Pages for switcher itself, then two pages per cpu */ | ||
| 18 | #define TOTAL_SWITCHER_PAGES (SHARED_SWITCHER_PAGES + 2 * NR_CPUS) | ||
| 19 | |||
| 20 | /* We map at -4M for ease of mapping into the guest (one PTE page). */ | ||
| 21 | #define SWITCHER_ADDR 0xFFC00000 | ||
| 22 | |||
| 23 | /* Found in switcher.S */ | ||
| 24 | extern unsigned long default_idt_entries[]; | ||
| 25 | |||
| 26 | struct lguest_regs | ||
| 27 | { | ||
| 28 | /* Manually saved part. */ | ||
| 29 | unsigned long eax, ebx, ecx, edx; | ||
| 30 | unsigned long esi, edi, ebp; | ||
| 31 | unsigned long gs; | ||
| 32 | unsigned long fs, ds, es; | ||
| 33 | unsigned long trapnum, errcode; | ||
| 34 | /* Trap pushed part */ | ||
| 35 | unsigned long eip; | ||
| 36 | unsigned long cs; | ||
| 37 | unsigned long eflags; | ||
| 38 | unsigned long esp; | ||
| 39 | unsigned long ss; | ||
| 40 | }; | ||
| 41 | |||
| 42 | /* This is a guest-specific page (mapped ro) into the guest. */ | ||
| 43 | struct lguest_ro_state | ||
| 44 | { | ||
| 45 | /* Host information we need to restore when we switch back. */ | ||
| 46 | u32 host_cr3; | ||
| 47 | struct Xgt_desc_struct host_idt_desc; | ||
| 48 | struct Xgt_desc_struct host_gdt_desc; | ||
| 49 | u32 host_sp; | ||
| 50 | |||
| 51 | /* Fields which are used when guest is running. */ | ||
| 52 | struct Xgt_desc_struct guest_idt_desc; | ||
| 53 | struct Xgt_desc_struct guest_gdt_desc; | ||
| 54 | struct i386_hw_tss guest_tss; | ||
| 55 | struct desc_struct guest_idt[IDT_ENTRIES]; | ||
| 56 | struct desc_struct guest_gdt[GDT_ENTRIES]; | ||
| 57 | }; | ||
| 58 | |||
| 59 | struct lguest_arch | ||
| 60 | { | ||
| 61 | /* The GDT entries copied into lguest_ro_state when running. */ | ||
| 62 | struct desc_struct gdt[GDT_ENTRIES]; | ||
| 63 | |||
| 64 | /* The IDT entries: some copied into lguest_ro_state when running. */ | ||
| 65 | struct desc_struct idt[IDT_ENTRIES]; | ||
| 66 | |||
| 67 | /* The address of the last guest-visible pagefault (ie. cr2). */ | ||
| 68 | unsigned long last_pagefault; | ||
| 69 | }; | ||
| 70 | |||
| 71 | static inline void lguest_set_ts(void) | ||
| 72 | { | ||
| 73 | u32 cr0; | ||
| 74 | |||
| 75 | cr0 = read_cr0(); | ||
| 76 | if (!(cr0 & 8)) | ||
| 77 | write_cr0(cr0|8); | ||
| 78 | } | ||
| 79 | |||
| 80 | /* Full 4G segment descriptors, suitable for CS and DS. */ | ||
| 81 | #define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00}) | ||
| 82 | #define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300}) | ||
| 83 | |||
| 84 | #endif /* __ASSEMBLY__ */ | ||
| 85 | |||
| 86 | #endif | ||
diff --git a/include/asm-x86/lguest_hcall.h b/include/asm-x86/lguest_hcall.h new file mode 100644 index 000000000000..f948491eb56a --- /dev/null +++ b/include/asm-x86/lguest_hcall.h | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | /* Architecture specific portion of the lguest hypercalls */ | ||
| 2 | #ifndef _X86_LGUEST_HCALL_H | ||
| 3 | #define _X86_LGUEST_HCALL_H | ||
| 4 | |||
| 5 | #define LHCALL_FLUSH_ASYNC 0 | ||
| 6 | #define LHCALL_LGUEST_INIT 1 | ||
| 7 | #define LHCALL_CRASH 2 | ||
| 8 | #define LHCALL_LOAD_GDT 3 | ||
| 9 | #define LHCALL_NEW_PGTABLE 4 | ||
| 10 | #define LHCALL_FLUSH_TLB 5 | ||
| 11 | #define LHCALL_LOAD_IDT_ENTRY 6 | ||
| 12 | #define LHCALL_SET_STACK 7 | ||
| 13 | #define LHCALL_TS 8 | ||
| 14 | #define LHCALL_SET_CLOCKEVENT 9 | ||
| 15 | #define LHCALL_HALT 10 | ||
| 16 | #define LHCALL_SET_PTE 14 | ||
| 17 | #define LHCALL_SET_PMD 15 | ||
| 18 | #define LHCALL_LOAD_TLS 16 | ||
| 19 | #define LHCALL_NOTIFY 17 | ||
| 20 | |||
| 21 | /*G:031 First, how does our Guest contact the Host to ask for privileged | ||
| 22 | * operations? There are two ways: the direct way is to make a "hypercall", | ||
| 23 | * to make requests of the Host Itself. | ||
| 24 | * | ||
| 25 | * Our hypercall mechanism uses the highest unused trap code (traps 32 and | ||
| 26 | * above are used by real hardware interrupts). Seventeen hypercalls are | ||
| 27 | * available: the hypercall number is put in the %eax register, and the | ||
| 28 | * arguments (when required) are placed in %edx, %ebx and %ecx. If a return | ||
| 29 | * value makes sense, it's returned in %eax. | ||
| 30 | * | ||
| 31 | * Grossly invalid calls result in Sudden Death at the hands of the vengeful | ||
| 32 | * Host, rather than returning failure. This reflects Winston Churchill's | ||
| 33 | * definition of a gentleman: "someone who is only rude intentionally". */ | ||
| 34 | #define LGUEST_TRAP_ENTRY 0x1F | ||
| 35 | |||
| 36 | #ifndef __ASSEMBLY__ | ||
| 37 | #include <asm/hw_irq.h> | ||
| 38 | |||
| 39 | static inline unsigned long | ||
| 40 | hcall(unsigned long call, | ||
| 41 | unsigned long arg1, unsigned long arg2, unsigned long arg3) | ||
| 42 | { | ||
| 43 | /* "int" is the Intel instruction to trigger a trap. */ | ||
| 44 | asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY) | ||
| 45 | /* The call is in %eax (aka "a"), and can be replaced */ | ||
| 46 | : "=a"(call) | ||
| 47 | /* The other arguments are in %eax, %edx, %ebx & %ecx */ | ||
| 48 | : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3) | ||
| 49 | /* "memory" means this might write somewhere in memory. | ||
| 50 | * This isn't true for all calls, but it's safe to tell | ||
| 51 | * gcc that it might happen so it doesn't get clever. */ | ||
| 52 | : "memory"); | ||
| 53 | return call; | ||
| 54 | } | ||
| 55 | /*:*/ | ||
| 56 | |||
| 57 | void async_hcall(unsigned long call, | ||
| 58 | unsigned long arg1, unsigned long arg2, unsigned long arg3); | ||
| 59 | |||
| 60 | /* Can't use our min() macro here: needs to be a constant */ | ||
| 61 | #define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32) | ||
| 62 | |||
| 63 | #define LHCALL_RING_SIZE 64 | ||
| 64 | struct hcall_args | ||
| 65 | { | ||
| 66 | /* These map directly onto eax, ebx, ecx, edx in struct lguest_regs */ | ||
| 67 | unsigned long arg0, arg2, arg3, arg1; | ||
| 68 | }; | ||
| 69 | |||
| 70 | #endif /* !__ASSEMBLY__ */ | ||
| 71 | #endif /* _I386_LGUEST_HCALL_H */ | ||
