mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brijesh Singh <brijesh.singh@amd.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: <brijesh.singh@amd.com>, <kvm@vger.kernel.org>,
	thomas lendacky <thomas.lendacky@amd.com>, <rkrcmar@redhat.com>,
	<joro@8bytes.org>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>, <mingo@redhat.com>,
	<hpa@zytor.com>, <tglx@linutronix.de>, <bp@suse.de>
Subject: Re: [PATCH v2 3/3] kvm: svm: Use the hardware provided GPA instead of page walk
Date: Wed, 14 Dec 2016 12:39:01 -0600	[thread overview]
Message-ID: <8ddf2c3b-833e-4c88-ff14-d1826171703e@amd.com> (raw)
In-Reply-To: <ed5a3921-00b0-9214-0767-62585fb6b166@redhat.com>


On 12/14/2016 11:23 AM, Paolo Bonzini wrote:
>
>
> On 14/12/2016 18:07, Brijesh Singh wrote:
>>>
>>
>> Since now we are going to perform multiple conditional checks before
>> concluding that its safe to use HW provided GPA. How about if we add two
>> functions "emulator_is_rep_string_op" and "emulator_is_two_mem_op" into
>> emulator.c and  use these functions inside the x86.c to determine if its
>> safe to use HW provided gpa?
>
> Why not export only emulator_can_use_gpa from emulate.c?  (So in the end
> leaving emulator_is_string_op in emulate.c was the right thing to do, it
> was just the test that was wrong :)).
>

Actually, I was not sure if putting emulator_can_use_gpa() in emulate.c 
was right thing - mainly because emulator.c does not deal with GPA. I 
will go with your advice and put it in emulator.c, it makes easy :)


> The patch below is still missing the check for cross-page MMIO.  Your
> reference to the BKDG only covers MMCONFIG (sometimes referred to as
> ECAM), not MMIO in general.  Doing AND or OR into video memory for
> example is perfectly legal, and I'm fairly sure that some obscure legacy
> software does PUSH/POP into vram as well!
>
>

I used your below code snippet to detect cross-page MMIO access. After 
applying these changes cross-page MMIO read/write unit test is passing 
just fine. I will include it in patch.

 > Actually there is a nice trick you can do to support cross-page
 > MMIO access detection:

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 37cd31645d45..754d251dc611 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4549,6 +4549,7 @@ static int emulator_read_write_onepage(unsigned 
long addr, void *val,
  	 */
  	if (vcpu->arch.gpa_available &&
  	    !emulator_can_use_hw_gpa(ctxt) &&
+	    (addr & ~PAGE_MASK) == (exception->address & ~PAGE_MASK) &&
  	    vcpu_is_mmio_gpa(vcpu, addr, exception->address, write)) {
  		gpa = exception->address;
  		goto mmio;

  reply	other threads:[~2016-12-14 18:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23 17:01 [PATCH v2 0/3] x86: SVM: add additional SVM NPF error and use HW GPA Brijesh Singh
2016-11-23 17:01 ` [PATCH v2 1/3] kvm: svm: Add support for additional SVM NPF error codes Brijesh Singh
2017-07-27 16:27   ` Paolo Bonzini
2017-07-31 13:30     ` Brijesh Singh
2017-07-31 15:44       ` Paolo Bonzini
2017-07-31 16:54         ` Brijesh Singh
2017-07-31 20:05           ` Paolo Bonzini
2017-08-01 13:36             ` Brijesh Singh
2017-08-02 10:42               ` Paolo Bonzini
2017-08-04  0:30                 ` Brijesh Singh
2017-08-04 14:05                   ` Paolo Bonzini
2017-08-04 14:23                     ` Brijesh Singh
2016-11-23 17:01 ` [PATCH v2 2/3] kvm: svm: Add kvm_fast_pio_in support Brijesh Singh
2016-11-23 17:02 ` [PATCH v2 3/3] kvm: svm: Use the hardware provided GPA instead of page walk Brijesh Singh
2016-11-23 21:53   ` Paolo Bonzini
2016-12-08 14:52   ` Paolo Bonzini
2016-12-08 15:39     ` Brijesh Singh
2016-12-08 19:00       ` Brijesh Singh
2016-12-09 15:41         ` Paolo Bonzini
2016-12-12 17:51           ` Brijesh Singh
2016-12-13 17:09             ` Paolo Bonzini
2016-12-14 17:07               ` Brijesh Singh
2016-12-14 17:23                 ` Paolo Bonzini
2016-12-14 18:39                   ` Brijesh Singh [this message]
2016-12-14 18:47                     ` Paolo Bonzini
2016-11-24 20:51 ` [PATCH v2 0/3] x86: SVM: add additional SVM NPF error and use HW GPA Radim Krčmář

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ddf2c3b-833e-4c88-ff14-d1826171703e@amd.com \
    --to=brijesh.singh@amd.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®