From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] x86: correct CPUID output for out of bounds input
Date: Thu, 1 Sep 2016 15:27:33 +0100 [thread overview]
Message-ID: <1e70d047-f84f-48c1-725c-eb07dcd9575e@citrix.com> (raw)
In-Reply-To: <57BDDA0C0200007800108BA7@prv-mh.provo.novell.com>
On 24/08/16 16:31, Jan Beulich wrote:
> Another place where we should try to behave like real hardware; see
> the code comments.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -3358,6 +3358,31 @@ void hvm_cpuid(unsigned int input, unsig
> if ( !edx )
> edx = &dummy;
>
> + if ( input & 0xffff )
> + {
> + /*
> + * Requests beyond the highest supported leaf within a group return
> + * zero on AMD and the highest basic leaf output on others.
> + */
> + unsigned int lvl;
> +
> + hvm_cpuid(input & 0xffff0000, &lvl, NULL, NULL, NULL);
> + if ( ((lvl ^ input) >> 16) || input > lvl )
This logic isn't correct. It doesn't cope in the Intel case when lvl
aliases the upper 16 bits of input, despite input being an unknown group.
When I considered the problem before, the only functioning logic I came
up with was to know that for Intel, input = 0x8000xxxx is the only
special case which doesn't collapse into the highest basic leaf.
> + {
> + if ( d->arch.x86_vendor == X86_VENDOR_AMD )
> + {
> + *eax = 0;
> + *ebx = 0;
> + *ecx = 0;
> + *edx = 0;
> + return;
> + }
> + if ( input >> 16 )
> + hvm_cpuid(0, &lvl, NULL, NULL, NULL);
Is this really the right way round? The AMD method of "reserved always
as zero" is the more sane default to take.
I have looked at the Transmeta and Cyrix CPUID docs, and they are
non-specific as to what reserved means.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-09-01 14:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 15:31 [PATCH] x86: correct CPUID output for out of bounds input Jan Beulich
2016-09-01 11:23 ` Andrew Cooper
2016-09-01 12:56 ` Jan Beulich
2016-09-01 14:17 ` Andrew Cooper
2016-09-01 14:27 ` Andrew Cooper [this message]
2016-09-01 15:27 ` Jan Beulich
2016-09-02 15:14 ` Andrew Cooper
2016-09-05 6:32 ` Jan Beulich
2016-09-05 9:43 ` Andrew Cooper
2016-09-05 9:51 ` Jan Beulich
2016-09-05 10:05 ` Andrew Cooper
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=1e70d047-f84f-48c1-725c-eb07dcd9575e@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.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 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).