From patchwork Mon Sep 12 06:30:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9325749 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 0AAC660231 for ; Mon, 12 Sep 2016 06:33:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7B3528A7F for ; Mon, 12 Sep 2016 06:33:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC12228AF5; Mon, 12 Sep 2016 06:33:41 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4C27F28A7F for ; Mon, 12 Sep 2016 06:33:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjKlJ-00089Q-Ez; Mon, 12 Sep 2016 06:30:37 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjKlI-00089K-Dz for xen-devel@lists.xenproject.org; Mon, 12 Sep 2016 06:30:36 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 42/FB-21406-B8B46D75; Mon, 12 Sep 2016 06:30:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRWlGSWpSXmKPExsXS6fjDS7fb+1q 4wZvvrBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8asB63MBXtFKlq/b2VqYDwj0MXIySEkkCdx anEPG4jNK2An0dm9hR3ElhAwlHj6/jpYnEVAVeLZ7zZWEJtNQF2i7dl2IJuDQ0TAQOLc0SSQM LNAlETf8qtMILawgKfEiYUNTCAlvAKCEn93CEOU2EnMn9HFPIGRaxZCZhaSDIStJfHw1y0WCF tbYtnC18wg5cwC0hLL/3FAhK0kLmw6y4aqBMR2lWi4co15ASPHKkb14tSistQiXXO9pKLM9Iy S3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYzA0GMAgh2MMy/7H2KU5GBSEuVNErwWLsSXlJ9S mZFYnBFfVJqTWnyIUYaDQ0mCt8MLKCdYlJqeWpGWmQOMApi0BAePkgivKkiat7ggMbc4Mx0id YpRUUqcVxQkIQCSyCjNg2uDRd4lRlkpYV5GoEOEeApSi3IzS1DlXzGKczAqCfO+9gSawpOZVw I3/RXQYiagxU+3XgZZXJKIkJJqYNS/3vwj47wEh1F6rEfBldIKTraAIt67t54WRH+W7nonb3r 1Mw/fpsv+HRv7VgetLpWr8frZln4wimO3RIKap7L1/MQ6A511OiK7brQabHZ9+ufc9Bd75O5z Nu/oWXuj5+b8nXsCty5UfivxRjpw6ilLffOzJUJ/6ipfLs9bN6PDOIrB6LawkRJLcUaioRZzU XEiANQOMG+3AgAA X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1473661833!32757686!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39091 invoked from network); 12 Sep 2016 06:30:34 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Sep 2016 06:30:34 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 12 Sep 2016 00:30:32 -0600 Message-Id: <57D667A2020000780010DD75@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Mon, 12 Sep 2016 00:30:26 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper , Paul Durrant Subject: [Xen-devel] [PATCH] x86/HVM: consistently check CR0.EM in hvmemul_get_fpu() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP I'm pretty certain I had meant to make this a follow-up to what is now 11c35f84b5 ("x86/emulator: generalize movq emulation (SSE2 and AVX variants)"), but I obviously never did. Correct this: Just like SSE insns, FPU and MMX ones require CR0.EM to be clear. Signed-off-by: Jan Beulich --- Albeit perhaps we should really make this deliver #NM instead of returning "unhandleable", but that's a separate step to take. x86/HVM: consistently check CR0.EM in hvmemul_get_fpu() I'm pretty certain I had meant to make this a follow-up to what is now 11c35f84b5 ("x86/emulator: generalize movq emulation (SSE2 and AVX variants)"), but I obviously never did. Correct this: Just like SSE insns, FPU and MMX ones require CR0.EM to be clear. Signed-off-by: Jan Beulich --- Albeit perhaps we should really make this deliver #NM instead of returning "unhandleable", but that's a separate step to take. --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -1628,9 +1628,12 @@ static int hvmemul_get_fpu( switch ( type ) { case X86EMUL_FPU_fpu: + if ( (curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_EM) ) + return X86EMUL_UNHANDLEABLE; break; case X86EMUL_FPU_mmx: - if ( !cpu_has_mmx ) + if ( !cpu_has_mmx || + (curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_EM) ) return X86EMUL_UNHANDLEABLE; break; case X86EMUL_FPU_xmm: --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -1628,9 +1628,12 @@ static int hvmemul_get_fpu( switch ( type ) { case X86EMUL_FPU_fpu: + if ( (curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_EM) ) + return X86EMUL_UNHANDLEABLE; break; case X86EMUL_FPU_mmx: - if ( !cpu_has_mmx ) + if ( !cpu_has_mmx || + (curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_EM) ) return X86EMUL_UNHANDLEABLE; break; case X86EMUL_FPU_xmm: