All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Kevin Tian <kevin.tian@intel.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: Ping VT-x: [PATCH 10/11] x86/vmx: Work around VMEntry failure when Single Stepping in an STI shadow
Date: Mon, 3 Sep 2018 11:39:37 +0100	[thread overview]
Message-ID: <0d01afe4-04f4-5051-8339-54327683ff5b@citrix.com> (raw)
In-Reply-To: <1528120755-17455-11-git-send-email-andrew.cooper3@citrix.com>

On 04/06/18 14:59, Andrew Cooper wrote:
> See the code comment for the details.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Jun Nakajima <jun.nakajima@intel.com>
> CC: Kevin Tian <kevin.tian@intel.com>
>
> Jun/Kevin: This workaround is as suggested by Gil, and there is expected to be
> an SDM update discussing the corner case.
>
> Note that, like elsewhere dealing with eflags.tf, this is probably buggy in
> combination with MSR_DEBUGCTL.BTF.  I'll untangle the BTF swamp at some later
> point.
> ---
>  xen/arch/x86/hvm/vmx/vmx.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
>
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 82ef3aa..58ff8c7 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1794,6 +1794,36 @@ static void vmx_inject_event(const struct x86_event *event)
>          write_debugreg(6, merge_dr6(read_debugreg(6), event->pending_dbg,
>                                      curr->domain->arch.cpuid->feat.rtm));
>  
> +        /*
> +         * Work around SS/STI vmentry bug.
> +         *
> +         * If kernel code is single stepping itself and executes an STI
> +         * instruction resulting in an STI shadow, a vmexit occurs due to #DB
> +         * interception, but the vmentry fails due to a failed consistency
> +         * check.  (Hardware comes to the conclusion that there should be a
> +         * pending debug exception, but doesn't account for the pending #DB in
> +         * VMENTRY_INTR_INFO.)
> +         *
> +         * Manually adjust the pending debug exception field to mark BS as
> +         * pending, which satisfies the consistency check and allows the
> +         * vmentry to succeed.
> +         */
> +        if ( unlikely(regs->eflags & X86_EFLAGS_TF) )
> +        {
> +            unsigned long int_info;
> +
> +            __vmread(GUEST_INTERRUPTIBILITY_INFO, &int_info);
> +
> +            if ( int_info & VMX_INTR_SHADOW_STI )
> +            {
> +                unsigned long pending_dbg;
> +
> +                __vmread(GUEST_PENDING_DBG_EXCEPTIONS, &pending_dbg);
> +                __vmwrite(GUEST_PENDING_DBG_EXCEPTIONS,
> +                          pending_dbg | X86_DR6_BS);
> +            }
> +        }
> +
>          if ( !nestedhvm_vcpu_in_guestmode(curr) ||
>               !nvmx_intercepts_exception(curr, TRAP_debug, _event.error_code) )
>          {


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-09-03 10:39 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 13:59 [PATCH 00/11] Fixes to debugging facilities Andrew Cooper
2018-06-04 13:59 ` [PATCH 01/11] x86/svm Fixes and cleanup to svm_inject_event() Andrew Cooper
2018-06-06 13:37   ` Jan Beulich
2018-07-16 13:33     ` Andrew Cooper
2018-07-17  2:01       ` Boris Ostrovsky
2018-06-04 13:59 ` [PATCH 02/11] x86/vmx: Don't clobber %dr6 while debugging state is lazy Andrew Cooper
2018-06-06 10:16   ` Roger Pau Monné
2018-06-06 13:50   ` Jan Beulich
2018-06-06 14:16     ` Andrew Cooper
2018-06-07 11:05       ` Jan Beulich
2018-06-08 15:58         ` Andrew Cooper
2018-06-08 16:10           ` Jan Beulich
2018-07-17  9:28   ` Andrew Cooper
2018-07-19  2:14     ` Tian, Kevin
2018-06-04 13:59 ` [PATCH 03/11] x86: Initialise debug registers correctly Andrew Cooper
2018-06-06 10:34   ` Roger Pau Monné
2018-06-08 15:23     ` Andrew Cooper
2018-06-06 13:56   ` Jan Beulich
2018-06-08 15:42     ` Andrew Cooper
2018-06-08 16:14       ` Jan Beulich
2018-06-04 13:59 ` [PATCH 04/11] x86: Fix calculation of %dr6/7 reserved bits Andrew Cooper
2018-06-06 14:16   ` Jan Beulich
2018-06-06 14:50     ` Andrew Cooper
2018-06-06 14:52       ` Andrew Cooper
2018-06-06 15:11       ` Jan Beulich
2018-06-06 15:49   ` Roger Pau Monné
2018-06-06 15:59     ` Andrew Cooper
2018-06-06 17:36       ` Roger Pau Monné
2018-06-04 13:59 ` [PATCH 05/11] x86/emul: Unfold %cr4.de handling in x86emul_read_dr() Andrew Cooper
2018-06-06 14:20   ` Jan Beulich
2018-06-08 16:03     ` Andrew Cooper
2018-06-08 16:16       ` Jan Beulich
2018-06-06 15:54   ` Roger Pau Monné
2018-06-04 13:59 ` [PATCH 06/11] x86: Reorganise and rename debug register fields in struct vcpu Andrew Cooper
2018-06-06 15:00   ` Jan Beulich
2018-06-06 15:21     ` Andrew Cooper
2018-06-07 10:59       ` Jan Beulich
2018-06-06 16:22   ` Roger Pau Monné
2018-06-04 13:59 ` [PATCH 07/11] x86/emul: Add pending_dbg field to x86_event Andrew Cooper
2018-06-06 16:46   ` Roger Pau Monné
2018-06-06 16:50     ` Andrew Cooper
2018-06-06 17:03       ` Roger Pau Monné
2018-06-08 12:34   ` Jan Beulich
2018-06-08 12:48     ` Andrew Cooper
2018-06-04 13:59 ` [PATCH 08/11] x86/hvm: RFC - PROBABLY BROKEN - Defer all debugging/monitor actions to {svm, vmx}_inject_event() Andrew Cooper
2018-06-04 14:53   ` Razvan Cojocaru
2018-06-04 15:07     ` Razvan Cojocaru
2018-06-06 17:02   ` Roger Pau Monné
2018-06-08 13:00   ` Jan Beulich
2018-06-08 13:13     ` Andrew Cooper
2018-06-04 13:59 ` [PATCH 09/11] x86: Fix merging of new status bits into %dr6 Andrew Cooper
2018-06-06 17:09   ` Roger Pau Monné
2018-06-08 13:09   ` Jan Beulich
2018-06-04 13:59 ` [PATCH 10/11] x86/vmx: Work around VMEntry failure when Single Stepping in an STI shadow Andrew Cooper
2018-09-03 10:39   ` Andrew Cooper [this message]
2018-09-04  5:27     ` Ping VT-x: " Tian, Kevin
2018-06-04 13:59 ` [PATCH 11/11] x86/dbg: Cleanup of legacy dr6 constants Andrew Cooper
2018-06-06 17:10   ` Roger Pau Monné
2018-06-08 13:12   ` Jan Beulich
2018-06-04 15:39 ` [PATCH 00/11] Fixes to debugging facilities Andrew Cooper
2018-06-04 17:09   ` Razvan Cojocaru
2018-06-04 17:18     ` Andrew Cooper

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=0d01afe4-04f4-5051-8339-54327683ff5b@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xen.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.