From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933917AbcKQB7g (ORCPT ); Wed, 16 Nov 2016 20:59:36 -0500 Received: from mail-vk0-f68.google.com ([209.85.213.68]:35318 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753892AbcKQB7b (ORCPT ); Wed, 16 Nov 2016 20:59:31 -0500 MIME-Version: 1.0 In-Reply-To: <1514461290.13216247.1479328935760.JavaMail.zimbra@redhat.com> References: <20161110234055.8654-1-khuey@kylehuey.com> <20161110234055.8654-8-khuey@kylehuey.com> <26413C89-E639-4834-A600-C4B6679162F2@gmail.com> <1514461290.13216247.1479328935760.JavaMail.zimbra@redhat.com> From: Kyle Huey Date: Wed, 16 Nov 2016 17:59:30 -0800 Message-ID: Subject: Re: [PATCH v11 7/7] KVM: x86: virtualize cpuid faulting To: Paolo Bonzini Cc: Nadav Amit , "Robert O'Callahan" , Thomas Gleixner , Andy Lutomirski , Ingo Molnar , "H. Peter Anvin" , X86 ML , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Jeff Dike , Richard Weinberger , Alexander Viro , Shuah Khan , Dave Hansen , Borislav Petkov , Peter Zijlstra , Boris Ostrovsky , Len Brown , "Rafael J. Wysocki" , Dmitry Safonov , David Matlack , LKML , "open list:USER-MODE LINUX (UML)" , "open list:USER-MODE LINUX (UML)" , "open list:FILESYSTEMS (VFS and infrastructure)" , "open list:KERNEL SELFTEST FRAMEWORK" , KVM 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 Wed, Nov 16, 2016 at 12:42 PM, Paolo Bonzini wrote: >> On Fri, Nov 11, 2016 at 12:54 PM, Nadav Amit wrote: >> > >> >> On Nov 10, 2016, at 3:40 PM, Kyle Huey wrote: >> >> >> >> Hardware support for faulting on the cpuid instruction is not required to >> >> emulate it, because cpuid triggers a VM exit anyways. KVM handles the >> >> relevant >> >> MSRs (MSR_PLATFORM_INFO and MSR_MISC_FEATURES_ENABLE) and upon a >> >> cpuid-induced VM exit checks the cpuid faulting state and the CPL. >> >> kvm_require_cpl is even kind enough to inject the GP fault for us. >> > >> > I think that for consistency you should also revise em_cpuid() of KVM >> > instruction emulator. Otherwise it may be a potential security >> > hazard (as far fetched as it currently seems). >> >> Hmm, ok. Do you know how I can test this code path? > > Try this patch (untested!) Heh, yes, that would do it. Thanks! > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 5382b82462fc..06d940a7c9fa 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -5868,8 +5868,7 @@ static void vmx_set_dr7(struct kvm_vcpu *vcpu, unsigned long val) > > static int handle_cpuid(struct kvm_vcpu *vcpu) > { > - kvm_emulate_cpuid(vcpu); > - return 1; > + return emulate_instruction(vcpu, 0) == EMULATE_DONE; > } > > static int handle_rdmsr(struct kvm_vcpu *vcpu) > > Paolo - Kyle