Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread Paolo Bonzini
On 15/12/2016 14:09, David Hildenbrand wrote: >>> >>> bool exception_gpa_valid(struct kvm_vcpu) >>> { >>> // check if svm >>> // check if exit code is NPF >>> // check ctxt >>> } >> >> No, this would be a layering violation. The emulator ops don't know >> about svm and exit codes

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread Paolo Bonzini
On 15/12/2016 14:09, David Hildenbrand wrote: >>> >>> bool exception_gpa_valid(struct kvm_vcpu) >>> { >>> // check if svm >>> // check if exit code is NPF >>> // check ctxt >>> } >> >> No, this would be a layering violation. The emulator ops don't know >> about svm and exit codes

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread David Hildenbrand
+ * If the exit was due to a NPF we may already have a GPA. + * If the GPA is present, use it to avoid the GVA to GPA table walk. + * Note, this cannot be used on string operations since string + * operation using rep will only have the initial GPA from the NPF + * occurred.

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread David Hildenbrand
+ * If the exit was due to a NPF we may already have a GPA. + * If the GPA is present, use it to avoid the GVA to GPA table walk. + * Note, this cannot be used on string operations since string + * operation using rep will only have the initial GPA from the NPF + * occurred.

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread Paolo Bonzini
On 15/12/2016 13:42, David Hildenbrand wrote: > >> +++ b/arch/x86/kvm/x86.c >> @@ -4420,6 +4420,21 @@ int kvm_write_guest_virt_system(struct >> x86_emulate_ctxt *ctxt, >> } >> EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system); >> >> +static int vcpu_is_mmio_gpa(struct kvm_vcpu *vcpu, unsigned

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread Paolo Bonzini
On 15/12/2016 13:42, David Hildenbrand wrote: > >> +++ b/arch/x86/kvm/x86.c >> @@ -4420,6 +4420,21 @@ int kvm_write_guest_virt_system(struct >> x86_emulate_ctxt *ctxt, >> } >> EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system); >> >> +static int vcpu_is_mmio_gpa(struct kvm_vcpu *vcpu, unsigned

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread David Hildenbrand
+++ b/arch/x86/kvm/x86.c @@ -4420,6 +4420,21 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt, } EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system); +static int vcpu_is_mmio_gpa(struct kvm_vcpu *vcpu, unsigned long gva, + gpa_t gpa, bool write) +{ +

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-15 Thread David Hildenbrand
+++ b/arch/x86/kvm/x86.c @@ -4420,6 +4420,21 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt, } EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system); +static int vcpu_is_mmio_gpa(struct kvm_vcpu *vcpu, unsigned long gva, + gpa_t gpa, bool write) +{ +

[PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-14 Thread Brijesh Singh
From: Tom Lendacky When a guest causes a NPF which requires emulation, KVM sometimes walks the guest page tables to translate the GVA to a GPA. This is unnecessary most of the time on AMD hardware since the hardware provides the GPA in EXITINFO2. The only exception

[PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-14 Thread Brijesh Singh
From: Tom Lendacky When a guest causes a NPF which requires emulation, KVM sometimes walks the guest page tables to translate the GVA to a GPA. This is unnecessary most of the time on AMD hardware since the hardware provides the GPA in EXITINFO2. The only exception cases involve string

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-08 Thread Paolo Bonzini
On 29/11/2016 20:38, Brijesh Singh wrote: > > > On 11/29/2016 12:20 PM, Thomas Gleixner wrote: >> On Tue, 29 Nov 2016, Brijesh Singh wrote: >>> --- a/arch/x86/kvm/emulate.c >>> +++ b/arch/x86/kvm/emulate.c >>> @@ -5483,3 +5483,11 @@ void emulator_writeback_register_cache(struct >>>

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-12-08 Thread Paolo Bonzini
On 29/11/2016 20:38, Brijesh Singh wrote: > > > On 11/29/2016 12:20 PM, Thomas Gleixner wrote: >> On Tue, 29 Nov 2016, Brijesh Singh wrote: >>> --- a/arch/x86/kvm/emulate.c >>> +++ b/arch/x86/kvm/emulate.c >>> @@ -5483,3 +5483,11 @@ void emulator_writeback_register_cache(struct >>>

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Brijesh Singh
On 11/29/2016 12:20 PM, Thomas Gleixner wrote: On Tue, 29 Nov 2016, Brijesh Singh wrote: --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -5483,3 +5483,11 @@ void emulator_writeback_register_cache(struct x86_emulate_ctxt *ctxt) { writeback_registers(ctxt); } + +bool

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Brijesh Singh
On 11/29/2016 12:20 PM, Thomas Gleixner wrote: On Tue, 29 Nov 2016, Brijesh Singh wrote: --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -5483,3 +5483,11 @@ void emulator_writeback_register_cache(struct x86_emulate_ctxt *ctxt) { writeback_registers(ctxt); } + +bool

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Thomas Gleixner
On Tue, 29 Nov 2016, Brijesh Singh wrote: > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -5483,3 +5483,11 @@ void emulator_writeback_register_cache(struct > x86_emulate_ctxt *ctxt) > { > writeback_registers(ctxt); > } > + > +bool emulator_is_string_op(struct

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Thomas Gleixner
On Tue, 29 Nov 2016, Brijesh Singh wrote: > --- a/arch/x86/kvm/emulate.c > +++ b/arch/x86/kvm/emulate.c > @@ -5483,3 +5483,11 @@ void emulator_writeback_register_cache(struct > x86_emulate_ctxt *ctxt) > { > writeback_registers(ctxt); > } > + > +bool emulator_is_string_op(struct

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Paolo Bonzini
On 29/11/2016 19:01, Brijesh Singh wrote: > From: Tom Lendacky > > When a guest causes a NPF which requires emulation, KVM sometimes walks > the guest page tables to translate the GVA to a GPA. This is unnecessary > most of the time on AMD hardware since the hardware

Re: [PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Paolo Bonzini
On 29/11/2016 19:01, Brijesh Singh wrote: > From: Tom Lendacky > > When a guest causes a NPF which requires emulation, KVM sometimes walks > the guest page tables to translate the GVA to a GPA. This is unnecessary > most of the time on AMD hardware since the hardware provides the GPA in >

[PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Brijesh Singh
From: Tom Lendacky When a guest causes a NPF which requires emulation, KVM sometimes walks the guest page tables to translate the GVA to a GPA. This is unnecessary most of the time on AMD hardware since the hardware provides the GPA in EXITINFO2. The only exception

[PATCH v3] kvm: svm: Use the hardware provided GPA instead of page walk

2016-11-29 Thread Brijesh Singh
From: Tom Lendacky When a guest causes a NPF which requires emulation, KVM sometimes walks the guest page tables to translate the GVA to a GPA. This is unnecessary most of the time on AMD hardware since the hardware provides the GPA in EXITINFO2. The only exception cases involve string