public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Jonny Barker <jonny@jonnybarker.com>, KVM <kvm@vger.kernel.org>
Subject: Re: your patch "KVM: x86: Update emulator context mode if SYSENTER xfers to 64-bit mode"
Date: Thu, 11 Feb 2021 08:43:39 -0800	[thread overview]
Message-ID: <YCVeuxKYW2L6+pFs@google.com> (raw)
In-Reply-To: <6032a7c3-94d3-0d53-4c94-4767b5a9d6c3@suse.com>

On Wed, Feb 10, 2021, Jan Beulich wrote:
> I've noticed this patch while routinely screening the stable
> kernel logs for issues we may also need to fix in Xen. Isn't
> a similar change needed in SYSCALL emulation when going from
> compat to 64-bit mode?

Yep, it is.  AMD's APM explicitly states that compat always transitions to long
mode.

I believe em_sysexit() is technically buggy as well, though in the opposite way,
as it doesn't set ctxt->mode when switching from long mode to compat mode.  But,
it explicitly truncates rdx before assigning to rip so that's likely a benign
bug, at least for now.

I don't see anything in em_rsm() that will fixup ctxt->mode, so I'm guessing an
SMI with a 64-bit RIP will be fatal, too.

__emulate_int_real() can't switch mode, and INTn and company aren't emulated in
protected mode.

assign_eip_far() does update ctxt->mode, so far call/ret aren't broken.

Given the number of flows that can potentially affect mode, and the difficulty
in testing them, I feel like x86_emulate_insn() should handle refreshing the
mode, or at least do a sanity check to verify that it was already updated.

Side topic, I'm super curious why Intel lets SYSRET return to compat mode, when
SYSCALL #UDs in compat mode...

      reply	other threads:[~2021-02-11 16:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10  9:13 your patch "KVM: x86: Update emulator context mode if SYSENTER xfers to 64-bit mode" Jan Beulich
2021-02-11 16:43 ` Sean Christopherson [this message]

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=YCVeuxKYW2L6+pFs@google.com \
    --to=seanjc@google.com \
    --cc=jbeulich@suse.com \
    --cc=jonny@jonnybarker.com \
    --cc=kvm@vger.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