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 09:04:07 -0600	[thread overview]
Message-ID: <58F79887020000780015205A@prv-mh.provo.novell.com> (raw)
In-Reply-To: <20170419074141.GA100130@skl-2s3.sh.intel.com>

>>> On 19.04.17 at 09:41, <chao.gao@intel.com> wrote:
> On Wed, Apr 19, 2017 at 08:17:14AM -0600, Jan Beulich wrote:
>>>>> 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 ...
> 
> Got it and will fix. The APIC_LDR is also cleared in vlapic_reset.
> Do you mean it will do a cast automatically? I don't know that before.
> I was afraid that the higher qword of ~MSR_IA32_APICBASE_EXTD will is 
> zero.

Depends on whether the value is signed (in which case it will be
sign extended) or unsigned (resulting in zero-extension). The
constant in this case is signed, so the high bits wouldn't be unduly
chopped off.

Jan


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

  reply	other threads:[~2017-04-19 15:04 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
2017-04-19  7:41   ` Chao Gao
2017-04-19 15:04     ` Jan Beulich [this message]
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=58F79887020000780015205A@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.