Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755454AbcDGIV1 (ORCPT ); Thu, 7 Apr 2016 04:21:27 -0400 Received: from mail-by2on0082.outbound.protection.outlook.com ([207.46.100.82]:51967 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751231AbcDGIVW (ORCPT ); Thu, 7 Apr 2016 04:21:22 -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 02/11] KVM: x86: Introducing kvm_x86_ops VM init/uninit hooks Date: Thu, 7 Apr 2016 03:20:23 -0500 Message-ID: <1460017232-17429-3-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: efbfca43-e400-4229-1411-08d35ebd983f X-Microsoft-Exchange-Diagnostics: 1;SN1PR12MB0445;2:u3+9/EcbzbOD30o+4fu/S4rwMUMGXcPMRnMhQn8Y3vtg+9ozhXLNoLXb4qV3p3AJGUnx5ZM2Hud6f/hPWueFhOGFkYOlQCqr2US9kyhRdJ4isVA0aAjj9a+PDLDJP+GmaGefh8TGDfuXkC9WSa5N/69d7sUOcz2BhbFz9he5/mO74mo43RN3w6drVDMrrJCU;3:mWipPUx3Wa/dRtu9BLc9iXMLHRO5oJ5jK7mbQB6aht52J2i5h1GSza58tWsCn+lqRiFSmf4Ecy8i773pU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yXIajk93E3z/lh0Ez9MCxi4kdhGR+3+m35JsJs7pkh9Zb0auRFjH50AlLgBTuO0MT2HBo5kpn6RDGARm/+xLmBeKjJ0XsClV/aaMqQYXrMi4fxyzR7AcxwLwJFTY2q0yGtVeV9WlmjNzKFM2DYaN8NrMy2NTHd4lE8JWXUXTGV+z1gM29h1Tve2LQPss3WnbswRFZBZG0H5GKDn6t;4:q00D4yHmn4aBZamccQnmRYQ8qMPx0oZakAobqTU0X7nk1kcTOwq//ryVbpfOqfBzIvZ5B4UNa03pupf8re35xVc44jljoDbKlu1DHGHdGBWJr+5Se+rKSJBVnkjvVoInjNw99WHa2yRD7kU2AGT+JFP8REuKUzkon4vJs+lYndVXCq21sDvUHHyfieERd8mOr6yzVxdRlB6p+Cr2aIxLNGm/YVbmcYc5kL6ngfPAdeSoaNS+H9c+0rGXx+m6+LpPoCJBCrRYHgbeYLDpM1xGuiRNa1rkYbUa+i6wsdcNzEY+y69P+2ctf1aw0pYrup6YVdYj5z3atSWuvYYRWJPV7+XmCyViTnCVIcHPrisuBIX3E8SBXNSLmTjklMZwQ5+g 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)(6069001)(6009001)(50226001)(86362001)(19580395003)(2201001)(229853001)(19580405001)(81166005)(66066001)(5008740100001)(6116002)(5890100001)(1096002)(586003)(42186005)(3846002)(48376002)(2906002)(50466002)(5001770100001)(4326007)(36756003)(2950100001)(47776003)(5003940100001)(76176999)(92566002)(50986999)(575784001)(77096005)(189998001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR12MB0445;H:localhost.localdomain;FPR:;SPF:None;MLV:sf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UyLobpLAk4G8rl2LnYaHgcprRLEZupzaV3xnEaqWvse6T6EzvW0IL5NT47vPkr8JcaHeojJqo8EViWhuZBZeBEqvqDGpphrEqg==;24:q7whkxPyOOlYFzyyBSnuHLpFmbvFGupQef0BcPXf8WUJt+HUpVTr58kTpmlO0X7zxLk9FWGiMB+3RdnLRG78OauGRUjyPwBgFj/emjPNl1A=;20:y97Exen/ysP5PY8ubXID3qCIOEH+FCraIhFNv/FS7puiqfDkvcqgKDrkRYxbCxvDkUuLv8wgY0iIIESviySB7K9VfwGNpIHnTRlN/GWuYX9M9759kwicKZ6O/01HHTrxYoJL3cTFg7Ukgju6teVtu7gr2hb49OgYTIG6aD/P7gae8szr4vS7ZNgLrXlhVTUHoqKb7wGvHCzi1TWG6clA9MPS/M8okf1K7BZ43tNUl86AnCpQbzZ9HU2YCKSOaSVC X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2016 08:21:09.9062 (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: 1548 Lines: 49 Adding function pointers in struct kvm_x86_ops for processor-specific layer to provide hooks for when KVM initialize and un-initialize VM. Signed-off-by: Suravee Suthikulpanit --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/x86.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index f62a9f37..22bd70c 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_uninit)(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 742d0f7..d12583e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7754,6 +7754,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; } @@ -7781,6 +7784,9 @@ static void kvm_free_vcpus(struct kvm *kvm) kvm_for_each_vcpu(i, vcpu, kvm) kvm_arch_vcpu_free(vcpu); + if (kvm_x86_ops->vm_uninit) + kvm_x86_ops->vm_uninit(kvm); + mutex_lock(&kvm->lock); for (i = 0; i < atomic_read(&kvm->online_vcpus); i++) kvm->vcpus[i] = NULL; -- 1.9.1