From patchwork Fri Mar 4 20:46:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 63607 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp281351lbc; Fri, 4 Mar 2016 12:49:05 -0800 (PST) X-Received: by 10.66.152.231 with SMTP id vb7mr15172746pab.132.1457124543629; Fri, 04 Mar 2016 12:49:03 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10si7940323pfb.71.2016.03.04.12.49.03; Fri, 04 Mar 2016 12:49:03 -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 S1760160AbcCDUsr (ORCPT + 30 others); Fri, 4 Mar 2016 15:48:47 -0500 Received: from mail-by2on0059.outbound.protection.outlook.com ([207.46.100.59]:15904 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1760078AbcCDUsn (ORCPT ); Fri, 4 Mar 2016 15:48:43 -0500 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.415.20; Fri, 4 Mar 2016 20:48:32 +0000 From: Suravee Suthikulpanit To: , , , , , CC: , , , , Suravee Suthikulpanit , Suravee Suthikulpanit Subject: [PART1 RFC v2 02/10] KVM: x86: Introducing kvm_x86_ops VCPU blocking/unblocking Date: Fri, 4 Mar 2016 14:46:00 -0600 Message-ID: <1457124368-2025-3-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457124368-2025-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1457124368-2025-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [124.121.8.20] X-ClientProxiedBy: SINPR01CA0045.apcprd01.prod.exchangelabs.com (10.141.109.45) To SN1PR12MB0445.namprd12.prod.outlook.com (25.162.105.139) X-MS-Office365-Filtering-Correlation-Id: 18a0db24-78ef-4b4b-5d8e-08d3446e5e1f X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 2:O0fA6T4l8hMzqd01Lk+dfv3Px0sE3Q/U/YBtDqAebZYo2nE8QDBcGnrmQqZZp4GISSoC3uB7IVUDX5QlTKcLr5Fs9KcDyGZnF0u70I6pGJughCRVVACldMuwT3ZVy+8YfXlq5NTASxNM6hV0akV3I420Rdo2wIez74hflwr6mLArqlsiV0/FEAI0uuXkl3V6; 3:g0JGaE3nytAv/Xo7X8d2TmSedhJaWJEpx7UGOXDZpIVlfutG7IsLXLMnm3oKK4EIYyVv6NvlYgSt+qOVmmI1wEVx2ewgxyWdq03nBzIG92PdGMAJTBizjgT0Ec2nOSwY; 25:nRca3bxeMnAYwRFByOJhXAaICSN8qJvc0rRrqFdgWUYpYkJ6YfNkulE+kpXV0BrqS4wpIqQhQSmtAkBZnGdMzHX6Hvp8vUtzI2KXg8PLGO7WGvxr6G+gFG/7o/ZdrjcVftm3MOzLVQer2eUL0TiFY+RY8DPmdViOAPSFCTlZCIOhYpU1Wg1EZSXHN9yWRTZwaHO52KMZINhcAGJjArNQ9tKStua6HaYd53tRK2r9pt0goDMAySxJRXuGo13nQSfmMszfNSelJ0P/2mhtVBkD6HjHlkqV123NK+yMHqWGeA+59Q5uEUm4RCE1PwtyqN9GqQLlSc0fEdOOGVXLORc1KQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0445; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 20:xkNZMGqbqVX0okGoilYbqP++7taeCFoeHllPWSN10aMe7Yt3dEtjvFhl1pt3wLKwsuE42MHLC7B0lgdTzJKv+LPcWs8vnbjQN0CLeHvy6+rmMLiYa4vt9nY35RUWfKzur5BQOlJ5+2DbC5nrIV1VIAtlpKZQcAVSjj/REhAlxDITWX/SjQ3wLPG+tNY7tEo9M15lGD1oym84Y5XSw4E5yO0gj8KL10tg4eUo8XwOAcCXvyE+A2XfN+iedANIQUmOYCxkDF1O41KtepZGwh5ltxoWk0H/OE88rmLoo9xhwVyqDhXRnNvRacqUzPh0TpHC68ejFIb3fnF9X8eHP3wwPwzqYPuAZpHbl98aPsGKTfYzYMA3NMUP4IyM+Yqb6kCudgaC4m0c41bvnjLVQe7RzXOybO/vrMdWwo5z3ksUzdZCjX+oGzQoLsmoSCFoBm6BuxPalLSBUFvWz8HdOpRuCPoK3l70MWgtW1kUVVY158HG4FN0av3l9IfIGoMHEokg; 4:aIbgQor1RlKQduTutY8panmHjIqZ+u2SSug75VHU3i4D0jSJ1tR3tNyzvinpFMMF2UcYqyB3484RwBdbtRh35V+vPaY6HdDn8nEFw91KzXhKme+HQQ35wtgt+6cZMZDCEPbf7MhSi1cICOuMIkWnCYKuv6VUQ6hPoDsWTA4J/q5U5XwIN/zdkIsYV084Bta1mV3wwHISDOFLGiPeM8Ao0x9dYMGTPcECnjvn9zuozJLDhptATpBG0AFNizVsdaFk5xXEWJqd3PbOxaoSlLwcSB8rpIk6SHPZTF9bl5gglp/f/ayYPyrqizCr3d5NANmUFP0LcrWI3rdUNuRM6nCuYVDE566sRKogqb2gxktl11Oh/jjrAeoQTqeFwuE1UFoR 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)(3002001)(10201501046); SRVR:SN1PR12MB0445; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0445; X-Forefront-PRVS: 0871917CDA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(77096005)(5001770100001)(87976001)(48376002)(47776003)(229853001)(36756003)(2201001)(66066001)(81166005)(50466002)(2950100001)(5004730100002)(189998001)(40100003)(50226001)(5003940100001)(122386002)(5008740100001)(19580405001)(2906002)(19580395003)(86362001)(4326007)(42186005)(50986999)(6116002)(3846002)(1096002)(92566002)(586003)(76176999); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0445; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0445; 23:XDiaKNsLwv4fWHlpnbM9xfERblOD/X/083bdDyz32?= =?us-ascii?Q?OOUqyQk/z2v44pFtUR0ZKpIzm6VUjTWg3OiHyV7fM1qh57Hw+kj9oLH6Sjqh?= =?us-ascii?Q?prpSjhZ4XTa+XhHtVPC5tGiyDPYRv2x6/xQjlmMKvZc1nEdbHl10MrxQpdRW?= =?us-ascii?Q?FRHTmN1+1RccePwp/CbEHfRNg14zlcwVP2oNSZRgtA3+OPQ2yxesftFQMvko?= =?us-ascii?Q?s0Pz+SEKRmA1+Gr9/l3DQ0ik6psWgCowePou7uVtTn0ze/BB4lTiY2VPyVTJ?= =?us-ascii?Q?05RzbWQHTRXAG6dtssX8pevRZkkoimkma7HdezqQvhgaq+9XDqUOkf52D6of?= =?us-ascii?Q?mm21hhw7FEoQlSCat+Lx3xDE3KU5i6BdcY2y6I+Dj+Jpzu4vyKXzpF9SDgkt?= =?us-ascii?Q?NaG/BTlvMuxCKldZh4v2Zrm8NTG82wBeH3+bzIgAelQgfEmNgQwzDwt7bMrx?= =?us-ascii?Q?+opyfVZJ2rb8OAUJUifIIUxWBcyhofBDjC6UmOYpTrJVSu3Hj2MZk5hsurQS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M4fWwauLMYeex67vEmWs37O8DJlL6LeZRFQ7jbW0r2adXwONBL3qG X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2016 20:48:32.0886 (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 This patch add new function hooks to the struct kvm_x86_ops, and calling them from the kvm_arch_vcpu[blocking/unblocking]. This will be used later on by SVM AVIC code. Signed-off-by: Suravee Suthikulpanit --- arch/x86/include/asm/kvm_host.h | 17 +++++++++++++++-- arch/x86/kvm/svm.c | 12 ++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) -- 1.9.1 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 44adbb8..9a61669 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -969,6 +969,10 @@ struct kvm_x86_ops { */ int (*pre_block)(struct kvm_vcpu *vcpu); void (*post_block)(struct kvm_vcpu *vcpu); + + void (*vcpu_blocking)(struct kvm_vcpu *vcpu); + void (*vcpu_unblocking)(struct kvm_vcpu *vcpu); + int (*update_pi_irte)(struct kvm *kvm, unsigned int host_irq, uint32_t guest_irq, bool set); }; @@ -1320,7 +1324,16 @@ bool kvm_intr_is_single_vcpu(struct kvm *kvm, struct kvm_lapic_irq *irq, void kvm_set_msi_irq(struct kvm_kernel_irq_routing_entry *e, struct kvm_lapic_irq *irq); -static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {} -static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {} +static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) +{ + if (kvm_x86_ops->vcpu_blocking) + kvm_x86_ops->vcpu_blocking(vcpu); +} + +static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) +{ + if (kvm_x86_ops->vcpu_unblocking) + kvm_x86_ops->vcpu_unblocking(vcpu); +} #endif /* _ASM_X86_KVM_HOST_H */ diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index c13a64b..28f8618 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1265,6 +1265,16 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu) wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); } +static void svm_vcpu_blocking(struct kvm_vcpu *vcpu) +{ + avic_set_running(vcpu, false); +} + +static void svm_vcpu_unblocking(struct kvm_vcpu *vcpu) +{ + avic_set_running(vcpu, true); +} + static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu) { return to_svm(vcpu)->vmcb->save.rflags; @@ -4321,6 +4331,8 @@ static struct kvm_x86_ops svm_x86_ops = { .prepare_guest_switch = svm_prepare_guest_switch, .vcpu_load = svm_vcpu_load, .vcpu_put = svm_vcpu_put, + .vcpu_blocking = svm_vcpu_blocking, + .vcpu_unblocking = svm_vcpu_unblocking, .update_bp_intercept = update_bp_intercept, .get_msr = svm_get_msr,