Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 1 | /* Paravirtualization interfaces |
| 2 | Copyright (C) 2006 Rusty Russell IBM Corporation |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by |
| 6 | the Free Software Foundation; either version 2 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | #include <linux/errno.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/efi.h> |
| 21 | #include <linux/bcd.h> |
Jeremy Fitzhardinge | ce6234b | 2007-05-02 19:27:15 +0200 | [diff] [blame] | 22 | #include <linux/highmem.h> |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 23 | |
| 24 | #include <asm/bug.h> |
| 25 | #include <asm/paravirt.h> |
| 26 | #include <asm/desc.h> |
| 27 | #include <asm/setup.h> |
| 28 | #include <asm/arch_hooks.h> |
| 29 | #include <asm/time.h> |
| 30 | #include <asm/irq.h> |
| 31 | #include <asm/delay.h> |
Rusty Russell | 13623d7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 32 | #include <asm/fixmap.h> |
| 33 | #include <asm/apic.h> |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 34 | #include <asm/tlbflush.h> |
Zachary Amsden | 6cb9a83 | 2007-03-05 00:30:35 -0800 | [diff] [blame] | 35 | #include <asm/timer.h> |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 36 | |
| 37 | /* nop stub */ |
Jeremy Fitzhardinge | 4587623 | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 38 | void _paravirt_nop(void) |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 39 | { |
| 40 | } |
| 41 | |
| 42 | static void __init default_banner(void) |
| 43 | { |
| 44 | printk(KERN_INFO "Booting paravirtualized kernel on %s\n", |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 45 | pv_info.name); |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | char *memory_setup(void) |
| 49 | { |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 50 | return pv_init_ops.memory_setup(); |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 53 | /* Simple instruction patching code. */ |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 54 | #define DEF_NATIVE(ops, name, code) \ |
| 55 | extern const char start_##ops##_##name[], end_##ops##_##name[]; \ |
| 56 | asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":") |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 57 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 58 | DEF_NATIVE(pv_irq_ops, irq_disable, "cli"); |
| 59 | DEF_NATIVE(pv_irq_ops, irq_enable, "sti"); |
| 60 | DEF_NATIVE(pv_irq_ops, restore_fl, "push %eax; popf"); |
| 61 | DEF_NATIVE(pv_irq_ops, save_fl, "pushf; pop %eax"); |
| 62 | DEF_NATIVE(pv_cpu_ops, iret, "iret"); |
Glauber de Oliveira Costa | 6abcd98 | 2008-01-30 13:30:33 +0100 | [diff] [blame] | 63 | DEF_NATIVE(pv_cpu_ops, irq_enable_syscall_ret, "sti; sysexit"); |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 64 | DEF_NATIVE(pv_mmu_ops, read_cr2, "mov %cr2, %eax"); |
| 65 | DEF_NATIVE(pv_mmu_ops, write_cr3, "mov %eax, %cr3"); |
| 66 | DEF_NATIVE(pv_mmu_ops, read_cr3, "mov %cr3, %eax"); |
| 67 | DEF_NATIVE(pv_cpu_ops, clts, "clts"); |
| 68 | DEF_NATIVE(pv_cpu_ops, read_tsc, "rdtsc"); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 69 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 70 | /* Undefined instruction for dealing with missing ops pointers. */ |
| 71 | static const unsigned char ud2a[] = { 0x0f, 0x0b }; |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 72 | |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 73 | static unsigned native_patch(u8 type, u16 clobbers, void *ibuf, |
| 74 | unsigned long addr, unsigned len) |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 75 | { |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 76 | const unsigned char *start, *end; |
| 77 | unsigned ret; |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 78 | |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 79 | switch(type) { |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 80 | #define SITE(ops, x) \ |
| 81 | case PARAVIRT_PATCH(ops.x): \ |
| 82 | start = start_##ops##_##x; \ |
| 83 | end = end_##ops##_##x; \ |
| 84 | goto patch_site |
| 85 | |
| 86 | SITE(pv_irq_ops, irq_disable); |
| 87 | SITE(pv_irq_ops, irq_enable); |
| 88 | SITE(pv_irq_ops, restore_fl); |
| 89 | SITE(pv_irq_ops, save_fl); |
| 90 | SITE(pv_cpu_ops, iret); |
Glauber de Oliveira Costa | 6abcd98 | 2008-01-30 13:30:33 +0100 | [diff] [blame] | 91 | SITE(pv_cpu_ops, irq_enable_syscall_ret); |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 92 | SITE(pv_mmu_ops, read_cr2); |
| 93 | SITE(pv_mmu_ops, read_cr3); |
| 94 | SITE(pv_mmu_ops, write_cr3); |
| 95 | SITE(pv_cpu_ops, clts); |
| 96 | SITE(pv_cpu_ops, read_tsc); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 97 | #undef SITE |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 98 | |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 99 | patch_site: |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 100 | ret = paravirt_patch_insns(ibuf, len, start, end); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 101 | break; |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 102 | |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 103 | default: |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 104 | ret = paravirt_patch_default(type, clobbers, ibuf, addr, len); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 105 | break; |
| 106 | } |
| 107 | |
| 108 | return ret; |
| 109 | } |
| 110 | |
| 111 | unsigned paravirt_patch_nop(void) |
| 112 | { |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | unsigned paravirt_patch_ignore(unsigned len) |
| 117 | { |
| 118 | return len; |
| 119 | } |
| 120 | |
Andi Kleen | 19d36cc | 2007-07-22 11:12:31 +0200 | [diff] [blame] | 121 | struct branch { |
| 122 | unsigned char opcode; |
| 123 | u32 delta; |
| 124 | } __attribute__((packed)); |
| 125 | |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 126 | unsigned paravirt_patch_call(void *insnbuf, |
| 127 | const void *target, u16 tgt_clobbers, |
| 128 | unsigned long addr, u16 site_clobbers, |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 129 | unsigned len) |
| 130 | { |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 131 | struct branch *b = insnbuf; |
| 132 | unsigned long delta = (unsigned long)target - (addr+5); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 133 | |
| 134 | if (tgt_clobbers & ~site_clobbers) |
| 135 | return len; /* target would clobber too much for this site */ |
| 136 | if (len < 5) |
| 137 | return len; /* call too long for patch site */ |
| 138 | |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 139 | b->opcode = 0xe8; /* call */ |
| 140 | b->delta = delta; |
| 141 | BUILD_BUG_ON(sizeof(*b) != 5); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 142 | |
| 143 | return 5; |
| 144 | } |
| 145 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 146 | unsigned paravirt_patch_jmp(void *insnbuf, const void *target, |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 147 | unsigned long addr, unsigned len) |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 148 | { |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 149 | struct branch *b = insnbuf; |
| 150 | unsigned long delta = (unsigned long)target - (addr+5); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 151 | |
| 152 | if (len < 5) |
| 153 | return len; /* call too long for patch site */ |
| 154 | |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 155 | b->opcode = 0xe9; /* jmp */ |
| 156 | b->delta = delta; |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 157 | |
| 158 | return 5; |
| 159 | } |
| 160 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 161 | /* Neat trick to map patch type back to the call within the |
| 162 | * corresponding structure. */ |
| 163 | static void *get_call_destination(u8 type) |
| 164 | { |
| 165 | struct paravirt_patch_template tmpl = { |
| 166 | .pv_init_ops = pv_init_ops, |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 167 | .pv_time_ops = pv_time_ops, |
| 168 | .pv_cpu_ops = pv_cpu_ops, |
| 169 | .pv_irq_ops = pv_irq_ops, |
| 170 | .pv_apic_ops = pv_apic_ops, |
| 171 | .pv_mmu_ops = pv_mmu_ops, |
| 172 | }; |
| 173 | return *((void **)&tmpl + type); |
| 174 | } |
| 175 | |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 176 | unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf, |
| 177 | unsigned long addr, unsigned len) |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 178 | { |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 179 | void *opfunc = get_call_destination(type); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 180 | unsigned ret; |
| 181 | |
| 182 | if (opfunc == NULL) |
| 183 | /* If there's no function, patch it with a ud2a (BUG) */ |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 184 | ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a)); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 185 | else if (opfunc == paravirt_nop) |
| 186 | /* If the operation is a nop, then nop the callsite */ |
| 187 | ret = paravirt_patch_nop(); |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 188 | else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) || |
Glauber de Oliveira Costa | 6abcd98 | 2008-01-30 13:30:33 +0100 | [diff] [blame] | 189 | type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_syscall_ret)) |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 190 | /* If operation requires a jmp, then jmp */ |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 191 | ret = paravirt_patch_jmp(insnbuf, opfunc, addr, len); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 192 | else |
| 193 | /* Otherwise call the function; assume target could |
| 194 | clobber any caller-save reg */ |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 195 | ret = paravirt_patch_call(insnbuf, opfunc, CLBR_ANY, |
| 196 | addr, clobbers, len); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 197 | |
| 198 | return ret; |
| 199 | } |
| 200 | |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 201 | unsigned paravirt_patch_insns(void *insnbuf, unsigned len, |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 202 | const char *start, const char *end) |
| 203 | { |
| 204 | unsigned insn_len = end - start; |
| 205 | |
| 206 | if (insn_len > len || start == NULL) |
| 207 | insn_len = len; |
| 208 | else |
Andi Kleen | ab144f5 | 2007-08-10 22:31:03 +0200 | [diff] [blame] | 209 | memcpy(insnbuf, start, insn_len); |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 210 | |
Rusty Russell | 139ec7c | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 211 | return insn_len; |
| 212 | } |
| 213 | |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 214 | void init_IRQ(void) |
| 215 | { |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 216 | pv_irq_ops.init_IRQ(); |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 217 | } |
| 218 | |
Andi Kleen | 1a1eecd | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 219 | static void native_flush_tlb(void) |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 220 | { |
| 221 | __native_flush_tlb(); |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | * Global pages have to be flushed a bit differently. Not a real |
| 226 | * performance problem because this does not happen often. |
| 227 | */ |
Andi Kleen | 1a1eecd | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 228 | static void native_flush_tlb_global(void) |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 229 | { |
| 230 | __native_flush_tlb_global(); |
| 231 | } |
| 232 | |
Jeremy Fitzhardinge | 63f7027 | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 233 | static void native_flush_tlb_single(unsigned long addr) |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 234 | { |
| 235 | __native_flush_tlb_single(addr); |
| 236 | } |
| 237 | |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 238 | /* These are in entry.S */ |
Andi Kleen | 1a1eecd | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 239 | extern void native_iret(void); |
Glauber de Oliveira Costa | 6abcd98 | 2008-01-30 13:30:33 +0100 | [diff] [blame] | 240 | extern void native_irq_enable_syscall_ret(void); |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 241 | |
| 242 | static int __init print_banner(void) |
| 243 | { |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 244 | pv_init_ops.banner(); |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 245 | return 0; |
| 246 | } |
| 247 | core_initcall(print_banner); |
| 248 | |
Jeremy Fitzhardinge | d572929 | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 249 | static struct resource reserve_ioports = { |
| 250 | .start = 0, |
| 251 | .end = IO_SPACE_LIMIT, |
| 252 | .name = "paravirt-ioport", |
| 253 | .flags = IORESOURCE_IO | IORESOURCE_BUSY, |
| 254 | }; |
| 255 | |
| 256 | static struct resource reserve_iomem = { |
| 257 | .start = 0, |
| 258 | .end = -1, |
| 259 | .name = "paravirt-iomem", |
| 260 | .flags = IORESOURCE_MEM | IORESOURCE_BUSY, |
| 261 | }; |
| 262 | |
| 263 | /* |
| 264 | * Reserve the whole legacy IO space to prevent any legacy drivers |
| 265 | * from wasting time probing for their hardware. This is a fairly |
| 266 | * brute-force approach to disabling all non-virtual drivers. |
| 267 | * |
| 268 | * Note that this must be called very early to have any effect. |
| 269 | */ |
| 270 | int paravirt_disable_iospace(void) |
| 271 | { |
| 272 | int ret; |
| 273 | |
| 274 | ret = request_resource(&ioport_resource, &reserve_ioports); |
| 275 | if (ret == 0) { |
| 276 | ret = request_resource(&iomem_resource, &reserve_iomem); |
| 277 | if (ret) |
| 278 | release_resource(&reserve_ioports); |
| 279 | } |
| 280 | |
| 281 | return ret; |
| 282 | } |
| 283 | |
Jeremy Fitzhardinge | 8965c1c | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 284 | static DEFINE_PER_CPU(enum paravirt_lazy_mode, paravirt_lazy_mode) = PARAVIRT_LAZY_NONE; |
| 285 | |
| 286 | static inline void enter_lazy(enum paravirt_lazy_mode mode) |
| 287 | { |
| 288 | BUG_ON(x86_read_percpu(paravirt_lazy_mode) != PARAVIRT_LAZY_NONE); |
| 289 | BUG_ON(preemptible()); |
| 290 | |
| 291 | x86_write_percpu(paravirt_lazy_mode, mode); |
| 292 | } |
| 293 | |
| 294 | void paravirt_leave_lazy(enum paravirt_lazy_mode mode) |
| 295 | { |
| 296 | BUG_ON(x86_read_percpu(paravirt_lazy_mode) != mode); |
| 297 | BUG_ON(preemptible()); |
| 298 | |
| 299 | x86_write_percpu(paravirt_lazy_mode, PARAVIRT_LAZY_NONE); |
| 300 | } |
| 301 | |
| 302 | void paravirt_enter_lazy_mmu(void) |
| 303 | { |
| 304 | enter_lazy(PARAVIRT_LAZY_MMU); |
| 305 | } |
| 306 | |
| 307 | void paravirt_leave_lazy_mmu(void) |
| 308 | { |
| 309 | paravirt_leave_lazy(PARAVIRT_LAZY_MMU); |
| 310 | } |
| 311 | |
| 312 | void paravirt_enter_lazy_cpu(void) |
| 313 | { |
| 314 | enter_lazy(PARAVIRT_LAZY_CPU); |
| 315 | } |
| 316 | |
| 317 | void paravirt_leave_lazy_cpu(void) |
| 318 | { |
| 319 | paravirt_leave_lazy(PARAVIRT_LAZY_CPU); |
| 320 | } |
| 321 | |
| 322 | enum paravirt_lazy_mode paravirt_get_lazy_mode(void) |
| 323 | { |
| 324 | return x86_read_percpu(paravirt_lazy_mode); |
| 325 | } |
| 326 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 327 | struct pv_info pv_info = { |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 328 | .name = "bare hardware", |
| 329 | .paravirt_enabled = 0, |
| 330 | .kernel_rpl = 0, |
Jeremy Fitzhardinge | 5311ab6 | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 331 | .shared_kernel_pmd = 1, /* Only used when CONFIG_X86_PAE is set */ |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 332 | }; |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 333 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 334 | struct pv_init_ops pv_init_ops = { |
| 335 | .patch = native_patch, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 336 | .banner = default_banner, |
Jeremy Fitzhardinge | 4587623 | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 337 | .arch_setup = paravirt_nop, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 338 | .memory_setup = machine_specific_memory_setup, |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 339 | }; |
| 340 | |
| 341 | struct pv_time_ops pv_time_ops = { |
| 342 | .time_init = hpet_time_init, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 343 | .get_wallclock = native_get_wallclock, |
| 344 | .set_wallclock = native_set_wallclock, |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 345 | .sched_clock = native_sched_clock, |
| 346 | .get_cpu_khz = native_calculate_cpu_khz, |
| 347 | }; |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 348 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 349 | struct pv_irq_ops pv_irq_ops = { |
| 350 | .init_IRQ = native_init_IRQ, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 351 | .save_fl = native_save_fl, |
| 352 | .restore_fl = native_restore_fl, |
| 353 | .irq_disable = native_irq_disable, |
| 354 | .irq_enable = native_irq_enable, |
| 355 | .safe_halt = native_safe_halt, |
| 356 | .halt = native_halt, |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 357 | }; |
| 358 | |
| 359 | struct pv_cpu_ops pv_cpu_ops = { |
| 360 | .cpuid = native_cpuid, |
| 361 | .get_debugreg = native_get_debugreg, |
| 362 | .set_debugreg = native_set_debugreg, |
| 363 | .clts = native_clts, |
| 364 | .read_cr0 = native_read_cr0, |
| 365 | .write_cr0 = native_write_cr0, |
| 366 | .read_cr4 = native_read_cr4, |
| 367 | .read_cr4_safe = native_read_cr4_safe, |
| 368 | .write_cr4 = native_write_cr4, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 369 | .wbinvd = native_wbinvd, |
Rusty Russell | 90a0a06 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 370 | .read_msr = native_read_msr_safe, |
| 371 | .write_msr = native_write_msr_safe, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 372 | .read_tsc = native_read_tsc, |
| 373 | .read_pmc = native_read_pmc, |
| 374 | .load_tr_desc = native_load_tr_desc, |
| 375 | .set_ldt = native_set_ldt, |
| 376 | .load_gdt = native_load_gdt, |
| 377 | .load_idt = native_load_idt, |
| 378 | .store_gdt = native_store_gdt, |
| 379 | .store_idt = native_store_idt, |
| 380 | .store_tr = native_store_tr, |
| 381 | .load_tls = native_load_tls, |
Rusty Russell | 90a0a06 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 382 | .write_ldt_entry = write_dt_entry, |
Glauber de Oliveira Costa | 014b15b | 2008-01-30 13:31:13 +0100 | [diff] [blame^] | 383 | .write_gdt_entry = native_write_gdt_entry, |
Glauber de Oliveira Costa | 8d94734 | 2008-01-30 13:31:12 +0100 | [diff] [blame] | 384 | .write_idt_entry = native_write_idt_entry, |
H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 385 | .load_sp0 = native_load_sp0, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 386 | |
Glauber de Oliveira Costa | 6abcd98 | 2008-01-30 13:30:33 +0100 | [diff] [blame] | 387 | .irq_enable_syscall_ret = native_irq_enable_syscall_ret, |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 388 | .iret = native_iret, |
| 389 | |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 390 | .set_iopl_mask = native_set_iopl_mask, |
| 391 | .io_delay = native_io_delay, |
Jeremy Fitzhardinge | 8965c1c | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 392 | |
| 393 | .lazy_mode = { |
| 394 | .enter = paravirt_nop, |
| 395 | .leave = paravirt_nop, |
| 396 | }, |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 397 | }; |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 398 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 399 | struct pv_apic_ops pv_apic_ops = { |
Rusty Russell | 13623d7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 400 | #ifdef CONFIG_X86_LOCAL_APIC |
| 401 | .apic_write = native_apic_write, |
| 402 | .apic_write_atomic = native_apic_write_atomic, |
| 403 | .apic_read = native_apic_read, |
Zachary Amsden | bbab4f3 | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 404 | .setup_boot_clock = setup_boot_APIC_clock, |
| 405 | .setup_secondary_clock = setup_secondary_APIC_clock, |
Jeremy Fitzhardinge | 0260c19 | 2007-05-02 19:27:18 +0200 | [diff] [blame] | 406 | .startup_ipi_hook = paravirt_nop, |
Rusty Russell | 13623d7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 407 | #endif |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 408 | }; |
Rusty Russell | 13623d7 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 409 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 410 | struct pv_mmu_ops pv_mmu_ops = { |
Jeremy Fitzhardinge | b239fb2 | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 411 | .pagetable_setup_start = native_pagetable_setup_start, |
| 412 | .pagetable_setup_done = native_pagetable_setup_done, |
| 413 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 414 | .read_cr2 = native_read_cr2, |
| 415 | .write_cr2 = native_write_cr2, |
| 416 | .read_cr3 = native_read_cr3, |
| 417 | .write_cr3 = native_write_cr3, |
| 418 | |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 419 | .flush_tlb_user = native_flush_tlb, |
| 420 | .flush_tlb_kernel = native_flush_tlb_global, |
| 421 | .flush_tlb_single = native_flush_tlb_single, |
Jeremy Fitzhardinge | d4c1047 | 2007-05-02 19:27:15 +0200 | [diff] [blame] | 422 | .flush_tlb_others = native_flush_tlb_others, |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 423 | |
Jeremy Fitzhardinge | 4587623 | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 424 | .alloc_pt = paravirt_nop, |
| 425 | .alloc_pd = paravirt_nop, |
| 426 | .alloc_pd_clone = paravirt_nop, |
| 427 | .release_pt = paravirt_nop, |
| 428 | .release_pd = paravirt_nop, |
Zachary Amsden | c119ecc | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 429 | |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 430 | .set_pte = native_set_pte, |
| 431 | .set_pte_at = native_set_pte_at, |
| 432 | .set_pmd = native_set_pmd, |
Jeremy Fitzhardinge | 4587623 | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 433 | .pte_update = paravirt_nop, |
| 434 | .pte_update_defer = paravirt_nop, |
Jeremy Fitzhardinge | 3dc494e | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 435 | |
Jeremy Fitzhardinge | ce6234b | 2007-05-02 19:27:15 +0200 | [diff] [blame] | 436 | #ifdef CONFIG_HIGHPTE |
| 437 | .kmap_atomic_pte = kmap_atomic, |
| 438 | #endif |
| 439 | |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 440 | #ifdef CONFIG_X86_PAE |
| 441 | .set_pte_atomic = native_set_pte_atomic, |
| 442 | .set_pte_present = native_set_pte_present, |
| 443 | .set_pud = native_set_pud, |
| 444 | .pte_clear = native_pte_clear, |
| 445 | .pmd_clear = native_pmd_clear, |
Jeremy Fitzhardinge | 3dc494e | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 446 | |
| 447 | .pmd_val = native_pmd_val, |
| 448 | .make_pmd = native_make_pmd, |
Rusty Russell | da181a8 | 2006-12-07 02:14:08 +0100 | [diff] [blame] | 449 | #endif |
| 450 | |
Jeremy Fitzhardinge | 3dc494e | 2007-05-02 19:27:13 +0200 | [diff] [blame] | 451 | .pte_val = native_pte_val, |
| 452 | .pgd_val = native_pgd_val, |
| 453 | |
| 454 | .make_pte = native_make_pte, |
| 455 | .make_pgd = native_make_pgd, |
| 456 | |
Jeremy Fitzhardinge | d6dd61c | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 457 | .dup_mmap = paravirt_nop, |
| 458 | .exit_mmap = paravirt_nop, |
| 459 | .activate_mm = paravirt_nop, |
Jeremy Fitzhardinge | 8965c1c | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 460 | |
| 461 | .lazy_mode = { |
| 462 | .enter = paravirt_nop, |
| 463 | .leave = paravirt_nop, |
| 464 | }, |
Rusty Russell | d3561b7 | 2006-12-07 02:14:07 +0100 | [diff] [blame] | 465 | }; |
Ingo Molnar | 0dbe5a1 | 2007-01-22 20:40:36 -0800 | [diff] [blame] | 466 | |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 467 | EXPORT_SYMBOL_GPL(pv_time_ops); |
Jeremy Fitzhardinge | f97b895 | 2007-11-28 16:22:11 -0800 | [diff] [blame] | 468 | EXPORT_SYMBOL (pv_cpu_ops); |
| 469 | EXPORT_SYMBOL (pv_mmu_ops); |
Jeremy Fitzhardinge | 93b1eab | 2007-10-16 11:51:29 -0700 | [diff] [blame] | 470 | EXPORT_SYMBOL_GPL(pv_apic_ops); |
| 471 | EXPORT_SYMBOL_GPL(pv_info); |
| 472 | EXPORT_SYMBOL (pv_irq_ops); |