diff options
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r-- | arch/x86/kvm/emulate.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 27d2c22b114e..2b08b78b6cab 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -487,11 +487,9 @@ static void emulate_gp(struct x86_emulate_ctxt *ctxt, int err) | |||
487 | emulate_exception(ctxt, GP_VECTOR, err, true); | 487 | emulate_exception(ctxt, GP_VECTOR, err, true); |
488 | } | 488 | } |
489 | 489 | ||
490 | static void emulate_pf(struct x86_emulate_ctxt *ctxt, unsigned long addr, | 490 | static void emulate_pf(struct x86_emulate_ctxt *ctxt) |
491 | int err) | ||
492 | { | 491 | { |
493 | ctxt->cr2 = addr; | 492 | emulate_exception(ctxt, PF_VECTOR, 0, true); |
494 | emulate_exception(ctxt, PF_VECTOR, err, true); | ||
495 | } | 493 | } |
496 | 494 | ||
497 | static void emulate_ud(struct x86_emulate_ctxt *ctxt) | 495 | static void emulate_ud(struct x86_emulate_ctxt *ctxt) |
@@ -834,7 +832,7 @@ static int read_emulated(struct x86_emulate_ctxt *ctxt, | |||
834 | rc = ops->read_emulated(addr, mc->data + mc->end, n, &err, | 832 | rc = ops->read_emulated(addr, mc->data + mc->end, n, &err, |
835 | ctxt->vcpu); | 833 | ctxt->vcpu); |
836 | if (rc == X86EMUL_PROPAGATE_FAULT) | 834 | if (rc == X86EMUL_PROPAGATE_FAULT) |
837 | emulate_pf(ctxt, addr, err); | 835 | emulate_pf(ctxt); |
838 | if (rc != X86EMUL_CONTINUE) | 836 | if (rc != X86EMUL_CONTINUE) |
839 | return rc; | 837 | return rc; |
840 | mc->end += n; | 838 | mc->end += n; |
@@ -921,7 +919,7 @@ static int read_segment_descriptor(struct x86_emulate_ctxt *ctxt, | |||
921 | addr = dt.address + index * 8; | 919 | addr = dt.address + index * 8; |
922 | ret = ops->read_std(addr, desc, sizeof *desc, ctxt->vcpu, &err); | 920 | ret = ops->read_std(addr, desc, sizeof *desc, ctxt->vcpu, &err); |
923 | if (ret == X86EMUL_PROPAGATE_FAULT) | 921 | if (ret == X86EMUL_PROPAGATE_FAULT) |
924 | emulate_pf(ctxt, addr, err); | 922 | emulate_pf(ctxt); |
925 | 923 | ||
926 | return ret; | 924 | return ret; |
927 | } | 925 | } |
@@ -947,7 +945,7 @@ static int write_segment_descriptor(struct x86_emulate_ctxt *ctxt, | |||
947 | addr = dt.address + index * 8; | 945 | addr = dt.address + index * 8; |
948 | ret = ops->write_std(addr, desc, sizeof *desc, ctxt->vcpu, &err); | 946 | ret = ops->write_std(addr, desc, sizeof *desc, ctxt->vcpu, &err); |
949 | if (ret == X86EMUL_PROPAGATE_FAULT) | 947 | if (ret == X86EMUL_PROPAGATE_FAULT) |
950 | emulate_pf(ctxt, addr, err); | 948 | emulate_pf(ctxt); |
951 | 949 | ||
952 | return ret; | 950 | return ret; |
953 | } | 951 | } |
@@ -1117,7 +1115,7 @@ static inline int writeback(struct x86_emulate_ctxt *ctxt, | |||
1117 | &err, | 1115 | &err, |
1118 | ctxt->vcpu); | 1116 | ctxt->vcpu); |
1119 | if (rc == X86EMUL_PROPAGATE_FAULT) | 1117 | if (rc == X86EMUL_PROPAGATE_FAULT) |
1120 | emulate_pf(ctxt, c->dst.addr.mem, err); | 1118 | emulate_pf(ctxt); |
1121 | if (rc != X86EMUL_CONTINUE) | 1119 | if (rc != X86EMUL_CONTINUE) |
1122 | return rc; | 1120 | return rc; |
1123 | break; | 1121 | break; |
@@ -1939,7 +1937,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
1939 | &err); | 1937 | &err); |
1940 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 1938 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
1941 | /* FIXME: need to provide precise fault address */ | 1939 | /* FIXME: need to provide precise fault address */ |
1942 | emulate_pf(ctxt, old_tss_base, err); | 1940 | emulate_pf(ctxt); |
1943 | return ret; | 1941 | return ret; |
1944 | } | 1942 | } |
1945 | 1943 | ||
@@ -1949,7 +1947,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
1949 | &err); | 1947 | &err); |
1950 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 1948 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
1951 | /* FIXME: need to provide precise fault address */ | 1949 | /* FIXME: need to provide precise fault address */ |
1952 | emulate_pf(ctxt, old_tss_base, err); | 1950 | emulate_pf(ctxt); |
1953 | return ret; | 1951 | return ret; |
1954 | } | 1952 | } |
1955 | 1953 | ||
@@ -1957,7 +1955,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
1957 | &err); | 1955 | &err); |
1958 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 1956 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
1959 | /* FIXME: need to provide precise fault address */ | 1957 | /* FIXME: need to provide precise fault address */ |
1960 | emulate_pf(ctxt, new_tss_base, err); | 1958 | emulate_pf(ctxt); |
1961 | return ret; | 1959 | return ret; |
1962 | } | 1960 | } |
1963 | 1961 | ||
@@ -1970,7 +1968,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, | |||
1970 | ctxt->vcpu, &err); | 1968 | ctxt->vcpu, &err); |
1971 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 1969 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
1972 | /* FIXME: need to provide precise fault address */ | 1970 | /* FIXME: need to provide precise fault address */ |
1973 | emulate_pf(ctxt, new_tss_base, err); | 1971 | emulate_pf(ctxt); |
1974 | return ret; | 1972 | return ret; |
1975 | } | 1973 | } |
1976 | } | 1974 | } |
@@ -2081,7 +2079,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2081 | &err); | 2079 | &err); |
2082 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 2080 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
2083 | /* FIXME: need to provide precise fault address */ | 2081 | /* FIXME: need to provide precise fault address */ |
2084 | emulate_pf(ctxt, old_tss_base, err); | 2082 | emulate_pf(ctxt); |
2085 | return ret; | 2083 | return ret; |
2086 | } | 2084 | } |
2087 | 2085 | ||
@@ -2091,7 +2089,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2091 | &err); | 2089 | &err); |
2092 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 2090 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
2093 | /* FIXME: need to provide precise fault address */ | 2091 | /* FIXME: need to provide precise fault address */ |
2094 | emulate_pf(ctxt, old_tss_base, err); | 2092 | emulate_pf(ctxt); |
2095 | return ret; | 2093 | return ret; |
2096 | } | 2094 | } |
2097 | 2095 | ||
@@ -2099,7 +2097,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2099 | &err); | 2097 | &err); |
2100 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 2098 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
2101 | /* FIXME: need to provide precise fault address */ | 2099 | /* FIXME: need to provide precise fault address */ |
2102 | emulate_pf(ctxt, new_tss_base, err); | 2100 | emulate_pf(ctxt); |
2103 | return ret; | 2101 | return ret; |
2104 | } | 2102 | } |
2105 | 2103 | ||
@@ -2112,7 +2110,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, | |||
2112 | ctxt->vcpu, &err); | 2110 | ctxt->vcpu, &err); |
2113 | if (ret == X86EMUL_PROPAGATE_FAULT) { | 2111 | if (ret == X86EMUL_PROPAGATE_FAULT) { |
2114 | /* FIXME: need to provide precise fault address */ | 2112 | /* FIXME: need to provide precise fault address */ |
2115 | emulate_pf(ctxt, new_tss_base, err); | 2113 | emulate_pf(ctxt); |
2116 | return ret; | 2114 | return ret; |
2117 | } | 2115 | } |
2118 | } | 2116 | } |