Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1484500

Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo
Date 2016-09-15 21:40 +0200
Message-ID <shKFQ-2IM-23@gated-at.bofh.it> (permalink)
References <shpBn-665-13@gated-at.bofh.it> <shpBn-665-11@gated-at.bofh.it> <shBMd-5DZ-3@gated-at.bofh.it> <shC5z-5KS-1@gated-at.bofh.it> <shKmu-2C4-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Sep 15, 2016 at 12:11 PM, Kyle Huey <me@kylehuey.com> wrote:
> On Thu, Sep 15, 2016 at 3:25 AM, Jan Beulich <JBeulich@suse.com> wrote:
>>>>> On 15.09.16 at 12:05, <david.vrabel@citrix.com> wrote:
>>> On 14/09/16 22:01, Kyle Huey wrote:
>>>> Xen advertises the underlying support for CPUID faulting but not does pass
>>>> through writes to the relevant MSR, nor does it virtualize it, so it does
>>>> not actually work. For now mask off the relevant bit on MSR_PLATFORM_INFO.
>>>
>>> Could you clarify in the commit message that it is PV guests that are
>>> affected.
>>
>> What makes you think HVM ones aren't?
>
> Testing on EC2, HVM guests are affected as well.  Not sure what to do
> about that.
>

It's kind of nasty, but it shouldn't be *too* hard to probe for this
thing during early boot.  Allocate a page somewhere that has the user
bit set, put something like this in it:

cpuid
inc %eax  /* return 1 */
movw %ax, %ss /* force %GP to get out of here */

Call it like this from asm (real asm, not inline):

FRAME_BEGIN
pushq %rbx

xorl %eax, %eax

/* Push return frame */
pushq %ss
pushq %rsp
addq $8, (%rsp)
pushfq
pushq %cs
pushq $end_of_cpuid_faulting_test

/* Call it! */
pushq $__USER_DS
pushq $0
pushq $X86_EFLAGS_FIXED  /* leave IF off when running the CPL3 stub */
pushq $__USER_CS
pushq [address of userspace stub]
INTERRUPT_RETURN

end_of_cpuid_faulting_test:
pop %rbx

FRAME_END

Run this after the main GDT is loaded but while the #GP vector is
temporarily pointing to:

movq SS-RIP(%rsp), %rsp  /* pop the real return frame */
INTERRUPT_RETURN

and with interrupts off.  The function should return 0 if CPUID
faulting works and 1 if it doesn't.

Yeah, this is gross, but it should work.  I'm not sure how okay I am
with putting this crap in the kernel...

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo Kyle Huey <me@kylehuey.com> - 2016-09-14 23:10 +0200
  Re: [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in  /proc/cpuinfo Dave Hansen <dave.hansen@linux.intel.com> - 2016-09-14 23:40 +0200
    Re: [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo Kyle Huey <me@kylehuey.com> - 2016-09-15 00:10 +0200
      Re: [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo Andy Lutomirski <luto@amacapital.net> - 2016-09-15 03:20 +0200
        Re: [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo Kyle Huey <me@kylehuey.com> - 2016-09-15 04:30 +0200
        Re: [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo "H. Peter Anvin" <hpa@zytor.com> - 2016-09-15 22:50 +0200
          Re: [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo Andy Lutomirski <luto@amacapital.net> - 2016-09-16 01:20 +0200
    Re: [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in  /proc/cpuinfo David Vrabel <david.vrabel@citrix.com> - 2016-09-15 12:10 +0200
  Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting  capabilities in /proc/cpuinfo David Vrabel <david.vrabel@citrix.com> - 2016-09-15 12:10 +0200
    Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID  faulting capabilities in /proc/cpuinfo "Jan Beulich" <JBeulich@suse.com> - 2016-09-15 12:30 +0200
      Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting  capabilities in /proc/cpuinfo Kyle Huey <me@kylehuey.com> - 2016-09-15 21:20 +0200
        Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting  capabilities in /proc/cpuinfo Andy Lutomirski <luto@amacapital.net> - 2016-09-15 21:40 +0200
          Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting  capabilities in /proc/cpuinfo Kyle Huey <me@kylehuey.com> - 2016-09-16 01:40 +0200
        Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting  capabilities in /proc/cpuinfo Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2016-09-15 21:50 +0200

csiph-web