All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Amit Shah <amit.shah@redhat.com>,
	tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	kvm list <kvm@vger.kernel.org>
Subject: Re: [KVM paravirt issue?] Re: vsyscall=emulate regression
Date: Thu, 16 Feb 2012 19:39:37 +0200	[thread overview]
Message-ID: <4F3D3F59.80807@redhat.com> (raw)
In-Reply-To: <CALCETrXjJtKLhe2rRkuy57Ai+5X2-+qh9eMbE5y-UhX=CPWftA@mail.gmail.com>

On 02/16/2012 07:35 PM, Andy Lutomirski wrote:
> >
> > so it seems like kvm doesn't set PF_INSTR?
>
> Yes, this is on purpose, and you're almost certainly right (and I feel
> dumb for not figuring this out immediately).  The error message is:
>
> segfault at ffffffffff600400 ip ffffffffff600400 sp 00007fff103d72f8 error 5
>
> which is garbage.  The instruction at 0xffffffffff600400 can't fetch
> itself as data and fault on the data access (at least not in 64-bit
> mode, as far as I can think of, without evil messing with the TLBs).
>
> So... what do we do about this?  This (whitespace-damaged, untested)
> patch will probably work around it well enough to boot the system:
>
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index 9d74824..52b9522 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -741,8 +741,11 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long
>                  * Instruction fetch faults in the vsyscall page might need
>                  * emulation.
>                  */
> -               if (unlikely((error_code & PF_INSTR) &&
> +               if (unlikely(address == regs->ip && !(error_code & PF_WRITE) &&
>                              ((address & ~0xfff) == VSYSCALL_START))) {
> +                       WARN_ONCE(!(error_code & PF_INSTR),
> +                                 "Fixing up bogus vsyscall read fault -- "
> +                                 "your hypervisor is buggy.");
>                         if (emulate_vsyscall(regs, address))
>                                 return;
>                 }
>
> Before we patch the guest like this, though, it would be nice to know
> what hosts are affected.  If it's just one version of RHEL6, maybe it
> makes sense to fix the hypervisor and either leave the guest alone or
> just add a warning saying to fix your hypervisor, like:
>
> WARN_ONCE(address == regs->ip && !(error_code & (PF_INSTR | PF_WRITE))
> && user_64bit_mode(regs), "Fishy page fault -- you might need to fix
> your hypervisor");
>
> near some exit path in the page fault handler.  The 64-bit check is
> because (I think) 32-bit code can mess with regs->ip using a cs offset
> in the LDT and trigger the warning at will.
>

We'll just fix all affected hypervisor versions.  No need to uglify the
guest for a clear kvm bug.

-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2012-02-16 17:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03  8:27 vsyscall=emulate regression Amit Shah
2012-02-03 15:30 ` Andy Lutomirski
2012-02-03 17:32   ` Amit Shah
2012-02-14 12:22 ` Amit Shah
2012-02-14 16:26   ` Andy Lutomirski
2012-02-15 11:01     ` Amit Shah
2012-02-15 19:36       ` [KVM paravirt issue?] " Andy Lutomirski
2012-02-16 16:17         ` Avi Kivity
2012-02-16 16:45           ` Andy Lutomirski
2012-02-16 17:14             ` Avi Kivity
2012-02-16 17:35               ` Andy Lutomirski
2012-02-16 17:39                 ` Avi Kivity [this message]
2012-02-24  4:34                   ` H. Peter Anvin
2012-02-24 18:58                     ` Andy Lutomirski
2012-02-28 10:00                       ` Avi Kivity
2012-02-28 11:08                         ` Amit Shah

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=4F3D3F59.80807@redhat.com \
    --to=avi@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --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 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.