From patchwork Thu Apr 7 08:20:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 65244 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp335560lbc; Thu, 7 Apr 2016 01:37:40 -0700 (PDT) X-Received: by 10.98.31.79 with SMTP id f76mr3084387pff.92.1460018260351; Thu, 07 Apr 2016 01:37:40 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pb2si10342460pac.41.2016.04.07.01.37.40; Thu, 07 Apr 2016 01:37:40 -0700 (PDT) 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; dkim=pass header.i=@amdcloud.onmicrosoft.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 S1755495AbcDGIhY (ORCPT + 29 others); 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GvAcO7JlnTZZ47OsP3RILeiNqErYffO1GvsZhegreDI=; b=3hiVc9bUDDNxhMoQ9zWCpp5lqS566Ao66TZ1B/n2t9OYvP0501O1qh7W9morVRf0/3xO9Wxd/AslFrfZVe0PYT1iiiKYSrPI42+7wc6H+Z9W0otTP8Z+i37j86QXq41jJyBdowxIWBhsYTGmacnNnnCWr3rTtZCaSuSXvM28tIg= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=amd.com; Received: from localhost.localdomain (124.121.8.20) by SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) with Microsoft SMTP Server (TLS) id 15.1.447.15; Thu, 7 Apr 2016 08:22:07 +0000 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 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:iPelnucHDKttpAzeUezyBU2aqdFGyYl5uobgMCdC4gDYrHwLtNuURvxhBtRdEUcA33y6owgKcyedsuKsvCnPGCJMV0cS6rz2tjyatuQOmISaYGmGI2ex0ajVTbDhQx04; 25:zPRcuwfE5NOo7EUFDMDAa5HJjecMpWLMIu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oP8KMD6PK5w9512WTMRvfIxktHA8dJCt1XqDWDj3rF3Kr1qw0jyQpsYZOro0pCRdwwFmwcApPV1Lb6pyUwvSa86AQdaFb4Wir831dUTXMm0DWG1CviyHxMZdkB/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-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o/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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 1.9.1 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)