Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-05-02 Thread Brijesh Singh
Hi Paolo, I've tried the below patch and it seems to work fine. This does not consider PIO case and as you rightly pointed PIO should trigger #NPF relatively rarely. At least so far in my runs I have not seen PIO causing #NPF. If this sounds acceptable approach then I can submit v2 with these

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-05-02 Thread Brijesh Singh
Hi Paolo, I've tried the below patch and it seems to work fine. This does not consider PIO case and as you rightly pointed PIO should trigger #NPF relatively rarely. At least so far in my runs I have not seen PIO causing #NPF. If this sounds acceptable approach then I can submit v2 with these

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-05-02 Thread Paolo Bonzini
On 28/04/2017 21:15, Brijesh Singh wrote: > Hi Radim, > >> >> This will probably return false negatives when then vcpu->arch.gpa_val >> couldn't be used anyway (possibly after a VM exits), so it is hard to >> draw a conclusion. >> >> I would really like if we had a solution that passed the gpa

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-05-02 Thread Paolo Bonzini
On 28/04/2017 21:15, Brijesh Singh wrote: > Hi Radim, > >> >> This will probably return false negatives when then vcpu->arch.gpa_val >> couldn't be used anyway (possibly after a VM exits), so it is hard to >> draw a conclusion. >> >> I would really like if we had a solution that passed the gpa

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-28 Thread Brijesh Singh
Hi Radim, This will probably return false negatives when then vcpu->arch.gpa_val couldn't be used anyway (possibly after a VM exits), so it is hard to draw a conclusion. I would really like if we had a solution that passed the gpa inside function parameters. (Btw. cr2 can also be a virtual

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-28 Thread Brijesh Singh
Hi Radim, This will probably return false negatives when then vcpu->arch.gpa_val couldn't be used anyway (possibly after a VM exits), so it is hard to draw a conclusion. I would really like if we had a solution that passed the gpa inside function parameters. (Btw. cr2 can also be a virtual

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-26 Thread Radim Krčmář
2017-04-25 17:02-0500, Brijesh Singh: > > > I also wanted to avoid adding yet another variable but we can't depend on > > > cr2 parameters passed into x86_emulate_instruction(). > > > > > > The x86_emulate_instruction() function is called from two places: > > > > > > 1) handling the page-fault.

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-26 Thread Radim Krčmář
2017-04-25 17:02-0500, Brijesh Singh: > > > I also wanted to avoid adding yet another variable but we can't depend on > > > cr2 parameters passed into x86_emulate_instruction(). > > > > > > The x86_emulate_instruction() function is called from two places: > > > > > > 1) handling the page-fault.

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-25 Thread Brijesh Singh
I also wanted to avoid adding yet another variable but we can't depend on cr2 parameters passed into x86_emulate_instruction(). The x86_emulate_instruction() function is called from two places: 1) handling the page-fault. pf_interception [svm.c] kvm_mmu_page_fault [mmu.c]

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-25 Thread Brijesh Singh
I also wanted to avoid adding yet another variable but we can't depend on cr2 parameters passed into x86_emulate_instruction(). The x86_emulate_instruction() function is called from two places: 1) handling the page-fault. pf_interception [svm.c] kvm_mmu_page_fault [mmu.c]

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-25 Thread Radim Krčmář
2017-04-24 17:14-0500, Brijesh Singh: >> >/* GPA available (AMD only) */ >> >bool gpa_available; >> > + gpa_t gpa_val; >> >> Can't we pass this information through function parameters? >> >> (I'd rather avoid intractable variables.) >> > > I also wanted to avoid adding yet another

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-25 Thread Radim Krčmář
2017-04-24 17:14-0500, Brijesh Singh: >> >/* GPA available (AMD only) */ >> >bool gpa_available; >> > + gpa_t gpa_val; >> >> Can't we pass this information through function parameters? >> >> (I'd rather avoid intractable variables.) >> > > I also wanted to avoid adding yet another

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-24 Thread Brijesh Singh
Hi Radim, /* GPA available (AMD only) */ bool gpa_available; + gpa_t gpa_val; Can't we pass this information through function parameters? (I'd rather avoid intractable variables.) I also wanted to avoid adding yet another variable but we can't depend on cr2

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-24 Thread Brijesh Singh
Hi Radim, /* GPA available (AMD only) */ bool gpa_available; + gpa_t gpa_val; Can't we pass this information through function parameters? (I'd rather avoid intractable variables.) I also wanted to avoid adding yet another variable but we can't depend on cr2

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-24 Thread Radim Krčmář
2017-04-24 11:52-0400, Brijesh Singh: > On AMD hardware when a guest causes a NFP which requires emulation, > the vcpu->arch.gpa_available flag is set to indicate that cr2 contains > a valid GPA. > > Currently, emulator_read_write_onepage() makes use of gpa_available flag > to avoid a guest page

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-24 Thread Radim Krčmář
2017-04-24 11:52-0400, Brijesh Singh: > On AMD hardware when a guest causes a NFP which requires emulation, > the vcpu->arch.gpa_available flag is set to indicate that cr2 contains > a valid GPA. > > Currently, emulator_read_write_onepage() makes use of gpa_available flag > to avoid a guest page

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-24 Thread Brijesh Singh
On 04/24/2017 10:52 AM, Brijesh Singh wrote: On AMD hardware when a guest causes a NFP which requires emulation, Just realized a typo in patch description, s/NFP/NPF the vcpu->arch.gpa_available flag is set to indicate that cr2 contains a valid GPA. Currently,

Re: [PATCH] x86: kvm: Avoid guest page table walk when gpa_available is set

2017-04-24 Thread Brijesh Singh
On 04/24/2017 10:52 AM, Brijesh Singh wrote: On AMD hardware when a guest causes a NFP which requires emulation, Just realized a typo in patch description, s/NFP/NPF the vcpu->arch.gpa_available flag is set to indicate that cr2 contains a valid GPA. Currently,