From patchwork Wed May 4 19:09:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 67167 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp357494qge; Wed, 4 May 2016 12:10:54 -0700 (PDT) X-Received: by 10.66.199.66 with SMTP id ji2mr14460913pac.34.1462389054526; Wed, 04 May 2016 12:10:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2si6356323paz.87.2016.05.04.12.10.53; Wed, 04 May 2016 12:10:54 -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 S1754513AbcEDTKf (ORCPT + 29 others); Wed, 4 May 2016 15:10:35 -0400 Received: from mail-by2on0094.outbound.protection.outlook.com ([207.46.100.94]:2275 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753526AbcEDTKa (ORCPT ); Wed, 4 May 2016 15:10:30 -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=TL6FgbROTzk3P03u9K+2unslNOpmxD+hVg2w/C1fe04=; b=A5wUvxlvfcG92RxLgLoPKF1tfUsd/jdKKUAOMc/cKhtXr2Jrajki++zr0RgiqSTIf9uJ95EPHOxu9lQqgyeO2x4Zx6wF2oEFM4UJdU4fHlkPUoehglkJ9qSzyrwTpJsh3o05Xj76nm/m5EGCEoOM0F+htwiihm/YuypdE10qMJk= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=amd.com; Received: from ssuthiku-cz-dev.amd.com (165.204.77.1) by BLUPR12MB0433.namprd12.prod.outlook.com (10.162.92.139) with Microsoft SMTP Server (TLS) id 15.1.477.8; Wed, 4 May 2016 19:10:21 +0000 From: Suravee Suthikulpanit To: , , , , , CC: , , , , Suravee Suthikulpanit , Suravee Suthikulpanit Subject: [PART1 V5 03/13] KVM: x86: Introducing kvm_x86_ops VM init/destroy hooks Date: Wed, 4 May 2016 14:09:42 -0500 Message-ID: <1462388992-25242-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462388992-25242-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1462388992-25242-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BY2PR21CA0014.namprd21.prod.outlook.com (10.162.74.152) To BLUPR12MB0433.namprd12.prod.outlook.com (10.162.92.139) X-MS-Office365-Filtering-Correlation-Id: 687687b7-5464-4dfa-9760-08d3744fc129 X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0433; 2:eWLKQj5MBoJokEMPbN0HB9n1o9L5dDEHA/VYDvuikj2MwWXEetETtuzHCFJ5LM4uO+RTXXpZTwWAbZxT1IF6Uek7KzlkSXz5ZAO+8PFT1IOPc5PcXbVyswKM9fYhj7VfPKYYiRwQRmqh9aFF2h89b8KRCofkcl9yezbtgj6DqCwILWvQglmno5jEHhREfQlQ; 3:1BT5FFM/usTP2UnIh8pl9BwYZ1yCVZ9BN69pbXkAN0n8DOiC8es2nPQZhwt13K8ks9rX9QfCHB2aUed151Kb98ALNKRzEpaCXFg4o4PV8aVi3TOJSEvkUKqFotm3cMXi X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID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WB4osv0Q6U6Sa/betJsC6utzPFbm61NgyOrvwvyAM9qUzaOWtVuRs3oz1fH4KROd2vIbMgkKi4wiQMgaLkrqtqv1QJWr78x9Vrl0XVUPzylbN7atwU777kKmQqEb5vLRBqIHDk2M7GlZJUHdYHdRbeNU8mMooPLCmmwPMzRCc8RNDv9K85cpO/GM0TQIkVE2KGCPQv9mArlmLmVDA2LYj90; 4:DFZjGFP3zyHImujkLF3eguA7CqDaLO0QeASqxkwdUxuZ7PE7qlajkvA/v3HE6BlSWavg4wOJ0KQPBuv09bHGHLRje4kXBt9iqwNlqvFD45pzoRRvEgeyvYALRKuM8lKGIuShTxXG+eLQ+IC3XoxJWzZsSRQPmGYPqD1Xc264nN8bVnhD3MgB5YfFvtUNYYqkCUvSVDdD17HB3tzR6sIMBAOX4FwQHRRE4wvRb7rqCYLg/8oT6anUohInZtEPFYQMxaKw/G0SmZyP6zBgZleDYpHhQuhOxkpUoPd4iPUzy1dAciPHLs/3wPziZjyL6MYsg3zkCnxDBvDyqVlZYKYqzwtUtixADjO3GERZXCdAuOs/EHRtfWgATNiSeJzP98pieBa19BNnW4TNvwzCb2FjoJ7FVISOKCoqX+RmivqfGfhUorNEc8TYISwiN8nl5FeP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(9101528026)(9101521098)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:BLUPR12MB0433; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0433; X-Forefront-PRVS: 093290AD39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(50986999)(76176999)(50226002)(47776003)(66066001)(229853001)(36756003)(189998001)(19580395003)(19580405001)(2906002)(2950100001)(5003940100001)(53416004)(2201001)(5004730100002)(92566002)(4326007)(5001770100001)(77096005)(586003)(42186005)(5008740100001)(81166005)(5890100001)(48376002)(3846002)(6116002)(86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agnostics: 1; BLUPR12MB0433; 5:j1JLUFkHKutQr4X4kO/D0Od5kR0kAf/rl/5q2KVitSqnvr1OMggnvgTexMQ+ZcVxIc3wCNt/hDsVEMVEhJWLMhmpHcP66BtrwmRFkBu1zwUM6fjY3DH+ij1W0e8p2VLElujLY6fDze6MBdp8NBCkwg==; 24:7BQS5uOxKoKXPTuvtMkwfaAdrbdjoGEZQhhes/NtpIVecrESR6HDBNFZQliHlrwliQYRrMVrs8a0yy6OnldUu6a1vA0v0C6nzZf80TOSnts=; 7:cfCL4yVzuNABF6wvf5r4PwYJAyjV0UugcedKjMFl5y2KDM5iap/Hc5PWrb0c3fdVX1i/1kweNp6YJBBpIeit01OrQgRw8389aTWd/wz7y8yCZbE6U2dEXd+Up4O83VvmEFVWMPTJW039dcWufpf6y6hWhst8B42+0kD02gQJjC8=; 20:Dxmyeqm2GhycubSNKgY8Pyjy2+ekq0vf/7kto9xdN7xpQwve8Iksm833pyaAVKxV2NVV2eFSbrRCOIK0NzVnnBDyauzqkPtfFdsgb7XGiXxv53NGEvgfDbt0Ool5A1uSfgJn9Ckpnex77O9qmM/7Q2m0iAbp+K257MlTsngcGdjdaTZmWLkZ1K27mn0TSAMp1DksU7VkMgl0ZyppVeeYGq37YeLLvAck24q+VYuFmOMe+tK4alD7d2Rq4ahS3KB2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2016 19:10:21.3523 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0433 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding function pointers in struct kvm_x86_ops for processor-specific layer to provide hooks for when KVM initialize and destroy VM. Signed-off-by: Suravee Suthikulpanit --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/x86.c | 5 +++++ 2 files changed, 8 insertions(+) -- 1.9.1 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index b7e3944..353d61b 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -848,6 +848,9 @@ struct kvm_x86_ops { bool (*cpu_has_high_real_mode_segbase)(void); void (*cpuid_update)(struct kvm_vcpu *vcpu); + int (*vm_init)(struct kvm *kvm); + void (*vm_destroy)(struct kvm *kvm); + /* Create, but do not attach this VCPU */ struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id); void (*vcpu_free)(struct kvm_vcpu *vcpu); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 12f33e6..bbdcaa8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7752,6 +7752,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) kvm_page_track_init(kvm); kvm_mmu_init_vm(kvm); + if (kvm_x86_ops->vm_init) + return kvm_x86_ops->vm_init(kvm); + return 0; } @@ -7873,6 +7876,8 @@ void kvm_arch_destroy_vm(struct kvm *kvm) x86_set_memory_region(kvm, IDENTITY_PAGETABLE_PRIVATE_MEMSLOT, 0, 0); x86_set_memory_region(kvm, TSS_PRIVATE_MEMSLOT, 0, 0); } + if (kvm_x86_ops->vm_destroy) + kvm_x86_ops->vm_destroy(kvm); kvm_iommu_unmap_guest(kvm); kfree(kvm->arch.vpic); kfree(kvm->arch.vioapic);