All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Chao Gao <chao.gao@intel.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, xen-devel@lists.xen.org
Subject: Re: [PATCH v2] x86/vlapic: Don't reset APIC ID when handling INIT signal
Date: Wed, 19 Apr 2017 08:17:14 -0600	[thread overview]
Message-ID: <58F78D8A0200007800151FE6@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1492584052-92224-1-git-send-email-chao.gao@intel.com>

>>> On 19.04.17 at 08:40, <chao.gao@intel.com> wrote:
> @@ -1257,7 +1257,12 @@ void vlapic_reset(struct vlapic *vlapic)
>      }
>      vlapic_set_reg(vlapic, APIC_ICR,     0);
>      vlapic_set_reg(vlapic, APIC_ICR2,    0);
> -    vlapic_set_reg(vlapic, APIC_LDR,     0);
> +    /*
> +     * LDR is read-only in x2APIC mode. Preserve its value when handling
> +     * INIT signal in x2APIC mode.
> +     */
> +    if ( !vlapic_x2apic_mode(vlapic) )

In order for this to work you need to ...

> +        vlapic_set_reg(vlapic, APIC_LDR, 0);
>      vlapic_set_reg(vlapic, APIC_TASKPRI, 0);
>      vlapic_set_reg(vlapic, APIC_TMICT,   0);
>      vlapic_set_reg(vlapic, APIC_TMCCT,   0);
> @@ -1275,6 +1280,22 @@ void vlapic_reset(struct vlapic *vlapic)
>      destroy_periodic_time(&vlapic->pt);
>  }
>  
> +/* Reset the VLAPIC back to its power-on/reset state. */
> +void vlapic_reset(struct vlapic *vlapic)
> +{
> +    const struct vcpu *v = vlapic_vcpu(vlapic);
> +
> +    if ( !has_vlapic(v->domain) )
> +        return;
> +
> +    vlapic_set_reg(vlapic, APIC_ID, (v->vcpu_id * 2) << 24);
> +    vlapic_set_reg(vlapic, APIC_LDR, 0);
> +    vlapic_do_init(vlapic);
> +
> +    vlapic->hw.apic_base_msr &= ~(uint64_t)MSR_IA32_APICBASE_EXTD;

... do this before calling vlapic_do_init() afaict (and I see no strong
reason why you would need a cast here)). Likely it is a good idea
then to also ...

> +    vlapic->hw.apic_base_msr |= MSR_IA32_APICBASE_ENABLE;

... do this up front.

> @@ -1489,8 +1510,7 @@ int vlapic_init(struct vcpu *v)
>  
>      vlapic_reset(vlapic);
>  
> -    vlapic->hw.apic_base_msr = (MSR_IA32_APICBASE_ENABLE |
> -                                APIC_DEFAULT_PHYS_BASE);
> +    vlapic->hw.apic_base_msr |= APIC_DEFAULT_PHYS_BASE;

Perhaps better move this ahead of the call to vlapic_reset() then
too.

Remains the question (not answered by the SDM afaics): What
happens to the base address during reset?

Jan


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

  reply	other threads:[~2017-04-19 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19  6:40 [PATCH v2] x86/vlapic: Don't reset APIC ID when handling INIT signal Chao Gao
2017-04-19 14:17 ` Jan Beulich [this message]
2017-04-19  7:41   ` Chao Gao
2017-04-19 15:04     ` Jan Beulich
2017-04-19 19:33     ` Chao Gao
2017-04-20  9:55       ` 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=58F78D8A0200007800151FE6@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=chao.gao@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.