All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Simon Gaiser <simon@invisiblethingslab.com>
Cc: Juergen Gross <jgross@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 3/3] x86: check feature flags after resume
Date: Mon, 16 Apr 2018 04:16:55 -0600	[thread overview]
Message-ID: <5AD4781702000078001BB932@prv1-mh.provo.novell.com> (raw)
In-Reply-To: <8657d89c-ca48-2a81-3a12-35d62642b8a3@invisiblethingslab.com>

>>> On 13.04.18 at 20:56, <simon@invisiblethingslab.com> wrote:
> Simon Gaiser:
>> Jan Beulich:
>>> Make sure no previously present features are missing after resume (and
>>> the re-loading of microcode), to avoid later crashes or (likely silent)
>>> hangs / live locks. This doesn't go beyond checking x86_capability[],
>>> but this should be good enough for the immediate need of making sure
>>> that the BIT mitigation MSRs are still available.
>>>
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>
>>> --- a/xen/arch/x86/acpi/power.c
>>> +++ b/xen/arch/x86/acpi/power.c
>>> @@ -254,6 +254,9 @@ static int enter_state(u32 state)
>>>  
>>>      microcode_resume_cpu(0);
>>>  
>>> +    if ( !recheck_cpu_features(0) )
>>> +        panic("Missing previously available feature(s).");
>>> +
>>>      ci->bti_ist_info = default_bti_ist_info;
>>>      asm volatile (ALTERNATIVE("", "wrmsr", X86_FEATURE_XEN_IBRS_SET)
>>>                    :: "a" (SPEC_CTRL_IBRS), "c" (MSR_SPEC_CTRL), "d" (0)
>>> --- a/xen/arch/x86/cpu/common.c
>>> +++ b/xen/arch/x86/cpu/common.c
>>> @@ -501,6 +501,9 @@ void identify_cpu(struct cpuinfo_x86 *c)
>>>  	printk("\n");
>>>  #endif
>>>  
>>> +	if (system_state == SYS_STATE_resume)
>>> +		return;
>>> +
>>>  	/*
>>>  	 * On SMP, boot_cpu_data holds the common feature set between
>>>  	 * all CPUs; so make sure that we indicate which features are
>>> --- a/xen/arch/x86/cpuid.c
>>> +++ b/xen/arch/x86/cpuid.c
>>> @@ -473,6 +473,28 @@ void __init init_guest_cpuid(void)
>>>      calculate_hvm_max_policy();
>>>  }
>>>  
>>> +bool recheck_cpu_features(unsigned int cpu)
>>> +{
>>> +    bool okay = true;
>>> +    struct cpuinfo_x86 c;
>>> +    const struct cpuinfo_x86 *bsp = &boot_cpu_data;
>>> +    unsigned int i;
>>> +
>>> +    identify_cpu(&c);
>> 
>> This runs into a bug in identify_cpu(). x86_vendor_id does not get
>> zeroed, so the x86_vendor_id is not null terminated and the vendor
>> identification fails.
>> 
>> diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
>> index 4feaa2ceb6..5750d26216 100644
>> --- a/xen/arch/x86/cpu/common.c
>> +++ b/xen/arch/x86/cpu/common.c
>> @@ -366,8 +366,8 @@ void identify_cpu(struct cpuinfo_x86 *c)
>>         c->x86_vendor = X86_VENDOR_UNKNOWN;
>>         c->cpuid_level = -1;    /* CPUID not detected */
>>         c->x86_model = c->x86_mask = 0; /* So far unknown... */
>> -       c->x86_vendor_id[0] = '\0'; /* Unset */
>> -       c->x86_model_id[0] = '\0';  /* Unset */
>> +       memset(&c->x86_vendor_id, 0, sizeof(c->x86_vendor_id));
>> +       memset(&c->x86_model_id, 0, sizeof(c->x86_model_id));
>>         c->x86_max_cores = 1;
>>         c->x86_num_siblings = 1;
>>         c->x86_clflush_size = 0;
>> 
>> With this patch it works for me.
> 
> Meh, also a backport failure from me. Since e34bc403c3c7 this problem
> should not appear since it does not assume a null terminated string.

NP - it's good to be aware of such issues in case we as well decide to
backport this.

Thanks for the feedback,
Jan



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

  reply	other threads:[~2018-04-16 10:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13 11:49 [PATCH 0/3] x86: S3 resume adjustments Jan Beulich
2018-04-13 11:56 ` [PATCH 1/3] x86: correct ordering of operations during S3 resume Jan Beulich
2018-04-13 11:57 ` [PATCH 2/3] x86: suppress BTI mitigations around S3 suspend/resume Jan Beulich
2018-04-13 18:25   ` Simon Gaiser
2018-04-13 18:27     ` Andrew Cooper
2018-04-13 18:34       ` Simon Gaiser
2018-04-13 11:58 ` [PATCH 3/3] x86: check feature flags after resume Jan Beulich
2018-04-13 18:29   ` Simon Gaiser
2018-04-13 18:56     ` Simon Gaiser
2018-04-16 10:16       ` Jan Beulich [this message]
2018-04-13 12:01 ` [PATCH 0/3] x86: S3 resume adjustments Andrew Cooper
2018-04-16 11:57   ` Juergen Gross
2018-04-14  5:49 ` Simon Gaiser
2018-04-15 13:08   ` Andrew Cooper
2018-04-15 15:52     ` Simon Gaiser
2018-04-15 17:34       ` Andrew Cooper
2018-04-15 20:15         ` Simon Gaiser
2018-04-16 13:13           ` 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=5AD4781702000078001BB932@prv1-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jgross@suse.com \
    --cc=simon@invisiblethingslab.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.