xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH v4 1/4] x86/HVM: fix miscellaneous aspects of x2APIC emulation
Date: Mon, 22 Sep 2014 14:14:42 +0100	[thread overview]
Message-ID: <542020C2.9000304@citrix.com> (raw)
In-Reply-To: <541B0BB402000078000363BF@mail.emea.novell.com>

On 18/09/14 15:43, Jan Beulich wrote:
>  int hvm_x2apic_msr_write(struct vcpu *v, unsigned int msr, uint64_t msr_content)
> @@ -891,16 +876,33 @@ int hvm_x2apic_msr_write(struct vcpu *v,
>  
>      switch ( offset )
>      {
> -        int rc;
> +    case APIC_TASKPRI:
> +    case APIC_EOI:
> +    case APIC_SPIV:
> +    case APIC_CMCI:
> +    case APIC_LVTT ... APIC_LVTERR:
> +    case APIC_TMICT:
> +    case APIC_TMCCT:
> +    case APIC_TDCR:

Most (all?) of these MSRs have reserved bits, which should fail with a
#GP(0) for attempts to set. vlapic_reg_read() masks most of the relevant
bits, but doesn't appear to hit a misbehaving VM.

> +        break;
>  
>      case APIC_ICR:
> -        rc = vlapic_reg_write(v, APIC_ICR2, (uint32_t)(msr_content >> 32));
> -        if ( rc )
> -            return rc;
> +        vlapic_set_reg(vlapic, APIC_ICR2, msr_content >> 32);
>          break;
>  
> -    case APIC_ICR2:
> -        return X86EMUL_UNHANDLEABLE;
> +    case APIC_SELF_IPI:
> +        offset = APIC_ICR;
> +        msr_content = APIC_DEST_SELF | (uint8_t)msr_content;
> +        break;
> +
> +    case APIC_ESR:
> +        if ( msr_content )
> +        {
> +            printk(XENLOG_G_WARNING "%pv: non-zero (%lx) LAPIC ESR write\n",
> +                   v, msr_content);

I know this is just moving an existing error message, but is it actually
useful? ESR is no more special than the other registers with some/all
bits reserved.

> +    default:
> +            return X86EMUL_UNHANDLEABLE;
> +        }
>      }
>  
>      return vlapic_reg_write(v, offset, (uint32_t)msr_content);
> @@ -910,7 +912,10 @@ static int vlapic_range(struct vcpu *v, 
>  {
>      struct vlapic *vlapic = vcpu_vlapic(v);
>      unsigned long offset  = addr - vlapic_base_address(vlapic);
> -    return (!vlapic_hw_disabled(vlapic) && (offset < PAGE_SIZE));
> +
> +    return !vlapic_hw_disabled(vlapic) &&
> +           !vlapic_x2apic_mode(vlapic) &&
> +           (offset < PAGE_SIZE);

This check is too restrictive, at least on Intel. From SDM Vol 3 29.4.3.3

"As noted in Section 29.5, execution of WRMSR with ECX = 83FH (self-IPI
MSR) can lead to an APIC-write VM exit
if the “virtual-interrupt delivery” VM-execution control is 1. The exit
qualification for such an APIC-write VM exit is
3F0H."

So we can still end up wandering the vlapic MMIO codepaths even in
x2apic mode.

~Andrew

  reply	other threads:[~2014-09-22 13:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18 14:35 [PATCH v4 0/4] x86/HVM: fix various aspects of APIC emulation Jan Beulich
2014-09-18 14:43 ` [PATCH v4 1/4] x86/HVM: fix miscellaneous aspects of x2APIC emulation Jan Beulich
2014-09-22 13:14   ` Andrew Cooper [this message]
2014-09-22 13:40     ` Jan Beulich
2014-09-23 16:56       ` Andrew Cooper
2014-09-24  8:02         ` Jan Beulich
2014-09-18 14:44 ` [PATCH v4 2/4] x86/HVM: fix ID handling " Jan Beulich
2014-09-19  6:09   ` Jan Beulich
2014-09-22 14:30   ` Andrew Cooper
2014-09-22 15:19     ` Jan Beulich
2014-09-24 10:42       ` Andrew Cooper
2014-09-24 11:41         ` Jan Beulich
2014-09-24 12:10           ` Andrew Cooper
2014-09-18 14:44 ` [PATCH v4 3/4] x86/HVM: a few type adjustments Jan Beulich
2014-09-18 14:45 ` [PATCH v4 4/4] x86/vlapic: don't silently accept bad vectors Jan Beulich

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=542020C2.9000304@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).