From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jim Mattson <jmattson@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
kvm list <kvm@vger.kernel.org>, Joerg Roedel <joro@8bytes.org>,
everdox@gmail.com
Subject: Re: [PATCH] KVM: x86: handle wrap around 32-bit address space
Date: Mon, 27 Apr 2020 17:33:17 -0700 [thread overview]
Message-ID: <20200428003317.GC14870@linux.intel.com> (raw)
In-Reply-To: <CALMp9eTBs=deSYu1=CMLwZcO8HTpGM2JsgDxvFR1Y220tdUQ3w@mail.gmail.com>
On Mon, Apr 27, 2020 at 05:28:54PM -0700, Jim Mattson wrote:
> On Mon, Apr 27, 2020 at 9:59 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
> > @@ -1568,8 +1568,17 @@ static int skip_emulated_instruction(struct kvm_vcpu *vcpu)
> > */
> > if (!static_cpu_has(X86_FEATURE_HYPERVISOR) ||
> > to_vmx(vcpu)->exit_reason != EXIT_REASON_EPT_MISCONFIG) {
> > - rip = kvm_rip_read(vcpu);
> > - rip += vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
> > + orig_rip = kvm_rip_read(vcpu);
> > + rip = orig_rip + vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
> > +#ifdef CONFIG_X86_64
> > + /*
> > + * We need to mask out the high 32 bits of RIP if not in 64-bit
> > + * mode, but just finding out that we are in 64-bit mode is
> > + * quite expensive. Only do it if there was a carry.
> > + */
> > + if (unlikely(((rip ^ orig_rip) >> 31) == 3) && !is_64_bit_mode(vcpu))
>
> Is it actually possible to wrap around 0 without getting a segment
> limit violation, or is it only possible to wrap *to* 0 (i.e. rip==1ull
> << 32)?
Arbitrary wrap is possible. Limit checks are disabled for flat segs, it's
a legacy bug^W feature.
next prev parent reply other threads:[~2020-04-28 0:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 16:59 [PATCH] KVM: x86: handle wrap around 32-bit address space Paolo Bonzini
2020-04-28 0:28 ` Jim Mattson
2020-04-28 0:33 ` Sean Christopherson [this message]
2020-04-29 8:50 ` David Laight
2020-04-29 8:56 ` David Laight
2020-04-30 12:45 ` Paolo Bonzini
2020-04-30 13:18 ` David Laight
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=20200428003317.GC14870@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=everdox@gmail.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.