From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: stefano.stabellini@eu.citrix.com, jinsong.liu@alibaba-inc.com,
ian.jackson@eu.citrix.com, Zhuo Song <alfred.z.song@gmail.com>,
Zhuo Song <songzhuo.sz@alibaba-inc.com>,
boyu.mt@alibaba-inc.com, Jan Beulich <JBeulich@suse.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH v2 1/2] xc_cpuid_x86.c: Simplify masking conditions and remove redundant work
Date: Tue, 9 Sep 2014 13:49:39 +0100 [thread overview]
Message-ID: <540EF763.5040009@citrix.com> (raw)
In-Reply-To: <1410266622.8217.158.camel@kazak.uk.xensource.com>
On 09/09/14 13:43, Ian Campbell wrote:
> On Tue, 2014-09-09 at 13:29 +0100, Andrew Cooper wrote:
>> On 09/09/14 13:21, Ian Campbell wrote:
>>> On Tue, 2014-09-09 at 11:45 +0100, Jan Beulich wrote:
>>>>>>> On 09.09.14 at 06:31, <alfred.z.song@gmail.com> wrote:
>>>>> @@ -195,16 +186,14 @@ static void intel_xc_cpuid_policy(
>>>>> break;
>>>>>
>>>>> case 0x80000001: {
>>>>> - int is_64bit = hypervisor_is_64bit(xch) && is_pae;
>>>>> -
>>>>> /* Only a few features are advertised in Intel's 0x80000001. */
>>>>> - regs[2] &= (is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0) |
>>>>> - bitmaskof(X86_FEATURE_3DNOWPREFETCH) |
>>>>> - bitmaskof(X86_FEATURE_ABM);
>>>>> - regs[3] &= ((is_pae ? bitmaskof(X86_FEATURE_NX) : 0) |
>>>>> - (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) |
>>>>> - (is_64bit ? bitmaskof(X86_FEATURE_SYSCALL) : 0) |
>>>>> - (is_64bit ? bitmaskof(X86_FEATURE_RDTSCP) : 0));
>>>>> + regs[2] &= (bitmaskof(X86_FEATURE_LAHF_LM) |
>>>>> + bitmaskof(X86_FEATURE_3DNOWPREFETCH) |
>>>>> + bitmaskof(X86_FEATURE_ABM);
>>>>> + regs[3] &= (bitmaskof(X86_FEATURE_NX) |
>>>>> + bitmaskof(X86_FEATURE_LM) |
>>>>> + (is_pae ? bitmaskof(X86_FEATURE_SYSCALL) : 0) |
>>>>> + (is_pae ? bitmaskof(X86_FEATURE_RDTSCP) : 0));
>>>> As said before, tying these two features to is_pae seems a
>>>> little strange, but if the tools maintainers can live with that, I
>>>> guess I can too (short of having a better suggestion other
>>>> than to drop the conditionals altogether).
>>> Patch #2 here seems to remove it from the RDTSCP, surely that should be
>>> folded in.
>>>
>>> I also don't understand the link between PAE and the presence of
>>> SYSCALL.
>> On Intel, syscall is strictly only available in long mode, being an AMD
>> instruction mandated in the 64bit spec.
>>
>> is_64bit is disappearing as Xen is unconditionally 64bit these days, but
>> preventing the guest using PAE will preclude it being able to enter long
>> mode.
>>
>> I would agree that it is not necessarily obvious, and based on this
>> consideration, I think it would be better to keep the variable
>> "is_64bit" as it is more informative than "is_pae" in the contexts used.
> But right above we are advertising X86_FEATURE_LM unconditionally, so
> what is to stop the guest switching to long mode and therefore using
> syscall?
I made the same mistake. That is setting FEATURE_LM in an AND mask,
where the underlying bit may or may not be set from the common logic.
It is certainly not obvious.
>
> Does real h/w change the cpuid features reported depending on the
> current processor mode?
It is not the current processor mode. All of this logic is run during
domain create, before hvmloader starts.
>
> One other bit of confusion I'm having is whether is_pae refers to the
> guest or the host. Previously is_64bit seemed to be a hybrid of both...
> Ian.
>
It kind of was. It was a hybrid of "Xen is 64bit" (i.e. will permit the
guest to move into long mode if it tries), and "we have advertised pae
to the guest" which is a prerequisite to enter long mode.
All this code is nasty.
~Andrew
next prev parent reply other threads:[~2014-09-09 12:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 4:31 [PATCH v2 1/2] xc_cpuid_x86.c: Simplify masking conditions and remove redundant work Zhuo Song
2014-09-09 4:31 ` [PATCH v2 2/2] xc_cpuid_x86.c: Remove limit for RDTSCP Zhuo Song
2014-09-09 10:45 ` [PATCH v2 1/2] xc_cpuid_x86.c: Simplify masking conditions and remove redundant work Jan Beulich
2014-09-09 12:21 ` Ian Campbell
2014-09-09 12:29 ` Andrew Cooper
2014-09-09 12:43 ` Ian Campbell
2014-09-09 12:49 ` Andrew Cooper [this message]
2014-09-09 13:09 ` z
2014-09-09 13:23 ` Jan Beulich
2014-09-09 14:43 ` z
2014-09-09 14:49 ` Jan Beulich
2014-09-09 15:13 ` z
2014-09-10 2:06 ` z
2014-09-10 9:19 ` Jan Beulich
2014-09-09 12:38 ` z
2014-09-09 13:19 ` 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=540EF763.5040009@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=JBeulich@suse.com \
--cc=alfred.z.song@gmail.com \
--cc=boyu.mt@alibaba-inc.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jinsong.liu@alibaba-inc.com \
--cc=songzhuo.sz@alibaba-inc.com \
--cc=stefano.stabellini@eu.citrix.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 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).