mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>, X86 ML <x86@kernel.org>
Cc: "kvm list" <kvm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Borislav Petkov" <bpetkov@suse.de>,
	"Thomas Garnier" <thgarnie@google.com>,
	"Jim Mattson" <jmattson@google.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: [PATCH 3/6] x86/kvm/vmx: Get rid of segment_base() on 64-bit kernels
Date: Mon, 20 Feb 2017 08:56:11 -0800	[thread overview]
Message-ID: <87977e82b4a5e2aa604e0dff7c4ec8a815886313.1487609329.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1487609329.git.luto@kernel.org>
In-Reply-To: <cover.1487609329.git.luto@kernel.org>

It was a bit buggy (it didn't list all segment types that needed
64-bit fixups), but the bug was irrelevant because it wasn't called
in any interesting context on 64-bit kernels and was only used for
data segents on 32-bit kernels.

To avoid confusion, make it explicitly 32-bit only.

Cc: Thomas Garnier <thgarnie@google.com>
Cc: Jim Mattson <jmattson@google.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/kvm/vmx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 46420aaf1684..b1810a0edec3 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2059,6 +2059,12 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
 	}
 }
 
+#ifdef CONFIG_X86_32
+/*
+ * On 32-bit kernels, VM exits still load the FS and GS bases from the
+ * VMCS rather than the segment table.  KVM uses this helper to figure
+ * out the current bases to poke them into the VMCS before entry.
+ */
 static unsigned long segment_base(u16 selector)
 {
 	struct desc_ptr *gdt = this_cpu_ptr(&host_gdt);
@@ -2081,12 +2087,9 @@ static unsigned long segment_base(u16 selector)
 	}
 	d = (struct desc_struct *)(table_base + (selector & ~7));
 	v = get_desc_base(d);
-#ifdef CONFIG_X86_64
-       if (d->s == 0 && (d->type == 2 || d->type == 9 || d->type == 11))
-               v |= ((unsigned long)((struct ldttss_desc64 *)d)->base3) << 32;
-#endif
 	return v;
 }
+#endif
 
 static void vmx_save_host_state(struct kvm_vcpu *vcpu)
 {
-- 
2.9.3

  parent reply	other threads:[~2017-02-20 16:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20 16:56 [PATCH 0/6] KVM TSS cleanups and speedups Andy Lutomirski
2017-02-20 16:56 ` [PATCH 1/6] x86/asm: Define the kernel TSS limit in a macro Andy Lutomirski
2017-02-20 16:56 ` [PATCH 2/6] x86/kvm/vmx: Don't fetch the TSS base from the GDT Andy Lutomirski
2017-02-20 16:56 ` Andy Lutomirski [this message]
2017-02-20 16:56 ` [PATCH 4/6] x86/kvm/vmx: Simplify segment_base() Andy Lutomirski
2017-02-20 17:49   ` Thomas Garnier
2017-02-20 16:56 ` [PATCH 5/6] x86/asm/64: Drop __cacheline_aligned from struct x86_hw_tss Andy Lutomirski
2017-02-20 16:56 ` [PATCH 6/6] x86/kvm/vmx: Defer TR reload after VM exit Andy Lutomirski
2017-02-20 17:51   ` Paolo Bonzini
2017-02-20 17:52 ` [PATCH 0/6] KVM TSS cleanups and speedups 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=87977e82b4a5e2aa604e0dff7c4ec8a815886313.1487609329.git.luto@kernel.org \
    --to=luto@kernel.org \
    --cc=bpetkov@suse.de \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --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®