diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-08-02 05:47:51 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 04:50:29 -0400 |
commit | 4fc40f076f4fa289dd546990b597351c9cdad985 (patch) | |
tree | 589e394aee1efb859a398438ced6326a5df3f97e | |
parent | 9928ff608b1b6ba10fafde85f57970a83a181331 (diff) |
KVM: x86 emulator: check io permissions only once for string pio
Do not recheck io permission on every iteration.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/emulate.c | 6 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 0f901c16cf1c..8762411fe9bb 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -224,6 +224,7 @@ struct x86_emulate_ctxt { | |||
224 | int interruptibility; | 224 | int interruptibility; |
225 | 225 | ||
226 | bool restart; /* restart string instruction after writeback */ | 226 | bool restart; /* restart string instruction after writeback */ |
227 | bool perm_ok; /* do not check permissions if true */ | ||
227 | 228 | ||
228 | int exception; /* exception that happens during emulation or -1 */ | 229 | int exception; /* exception that happens during emulation or -1 */ |
229 | u32 error_code; /* error code for exception */ | 230 | u32 error_code; /* error code for exception */ |
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 4d49514a919e..760e2b030e68 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1621,9 +1621,15 @@ static bool emulator_io_permited(struct x86_emulate_ctxt *ctxt, | |||
1621 | struct x86_emulate_ops *ops, | 1621 | struct x86_emulate_ops *ops, |
1622 | u16 port, u16 len) | 1622 | u16 port, u16 len) |
1623 | { | 1623 | { |
1624 | if (ctxt->perm_ok) | ||
1625 | return true; | ||
1626 | |||
1624 | if (emulator_bad_iopl(ctxt, ops)) | 1627 | if (emulator_bad_iopl(ctxt, ops)) |
1625 | if (!emulator_io_port_access_allowed(ctxt, ops, port, len)) | 1628 | if (!emulator_io_port_access_allowed(ctxt, ops, port, len)) |
1626 | return false; | 1629 | return false; |
1630 | |||
1631 | ctxt->perm_ok = true; | ||
1632 | |||
1627 | return true; | 1633 | return true; |
1628 | } | 1634 | } |
1629 | 1635 | ||
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 3cbe8032394a..35c0f4e4a621 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3997,6 +3997,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu, | |||
3997 | memcpy(c->regs, vcpu->arch.regs, sizeof c->regs); | 3997 | memcpy(c->regs, vcpu->arch.regs, sizeof c->regs); |
3998 | vcpu->arch.emulate_ctxt.interruptibility = 0; | 3998 | vcpu->arch.emulate_ctxt.interruptibility = 0; |
3999 | vcpu->arch.emulate_ctxt.exception = -1; | 3999 | vcpu->arch.emulate_ctxt.exception = -1; |
4000 | vcpu->arch.emulate_ctxt.perm_ok = false; | ||
4000 | 4001 | ||
4001 | r = x86_decode_insn(&vcpu->arch.emulate_ctxt); | 4002 | r = x86_decode_insn(&vcpu->arch.emulate_ctxt); |
4002 | trace_kvm_emulate_insn_start(vcpu); | 4003 | trace_kvm_emulate_insn_start(vcpu); |