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] x86/vlapic: Don't reset APIC mode/ID when handling INIT signal
Date: Wed, 19 Apr 2017 02:48:57 -0600	[thread overview]
Message-ID: <58F740990200007800151D80@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1492552313-44556-1-git-send-email-chao.gao@intel.com>

>>> On 18.04.17 at 23:51, <chao.gao@intel.com> wrote:
> According to SDM "ADVANCED PROGRAMMABLE INTERRUPT CONTROLLER (APIC) ->
> "EXTENDED XAPIC (X2APIC)" -> "x2APIC State Transitions", the APIC mode
> and APIC ID are preserved when handling INIT signal, no matter the
> current mode is x2APIC mode or xAPIC. All the other APIC registers are
> initialized, exactly like the result of a reset.  This patch
> introduces a new function lapic_INIT() and replaces the wrongly used
> lapic_reset().

Please refer to the correct function names. Also according to the
patch there's nothing wrong with mode handling (you only correct
the ID part), yet the text above reads as if both were wrong (but
see below for a mode related aspect wrt RESET).

> HVM guest can't enable x2apic as XENFEAT_hvm_pirqs is exposed to it.
> Why we have this restriction? As a consequence, This patch isn't
> tested in that case.

HVM guests very well can use x2APIC, I'm seeing them use it all
the time. Please be more specific with your question.

> --- a/xen/arch/x86/hvm/vlapic.c
> +++ b/xen/arch/x86/hvm/vlapic.c
> @@ -83,6 +83,8 @@ static const unsigned int vlapic_lvt_mask[VLAPIC_LVT_NUM] =
>      ((vlapic_get_reg(vlapic, APIC_LVTT) & APIC_TIMER_MODE_MASK) \
>       == APIC_TIMER_MODE_TSC_DEADLINE)
>  
> +static void vlapic_INIT(struct vlapic *vlapic);

Why the capitals? Yes, we do have a vlapic_init() function already,
but that doesn't preclude the new one being named e.g.
_vlapic_init(), vlapic_do_init(), or vlapic_handle_init().

> @@ -1237,18 +1239,15 @@ bool_t is_vlapic_lvtpc_enabled(struct vlapic *vlapic)
>              !(vlapic_get_reg(vlapic, APIC_LVTPC) & APIC_LVT_MASKED));
>  }
>  
> -/* Reset the VLPAIC back to its power-on/reset state. */
> -void vlapic_reset(struct vlapic *vlapic)
> +/* VLAPIC handles INIT signal */

Please make the comment state what the _function_ does (not the
vlapic). Using the original comment, perhaps "Put the VLAPIC back
into its init state"?

> +static void vlapic_INIT(struct vlapic *vlapic)
>  {
> -    struct vcpu *v = vlapic_vcpu(vlapic);
>      int i;
>  
> -    if ( !has_vlapic(v->domain) )
> +    if ( !has_vlapic(vlapic_vcpu(vlapic)->domain) )
>          return;
>  
> -    vlapic_set_reg(vlapic, APIC_ID,  (v->vcpu_id * 2) << 24);
>      vlapic_set_reg(vlapic, APIC_LVR, VLAPIC_VERSION);
> -
>      for ( i = 0; i < 8; i++ )

Please don't drop blank lines like this.

> @@ -1262,7 +1261,6 @@ void vlapic_reset(struct vlapic *vlapic)
>      vlapic_set_reg(vlapic, APIC_TMICT,   0);
>      vlapic_set_reg(vlapic, APIC_TMCCT,   0);

Upwards from here is an LDR write. Judging from set_x2apic_id()
this may need to remain untouched in the INIT case? The register
is r/o in x2APIC mode after all. While the documentation includes
LDR in the set of registers being set to zero, I'm wondering whether
that's wrong.


>      vlapic_set_tdcr(vlapic, 0);
> -
>      vlapic_set_reg(vlapic, APIC_DFR, 0xffffffffU);

Same here.

> @@ -1275,6 +1273,18 @@ void vlapic_reset(struct vlapic *vlapic)
>      destroy_periodic_time(&vlapic->pt);
>  }
>  
> +/* Reset the VLPAIC back to its power-on/reset state. */

VLAPIC

> +void vlapic_reset(struct vlapic *vlapic)
> +{
> +    struct vcpu *v = vlapic_vcpu(vlapic);

const

> +    if ( !has_vlapic(v->domain) )
> +        return;
> +
> +    vlapic_set_reg(vlapic, APIC_ID, (v->vcpu_id * 2) << 24);
> +    vlapic_INIT(vlapic);

With what is left here it now very much looks like mode isn't being
(and hasn't been) reset to xAPIC - wouldn't you need to correct
this too? This might be particularly relevant for the call from
hvm_s3_suspend().

Jan


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

  reply	other threads:[~2017-04-19  8:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18 21:51 [PATCH] x86/vlapic: Don't reset APIC mode/ID when handling INIT signal Chao Gao
2017-04-19  8:48 ` Jan Beulich [this message]
2017-04-19  4:56   ` Chao Gao
2017-04-19 13:21     ` Jan Beulich
2017-04-19 13:43       ` Boris Ostrovsky
2017-04-19 13:58         ` Juergen Gross
2017-04-19 14:13           ` Juergen Gross

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=58F740990200007800151D80@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.