KVM: mmio_fault_cr2 is not used.
PATCH 1/5 KVM: mmio_fault_cr2 is not used.
Remove unused variable mmio_fault_cr2.
--- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/x86.c | 2 +- 2 files changed, 1 insertions(+), 2 deletions(-)
arch/x86/include/asm/kvm_host.h +0 -1
@@ -358,7 +358,6 @@ struct kvm_vcpu_arch {struct fpu guest_fpu;u64 xcr0; -gva_t mmio_fault_cr2;struct kvm_pio_request pio;void *pio_data;
arch/x86/kvm/x86.c +1 -1
@@ -4504,7 +4504,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;kvm_clear_exception_queue (vcpu); - vcpu->arch.mmio_fault_cr2 = cr2; +/* * TODO: fix emulate.c to use guest_read/write_register * instead of direct ->regs accesses, can save hundred cycles
Signature · 1 line
1.7.2.3
PATCH 2/5 KVM: emulator: sysexit should #GP in non protected mode.
--- arch/x86/kvm/emulate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/x86/kvm/emulate.c +2 -0
@@ -1973,6 +1973,8 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) cs.d =0 ; cs.l =1 ;break ; +default : +return emulate_gp (ctxt,0 ); } cs_sel |=SELECTOR_RPL_MASK ; ss_sel |=SELECTOR_RPL_MASK ;
Signature · 1 line
1.7.2.3
PATCH 3/5 KVM: emulator: Propagate fault in far jump emulation.
In reply to Gleb Natapov--- arch/x86/kvm/emulate.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/kvm/emulate.c +2 -1
@@ -3876,7 +3876,8 @@ special_insn: jump_far:memcpy (&sel, c->src.valptr + c->op_bytes,2 ); -if (load_segment_descriptor (ctxt, ops, sel,VCPU_SREG_CS )) + rc =load_segment_descriptor (ctxt, ops, sel,VCPU_SREG_CS ); +if (rc !=X86EMUL_CONTINUE ) goto done; c->eip =0 ;
Signature · 1 line
1.7.2.3
PATCH 5/5 KVM: call cache_all_regs() only once during instruction emulation.
In reply to Gleb Natapov--- arch/x86/kvm/x86.c | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
arch/x86/kvm/x86.c +6 -8
@@ -4404,6 +4404,12 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu)struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;int cs_db, cs_l; +/* +* TODO: fix emulate.c to use guest_read/write_register +* instead of direct ->regs accesses, can save hundred cycles +* on Intel for instructions that don't read/change RSP, for +* for example. +*/ cache_all_regs (vcpu); kvm_x86_ops->get_cs_db_l_bits (vcpu, &cs_db, &cs_l);
@@ -4505,14 +4511,6 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,kvm_clear_exception_queue (vcpu); -/* -* TODO: fix emulate.c to use guest_read/write_register -* instead of direct ->regs accesses, can save hundred cycles -* on Intel for instructions that don't read/change RSP, for -* for example. -*/ -cache_all_regs (vcpu); -if (!(emulation_type &EMULTYPE_NO_DECODE )) {init_emulate_ctxt (vcpu); vcpu->arch.emulate_ctxt.interruptibility =0 ;
Signature · 1 line
1.7.2.3
PATCH 4/5 KVM: Fix compound mmio.
In reply to Gleb Natapovmmio_index should be taken into account when copying data from userspace.
--- arch/x86/kvm/x86.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86/kvm/x86.c +2 -1
@@ -5518,7 +5518,8 @@ static int complete_mmio(struct kvm_vcpu *vcpu)if (vcpu->mmio_needed) { vcpu->mmio_needed =0 ;if (!vcpu->mmio_is_write) -memcpy (vcpu->mmio_data, run->mmio.data,8 ); +memcpy (vcpu->mmio_data + vcpu->mmio_index, + run->mmio.data,8 ); vcpu->mmio_index +=8 ;if (vcpu->mmio_index < vcpu->mmio_size) { run->exit_reason =KVM_EXIT_MMIO ;
Signature · 1 line
1.7.2.3
Re: [PATCH 2/5] KVM: emulator: sysexit should #GP in non protected mode.
In reply to Gleb NatapovQuoted 10 lines · Gleb Natapov
Signed-off-by Gleb Natapov<[email protected]>--- arch/x86/kvm/emulate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)arch/x86/kvm/emulate.c +0
-0
arch/x86/kvm/emulate.c emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) · line 1978
Quoted 6 lines
arch/x86/kvm/emulate.c +2
-0@@ -1973,6 +1973,8 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) cs.d =0 ; cs.l =1 ;break ; +default : +return emulate_gp (ctxt,0 ); }
In addition, looks like the instruction is valid in 16-bit protected mode.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 4/5] KVM: Fix compound mmio.
In reply to Gleb NatapovQuoted 13 lines · Gleb Natapov
mmio_indexshould be taken into account when copying data from userspace.Signed-off-by Gleb Natapov<[email protected]>--- arch/x86/kvm/x86.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c static int complete_mmio(struct kvm_vcpu *vcpu) · line 5525
Quoted 9 lines
arch/x86/kvm/x86.c +2
-1@@ -5518,7 +5518,8 @@ static int complete_mmio(struct kvm_vcpu *vcpu)if (vcpu->mmio_needed) { vcpu->mmio_needed =0 ;if (!vcpu->mmio_is_write) -memcpy (vcpu->mmio_data, run->mmio.data,8 ); +memcpy (vcpu->mmio_data + vcpu->mmio_index, + run->mmio.data,8 ); vcpu->mmio_index +=8 ;if (vcpu->mmio_index< vcpu->mmio_size) { run->exit_reason =KVM_EXIT_MMIO ;
Interesting, the code passed the emulator.flat sse test. Does it now?
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 4/5] KVM: Fix compound mmio.
Quoted 9 lines · Avi Kivity
Quoted 8 lines · Gleb Natapov
mmio_indexshould be taken into account when copying data from userspace.Signed-off-by Gleb Natapov<[email protected]>--- arch/x86/kvm/x86.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
Quoted 17 lines
Quoted 5 lines
arch/x86/kvm/x86.c +0
-0arch/x86/kvm/x86.c static int complete_mmio(struct kvm_vcpu *vcpu) · line 5525
Quoted 9 lines
arch/x86/kvm/x86.c +2
-1@@ -5518,7 +5518,8 @@ static int complete_mmio(struct kvm_vcpu *vcpu)if (vcpu->mmio_needed) { vcpu->mmio_needed =0 ;if (!vcpu->mmio_is_write) -memcpy (vcpu->mmio_data, run->mmio.data,8 ); +memcpy (vcpu->mmio_data + vcpu->mmio_index, + run->mmio.data,8 ); vcpu->mmio_index +=8 ;if (vcpu->mmio_index< vcpu->mmio_size) { run->exit_reason =KVM_EXIT_MMIO ;Interesting, the code passed the emulator.flat sse test. Does it now?
It pass now and before. Probably by chance. But if I change read_emulated() to do
int n = min(size, (unsigned)KVM_MMIO_SIZE);
instead of
int n = min(size, 8u);
emulator.flat fails to emulate far jump instruction.
--
Gleb.
Re: [PATCH 2/5] KVM: emulator: sysexit should #GP in non protected mode.
In reply to Avi KivityQuoted 6 lines · Avi Kivity
Quoted 5 lines · Gleb Natapov
Signed-off-by Gleb Natapov<[email protected]>--- arch/x86/kvm/emulate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 14 lines
arch/x86/kvm/emulate.c emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) · line 1978
Quoted 11 lines
arch/x86/kvm/emulate.c +2
-0@@ -1973,6 +1973,8 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) cs.d =0 ; cs.l =1 ;break ; +default : +return emulate_gp (ctxt,0 ); }In addition, looks like the instruction is valid in 16-bit protected mode.
Actually we already check for real mode and vm86 at the start of the function, so the patch is incorrect. Will have to fix compile warning in some other way.
--
Gleb.
Re: [PATCH 4/5] KVM: Fix compound mmio.
In reply to Gleb NatapovQuoted 25 lines · Gleb Natapov
Quoted 24 lines · Avi Kivity
Quoted 22 lines · Gleb Natapov
mmio_indexshould be taken into account when copying data from userspace.Signed-off-by Gleb Natapov<[email protected]>--- arch/x86/kvm/x86.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)arch/x86/kvm/x86.c +2
-1@@ -5518,7 +5518,8 @@ static int complete_mmio(struct kvm_vcpu *vcpu)if (vcpu->mmio_needed) { vcpu->mmio_needed =0 ;if (!vcpu->mmio_is_write) -memcpy (vcpu->mmio_data, run->mmio.data,8 ); +memcpy (vcpu->mmio_data + vcpu->mmio_index, + run->mmio.data,8 ); vcpu->mmio_index +=8 ;if (vcpu->mmio_index< vcpu->mmio_size) { run->exit_reason =KVM_EXIT_MMIO ;
Quoted 3 lines
Quoted 2 lines
Interesting, the code passed the emulator.flat sse test. Does it now?
It pass now and before. Probably by chance.
I don't understand how. I explicitly set the values so that it would fail in that case.
Can you patch the test to fail with the current code?
Quoted 9 lines
But if I change
read_emulated()to doint n = min(size, (unsigned)KVM_MMIO_SIZE);instead of
int n = min(size, 8u);emulator.flat fails to emulate far jump instruction.
Ouch, looks like we have the multi-transaction support in two places. I guess this is what made sse mmio work.
Not sure what we should do (patch is fine, question is how to resolve the duplication).
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 2/5] KVM: emulator: sysexit should #GP in non protected mode.
In reply to Gleb NatapovQuoted 19 lines · Gleb Natapov
Quoted 18 lines · Avi Kivity
Quoted 16 lines · Gleb Natapov
Signed-off-by Gleb Natapov<[email protected]>--- arch/x86/kvm/emulate.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)arch/x86/kvm/emulate.c +2
-0@@ -1973,6 +1973,8 @@ emulate_sysexit(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) cs.d =0 ; cs.l =1 ;break ; +default : +return emulate_gp (ctxt,0 ); }
Quoted 6 lines
Quoted 2 lines
In addition, looks like the instruction is valid in 16-bit protected mode.
Actually we already check for real mode and vm86 at the start of the function, so the patch is incorrect. Will have to fix compile warning in some other way.
Right. Note the check for vm86 is unneeded, since we have the Priv tag set and vm86 implies cpl 3.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH 4/5] KVM: Fix compound mmio.
In reply to Avi KivityQuoted 26 lines · Avi Kivity
Quoted 25 lines · Gleb Natapov
Quoted 24 lines · Avi Kivity
Quoted 22 lines · Gleb Natapov
mmio_indexshould be taken into account when copying data from userspace.Signed-off-by Gleb Natapov<[email protected]>--- arch/x86/kvm/x86.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)arch/x86/kvm/x86.c +2
-1@@ -5518,7 +5518,8 @@ static int complete_mmio(struct kvm_vcpu *vcpu)if (vcpu->mmio_needed) { vcpu->mmio_needed =0 ;if (!vcpu->mmio_is_write) -memcpy (vcpu->mmio_data, run->mmio.data,8 ); +memcpy (vcpu->mmio_data + vcpu->mmio_index, + run->mmio.data,8 ); vcpu->mmio_index +=8 ;if (vcpu->mmio_index< vcpu->mmio_size) { run->exit_reason =KVM_EXIT_MMIO ;
Quoted 9 lines
Quoted 3 lines
Quoted 2 lines
Interesting, the code passed the emulator.flat sse test. Does it now?
It pass now and before. Probably by chance.
I don't understand how. I explicitly set the values so that it would fail in that case.
Can you patch the test to fail with the current code?
If I understand correctly you've already found the explanation why test case worked?
Quoted 8 lines
Quoted 8 lines
But if I change
read_emulated()to doint n =
min(size, (unsigned)KVM_MMIO_SIZE);instead of
int n =
min(size, 8u);
Quoted 8 lines
Quoted 1 line
emulator.flat fails to emulate far jump instruction.
Ouch, looks like we have the multi-transaction support in two places. I guess this is what made sse mmio work.
Not sure what we should do (patch is fine, question is how to resolve the duplication).
Multi-transaction works faster in complete_mmio, so read_emulated() should use it by doing int n = min(size, (unsigned)KVM_MMIO_SIZE). Other code in read_emulated() is still needed since it provides read re-play for multiple mmio reads during instruction emulation.
--
Gleb.
Re: [PATCH 4/5] KVM: Fix compound mmio.
Quoted 31 lines · Gleb Natapov
Quoted 30 lines · Avi Kivity
Quoted 28 lines · Gleb Natapov
Quoted 24 lines · Avi Kivity
On 04/12/2011 12:36 PM, Gleb Natapov wrote: >mmio_index should be taken into account when copying data from >userspace. > >Signed-off-by: Gleb Natapov<[email protected]> >--- > arch/x86/kvm/x86.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > >diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >index b568779..609c7ab 100644 >--- a/arch/x86/kvm/x86.c >+++ b/arch/x86/kvm/x86.c >@@ -5518,7 +5518,8 @@ static int complete_mmio(struct kvm_vcpu *vcpu) > if (vcpu->mmio_needed) { > vcpu->mmio_needed = 0; > if (!vcpu->mmio_is_write) >- memcpy(vcpu->mmio_data, run->mmio.data, 8); >+ memcpy(vcpu->mmio_data + vcpu->mmio_index, >+ run->mmio.data, 8); > vcpu->mmio_index += 8; > if (vcpu->mmio_index< vcpu->mmio_size) { > run->exit_reason = KVM_EXIT_MMIO;Quoted 2 lines
Interesting, the code passed the emulator.flat sse test. Does it now?
It pass now and before. Probably by chance.
Quoted 7 lines
Quoted 5 lines
I don't understand how. I explicitly set the values so that it would fail in that case.
Can you patch the test to fail with the current code?
If I understand correctly you've already found the explanation why test case worked?
Yes, but I used O_APPEND when writing my message.
Quoted 13 lines
Quoted 13 lines
Quoted 9 lines
But if I change
read_emulated()to doint n = min(size, (unsigned)KVM_MMIO_SIZE);instead of
int n = min(size, 8u);emulator.flat fails to emulate far jump instruction.
Ouch, looks like we have the multi-transaction support in two places. I guess this is what made sse mmio work.
Quoted 7 lines
Quoted 3 lines
Not sure what we should do (patch is fine, question is how to resolve the duplication).
Multi-transaction works faster in
complete_mmio, soread_emulated()should use it by doing int n =min(size, (unsigned)KVM_MMIO_SIZE). Other code inread_emulated()is still needed since it provides read re-play for multiple mmio reads during instruction emulation.
Not concerned about speed here.
Core support for large mmio feels correct, but the duplication doesn't.
Signature · 1 line
error compiling committee.c: too many arguments to function
Ping? What about those patches? 2/5 should be dropped, but others are not yet applied too as far as I see.
Quoted 40 lines · Gleb Natapov
Remove unused variable
mmio_fault_cr2.Signed-off-by Gleb Natapov <[email protected]>--- arch/x86/include/asm/kvm_host.h | 1 - arch/x86/kvm/x86.c | 2 +- 2 files changed, 1 insertions(+), 2 deletions(-)arch/x86/include/asm/kvm_host.h +0
-1@@ -358,7 +358,6 @@ struct kvm_vcpu_arch {struct fpu guest_fpu;u64 xcr0; -gva_t mmio_fault_cr2;struct kvm_pio_request pio;void *pio_data;arch/x86/kvm/x86.c +1
-1@@ -4504,7 +4504,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu,struct decode_cache *c = &vcpu->arch.emulate_ctxt.decode;kvm_clear_exception_queue (vcpu); - vcpu->arch.mmio_fault_cr2 = cr2; +/* * TODO: fix emulate.c to use guest_read/write_register * instead of direct ->regs accesses, can save hundred cycles Signature · 6 lines
1.7.2.3 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Gleb.
Quoted 2 lines · Gleb Natapov
Ping? What about those patches? 2/5 should be dropped, but others are not yet applied too as far as I see.
Applied now, thanks for the reminder.
Signature · 1 line
error compiling committee.c: too many arguments to function