Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755487AbcDGIhY (ORCPT ); Thu, 7 Apr 2016 04:37:24 -0400 Received: from mail-bn1bon0093.outbound.protection.outlook.com ([157.56.111.93]:47609 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755424AbcDGIhR (ORCPT ); Thu, 7 Apr 2016 04:37:17 -0400 Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; From: Suravee Suthikulpanit To: , , , , , CC: , , , , Suravee Suthikulpanit , Suravee Suthikulpanit Subject: [PART1 RFC v4 10/11] svm: Do not intercept CR8 when enable AVIC Date: Thu, 7 Apr 2016 03:20:31 -0500 Message-ID: <1460017232-17429-11-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460017232-17429-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1460017232-17429-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [124.121.8.20] X-ClientProxiedBy: KL1PR02CA0009.apcprd02.prod.outlook.com (10.165.15.19) To SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) X-MS-Office365-Filtering-Correlation-Id: 7f7488a0-b5b5-439b-a2ac-08d35ebdbac5 X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0445;2:zXnv5hILAkceROSFei9bNiiWqUcsSgCOithcgKLE+1Vt8fXCA35PYSBfttt6dKza4Fd8zdTMIQ6LGE4rKSTyWrVJvIfwsgf22FiIa91FOkjyZK0t1aND7B3ndgddczPP3wz+SE1/d9OkmN1M/3/7rLx4kDlpTnpl2us+5MoSImeft0+DvnWgKxcinFLzSnvI;3:iPelnucHDKttpAzeUezyBU2aqdFGyYl5uobgMCdC4gDYrHwLtNuURvxhBtRdEUcA33y6owgKcyedsuKsvCnPGCJMV0cS6r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emqhoM3O5lljs8rIe5WNmRzLALVTtZqYvOYjvYuNAxsjNeTHwdBwk/JQxPu0ImhmtcIm262oP8KMD6PK5w9512WTMRvfIxktHA8dJCt1XqDWDj3rF3Kr1qw0jyQpsYZOro0pCRdwwFmwcApPV1Lb6pyUwvSa86AQdaFb4Wir831dUTXMm0DWG1CviyHxMZdkB/qVTtQldj9XH;4:ftwQp12Sq1nXHw0wJGrLu0MX1b2qr227PpU+7xwuyprjAW3O7vYA0Y+XfyhTvVLrUlUApnVbPM213yj5FU0QQyP/NiYXEm+5wY+6qa+xJlDsrTW9NHfFQi8o4JV0aw8xr2lUlYDZLfp3rkNJ+3HYxyZ8quJKJEMK7MMpAcjCqC4Jr649A22ooW51Xwvo7tLQqrJkZ8mHeqA2c2xwjvFKzowzw6N27Vywoal66KI/BL1f1qX1XsJQZlMMQgssN/zwewb6OotkE6/Kr6fkNs+x40LbWnQb4kELMMBeTWu88dC1ykgB+rh3pJILN/L3BR1uIuLVTvgaOAlm0lBFXeQ7ONB4KNk1Gxr0WtS2wF9fbRWUppPcY02WVwFscOgvBccp X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:SN1PR12MB0445;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0445; X-Forefront-PRVS: 0905A6B2C7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(979002)(6069001)(6009001)(5001770100001)(50466002)(2906002)(48376002)(50986999)(189998001)(77096005)(4326007)(2950100001)(36756003)(5003940100001)(92566002)(76176999)(47776003)(19580395003)(19580405001)(81166005)(5004730100002)(2201001)(229853001)(50226001)(86362001)(42186005)(586003)(3846002)(5008740100001)(66066001)(1096002)(6116002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0445;H:localhost.localdomain;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR12MB0445;23:oO+bGIBLi24H8eaiw+gRyyNGlX/WkwfpKMMGM+q3z?= =?us-ascii?Q?e5OnYJoVm0rB1zawwvxu1CeDhNJkV3Xg/Hu+XSBzC/DzGOUU63hVZLQuTwbr?= =?us-ascii?Q?3jfSZQhYGYbd1st3f4sH5Pqd85s0EKFa9mLuMbX8mzalvEPnVGSEfA4B3MeD?= =?us-ascii?Q?sBHezJ50B3fxygmLIrhOZGOKnIkBJw2HrAUnrxLn+A6ZH2KpctnKya6lQfqa?= =?us-ascii?Q?T2PqvunNef5GQLm4iedNrenkbW27U/XMxpAXS8Px7VEnjVJpzYquyjvyxYuR?= =?us-ascii?Q?v5QYNgDOjH79lGbuV4o1JRjhIqs5LezXWtlz2NZaeb43ZeZl8/XZ4XY3swHT?= =?us-ascii?Q?0pgJkOc3xMB3JURq85ND3R/1P3xSfxQUYnhRAde0uoYTUmyPKvBDsWRhf17L?= =?us-ascii?Q?Mb01uUZGqKgVCowQ2H+epu2O9EiDWlQxDKdc3Lu8ccFaog3owQ1wN9LBEkmG?= =?us-ascii?Q?avRyYPx5JpHRtgYVKCE7HmljCgBGf042r9IlCkiH7PBXwiTKyhocgj11/dwH?= =?us-ascii?Q?b3AkykSPCGKmT5HyTvGhbbbzpFy1qp+367KwCCj47xKFf5tMRboX4X95cztB?= =?us-ascii?Q?2xYIQsWa/7k3bxGo9efc8vaNic7yS60tfMMpwVgEbnj3pQjP8AjyFXoVhJXx?= =?us-ascii?Q?DaXOtkXqDU+kXRhUz5MNyOLMh1FSurpO9w+RAaJitOZ47Id+2aLE/hqBdE77?= =?us-ascii?Q?PwjNeg6neOSLH9fVI2kQncYBMEIx70d9Zbv3dQ+AjGm2T7iV08NaT4dY23Sj?= =?us-ascii?Q?6TbeyJVhIhN/qXVznoLoxe4P4/DZ7dqVk3lXH8oj0o7Zngm+FyrZo14lkKqH?= =?us-ascii?Q?hWm6WZFO0wCfnSVrQHOxacbIpe4q9f/bLIrxkujajugo/7kVLJopxIGCJjkZ?= =?us-ascii?Q?pCjrMZ86MaQjR+ohuH4xPjQ2ob9Iw+RblTwXPXMmzpj4MibGnkcC/EOD71wP?= =?us-ascii?Q?1htBvdyiN7pXb3JTVNDhD/GTz9pw7GS9T+OlYC8+eRK3hWiv4RmQjH1Qp7t2?= =?us-ascii?Q?pY=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0445;5:4JzoTA7ukueqOumJiUcbdvXhefc/Z45FK9aVu6Czui5n4OPQy3U0oOJCyGQU7llcO0HpZdRrtljuVme6tp2jy/aeFbfAyxJyR3ylLZH7YouRe5Q1Fy70E4gLbb2WJ8wXmUMj80Ts7kZNVHS8RLR6/Q==;24:xO2BUNTb9dNBeR/nUpab75k3ilZqHG0RgHmEEFeBOM5UZP6lVu926mAbVmveTHGJYD4EWdxm/qmIFAQcLOE2FgxWmtoIKOc9/o4Tuljin4k=;20:yCIs2eXElLEbetgXPaC5EpOL0RnE+yAVK3nUfYESc6X4pWKCKl6n0f+EG4CW5ZNQMHHhrw0+FeBuC2yVDXRwz41e20j+oEvgO44tDbxYsPTQr6/0eO2EldUNLnvzFlAbEF4sQVjt37aTrhXyU8AdTQUcj2xklQxqfPD9oTsE3Unan9LjNZ6Zq5CsBDvSsETniUDUSzx9Q26NX7y6KSuPNNVY+X2hGJ5Pg/zrgSDr3t0cRMdZZu99fMqJTTzhVoE2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2016 08:22:07.8149 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0445 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1906 Lines: 55 When enable AVIC: * Do not intercept CR8 since this should be handled by AVIC HW. * Also, we don't need to sync cr8/V_TPR and APIC backing page. Signed-off-by: Suravee Suthikulpanit --- arch/x86/kvm/svm.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 74b0751..bccf6cb 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1092,7 +1092,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 (!svm_vcpu_avic_enabled(svm)) + set_cr_intercept(svm, INTERCEPT_CR8_WRITE); set_dr_intercepts(svm); @@ -4069,7 +4070,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)) || + svm_vcpu_avic_enabled(svm)) return; clr_cr_intercept(svm, INTERCEPT_CR8_WRITE); @@ -4255,14 +4257,15 @@ static inline void sync_cr8_to_lapic(struct kvm_vcpu *vcpu) static inline void sync_lapic_to_cr8(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); - u64 cr8; + struct kvm_lapic *apic = vcpu->arch.apic; - if (is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK)) + if (is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK) && + svm_vcpu_avic_enabled(svm)) return; - cr8 = kvm_get_cr8(vcpu); svm->vmcb->control.int_ctl &= ~V_TPR_MASK; - svm->vmcb->control.int_ctl |= cr8 & V_TPR_MASK; + svm->vmcb->control.int_ctl |= (kvm_apic_get_reg(apic, + APIC_TASKPRI) >> 4) & V_TPR_MASK; } static void svm_complete_interrupts(struct vcpu_svm *svm) -- 1.9.1