From patchwork Thu Oct 18 13:37:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 10647265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C98A814E2 for ; Thu, 18 Oct 2018 13:39:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7C83285B0 for ; Thu, 18 Oct 2018 13:39:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7785285D1; Thu, 18 Oct 2018 13:39:09 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A4A9285B0 for ; Thu, 18 Oct 2018 13:39:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Ou22tSFIlUIG6EaAXDRTsH6TmLe5eq9e/zasyB0Xx2k=; b=N8arI4L5yNeNrfZ/76RFp/v+jc 9UEWY8cmcQX1JzmDLVFFNh7UTPjHiFAKdBewriFYkTbl1ua6oypJUJFAcAki5zzEbF8XGftoRJoDF HFLIqAg2tlysNA0bGWL1SVuc7x6GFXlcyEb0CqFTGZKJUJNtRmt7dQdkVTbZzUq8g2lZlhCTK5W6v Qj5PwGgF79xOTKhO9ZshPrkzanxTppglanS335fXyBubv3y6SJInpQjobLLtkhq1pUJtf9AoYxfLn 7gf+i2IUJiH6+2J4yp1NLhOfEPBk5n8RQEsDlQ9Etf52iJ4Mc7TvBkVrE99AvxmSfswyflCrsqjPH L/c0r9Vw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD8Vr-0004Vh-4G; Thu, 18 Oct 2018 13:38:55 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD8V4-0004E5-UV for linux-arm-kernel@lists.infradead.org; Thu, 18 Oct 2018 13:38:09 +0000 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 8A44F15BE; Thu, 18 Oct 2018 06:37:57 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7BBCE3F59C; Thu, 18 Oct 2018 06:37:56 -0700 (PDT) From: Julien Grall To: linux-arm-kernel@lists.infradead.org Subject: [KVMTOOL][PATCH v2 2/9] kvm__arch_init: Don't pass hugetlbfs_path and ram_size in parameter Date: Thu, 18 Oct 2018 14:37:41 +0100 Message-Id: <20181018133748.32577-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181018133748.32577-1-julien.grall@arm.com> References: <20181018133748.32577-1-julien.grall@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181018_063807_007987_18FED032 X-CRM114-Status: GOOD ( 13.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marc.zyngier@arm.com, Julien Grall , will.deacon@arm.com, suzuki.poulose@arm.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The structure KVM already contains a pointer to the configuration. Both hugetlbfs_path and ram_size are part of the configuration, so is it not necessary to path them again in parameter. Signed-off-by: Julien Grall --- arm/kvm.c | 7 +++++-- include/kvm/kvm.h | 2 +- kvm.c | 2 +- mips/kvm.c | 5 ++++- powerpc/kvm.c | 5 ++++- x86/kvm.c | 5 ++++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/arm/kvm.c b/arm/kvm.c index 5b1f73c..5a68c9a 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -57,10 +57,13 @@ 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_init(struct kvm *kvm) { unsigned long alignment; + /* Convenience aliases */ + const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path; + /* * Allocate guest memory. We must align our buffer to 64K to * correlate with the maximum guest page size for virtio-mmio. @@ -73,7 +76,7 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) alignment = SZ_32M; else alignment = SZ_2M; - kvm->ram_size = min(ram_size, (u64)ARM_MAX_MEMORY(kvm)); + kvm->ram_size = min(kvm->cfg.ram_size, (u64)ARM_MAX_MEMORY(kvm)); kvm->arch.ram_alloc_size = kvm->ram_size + alignment; kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, kvm->arch.ram_alloc_size); diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 1edacfd..2d58ff4 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -136,7 +136,7 @@ int kvm__enumerate_instances(int (*callback)(const char *name, int pid)); void kvm__remove_socket(const char *name); 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_init(struct kvm *kvm); void kvm__arch_delete_ram(struct kvm *kvm); int kvm__arch_setup_firmware(struct kvm *kvm); int kvm__arch_free_firmware(struct kvm *kvm); diff --git a/kvm.c b/kvm.c index 7de825a..9769e85 100644 --- a/kvm.c +++ b/kvm.c @@ -386,7 +386,7 @@ int kvm__init(struct kvm *kvm) goto err_vm_fd; } - kvm__arch_init(kvm, kvm->cfg.hugetlbfs_path, kvm->cfg.ram_size); + kvm__arch_init(kvm); INIT_LIST_HEAD(&kvm->mem_banks); kvm__init_ram(kvm); diff --git a/mips/kvm.c b/mips/kvm.c index 211770d..e2a0c63 100644 --- a/mips/kvm.c +++ b/mips/kvm.c @@ -57,9 +57,12 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) } /* Architecture-specific KVM init */ -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { int ret; + /* Convenience aliases */ + u64 ram_size = kvm->cfg.ram_size; + const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path; kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size); kvm->ram_size = ram_size; diff --git a/powerpc/kvm.c b/powerpc/kvm.c index 702d67d..034bc46 100644 --- a/powerpc/kvm.c +++ b/powerpc/kvm.c @@ -88,10 +88,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) } /* Architecture-specific KVM init */ -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { int cap_ppc_rma; unsigned long hpt; + /* Convenience aliases */ + u64 ram_size = kvm->cfg.ram_size; + const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path; kvm->ram_size = ram_size; diff --git a/x86/kvm.c b/x86/kvm.c index 3e0f0b7..5abb41e 100644 --- a/x86/kvm.c +++ b/x86/kvm.c @@ -130,10 +130,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) } /* Architecture-specific KVM init */ -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { struct kvm_pit_config pit_config = { .flags = 0, }; int ret; + /* Convenience aliases */ + u64 ram_size = kvm->cfg.ram_size; + const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path; ret = ioctl(kvm->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000); if (ret < 0)