From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
xen-devel <xen-devel@lists.xenproject.org>
Cc: Kevin Tian <kevin.tian@intel.com>, Jun Nakajima <jun.nakajima@intel.com>
Subject: Re: [PATCH] VMX: fix/adjust trap injection
Date: Mon, 23 Nov 2015 15:01:12 +0000 [thread overview]
Message-ID: <56532A38.5020209@citrix.com> (raw)
In-Reply-To: <5653195202000078000B7CF0@prv-mh.provo.novell.com>
On 23/11/15 12:49, Jan Beulich wrote:
> In the course of investigating the 4.1.6 backport issue of the XSA-156
> patch I realized that #DB injection has always been broken, but with it
> now getting always intercepted the problem has got worse: Documentation
> clearly states that neither DR7.GD nor DebugCtl.LBR get cleared before
> the intercept, so this is something we need to do before reflecting the
> intercepted exception.
>
> While adjusting this (and also with 4.1.6's strange use of
> X86_EVENTTYPE_SW_EXCEPTION for #DB in mind) I further realized that
> the special casing of individual vectors shouldn't be done for
> software interrupts (resulting from INT $nn).
>
> And then some code movement: Setting of CR2 for #PF can be done in the
> same switch() statement (no need for a separate if()), and reading of
> intr_info is better done close the the consumption of the variable
> (allowing the compiler to generate better code / use fewer registers
> for variables).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -1508,16 +1508,7 @@ static void vmx_inject_trap(struct hvm_t
> struct vcpu *curr = current;
> struct hvm_trap _trap = *trap;
>
> - if ( (_trap.vector == TRAP_page_fault) &&
> - (_trap.type == X86_EVENTTYPE_HW_EXCEPTION) )
> - curr->arch.hvm_vcpu.guest_cr[2] = _trap.cr2;
> -
> - if ( nestedhvm_vcpu_in_guestmode(curr) )
> - intr_info = vcpu_2_nvmx(curr).intr.intr_info;
> - else
> - __vmread(VM_ENTRY_INTR_INFO, &intr_info);
> -
> - switch ( _trap.vector )
> + switch ( _trap.vector | -(_trap.type == X86_EVENTTYPE_SW_INTERRUPT) )
> {
> case TRAP_debug:
> if ( guest_cpu_user_regs()->eflags & X86_EFLAGS_TF )
> @@ -1525,6 +1516,16 @@ static void vmx_inject_trap(struct hvm_t
> __restore_debug_registers(curr);
> write_debugreg(6, read_debugreg(6) | DR_STEP);
> }
> + if ( !nestedhvm_vcpu_in_guestmode(curr) ||
> + !nvmx_intercepts_exception(curr, TRAP_debug, _trap.error_code) )
> + {
> + unsigned long val;
> +
> + __vmread(GUEST_DR7, &val);
> + __vmwrite(GUEST_DR7, val & ~DR_GENERAL_DETECT);
> + __vmread(GUEST_IA32_DEBUGCTL, &val);
> + __vmwrite(GUEST_IA32_DEBUGCTL, val & ~IA32_DEBUGCTLMSR_LBR);
Is it worth eliding the __vmwrite's if possible? It will be fewer
VMexits if this Xen is running nested, and ISTR it will avoid slowing
down the vmentry with further consistency checks.
~Andrew
next prev parent reply other threads:[~2015-11-23 15:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-23 12:49 [PATCH] VMX: fix/adjust trap injection Jan Beulich
2015-11-23 15:01 ` Andrew Cooper [this message]
2015-11-23 15:24 ` Jan Beulich
2015-11-24 11:15 ` Andrew Cooper
2015-11-24 5:02 ` Tian, Kevin
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=56532A38.5020209@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.xenproject.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.