提交 4fc40f07 编写于 作者: G Gleb Natapov 提交者: Avi Kivity

KVM: x86 emulator: check io permissions only once for string pio

Do not recheck io permission on every iteration.
Signed-off-by: NGleb Natapov <gleb@redhat.com>
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 9928ff60
...@@ -224,6 +224,7 @@ struct x86_emulate_ctxt { ...@@ -224,6 +224,7 @@ struct x86_emulate_ctxt {
int interruptibility; int interruptibility;
bool restart; /* restart string instruction after writeback */ bool restart; /* restart string instruction after writeback */
bool perm_ok; /* do not check permissions if true */
int exception; /* exception that happens during emulation or -1 */ int exception; /* exception that happens during emulation or -1 */
u32 error_code; /* error code for exception */ u32 error_code; /* error code for exception */
......
...@@ -1621,9 +1621,15 @@ static bool emulator_io_permited(struct x86_emulate_ctxt *ctxt, ...@@ -1621,9 +1621,15 @@ static bool emulator_io_permited(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops, struct x86_emulate_ops *ops,
u16 port, u16 len) u16 port, u16 len)
{ {
if (ctxt->perm_ok)
return true;
if (emulator_bad_iopl(ctxt, ops)) if (emulator_bad_iopl(ctxt, ops))
if (!emulator_io_port_access_allowed(ctxt, ops, port, len)) if (!emulator_io_port_access_allowed(ctxt, ops, port, len))
return false; return false;
ctxt->perm_ok = true;
return true; return true;
} }
......
...@@ -3997,6 +3997,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu, ...@@ -3997,6 +3997,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
memcpy(c->regs, vcpu->arch.regs, sizeof c->regs); memcpy(c->regs, vcpu->arch.regs, sizeof c->regs);
vcpu->arch.emulate_ctxt.interruptibility = 0; vcpu->arch.emulate_ctxt.interruptibility = 0;
vcpu->arch.emulate_ctxt.exception = -1; vcpu->arch.emulate_ctxt.exception = -1;
vcpu->arch.emulate_ctxt.perm_ok = false;
r = x86_decode_insn(&vcpu->arch.emulate_ctxt); r = x86_decode_insn(&vcpu->arch.emulate_ctxt);
trace_kvm_emulate_insn_start(vcpu); trace_kvm_emulate_insn_start(vcpu);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册