From patchwork Wed Jul 18 09:19:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 10531689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E710860547 for ; Wed, 18 Jul 2018 09:20:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0B39291CB for ; Wed, 18 Jul 2018 09:20:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE213291D4; Wed, 18 Jul 2018 09:20:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 926E429298 for ; Wed, 18 Jul 2018 09:20:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731058AbeGRJ5S (ORCPT ); Wed, 18 Jul 2018 05:57:18 -0400 Received: from foss.arm.com ([217.140.101.70]:58308 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731035AbeGRJ5S (ORCPT ); Wed, 18 Jul 2018 05:57:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A8E37A9; Wed, 18 Jul 2018 02:20:21 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AFAC13F318; Wed, 18 Jul 2018 02:20:18 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, cdall@kernel.org, eric.auger@redhat.com, julien.grall@arm.com, dave.martin@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, will.deacon@arm.com, catalin.marinas@arm.com, james.morse@arm.com, Suzuki K Poulose Subject: [kvmtool PATCH v4 21/24] kvmtool: Allow backends to run checks on the KVM device fd Date: Wed, 18 Jul 2018 10:19:04 +0100 Message-Id: <1531905547-25478-22-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531905547-25478-1-git-send-email-suzuki.poulose@arm.com> References: <1531905547-25478-1-git-send-email-suzuki.poulose@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow architectures to perform initialisation based on the KVM device fd ioctls, even before the VM is created. Signed-off-by: Suzuki K Poulose --- include/kvm/kvm.h | 4 ++++ kvm.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 90463b8..a036dd2 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -103,6 +103,10 @@ int kvm__get_sock_by_instance(const char *name); int kvm__enumerate_instances(int (*callback)(const char *name, int pid)); void kvm__remove_socket(const char *name); +#ifndef kvm__arch_init_hyp +static inline void kvm__arch_init_hyp(struct kvm *kvm) {} +#endif + void kvm__arch_set_cmdline(char *cmdline, bool video); void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size); void kvm__arch_delete_ram(struct kvm *kvm); diff --git a/kvm.c b/kvm.c index f8f2fdc..b992e74 100644 --- a/kvm.c +++ b/kvm.c @@ -304,6 +304,8 @@ int kvm__init(struct kvm *kvm) goto err_sys_fd; } + kvm__arch_init_hyp(kvm); + kvm->vm_fd = ioctl(kvm->sys_fd, KVM_CREATE_VM, KVM_VM_TYPE); if (kvm->vm_fd < 0) { pr_err("KVM_CREATE_VM ioctl");