From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757191AbcIOXgl (ORCPT ); Thu, 15 Sep 2016 19:36:41 -0400 Received: from mail-vk0-f67.google.com ([209.85.213.67]:33421 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755361AbcIOXgd (ORCPT ); Thu, 15 Sep 2016 19:36:33 -0400 MIME-Version: 1.0 In-Reply-To: References: <1473886902-17902-1-git-send-email-khuey@kylehuey.com> <1473886902-17902-3-git-send-email-khuey@kylehuey.com> <57DA724E.6090606@citrix.com> <57DA9342020000780010F267@prv-mh.provo.novell.com> From: Kyle Huey Date: Thu, 15 Sep 2016 16:36:31 -0700 Message-ID: Subject: Re: [Xen-devel] [PATCH v2 2/3] x86 Test and expose CPUID faulting capabilities in /proc/cpuinfo To: Andy Lutomirski Cc: Jan Beulich , David Vrabel , Aravind Gopalakrishnan , Huang Rui , Peter Zijlstra , Len Brown , "Rafael J. Wysocki" , Andy Lutomirski , "maintainer:X86 ARCHITECTURE 32-BIT AND 64-BIT" , Thomas Gleixner , Alexander Shishkin , DaveHansen , Kristen Carlson Accardi , Srinivas Pandruvada , "moderated list:XEN HYPERVISOR INTERFACE" , Vladimir Zapolskiy , "Robert O'Callahan" , Boris Ostrovsky , Ingo Molnar , Juergen Gross , Borislav Petkov , "open list:X86 ARCHITECTURE 32-BIT AND 64-BIT" , "H. PeterAnvin" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 15, 2016 at 12:37 PM, Andy Lutomirski wrote: > On Thu, Sep 15, 2016 at 12:11 PM, Kyle Huey wrote: >> On Thu, Sep 15, 2016 at 3:25 AM, Jan Beulich wrote: >>>>>> On 15.09.16 at 12:05, 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... This is rather heroic :) I think it's more trouble than it's worth though. The latest series I submitted doesn't try to handle this. Instead I'll patch Xen to fix the bug. - Kyle