diff options
author | Glauber Costa <glommer@redhat.com> | 2009-05-12 16:21:05 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-06-10 04:48:54 -0400 |
commit | 2809f5d2c4cfad171167b131bb2a21ab65eba40f (patch) | |
tree | eee772c1476fb05ababf306d6458f4ccd8b8412a /arch/x86/kvm/svm.c | |
parent | 547de29e5b1662deb05b5f90917902dc0e9ac182 (diff) |
KVM: Replace ->drop_interrupt_shadow() by ->set_interrupt_shadow()
This patch replaces drop_interrupt_shadow with the more
general set_interrupt_shadow, that can either drop or raise
it, depending on its parameter. It also adds ->get_interrupt_shadow()
for future use.
Signed-off-by: Glauber Costa <glommer@redhat.com>
CC: H. Peter Anvin <hpa@zytor.com>
CC: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r-- | arch/x86/kvm/svm.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f994c6df78be..8b5ffbd55c11 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
@@ -202,6 +202,27 @@ static int is_external_interrupt(u32 info) | |||
202 | return info == (SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_INTR); | 202 | return info == (SVM_EVTINJ_VALID | SVM_EVTINJ_TYPE_INTR); |
203 | } | 203 | } |
204 | 204 | ||
205 | static u32 svm_get_interrupt_shadow(struct kvm_vcpu *vcpu, int mask) | ||
206 | { | ||
207 | struct vcpu_svm *svm = to_svm(vcpu); | ||
208 | u32 ret = 0; | ||
209 | |||
210 | if (svm->vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) | ||
211 | ret |= X86_SHADOW_INT_STI | X86_SHADOW_INT_MOV_SS; | ||
212 | return ret & mask; | ||
213 | } | ||
214 | |||
215 | static void svm_set_interrupt_shadow(struct kvm_vcpu *vcpu, int mask) | ||
216 | { | ||
217 | struct vcpu_svm *svm = to_svm(vcpu); | ||
218 | |||
219 | if (mask == 0) | ||
220 | svm->vmcb->control.int_state &= ~SVM_INTERRUPT_SHADOW_MASK; | ||
221 | else | ||
222 | svm->vmcb->control.int_state |= SVM_INTERRUPT_SHADOW_MASK; | ||
223 | |||
224 | } | ||
225 | |||
205 | static void skip_emulated_instruction(struct kvm_vcpu *vcpu) | 226 | static void skip_emulated_instruction(struct kvm_vcpu *vcpu) |
206 | { | 227 | { |
207 | struct vcpu_svm *svm = to_svm(vcpu); | 228 | struct vcpu_svm *svm = to_svm(vcpu); |
@@ -215,7 +236,7 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu) | |||
215 | __func__, kvm_rip_read(vcpu), svm->next_rip); | 236 | __func__, kvm_rip_read(vcpu), svm->next_rip); |
216 | 237 | ||
217 | kvm_rip_write(vcpu, svm->next_rip); | 238 | kvm_rip_write(vcpu, svm->next_rip); |
218 | svm->vmcb->control.int_state &= ~SVM_INTERRUPT_SHADOW_MASK; | 239 | svm_set_interrupt_shadow(vcpu, 0); |
219 | } | 240 | } |
220 | 241 | ||
221 | static int has_svm(void) | 242 | static int has_svm(void) |
@@ -2259,12 +2280,6 @@ static void pre_svm_run(struct vcpu_svm *svm) | |||
2259 | new_asid(svm, svm_data); | 2280 | new_asid(svm, svm_data); |
2260 | } | 2281 | } |
2261 | 2282 | ||
2262 | static void svm_drop_interrupt_shadow(struct kvm_vcpu *vcpu) | ||
2263 | { | ||
2264 | struct vcpu_svm *svm = to_svm(vcpu); | ||
2265 | svm->vmcb->control.int_state &= ~SVM_INTERRUPT_SHADOW_MASK; | ||
2266 | } | ||
2267 | |||
2268 | static void svm_inject_nmi(struct kvm_vcpu *vcpu) | 2283 | static void svm_inject_nmi(struct kvm_vcpu *vcpu) |
2269 | { | 2284 | { |
2270 | struct vcpu_svm *svm = to_svm(vcpu); | 2285 | struct vcpu_svm *svm = to_svm(vcpu); |
@@ -2667,6 +2682,8 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
2667 | .run = svm_vcpu_run, | 2682 | .run = svm_vcpu_run, |
2668 | .handle_exit = handle_exit, | 2683 | .handle_exit = handle_exit, |
2669 | .skip_emulated_instruction = skip_emulated_instruction, | 2684 | .skip_emulated_instruction = skip_emulated_instruction, |
2685 | .set_interrupt_shadow = svm_set_interrupt_shadow, | ||
2686 | .get_interrupt_shadow = svm_get_interrupt_shadow, | ||
2670 | .patch_hypercall = svm_patch_hypercall, | 2687 | .patch_hypercall = svm_patch_hypercall, |
2671 | .set_irq = svm_set_irq, | 2688 | .set_irq = svm_set_irq, |
2672 | .set_nmi = svm_inject_nmi, | 2689 | .set_nmi = svm_inject_nmi, |
@@ -2676,7 +2693,6 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
2676 | .enable_nmi_window = enable_nmi_window, | 2693 | .enable_nmi_window = enable_nmi_window, |
2677 | .enable_irq_window = enable_irq_window, | 2694 | .enable_irq_window = enable_irq_window, |
2678 | .update_cr8_intercept = update_cr8_intercept, | 2695 | .update_cr8_intercept = update_cr8_intercept, |
2679 | .drop_interrupt_shadow = svm_drop_interrupt_shadow, | ||
2680 | 2696 | ||
2681 | .set_tss_addr = svm_set_tss_addr, | 2697 | .set_tss_addr = svm_set_tss_addr, |
2682 | .get_tdp_level = get_npt_level, | 2698 | .get_tdp_level = get_npt_level, |