From patchwork Wed Nov 16 20:42:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9432627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0B4060476 for ; Wed, 16 Nov 2016 20:43:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D266C2884E for ; Wed, 16 Nov 2016 20:43:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6A7728BDF; Wed, 16 Nov 2016 20:43:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEF7E2884E for ; Wed, 16 Nov 2016 20:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932883AbcKPUnT (ORCPT ); Wed, 16 Nov 2016 15:43:19 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:39549 "EHLO mx4-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932541AbcKPUnR (ORCPT ); Wed, 16 Nov 2016 15:43:17 -0500 Received: from zmail13.collab.prod.int.phx2.redhat.com (zmail13.collab.prod.int.phx2.redhat.com [10.5.83.15]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id uAGKgF9t029585; Wed, 16 Nov 2016 15:42:16 -0500 Date: Wed, 16 Nov 2016 15:42:15 -0500 (EST) From: Paolo Bonzini To: Kyle Huey Cc: Nadav Amit , "Robert O'Callahan" , Thomas Gleixner , Andy Lutomirski , Ingo Molnar , "H. Peter Anvin" , X86 ML , Radim =?utf-8?B?S3LEjW3DocWZ?= , 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 Message-ID: <1514461290.13216247.1479328935760.JavaMail.zimbra@redhat.com> In-Reply-To: References: <20161110234055.8654-1-khuey@kylehuey.com> <20161110234055.8654-8-khuey@kylehuey.com> <26413C89-E639-4834-A600-C4B6679162F2@gmail.com> Subject: Re: [PATCH v11 7/7] KVM: x86: virtualize cpuid faulting MIME-Version: 1.0 X-Originating-IP: [10.4.164.1, 10.5.101.130] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF49 (Linux)/8.0.6_GA_5922) Thread-Topic: x86: virtualize cpuid faulting Thread-Index: pBUiLVoc+1pn0eI2dQAFqXWcS9w2cA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > 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!) Paolo --- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)