From patchwork Thu May 10 14:04:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 10391863 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 4E10F6028E for ; Thu, 10 May 2018 14:14:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E33928B2D for ; Thu, 10 May 2018 14:14:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32BBD28BAB; Thu, 10 May 2018 14:14:31 +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 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 9B71E28B3D for ; Thu, 10 May 2018 14:14:30 +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=HhJitHx3rNJXZWH/DBj9eKtP+jrfzZbqu4++7858PTE=; b=H8onkt98K6h//f784ZgYLIwAs3 6+wnHqv9wTza40NYeqg4ybaVPbgqMsx9leI0dmdrpZiswI7lLmiqr5zHp8NmeWUMgKxw1dK6ewYqF 5nC6jbfzl/sYeeBk1y+badcelhdsgL1cZWD3kQovQKcmBAY79Pr27EcqVZkuMKTjbVYS2bTi+RLH5 qk/WHh/qaCh3jbE03DYrjLo4FSgNK0XUw0F7cLZ7t9sr3CZMfMGaknvAH0zW/Id0KBrXcIVsXso7f 5olwm9pi1NaZmZFiN4xE2uighG4NN/OwQWtuoR0GUXpH85RmXU0ZX21saQb88wk0qMeYv60ZeOUhc j9ohRugQ==; 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 1fGmKq-0005xs-2b; Thu, 10 May 2018 14:14:20 +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 1fGmC4-0007Gv-IL for linux-arm-kernel@lists.infradead.org; Thu, 10 May 2018 14:05:21 +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 728441991; Thu, 10 May 2018 07:05:05 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 888583F318; Thu, 10 May 2018 07:05:04 -0700 (PDT) From: Julien Grall To: linux-arm-kernel@lists.infradead.org Subject: [RFC 12/13] kvmtool: arm64: Switch memory layout Date: Thu, 10 May 2018 15:04:40 +0100 Message-Id: <20180510140441.24573-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180510140441.24573-1-julien.grall@arm.com> References: <20180510140441.24573-1-julien.grall@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180510_070516_704508_1C5D29AF X-CRM114-Status: GOOD ( 16.19 ) 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, 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 From: Suzuki K Poulose If the guest wants to use a larger physical address space place the RAM at upper half of the address space. Otherwise, it uses the default layout. Signed-off-by: Suzuki K Poulose --- arm/aarch32/include/kvm/kvm-arch.h | 1 + arm/aarch64/include/kvm/kvm-arch.h | 13 ++++++++++--- arm/include/arm-common/kvm-arch.h | 8 ++++++-- arm/kvm.c | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/arm/aarch32/include/kvm/kvm-arch.h b/arm/aarch32/include/kvm/kvm-arch.h index 2ee0cb1..f0f0943 100644 --- a/arm/aarch32/include/kvm/kvm-arch.h +++ b/arm/aarch32/include/kvm/kvm-arch.h @@ -4,6 +4,7 @@ #define ARM_KERN_OFFSET(...) 0x8000 #define ARM_MAX_PHYS_SHIFT(...) 32 +#define ARM_MEMORY_AREA(...) ARM32_MEMORY_AREA #include "arm-common/kvm-arch.h" diff --git a/arm/aarch64/include/kvm/kvm-arch.h b/arm/aarch64/include/kvm/kvm-arch.h index 53ac20f..9c9009b 100644 --- a/arm/aarch64/include/kvm/kvm-arch.h +++ b/arm/aarch64/include/kvm/kvm-arch.h @@ -1,12 +1,19 @@ #ifndef KVM__KVM_ARCH_H #define KVM__KVM_ARCH_H +#include "arm-common/kvm-arch.h" + +#define ARM64_MEMORY_AREA(phys_shift) (1UL << (phys_shift - 1)) + +#define ARM_MEMORY_AREA(cfg) ((cfg)->arch.aarch32_guest ? \ + ARM32_MEMORY_AREA : \ + ARM64_MEMORY_AREA((cfg)->arch.phys_shift)) + #define ARM_KERN_OFFSET(kvm) ((kvm)->cfg.arch.aarch32_guest ? \ 0x8000 : \ 0x80000) -#define ARM_MAX_PHYS_SHIFT(cfg) ((cfg)->arch.aarch32_guest ? 32 : 40) - -#include "arm-common/kvm-arch.h" +#define ARM_MAX_PHYS_SHIFT(cfg) ((cfg)->arch.aarch32_guest ? 32 : \ + (cfg)->arch.phys_shift) #endif /* KVM__KVM_ARCH_H */ diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index 884dda8..4be9589 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -10,7 +10,11 @@ #define ARM_IOPORT_AREA _AC(0x0000000000000000, UL) #define ARM_MMIO_AREA _AC(0x0000000000010000, UL) #define ARM_AXI_AREA _AC(0x0000000040000000, UL) -#define ARM_MEMORY_AREA _AC(0x0000000080000000, UL) + +#define ARM32_MEMORY_AREA _AC(0x0000000080000000, UL) +#define ARM32_MAX_MEMORY ((1ULL << 32) - ARM32_MEMORY_AREA) + +#define ARM_IOMEM_AREA_END ARM32_MEMORY_AREA #define ARM_GIC_DIST_BASE (ARM_AXI_AREA - ARM_GIC_DIST_SIZE) #define ARM_GIC_CPUI_BASE (ARM_GIC_DIST_BASE - ARM_GIC_CPUI_SIZE) @@ -21,7 +25,7 @@ #define ARM_IOPORT_SIZE (ARM_MMIO_AREA - ARM_IOPORT_AREA) #define ARM_VIRTIO_MMIO_SIZE (ARM_AXI_AREA - (ARM_MMIO_AREA + ARM_GIC_SIZE)) #define ARM_PCI_CFG_SIZE (1ULL << 24) -#define ARM_PCI_MMIO_SIZE (ARM_MEMORY_AREA - \ +#define ARM_PCI_MMIO_SIZE (ARM_IOMEM_AREA_END - \ (ARM_AXI_AREA + ARM_PCI_CFG_SIZE)) #define KVM_IOPORT_AREA ARM_IOPORT_AREA diff --git a/arm/kvm.c b/arm/kvm.c index 8a7c611..5a2bd28 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -127,7 +127,7 @@ static void kvm__arch_sanitize_cfg(struct kvm_config *cfg) */ if (cfg->nr_ram > 1) die("sanitize: Base address should be specified for all the banks\n"); - bank0->base = ARM_MEMORY_AREA; + bank0->base = ARM_MEMORY_AREA(cfg); /* * Keep compatibility with old KVM command line behavior where * the memory is capped.