diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-04-28 12:15:28 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-08-01 03:35:30 -0400 |
commit | 3fb1b5dbd397d16a855c97c3fb80fe6e9196ce7c (patch) | |
tree | 337a8ed2aba3f195d428c7b7827a323bd8b4428d /arch/x86/kvm/emulate.c | |
parent | 35aa5375d407ecadcc3adb5cb31d27044bf7f29f (diff) |
KVM: x86 emulator: add (set|get)_msr callbacks to x86_emulate_ops
Add (set|get)_msr callbacks to x86_emulate_ops instead of calling
them directly.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r-- | arch/x86/kvm/emulate.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 8a4aa73ff1e4..7c8ed560fd41 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1875,7 +1875,7 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt, | |||
1875 | } | 1875 | } |
1876 | 1876 | ||
1877 | static int | 1877 | static int |
1878 | emulate_syscall(struct x86_emulate_ctxt *ctxt) | 1878 | emulate_syscall(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) |
1879 | { | 1879 | { |
1880 | struct decode_cache *c = &ctxt->decode; | 1880 | struct decode_cache *c = &ctxt->decode; |
1881 | struct kvm_segment cs, ss; | 1881 | struct kvm_segment cs, ss; |
@@ -1890,7 +1890,7 @@ emulate_syscall(struct x86_emulate_ctxt *ctxt) | |||
1890 | 1890 | ||
1891 | setup_syscalls_segments(ctxt, &cs, &ss); | 1891 | setup_syscalls_segments(ctxt, &cs, &ss); |
1892 | 1892 | ||
1893 | kvm_x86_ops->get_msr(ctxt->vcpu, MSR_STAR, &msr_data); | 1893 | ops->get_msr(ctxt->vcpu, MSR_STAR, &msr_data); |
1894 | msr_data >>= 32; | 1894 | msr_data >>= 32; |
1895 | cs.selector = (u16)(msr_data & 0xfffc); | 1895 | cs.selector = (u16)(msr_data & 0xfffc); |
1896 | ss.selector = (u16)(msr_data + 8); | 1896 | ss.selector = (u16)(msr_data + 8); |
@@ -1907,17 +1907,17 @@ emulate_syscall(struct x86_emulate_ctxt *ctxt) | |||
1907 | #ifdef CONFIG_X86_64 | 1907 | #ifdef CONFIG_X86_64 |
1908 | c->regs[VCPU_REGS_R11] = ctxt->eflags & ~EFLG_RF; | 1908 | c->regs[VCPU_REGS_R11] = ctxt->eflags & ~EFLG_RF; |
1909 | 1909 | ||
1910 | kvm_x86_ops->get_msr(ctxt->vcpu, | 1910 | ops->get_msr(ctxt->vcpu, |
1911 | ctxt->mode == X86EMUL_MODE_PROT64 ? | 1911 | ctxt->mode == X86EMUL_MODE_PROT64 ? |
1912 | MSR_LSTAR : MSR_CSTAR, &msr_data); | 1912 | MSR_LSTAR : MSR_CSTAR, &msr_data); |
1913 | c->eip = msr_data; | 1913 | c->eip = msr_data; |
1914 | 1914 | ||
1915 | kvm_x86_ops->get_msr(ctxt->vcpu, MSR_SYSCALL_MASK, &msr_data); | 1915 | ops->get_msr(ctxt->vcpu, MSR_SYSCALL_MASK, &msr_data); |
1916 | ctxt->eflags &= ~(msr_data | EFLG_RF); | 1916 | ctxt->eflags &= ~(msr_data | EFLG_RF); |
1917 | #endif | 1917 | #endif |
1918 | } else { | 1918 | } else { |
1919 | /* legacy mode */ | 1919 | /* legacy mode */ |
1920 | kvm_x86_ops->get_msr(ctxt->vcpu, MSR_STAR, &msr_data); | 1920 | ops->get_msr(ctxt->vcpu, MSR_STAR, &msr_data); |
1921 | c->eip = (u32)msr_data; | 1921 | c->eip = (u32)msr_data; |
1922 | 1922 | ||
1923 | ctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF); | 1923 | ctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF); |
@@ -1927,7 +1927,7 @@ emulate_syscall(struct x86_emulate_ctxt *ctxt) | |||
1927 | } | 1927 | } |
1928 | 1928 | ||
1929 | static int | 1929 | static int |
1930 | emulate_sysenter(struct x86_emulate_ctxt *ctxt) | 1930 | emulate_sysenter(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) |
1931 | { | 1931 | { |
1932 | struct decode_cache *c = &ctxt->decode; | 1932 | struct decode_cache *c = &ctxt->decode; |
1933 | struct kvm_segment cs, ss; | 1933 | struct kvm_segment cs, ss; |
@@ -1949,7 +1949,7 @@ emulate_sysenter(struct x86_emulate_ctxt *ctxt) | |||
1949 | 1949 | ||
1950 | setup_syscalls_segments(ctxt, &cs, &ss); | 1950 | setup_syscalls_segments(ctxt, &cs, &ss); |
1951 | 1951 | ||
1952 | kvm_x86_ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_CS, &msr_data); | 1952 | ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_CS, &msr_data); |
1953 | switch (ctxt->mode) { | 1953 | switch (ctxt->mode) { |
1954 | case X86EMUL_MODE_PROT32: | 1954 | case X86EMUL_MODE_PROT32: |
1955 | if ((msr_data & 0xfffc) == 0x0) { | 1955 | if ((msr_data & 0xfffc) == 0x0) { |
@@ -1979,17 +1979,17 @@ emulate_sysenter(struct x86_emulate_ctxt *ctxt) | |||
1979 | kvm_x86_ops->set_segment(ctxt->vcpu, &cs, VCPU_SREG_CS); | 1979 | kvm_x86_ops->set_segment(ctxt->vcpu, &cs, VCPU_SREG_CS); |
1980 | kvm_x86_ops->set_segment(ctxt->vcpu, &ss, VCPU_SREG_SS); | 1980 | kvm_x86_ops->set_segment(ctxt->vcpu, &ss, VCPU_SREG_SS); |
1981 | 1981 | ||
1982 | kvm_x86_ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_EIP, &msr_data); | 1982 | ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_EIP, &msr_data); |
1983 | c->eip = msr_data; | 1983 | c->eip = msr_data; |
1984 | 1984 | ||
1985 | kvm_x86_ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_ESP, &msr_data); | 1985 | ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_ESP, &msr_data); |
1986 | c->regs[VCPU_REGS_RSP] = msr_data; | 1986 | c->regs[VCPU_REGS_RSP] = msr_data; |
1987 | 1987 | ||
1988 | return X86EMUL_CONTINUE; | 1988 | return X86EMUL_CONTINUE; |
1989 | } | 1989 | } |
1990 | 1990 | ||
1991 | static int | 1991 | static int |
1992 | emulate_sysexit(struct x86_emulate_ctxt *ctxt) | 1992 | emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) |
1993 | { | 1993 | { |
1994 | struct decode_cache *c = &ctxt->decode; | 1994 | struct decode_cache *c = &ctxt->decode; |
1995 | struct kvm_segment cs, ss; | 1995 | struct kvm_segment cs, ss; |
@@ -2012,7 +2012,7 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt) | |||
2012 | 2012 | ||
2013 | cs.dpl = 3; | 2013 | cs.dpl = 3; |
2014 | ss.dpl = 3; | 2014 | ss.dpl = 3; |
2015 | kvm_x86_ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_CS, &msr_data); | 2015 | ops->get_msr(ctxt->vcpu, MSR_IA32_SYSENTER_CS, &msr_data); |
2016 | switch (usermode) { | 2016 | switch (usermode) { |
2017 | case X86EMUL_MODE_PROT32: | 2017 | case X86EMUL_MODE_PROT32: |
2018 | cs.selector = (u16)(msr_data + 16); | 2018 | cs.selector = (u16)(msr_data + 16); |
@@ -3099,7 +3099,7 @@ twobyte_insn: | |||
3099 | } | 3099 | } |
3100 | break; | 3100 | break; |
3101 | case 0x05: /* syscall */ | 3101 | case 0x05: /* syscall */ |
3102 | rc = emulate_syscall(ctxt); | 3102 | rc = emulate_syscall(ctxt, ops); |
3103 | if (rc != X86EMUL_CONTINUE) | 3103 | if (rc != X86EMUL_CONTINUE) |
3104 | goto done; | 3104 | goto done; |
3105 | else | 3105 | else |
@@ -3155,7 +3155,7 @@ twobyte_insn: | |||
3155 | /* wrmsr */ | 3155 | /* wrmsr */ |
3156 | msr_data = (u32)c->regs[VCPU_REGS_RAX] | 3156 | msr_data = (u32)c->regs[VCPU_REGS_RAX] |
3157 | | ((u64)c->regs[VCPU_REGS_RDX] << 32); | 3157 | | ((u64)c->regs[VCPU_REGS_RDX] << 32); |
3158 | if (kvm_set_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], msr_data)) { | 3158 | if (ops->set_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], msr_data)) { |
3159 | kvm_inject_gp(ctxt->vcpu, 0); | 3159 | kvm_inject_gp(ctxt->vcpu, 0); |
3160 | goto done; | 3160 | goto done; |
3161 | } | 3161 | } |
@@ -3164,7 +3164,7 @@ twobyte_insn: | |||
3164 | break; | 3164 | break; |
3165 | case 0x32: | 3165 | case 0x32: |
3166 | /* rdmsr */ | 3166 | /* rdmsr */ |
3167 | if (kvm_get_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], &msr_data)) { | 3167 | if (ops->get_msr(ctxt->vcpu, c->regs[VCPU_REGS_RCX], &msr_data)) { |
3168 | kvm_inject_gp(ctxt->vcpu, 0); | 3168 | kvm_inject_gp(ctxt->vcpu, 0); |
3169 | goto done; | 3169 | goto done; |
3170 | } else { | 3170 | } else { |
@@ -3175,14 +3175,14 @@ twobyte_insn: | |||
3175 | c->dst.type = OP_NONE; | 3175 | c->dst.type = OP_NONE; |
3176 | break; | 3176 | break; |
3177 | case 0x34: /* sysenter */ | 3177 | case 0x34: /* sysenter */ |
3178 | rc = emulate_sysenter(ctxt); | 3178 | rc = emulate_sysenter(ctxt, ops); |
3179 | if (rc != X86EMUL_CONTINUE) | 3179 | if (rc != X86EMUL_CONTINUE) |
3180 | goto done; | 3180 | goto done; |
3181 | else | 3181 | else |
3182 | goto writeback; | 3182 | goto writeback; |
3183 | break; | 3183 | break; |
3184 | case 0x35: /* sysexit */ | 3184 | case 0x35: /* sysexit */ |
3185 | rc = emulate_sysexit(ctxt); | 3185 | rc = emulate_sysexit(ctxt, ops); |
3186 | if (rc != X86EMUL_CONTINUE) | 3186 | if (rc != X86EMUL_CONTINUE) |
3187 | goto done; | 3187 | goto done; |
3188 | else | 3188 | else |