mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Andy Lutomirski <luto@kernel.org>, X86 ML <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	kvm list <kvm@vger.kernel.org>, Borislav Petkov <bp@alien8.de>,
	Thomas Garnier <thgarnie@google.com>,
	Juergen Gross <jgross@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: Speeding up VMX with GDT fixmap trickery?
Date: Fri, 9 Jun 2017 09:14:51 +0200	[thread overview]
Message-ID: <f486b1f0-ae78-8c66-45e9-a58d3a727b29@redhat.com> (raw)
In-Reply-To: <CALCETrXTpbGikcLRQSUaEHhdPDPjem26LDS1umhQTOdmqPdyqg@mail.gmail.com>



On 09/06/2017 03:13, Andy Lutomirski wrote:
> Hi all-
> 
> As promised when Thomas did his GDT fixmap work, here is a draft patch
> to speed up KVM by extending it.
> 
> The downside of this patch is that it makes the fixmap significantly
> larger on 64-bit systems if NR_CPUS is large (it adds 15 more pages
> per CPU).  I don't know if we care at all.  It also bloats the kernel
> image by 4k and wastes 4k of RAM for the entire time the system is
> booted.  We could avoid the latter bit (sort of) by not mapping the
> extra fixmap pages at all and handling the resulting faults somehow.
> That would scare me -- now we have IRET generating #PF when running
> malicious , and that way lies utter madness.
> 
> The upside is that we don't need to do LGDT after a vmexit on VMX.
> LGDT is slooooooooooow.  But no, I haven't benchmarked this yet.
> 
> What do you all think?
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/commit/?h=x86/kvm&id=e249a09787d6956b52d8260b2326d8f12f768799

Not sure I understand this completely, but:

 /* Get the fixmap index for a specific processor */
 static inline unsigned int get_cpu_gdt_ro_index(int cpu)
 {
-	return FIX_GDT_REMAP_BEGIN + cpu;
+	return FIX_GDT_REMAP_END - cpu * PAGES_PER_GDT;
 }

isn't this off by one.  I think it should be

	FIX_GDT_REMAP_END + 1 - cpu * PAGES_PER_GDT

or just FIX_GDT_REMAP_BEGIN + cpu * PAGES_PER_GDT?  That is for example:

	FIX_GDT_REMAP_BEGIN = 100
	get_cpu_gdt_ro_index(0) = 100
	get_cpu_gdt_ro_index(1) = 116
	get_cpu_gdt_ro_index(2) = 132
	get_cpu_gdt_ro_index(3) = 148
	FIX_GDT_REMAP_END = 163

Paolo

  parent reply	other threads:[~2017-06-09  7:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09  1:13 Andy Lutomirski
2017-06-09  3:13 ` Andrew Cooper
2017-06-09  7:14 ` Paolo Bonzini [this message]
2017-06-09 15:45   ` Andy Lutomirski
2017-06-12 14:14     ` Paolo Bonzini

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=f486b1f0-ae78-8c66-45e9-a58d3a727b29@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=jgross@suse.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=thgarnie@google.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®