diff options
author | Mathias Krause <minipli@googlemail.com> | 2012-08-29 19:30:16 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-09-05 05:41:48 -0400 |
commit | 0225fb509d51fcf777eb0aa31c304c582e3248fd (patch) | |
tree | 3b6bb0ab01d673efcdd0121c15ced21171a562f1 /arch/x86 | |
parent | fd0a0d82083747301f6c8084b4141bb490625016 (diff) |
KVM: x86 emulator: constify emulate_ops
We never change emulate_ops[] at runtime so it should be r/o.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 2 | ||||
-rw-r--r-- | arch/x86/kvm/emulate.c | 22 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 2 |
3 files changed, 13 insertions, 13 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 282aee5d6ac1..b5bb73aecc06 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -250,7 +250,7 @@ struct read_cache { | |||
250 | }; | 250 | }; |
251 | 251 | ||
252 | struct x86_emulate_ctxt { | 252 | struct x86_emulate_ctxt { |
253 | struct x86_emulate_ops *ops; | 253 | const struct x86_emulate_ops *ops; |
254 | 254 | ||
255 | /* Register state before/after emulation. */ | 255 | /* Register state before/after emulation. */ |
256 | unsigned long eflags; | 256 | unsigned long eflags; |
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index fd06f9d65847..663e95881bdb 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1325,7 +1325,7 @@ static int read_interrupt_descriptor(struct x86_emulate_ctxt *ctxt, | |||
1325 | static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt, | 1325 | static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt, |
1326 | u16 selector, struct desc_ptr *dt) | 1326 | u16 selector, struct desc_ptr *dt) |
1327 | { | 1327 | { |
1328 | struct x86_emulate_ops *ops = ctxt->ops; | 1328 | const struct x86_emulate_ops *ops = ctxt->ops; |
1329 | 1329 | ||
1330 | if (selector & 1 << 2) { | 1330 | if (selector & 1 << 2) { |
1331 | struct desc_struct desc; | 1331 | struct desc_struct desc; |
@@ -1747,7 +1747,7 @@ static int em_popa(struct x86_emulate_ctxt *ctxt) | |||
1747 | 1747 | ||
1748 | static int __emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq) | 1748 | static int __emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq) |
1749 | { | 1749 | { |
1750 | struct x86_emulate_ops *ops = ctxt->ops; | 1750 | const struct x86_emulate_ops *ops = ctxt->ops; |
1751 | int rc; | 1751 | int rc; |
1752 | struct desc_ptr dt; | 1752 | struct desc_ptr dt; |
1753 | gva_t cs_addr; | 1753 | gva_t cs_addr; |
@@ -2129,7 +2129,7 @@ static bool vendor_intel(struct x86_emulate_ctxt *ctxt) | |||
2129 | 2129 | ||
2130 | static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt) | 2130 | static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt) |
2131 | { | 2131 | { |
2132 | struct x86_emulate_ops *ops = ctxt->ops; | 2132 | const struct x86_emulate_ops *ops = ctxt->ops; |
2133 | u32 eax, ebx, ecx, edx; | 2133 | u32 eax, ebx, ecx, edx; |
2134 | 2134 | ||
2135 | /* | 2135 | /* |
@@ -2173,7 +2173,7 @@ static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt) | |||
2173 | 2173 | ||
2174 | static int em_syscall(struct x86_emulate_ctxt *ctxt) | 2174 | static int em_syscall(struct x86_emulate_ctxt *ctxt) |
2175 | { | 2175 | { |
2176 | struct x86_emulate_ops *ops = ctxt->ops; | 2176 | const struct x86_emulate_ops *ops = ctxt->ops; |
2177 | struct desc_struct cs, ss; | 2177 | struct desc_struct cs, ss; |
2178 | u64 msr_data; | 2178 | u64 msr_data; |
2179 | u16 cs_sel, ss_sel; | 2179 | u16 cs_sel, ss_sel; |
@@ -2231,7 +2231,7 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt) | |||
2231 | 2231 | ||
2232 | static int em_sysenter(struct x86_emulate_ctxt *ctxt) | 2232 | static int em_sysenter(struct x86_emulate_ctxt *ctxt) |
2233 | { | 2233 | { |
2234 | struct x86_emulate_ops *ops = ctxt->ops; | 2234 | const struct x86_emulate_ops *ops = ctxt->ops; |
2235 | struct desc_struct cs, ss; | 2235 | struct desc_struct cs, ss; |
2236 | u64 msr_data; | 2236 | u64 msr_data; |
2237 | u16 cs_sel, ss_sel; | 2237 | u16 cs_sel, ss_sel; |
@@ -2294,7 +2294,7 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt) | |||
2294 | 2294 | ||
2295 | static int em_sysexit(struct x86_emulate_ctxt *ctxt) | 2295 | static int em_sysexit(struct x86_emulate_ctxt *ctxt) |
2296 | { | 2296 | { |
2297 | struct x86_emulate_ops *ops = ctxt->ops; | 2297 | const struct x86_emulate_ops *ops = ctxt->ops; |
2298 | struct desc_struct cs, ss; | 2298 | struct desc_struct cs, ss; |
2299 | u64 msr_data; | 2299 | u64 msr_data; |
2300 | int usermode; | 2300 | int usermode; |
@@ -2357,7 +2357,7 @@ static bool emulator_bad_iopl(struct x86_emulate_ctxt *ctxt) | |||
2357 | static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt, | 2357 | static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt, |
2358 | u16 port, u16 len) | 2358 | u16 port, u16 len) |
2359 | { | 2359 | { |
2360 | struct x86_emulate_ops *ops = ctxt->ops; | 2360 | const struct x86_emulate_ops *ops = ctxt->ops; |
2361 | struct desc_struct tr_seg; | 2361 | struct desc_struct tr_seg; |
2362 | u32 base3; | 2362 | u32 base3; |
2363 | int r; | 2363 | int r; |
@@ -2476,7 +2476,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
2476 | u16 tss_selector, u16 old_tss_sel, | 2476 | u16 tss_selector, u16 old_tss_sel, |
2477 | ulong old_tss_base, struct desc_struct *new_desc) | 2477 | ulong old_tss_base, struct desc_struct *new_desc) |
2478 | { | 2478 | { |
2479 | struct x86_emulate_ops *ops = ctxt->ops; | 2479 | const struct x86_emulate_ops *ops = ctxt->ops; |
2480 | struct tss_segment_16 tss_seg; | 2480 | struct tss_segment_16 tss_seg; |
2481 | int ret; | 2481 | int ret; |
2482 | u32 new_tss_base = get_desc_base(new_desc); | 2482 | u32 new_tss_base = get_desc_base(new_desc); |
@@ -2623,7 +2623,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2623 | u16 tss_selector, u16 old_tss_sel, | 2623 | u16 tss_selector, u16 old_tss_sel, |
2624 | ulong old_tss_base, struct desc_struct *new_desc) | 2624 | ulong old_tss_base, struct desc_struct *new_desc) |
2625 | { | 2625 | { |
2626 | struct x86_emulate_ops *ops = ctxt->ops; | 2626 | const struct x86_emulate_ops *ops = ctxt->ops; |
2627 | struct tss_segment_32 tss_seg; | 2627 | struct tss_segment_32 tss_seg; |
2628 | int ret; | 2628 | int ret; |
2629 | u32 new_tss_base = get_desc_base(new_desc); | 2629 | u32 new_tss_base = get_desc_base(new_desc); |
@@ -2667,7 +2667,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, | |||
2667 | u16 tss_selector, int idt_index, int reason, | 2667 | u16 tss_selector, int idt_index, int reason, |
2668 | bool has_error_code, u32 error_code) | 2668 | bool has_error_code, u32 error_code) |
2669 | { | 2669 | { |
2670 | struct x86_emulate_ops *ops = ctxt->ops; | 2670 | const struct x86_emulate_ops *ops = ctxt->ops; |
2671 | struct desc_struct curr_tss_desc, next_tss_desc; | 2671 | struct desc_struct curr_tss_desc, next_tss_desc; |
2672 | int ret; | 2672 | int ret; |
2673 | u16 old_tss_sel = get_segment_selector(ctxt, VCPU_SREG_TR); | 2673 | u16 old_tss_sel = get_segment_selector(ctxt, VCPU_SREG_TR); |
@@ -4339,7 +4339,7 @@ static void fetch_possible_mmx_operand(struct x86_emulate_ctxt *ctxt, | |||
4339 | 4339 | ||
4340 | int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) | 4340 | int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) |
4341 | { | 4341 | { |
4342 | struct x86_emulate_ops *ops = ctxt->ops; | 4342 | const struct x86_emulate_ops *ops = ctxt->ops; |
4343 | int rc = X86EMUL_CONTINUE; | 4343 | int rc = X86EMUL_CONTINUE; |
4344 | int saved_dst_type = ctxt->dst.type; | 4344 | int saved_dst_type = ctxt->dst.type; |
4345 | 4345 | ||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 20f2266dfb64..0dc066f0428d 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4323,7 +4323,7 @@ static void emulator_write_gpr(struct x86_emulate_ctxt *ctxt, unsigned reg, ulon | |||
4323 | kvm_register_write(emul_to_vcpu(ctxt), reg, val); | 4323 | kvm_register_write(emul_to_vcpu(ctxt), reg, val); |
4324 | } | 4324 | } |
4325 | 4325 | ||
4326 | static struct x86_emulate_ops emulate_ops = { | 4326 | static const struct x86_emulate_ops emulate_ops = { |
4327 | .read_gpr = emulator_read_gpr, | 4327 | .read_gpr = emulator_read_gpr, |
4328 | .write_gpr = emulator_write_gpr, | 4328 | .write_gpr = emulator_write_gpr, |
4329 | .read_std = kvm_read_guest_virt_system, | 4329 | .read_std = kvm_read_guest_virt_system, |