From patchwork Fri Feb 12 13:59:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 61851 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp840707lbl; Fri, 12 Feb 2016 06:01:53 -0800 (PST) X-Received: by 10.98.67.8 with SMTP id q8mr2309151pfa.133.1455285713504; Fri, 12 Feb 2016 06:01:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qy6si20209053pab.185.2016.02.12.06.01.53; Fri, 12 Feb 2016 06:01:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753009AbcBLOBv (ORCPT + 30 others); Fri, 12 Feb 2016 09:01:51 -0500 Received: from mail-bn1bon0097.outbound.protection.outlook.com ([157.56.111.97]:24224 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752933AbcBLOBP (ORCPT ); Fri, 12 Feb 2016 09:01:15 -0500 Authentication-Results: 8bytes.org; dkim=none (message not signed) header.d=none; 8bytes.org; dmarc=none action=none header.from=amd.com; Received: from localhost.localdomain (124.121.8.20) by BY1PR12MB0440.namprd12.prod.outlook.com (10.162.147.141) with Microsoft SMTP Server (TLS) id 15.1.403.16; Fri, 12 Feb 2016 14:01:10 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , , Suravee Suthikulpanit Subject: [PART1 RFC 8/9] svm: Do not intercept CR8 when enable AVIC Date: Fri, 12 Feb 2016 20:59:33 +0700 Message-ID: <1455285574-27892-9-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455285574-27892-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1455285574-27892-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [124.121.8.20] X-ClientProxiedBy: SG2PR03CA0036.apcprd03.prod.outlook.com (25.160.233.46) To BY1PR12MB0440.namprd12.prod.outlook.com (25.162.147.141) X-MS-Office365-Filtering-Correlation-Id: fb0dccce-99b1-4ca6-4d73-08d333b4f783 X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0440; 2:hDXVqQPoBapP4Abj/Mwip/ZR8vGVEBpefQlwadO7da1Ygy9mPLFDB+Cm9Mq7fb9ru+w+wygw9fNE9Ji0czBbv4Xtcjs4KVkhlUg2sDpLpLQvfR5c9URLpoWX2IZdFc6lV01pFEDilVheyJ5kz2iArqqWYgEMkAqrb/6oCgJLmvGcGTQngeTBczLKnY91CQoC; 3:oLDuscETKvttctLpxUpPkepIZtEaYhZ9PWmI3SCTgMzUJK4Sx+bwFJPCamF73iEY/wpJCUTdWvin3wFpPT+2BN4Yi+fhMflp/3bn6Z69rPvgs/GvE5KvATlEyvZCVaRU; 25:azIN/lpv7GKrhHpPC72Xp60gEX3u9xShOkhJ3vLXOvFbMa56yhBFYVlxuGsT/MFmdn3zkaCvaZjilya7V3BC7AOBBDTfihCxZG+vE71N3eHK4OSbLMTcY910hPmJwfHbprX4xHk1gCp+CI9m+2S1OpBhExcMbzCZietQaW1mnAAW+RgDUppQGnMVkpcBIJlBmbo6LjB2Vgb0SrLf3zOUmsgSdhb0EThOk3T0cSSoUGTQ/aAp3ZJdI0QQhvQd61xjPwEmT1MvisLouhD8gdI/4lrI5Uf0rMMjJlpNhvcCxfw9hGq3c3tU9UTst+P/PNvi X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR12MB0440; X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0440; 20:N2MpvPw5ZmqdY/XcktPDBOpS0XJ3X5Yd48MOWra6FIFJNFbHVjY8za0w+OqmZL4hTWJ4rXOzO0NeOAWuzqqpgDe7gu9xHJKNNqG4jgRWUOQpOC0i50InQDIYpM+xNHRZJyzIWJqd8ibXIrcAPaMMF6g00PzV2CXxDVNkarpXLb56N6oddgjR8ysTDr8qLfj4Hn7qECXeOtLP/9iHdbLXKWbWTvq2n1IwofjxIZdIIbBdcbI0AvWMACl29Kts62gOMfl8iZqz/x+TcT4bO5ddgXmOW2PyDx1h/7vkXcQZ9lUISAOg3F9DLIFSyoSTnTOs+4HsL4O6pbSczefFYbaaC98MfZ8t+0J1qA9MsOavMilc+pUF3nFoV1JuLcWOxAX6QY8x6VbX5HiY/aQYCsejWYOq1RPKcLt8vOhztvWi/CisB7gRC+xpTyXU/j8bOIEMASHrdvPMl7KE5xYuDp4SgNSn4/IxHc/rYvVy0p3SJNKoCJX+tlWbWE6tG1JiP+G2; 4:0se6iYpCrqIDRyKlnXj+24I80JtisPlBxMF9krsB/mEWRAiqfXpjvp8sio939YzK+IapWGaB4b22WQOkBLIDRF8TfsJGDmfBWt4hEBZm2gk1nZMvxvwD+tuf4VM7ZdLn0qIu9eUcCgA9dStob/o8TAvocJhVbw321+pWobp8cOzHrHWrREvCqYq9qR5rgoIlSLekklI3pYZJ7fO8e2QozBrQ0Pk1zrQNKHW0HVGqMsI2fCEIsESqjSzTczb/Mcu1LMuMUl8pouyzPr3uktM9+yyvMV2AQF7QSNQVLvFumMh/hOSHFgLdZ1e74z8Jv8fL1bkBMP2Jk/oClcdo5KhfhENg/L9kB9uXNlqqLurleAB7IuKqHqv3xZYNKVvCJUTGidWR63kRBzMu2r0uKTjyi1w2HpzsbItRdFjLLWeflRU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BY1PR12MB0440; BCL:0; PCL:0; RULEID:; SRVR:BY1PR12MB0440; X-Forefront-PRVS: 0850800A29 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(2201001)(36756003)(48376002)(586003)(40100003)(92566002)(3846002)(5003940100001)(77096005)(229853001)(2950100001)(19580395003)(19580405001)(6116002)(5004730100002)(189998001)(4326007)(42186005)(66066001)(50226001)(87976001)(5008740100001)(5001770100001)(122386002)(33646002)(50466002)(76176999)(50986999)(86362001)(5001960100002)(47776003)(1096002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR12MB0440; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR12MB0440; 23:SvrI1KUXPpEcuL5adKx3FdnuAQFNWYuVH0KGjPRAh?= =?us-ascii?Q?0mLyLHmYu4KkRM3LRmq8X9cQCbwR6T+nC4l0It5J/9HXCC2aLq3aXvFG4XaD?= =?us-ascii?Q?EmnRuYh59LPMW/A2C5iz2yCs6rfEiP5e1jZUn+Zocaid6PH5zREZrLfM5reZ?= =?us-ascii?Q?3slURzkkS2lu4U/26zAv/CvRzRizXRpP6qqRBK3jtdXLIWI1u8CZRUKMIJwh?= =?us-ascii?Q?QKYt9TSxvjyAdtcP3FmChwx5p+QJBeyo2+XKpgKHI+VuIyOov/BD8VxRHiYA?= =?us-ascii?Q?qwbAA1jNsqaLvZBf/bAyLs5Si2PlG+bufOciWmuZH7tw4bPGSm84cI/XFQq9?= =?us-ascii?Q?ky4UFLPehIDa25ms08anAAgtTzO9eiDUTPtnkwfG9xXg6K8GbZGabngRGkpK?= =?us-ascii?Q?t3EsWCx8nOQCPzSfjAjnrLUH40EZjJgJct+Oae5hnNr23OrVXZvGVzjDzgHM?= =?us-ascii?Q?htc5bBE/zyt7VSeeGVu5PajgBmPcbsuzdsi07dqU6E1XJy2zMlUvhc/TEorr?= =?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NakbJfeKzox8teAbHMxs57oxlPK2WuHyM21VSseUtt1IBCyth6F0E6C8XsX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2016 14:01:10.1890 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB0440 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit When enable AVIC: * Do not intercept CR8 since this should be handled by AVIC HW. * Also update TPR in APIC backing page when syncing CR8 before VMRUN Signed-off-by: Suravee Suthikulpanit --- arch/x86/kvm/svm.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 0998e67..32da657 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -981,6 +981,9 @@ static __init int svm_hardware_setup(void) if (avic) { printk(KERN_INFO "kvm: AVIC enabled\n"); + + /* Do not do cr8 intercept if AVIC is enabled. */ + svm_x86_ops.update_cr8_intercept = NULL; } else { svm_x86_ops.deliver_posted_interrupt = NULL; svm_x86_ops.apicv_intr_pending = NULL; @@ -1098,7 +1101,8 @@ static void init_vmcb(struct vcpu_svm *svm) set_cr_intercept(svm, INTERCEPT_CR0_WRITE); set_cr_intercept(svm, INTERCEPT_CR3_WRITE); set_cr_intercept(svm, INTERCEPT_CR4_WRITE); - set_cr_intercept(svm, INTERCEPT_CR8_WRITE); + if (!avic) + set_cr_intercept(svm, INTERCEPT_CR8_WRITE); set_dr_intercepts(svm); @@ -4248,7 +4252,8 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int irr) { struct vcpu_svm *svm = to_svm(vcpu); - if (is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK)) + if ((is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK)) || + avic) return; clr_cr_intercept(svm, INTERCEPT_CR8_WRITE); @@ -4440,8 +4445,10 @@ static inline void sync_lapic_to_cr8(struct kvm_vcpu *vcpu) if (is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK)) return; - cr8 = kvm_get_cr8(vcpu); - svm->vmcb->control.v_tpr = cr8 & V_TPR_MASK; + svm->vmcb->control.v_tpr = cr8 = kvm_get_cr8(vcpu) & V_TPR_MASK; + + if (avic) + *(avic_get_bk_page_entry(svm, APIC_TASKPRI)) = (u32)cr8 << 4; } static void svm_complete_interrupts(struct vcpu_svm *svm)