From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754167AbcILQ4f (ORCPT ); Mon, 12 Sep 2016 12:56:35 -0400 Received: from mail-vk0-f41.google.com ([209.85.213.41]:36551 "EHLO mail-vk0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbcILQ4d (ORCPT ); Mon, 12 Sep 2016 12:56:33 -0400 MIME-Version: 1.0 In-Reply-To: <1473640169-24145-1-git-send-email-khuey@kylehuey.com> References: <1473640169-24145-1-git-send-email-khuey@kylehuey.com> From: Andy Lutomirski Date: Mon, 12 Sep 2016 09:56:11 -0700 Message-ID: Subject: Re: [PATCH] prctl,x86 Add PR_[GET|SET]_CPUID for controlling the CPUID instruction. To: Kyle Huey Cc: Thomas Gleixner , John Stultz , Ingo Molnar , Michal Hocko , Andrew Morton , "Michael S. Tsirkin" , Alexander Shishkin , Aravind Gopalakrishnan , Vlastimil Babka , "Luis R. Rodriguez" , Mateusz Guzik , Alex Thorlton , "Rafael J. Wysocki" , Dmitry Vyukov , Vladimir Zapolskiy , Jiri Slaby , Andrey Ryabinin , Ben Segall , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Denys Vlasenko , Paul Gortmaker , Srinivas Pandruvada , "Robert O'Callahan" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Juergen Gross , Linux API , Fenghua Yu , Kees Cook , "Peter Zijlstra (Intel)" , Borislav Petkov , Len Brown , Huang Rui , "H. Peter Anvin" 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 Sep 11, 2016 5:29 PM, "Kyle Huey" wrote: > > rr (http://rr-project.org/), a userspace record-and-replay reverse- > execution debugger, would like to trap and emulate the CPUID instruction. > This would allow us to a) mask away certain hardware features that rr does > not support (e.g. RDRAND) and b) enable trace portability across machines > by providing constant results. > > Intel supports faulting on the CPUID instruction in newer processors. Bit > 31 of MSR_PLATFORM_INFO advertises support for this feature. It is > documented in detail in Section 2.3.2 of > http://www.intel.com/content/dam/www/public/us/en/documents/application-notes/virtualization-technology-flexmigration-application-note.pdf. > This should have a cpufeature bit and show up in /proc/cpuinfo. That should be its own patch. You should explicitly check that, if the feature is set under Xen PV, then the MSR actually works as advertised. This may require talking to the Xen folks to make sure you're testing the right configuration. There should be a selftest. The behavior on fork() should be defined, and that behavior should be tested by the selftest. If this bit is preserved on fork(), then no_new_privs must be checked (or it must be cleared on "unsafe" exec, but that's nasty). --Andy