public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@amd.com>
To: Vladimir Davydov <vdavydov@parallels.com>
Cc: Borislav Petkov <bp@amd64.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Andi Kleen <ak@linux.intel.com>,
	Borislav Petkov <borislav.petkov@amd.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andreas Herrmann <andreas.herrmann3@amd.com>
Subject: Re: [PATCH 2/2] cpu: intel, amd: mask cleared cpuid features
Date: Tue, 24 Jul 2012 10:14:09 +0200	[thread overview]
Message-ID: <500E5951.5020900@amd.com> (raw)
In-Reply-To: <500E4960.8040307@parallels.com>

On 07/24/2012 09:06 AM, Vladimir Davydov wrote:
> On 07/21/2012 02:37 PM, Borislav Petkov wrote:
>> (+ Andre who's been doing some cross vendor stuff)
>>
>> On Fri, Jul 20, 2012 at 08:37:33PM +0400, Vladimir Davydov wrote:
>>> If 'clearcpuid=N' is specified in boot options, CPU feature #N won't be
>>> reported in /proc/cpuinfo and used by the kernel. However, if a
>>> userpsace process checks CPU features directly using the cpuid
>>> instruction, it will be reported about all features supported by the CPU
>>> irrespective of what features are cleared.
>>>
>>> The patch makes the clearcpuid boot option not only clear CPU features
>>> in kernel but also mask them in hardware for Intel and AMD CPUs that
>>> support it so that the features cleared won't be reported even by the
>>> cpuid instruction.
>>>
>>> This can be useful for migration of virtual machines managed by
>>> hypervisors that do not support/use Intel VT/AMD-V hardware-assisted
>>> virtualization technology.

But for this case you want it more fine-grained, say on a pre-process or 
per-container level, right?
For hardware-assisted virtualization you simply don't need it, and for 
Xen PV guests for instance this can be more safely done by the 
hypervisor. I assume Parallels is similar in this respect, so you may 
want to switch the MSRs on the guest's entry and exit by the VMM.
Also if you want to restrict a guest's CPUID features, you don't want to 
do this at the guest's discretion, but better one level below where the 
guest cannot revert this, right?

In general I am not reluctant to have this feature with a sane 
interface, but I simply don't see the usefulness of having it per kernel.
Also note that AFAIK this masking only helps with the basic CPUID 
features, namely leaf 1 and 0x80000001 for ECX and EDX. This does not 
cover the more advanced features and not the new ones at leaf 7.

>> So opening the floodgates to people fiddling with this (not only
>> migrators) makes me feel pretty uneasy. And I won't wonder if all of
>> a sudden strange failures start to appear because code is querying
>> cpuid features but some funny distro has disabled it in its kernel boot
>> options.

Actually these "strange failures" would be a bug then. If CPUID is not 
there, the feature is not there. Full stop. In the past we had had 
already some trouble with people ignoring CPUID and stating some funny 
things like: "Every XYZ processor has this feature."
If someone disables MCE, then on purpose. Let the code cope with it.

And Boris: I don't like this "majority of users" argument. If there is 
some sense in this feature, why not have it (unless it significantly 
hurts the code base)? Remember, this is Linux: If you want to shoot 
yourself in the foot, we will not prevent you.

Regards,
Andre.

-- 
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany


  parent reply	other threads:[~2012-07-24  8:15 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 16:37 [PATCH 1/2] cpu: common: make clearcpuid option take bits list Vladimir Davydov
2012-07-20 16:37 ` [PATCH 2/2] cpu: intel, amd: mask cleared cpuid features Vladimir Davydov
2012-07-20 17:10   ` Andi Kleen
2012-07-20 17:18     ` H. Peter Anvin
2012-07-25 11:51     ` Vladimir Davydov
2012-07-20 17:20   ` H. Peter Anvin
2012-07-20 18:21     ` Vladimir Davydov
2012-07-20 20:19       ` H. Peter Anvin
2012-07-20 20:37         ` Vladimir Davydov
2012-07-21 10:37   ` Borislav Petkov
2012-07-24  7:06     ` Vladimir Davydov
2012-07-24  7:48       ` Borislav Petkov
2012-07-24  8:14       ` Andre Przywara [this message]
2012-07-24  8:29         ` Vladimir Davydov
2012-07-24 10:10           ` Borislav Petkov
2012-07-24 11:09             ` Vladimir Davydov
2012-07-24 12:34               ` Andre Przywara
2012-07-24 12:44                 ` Alan Cox
2012-07-25 10:31                   ` Vladimir Davydov
2012-07-25 10:58                     ` Andre Przywara
2012-07-25 11:02                       ` Vladimir Davydov
2012-07-25 11:17                         ` Andre Przywara
2012-07-25 11:43                           ` Vladimir Davydov
2012-07-25 11:31                     ` Alan Cox
2012-07-25 11:46                       ` Vladimir Davydov
2012-07-25 10:31                 ` Vladimir Davydov
2012-07-25 10:43                   ` Borislav Petkov
2012-07-25 11:39                     ` Vladimir Davydov
2012-07-25  0:57               ` H. Peter Anvin
2012-07-25  6:58                 ` Vladimir Davydov
2012-07-25 14:13                   ` H. Peter Anvin
2012-07-25 11:49                 ` Vladimir Davydov
2012-07-24  9:50         ` Borislav Petkov
2012-07-24 10:32           ` Alan Cox
2012-07-24 11:04             ` Borislav Petkov

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=500E5951.5020900@amd.com \
    --to=andre.przywara@amd.com \
    --cc=ak@linux.intel.com \
    --cc=andreas.herrmann3@amd.com \
    --cc=borislav.petkov@amd.com \
    --cc=bp@amd64.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vdavydov@parallels.com \
    --cc=x86@kernel.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