diff options
author | Avi Kivity <avi@redhat.com> | 2011-04-20 06:37:53 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-05-11 07:57:10 -0400 |
commit | 0f65dd70a442ff498da10cec0a599fbd9d2d6f9e (patch) | |
tree | a460005086619e5959242404c8cd7be0d766de3d /arch/x86/kvm/emulate.c | |
parent | 7295261cdd42e6d41666df38d1b613cdd9e95f46 (diff) |
KVM: x86 emulator: drop vcpu argument from memory read/write callbacks
Making the emulator caller agnostic.
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r-- | arch/x86/kvm/emulate.c | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 4a5b61ff0ae9..ff64b17df772 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -645,8 +645,7 @@ static int segmented_read_std(struct x86_emulate_ctxt *ctxt, | |||
645 | rc = linearize(ctxt, addr, size, false, &linear); | 645 | rc = linearize(ctxt, addr, size, false, &linear); |
646 | if (rc != X86EMUL_CONTINUE) | 646 | if (rc != X86EMUL_CONTINUE) |
647 | return rc; | 647 | return rc; |
648 | return ctxt->ops->read_std(linear, data, size, ctxt->vcpu, | 648 | return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception); |
649 | &ctxt->exception); | ||
650 | } | 649 | } |
651 | 650 | ||
652 | static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt, | 651 | static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt, |
@@ -665,8 +664,8 @@ static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt, | |||
665 | rc = __linearize(ctxt, addr, size, false, true, &linear); | 664 | rc = __linearize(ctxt, addr, size, false, true, &linear); |
666 | if (rc != X86EMUL_CONTINUE) | 665 | if (rc != X86EMUL_CONTINUE) |
667 | return rc; | 666 | return rc; |
668 | rc = ops->fetch(linear, fc->data + cur_size, | 667 | rc = ops->fetch(ctxt, linear, fc->data + cur_size, |
669 | size, ctxt->vcpu, &ctxt->exception); | 668 | size, &ctxt->exception); |
670 | if (rc != X86EMUL_CONTINUE) | 669 | if (rc != X86EMUL_CONTINUE) |
671 | return rc; | 670 | return rc; |
672 | fc->end += size; | 671 | fc->end += size; |
@@ -1047,8 +1046,8 @@ static int read_emulated(struct x86_emulate_ctxt *ctxt, | |||
1047 | if (mc->pos < mc->end) | 1046 | if (mc->pos < mc->end) |
1048 | goto read_cached; | 1047 | goto read_cached; |
1049 | 1048 | ||
1050 | rc = ops->read_emulated(addr, mc->data + mc->end, n, | 1049 | rc = ops->read_emulated(ctxt, addr, mc->data + mc->end, n, |
1051 | &ctxt->exception, ctxt->vcpu); | 1050 | &ctxt->exception); |
1052 | if (rc != X86EMUL_CONTINUE) | 1051 | if (rc != X86EMUL_CONTINUE) |
1053 | return rc; | 1052 | return rc; |
1054 | mc->end += n; | 1053 | mc->end += n; |
@@ -1087,8 +1086,8 @@ static int segmented_write(struct x86_emulate_ctxt *ctxt, | |||
1087 | rc = linearize(ctxt, addr, size, true, &linear); | 1086 | rc = linearize(ctxt, addr, size, true, &linear); |
1088 | if (rc != X86EMUL_CONTINUE) | 1087 | if (rc != X86EMUL_CONTINUE) |
1089 | return rc; | 1088 | return rc; |
1090 | return ctxt->ops->write_emulated(linear, data, size, | 1089 | return ctxt->ops->write_emulated(ctxt, linear, data, size, |
1091 | &ctxt->exception, ctxt->vcpu); | 1090 | &ctxt->exception); |
1092 | } | 1091 | } |
1093 | 1092 | ||
1094 | static int segmented_cmpxchg(struct x86_emulate_ctxt *ctxt, | 1093 | static int segmented_cmpxchg(struct x86_emulate_ctxt *ctxt, |
@@ -1102,8 +1101,8 @@ static int segmented_cmpxchg(struct x86_emulate_ctxt *ctxt, | |||
1102 | rc = linearize(ctxt, addr, size, true, &linear); | 1101 | rc = linearize(ctxt, addr, size, true, &linear); |
1103 | if (rc != X86EMUL_CONTINUE) | 1102 | if (rc != X86EMUL_CONTINUE) |
1104 | return rc; | 1103 | return rc; |
1105 | return ctxt->ops->cmpxchg_emulated(linear, orig_data, data, | 1104 | return ctxt->ops->cmpxchg_emulated(ctxt, linear, orig_data, data, |
1106 | size, &ctxt->exception, ctxt->vcpu); | 1105 | size, &ctxt->exception); |
1107 | } | 1106 | } |
1108 | 1107 | ||
1109 | static int pio_in_emulated(struct x86_emulate_ctxt *ctxt, | 1108 | static int pio_in_emulated(struct x86_emulate_ctxt *ctxt, |
@@ -1168,8 +1167,7 @@ static int read_segment_descriptor(struct x86_emulate_ctxt *ctxt, | |||
1168 | if (dt.size < index * 8 + 7) | 1167 | if (dt.size < index * 8 + 7) |
1169 | return emulate_gp(ctxt, selector & 0xfffc); | 1168 | return emulate_gp(ctxt, selector & 0xfffc); |
1170 | addr = dt.address + index * 8; | 1169 | addr = dt.address + index * 8; |
1171 | ret = ops->read_std(addr, desc, sizeof *desc, ctxt->vcpu, | 1170 | ret = ops->read_std(ctxt, addr, desc, sizeof *desc, &ctxt->exception); |
1172 | &ctxt->exception); | ||
1173 | 1171 | ||
1174 | return ret; | 1172 | return ret; |
1175 | } | 1173 | } |
@@ -1190,8 +1188,7 @@ static int write_segment_descriptor(struct x86_emulate_ctxt *ctxt, | |||
1190 | return emulate_gp(ctxt, selector & 0xfffc); | 1188 | return emulate_gp(ctxt, selector & 0xfffc); |
1191 | 1189 | ||
1192 | addr = dt.address + index * 8; | 1190 | addr = dt.address + index * 8; |
1193 | ret = ops->write_std(addr, desc, sizeof *desc, ctxt->vcpu, | 1191 | ret = ops->write_std(ctxt, addr, desc, sizeof *desc, &ctxt->exception); |
1194 | &ctxt->exception); | ||
1195 | 1192 | ||
1196 | return ret; | 1193 | return ret; |
1197 | } | 1194 | } |
@@ -1545,11 +1542,11 @@ int emulate_int_real(struct x86_emulate_ctxt *ctxt, | |||
1545 | eip_addr = dt.address + (irq << 2); | 1542 | eip_addr = dt.address + (irq << 2); |
1546 | cs_addr = dt.address + (irq << 2) + 2; | 1543 | cs_addr = dt.address + (irq << 2) + 2; |
1547 | 1544 | ||
1548 | rc = ops->read_std(cs_addr, &cs, 2, ctxt->vcpu, &ctxt->exception); | 1545 | rc = ops->read_std(ctxt, cs_addr, &cs, 2, &ctxt->exception); |
1549 | if (rc != X86EMUL_CONTINUE) | 1546 | if (rc != X86EMUL_CONTINUE) |
1550 | return rc; | 1547 | return rc; |
1551 | 1548 | ||
1552 | rc = ops->read_std(eip_addr, &eip, 2, ctxt->vcpu, &ctxt->exception); | 1549 | rc = ops->read_std(ctxt, eip_addr, &eip, 2, &ctxt->exception); |
1553 | if (rc != X86EMUL_CONTINUE) | 1550 | if (rc != X86EMUL_CONTINUE) |
1554 | return rc; | 1551 | return rc; |
1555 | 1552 | ||
@@ -2036,13 +2033,12 @@ static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt, | |||
2036 | #ifdef CONFIG_X86_64 | 2033 | #ifdef CONFIG_X86_64 |
2037 | base |= ((u64)base3) << 32; | 2034 | base |= ((u64)base3) << 32; |
2038 | #endif | 2035 | #endif |
2039 | r = ops->read_std(base + 102, &io_bitmap_ptr, 2, ctxt->vcpu, NULL); | 2036 | r = ops->read_std(ctxt, base + 102, &io_bitmap_ptr, 2, NULL); |
2040 | if (r != X86EMUL_CONTINUE) | 2037 | if (r != X86EMUL_CONTINUE) |
2041 | return false; | 2038 | return false; |
2042 | if (io_bitmap_ptr + port/8 > desc_limit_scaled(&tr_seg)) | 2039 | if (io_bitmap_ptr + port/8 > desc_limit_scaled(&tr_seg)) |
2043 | return false; | 2040 | return false; |
2044 | r = ops->read_std(base + io_bitmap_ptr + port/8, &perm, 2, ctxt->vcpu, | 2041 | r = ops->read_std(ctxt, base + io_bitmap_ptr + port/8, &perm, 2, NULL); |
2045 | NULL); | ||
2046 | if (r != X86EMUL_CONTINUE) | 2042 | if (r != X86EMUL_CONTINUE) |
2047 | return false; | 2043 | return false; |
2048 | if ((perm >> bit_idx) & mask) | 2044 | if ((perm >> bit_idx) & mask) |
@@ -2150,7 +2146,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
2150 | int ret; | 2146 | int ret; |
2151 | u32 new_tss_base = get_desc_base(new_desc); | 2147 | u32 new_tss_base = get_desc_base(new_desc); |
2152 | 2148 | ||
2153 | ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, | 2149 | ret = ops->read_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg, |
2154 | &ctxt->exception); | 2150 | &ctxt->exception); |
2155 | if (ret != X86EMUL_CONTINUE) | 2151 | if (ret != X86EMUL_CONTINUE) |
2156 | /* FIXME: need to provide precise fault address */ | 2152 | /* FIXME: need to provide precise fault address */ |
@@ -2158,13 +2154,13 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
2158 | 2154 | ||
2159 | save_state_to_tss16(ctxt, ops, &tss_seg); | 2155 | save_state_to_tss16(ctxt, ops, &tss_seg); |
2160 | 2156 | ||
2161 | ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, | 2157 | ret = ops->write_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg, |
2162 | &ctxt->exception); | 2158 | &ctxt->exception); |
2163 | if (ret != X86EMUL_CONTINUE) | 2159 | if (ret != X86EMUL_CONTINUE) |
2164 | /* FIXME: need to provide precise fault address */ | 2160 | /* FIXME: need to provide precise fault address */ |
2165 | return ret; | 2161 | return ret; |
2166 | 2162 | ||
2167 | ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, | 2163 | ret = ops->read_std(ctxt, new_tss_base, &tss_seg, sizeof tss_seg, |
2168 | &ctxt->exception); | 2164 | &ctxt->exception); |
2169 | if (ret != X86EMUL_CONTINUE) | 2165 | if (ret != X86EMUL_CONTINUE) |
2170 | /* FIXME: need to provide precise fault address */ | 2166 | /* FIXME: need to provide precise fault address */ |
@@ -2173,10 +2169,10 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
2173 | if (old_tss_sel != 0xffff) { | 2169 | if (old_tss_sel != 0xffff) { |
2174 | tss_seg.prev_task_link = old_tss_sel; | 2170 | tss_seg.prev_task_link = old_tss_sel; |
2175 | 2171 | ||
2176 | ret = ops->write_std(new_tss_base, | 2172 | ret = ops->write_std(ctxt, new_tss_base, |
2177 | &tss_seg.prev_task_link, | 2173 | &tss_seg.prev_task_link, |
2178 | sizeof tss_seg.prev_task_link, | 2174 | sizeof tss_seg.prev_task_link, |
2179 | ctxt->vcpu, &ctxt->exception); | 2175 | &ctxt->exception); |
2180 | if (ret != X86EMUL_CONTINUE) | 2176 | if (ret != X86EMUL_CONTINUE) |
2181 | /* FIXME: need to provide precise fault address */ | 2177 | /* FIXME: need to provide precise fault address */ |
2182 | return ret; | 2178 | return ret; |
@@ -2282,7 +2278,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2282 | int ret; | 2278 | int ret; |
2283 | u32 new_tss_base = get_desc_base(new_desc); | 2279 | u32 new_tss_base = get_desc_base(new_desc); |
2284 | 2280 | ||
2285 | ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, | 2281 | ret = ops->read_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg, |
2286 | &ctxt->exception); | 2282 | &ctxt->exception); |
2287 | if (ret != X86EMUL_CONTINUE) | 2283 | if (ret != X86EMUL_CONTINUE) |
2288 | /* FIXME: need to provide precise fault address */ | 2284 | /* FIXME: need to provide precise fault address */ |
@@ -2290,13 +2286,13 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2290 | 2286 | ||
2291 | save_state_to_tss32(ctxt, ops, &tss_seg); | 2287 | save_state_to_tss32(ctxt, ops, &tss_seg); |
2292 | 2288 | ||
2293 | ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, | 2289 | ret = ops->write_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg, |
2294 | &ctxt->exception); | 2290 | &ctxt->exception); |
2295 | if (ret != X86EMUL_CONTINUE) | 2291 | if (ret != X86EMUL_CONTINUE) |
2296 | /* FIXME: need to provide precise fault address */ | 2292 | /* FIXME: need to provide precise fault address */ |
2297 | return ret; | 2293 | return ret; |
2298 | 2294 | ||
2299 | ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, | 2295 | ret = ops->read_std(ctxt, new_tss_base, &tss_seg, sizeof tss_seg, |
2300 | &ctxt->exception); | 2296 | &ctxt->exception); |
2301 | if (ret != X86EMUL_CONTINUE) | 2297 | if (ret != X86EMUL_CONTINUE) |
2302 | /* FIXME: need to provide precise fault address */ | 2298 | /* FIXME: need to provide precise fault address */ |
@@ -2305,10 +2301,10 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2305 | if (old_tss_sel != 0xffff) { | 2301 | if (old_tss_sel != 0xffff) { |
2306 | tss_seg.prev_task_link = old_tss_sel; | 2302 | tss_seg.prev_task_link = old_tss_sel; |
2307 | 2303 | ||
2308 | ret = ops->write_std(new_tss_base, | 2304 | ret = ops->write_std(ctxt, new_tss_base, |
2309 | &tss_seg.prev_task_link, | 2305 | &tss_seg.prev_task_link, |
2310 | sizeof tss_seg.prev_task_link, | 2306 | sizeof tss_seg.prev_task_link, |
2311 | ctxt->vcpu, &ctxt->exception); | 2307 | &ctxt->exception); |
2312 | if (ret != X86EMUL_CONTINUE) | 2308 | if (ret != X86EMUL_CONTINUE) |
2313 | /* FIXME: need to provide precise fault address */ | 2309 | /* FIXME: need to provide precise fault address */ |
2314 | return ret; | 2310 | return ret; |