From patchwork Fri Mar 6 20:39:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Schopp X-Patchwork-Id: 5957721 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A6469BF440 for ; Fri, 6 Mar 2015 20:35:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9A9E20397 for ; Fri, 6 Mar 2015 20:35:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7B4D2038D for ; Fri, 6 Mar 2015 20:35:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756432AbbCFUfT (ORCPT ); Fri, 6 Mar 2015 15:35:19 -0500 Received: from mail-bn1bn0107.outbound.protection.outlook.com ([157.56.110.107]:63324 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752368AbbCFUfR (ORCPT ); Fri, 6 Mar 2015 15:35:17 -0500 Received: from BN3PR0201MB1044.namprd02.prod.outlook.com (25.161.207.153) by BN3PR0201MB1076.namprd02.prod.outlook.com (25.161.209.144) with Microsoft SMTP Server (TLS) id 15.1.99.14; Fri, 6 Mar 2015 20:35:15 +0000 Received: from BY2PR02CA0081.namprd02.prod.outlook.com (10.242.32.39) by BN3PR0201MB1044.namprd02.prod.outlook.com (25.161.207.153) with Microsoft SMTP Server (TLS) id 15.1.99.14; Fri, 6 Mar 2015 20:35:14 +0000 Received: from BL2FFO11FD016.protection.gbl (2a01:111:f400:7c09::194) by BY2PR02CA0081.outlook.office365.com (2a01:111:e400:2c2a::39) with Microsoft SMTP Server (TLS) id 15.1.106.15 via Frontend Transport; Fri, 6 Mar 2015 20:35:13 +0000 Received: from atltwp01.amd.com (165.204.84.221) by BL2FFO11FD016.mail.protection.outlook.com (10.173.160.224) with Microsoft SMTP Server id 15.1.112.13 via Frontend Transport; Fri, 6 Mar 2015 20:35:12 +0000 X-WSS-ID: 0NKT56M-07-DB6-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 28B94CAE7B8; Fri, 6 Mar 2015 14:35:09 -0600 (CST) Received: from SATLEXDAG03.amd.com (10.181.40.7) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 6 Mar 2015 14:35:28 -0600 Received: from joelvmguard2.amd.com (10.180.168.240) by satlexdag03.amd.com (10.181.40.7) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 6 Mar 2015 15:35:09 -0500 Subject: [PATCH] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE From: Joel Schopp To: Gleb Natapov , Paolo Bonzini , CC: Joerg Roedel , Borislav Petkov , , David Kaplan , Date: Fri, 6 Mar 2015 14:39:16 -0600 Message-ID: <20150306203916.12198.57824.stgit@joelvmguard2.amd.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=Joel.Schopp@amd.com; 8bytes.org; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; BMV:0; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(15975445007)(105586002)(47776003)(229853001)(46102003)(53416004)(103116003)(33646002)(87936001)(50466002)(50986999)(23676002)(54356999)(77156002)(101416001)(19580395003)(19580405001)(92566002)(62966003)(97746001)(83506001)(575784001)(86362001)(77096005)(71626003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0201MB1044; H:atltwp01.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0201MB1044; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0201MB1076; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5001007)(5005006); SRVR:BN3PR0201MB1044; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0201MB1044; X-Forefront-PRVS: 05079D8470 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2015 20:35:12.5525 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96; Ip=[165.204.84.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0201MB1044 X-OriginatorOrg: amd4.onmicrosoft.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Kaplan Another patch in my war on emulate_on_interception() use as a svm exit handler. These were pulled out of a larger patch at the suggestion of Radim Krcmar, see https://lkml.org/lkml/2015/2/25/559 Signed-off-by: David Kaplan [separated out just cr_interception part from larger removal of INTERCEPT_CR0_WRITE, forward ported, tested] Signed-off-by: Joel Schopp --- arch/x86/kvm/svm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" 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/svm.c b/arch/x86/kvm/svm.c index d319e0c..57f0240 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2940,7 +2940,10 @@ static int cr_interception(struct vcpu_svm *svm) return emulate_on_interception(svm); reg = svm->vmcb->control.exit_info_1 & SVM_EXITINFO_REG_MASK; - cr = svm->vmcb->control.exit_code - SVM_EXIT_READ_CR0; + if (svm->vmcb->control.exit_code == SVM_EXIT_SEL_CR0_WRITE) + cr = SVM_EXIT_WRITE_CR0 - SVM_EXIT_READ_CR0; + else + cr = svm->vmcb->control.exit_code - SVM_EXIT_READ_CR0; err = 0; if (cr >= 16) { /* mov to cr */ @@ -3325,7 +3328,7 @@ static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = { [SVM_EXIT_READ_CR3] = cr_interception, [SVM_EXIT_READ_CR4] = cr_interception, [SVM_EXIT_READ_CR8] = cr_interception, - [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception, + [SVM_EXIT_CR0_SEL_WRITE] = cr_interception, [SVM_EXIT_WRITE_CR0] = cr_interception, [SVM_EXIT_WRITE_CR3] = cr_interception, [SVM_EXIT_WRITE_CR4] = cr_interception,