Received: by 10.213.65.68 with SMTP id h4csp647172imn; Tue, 27 Mar 2018 06:18:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELtOD3v933XZq6jtPcjf2ukDQR/LBzBAbCct3077qJi7wCoKmEFPjL70PUK7k+PdH7YSCwdO X-Received: by 10.98.160.92 with SMTP id r89mr34124795pfe.235.1522156703074; Tue, 27 Mar 2018 06:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522156703; cv=none; d=google.com; s=arc-20160816; b=SQJKZBfROqcIIhb4JizEK2jmIjqeSbTo8mMlRsfu+pSPpE+THxfoFHebtFgPly8nib QqUaY3Y4TjAXrZ8sigJMOq13SiucZatwHWIF9s8Fqg3Y+yOmYcVq42yfww4FJ2QEIN/S jlsvlC6bjFHstPy7xwlFvb+rm6CnZk5yuuSntBDY/yqTiMQFxr3LeWA4dxnNb0qtCbCc MB0IrInEO7iDbIVo9I71tpu6FTg86QW+gxENioPzkf/kgy5DwoXH2lDoa4g7G34HxXq5 VshaBnBhb/JgnPGXQvOx2qWPQIyzmTrC/2hKsZgLvK4OJ0FbdLeWi4ppQvGWOoiZRjxu GRQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ZdW5n3TCQCMcZfC5horJCy3uDHpSeYrcM02NU/jCHsM=; b=rKGfSdeagIm2ONwmXNXas+KRep8l7/YNRmSOK/S2u6PHOoMR6Jkvsgt2a27JoPILeB cxRMzf4lwq9YTFyxMd7nlGuwO2ymwoHt2dLJZ41Fd/jWWaMJ7BEAeLeTz1AZx78yMqnr FLnI+D2Nf9xvh5Jnmcqb++zIimDKBxJ+uIjbDodxpRuUlVAYj6vEKkpKUQEEMkymJ+Gt 6QV0cQsYvpZBITHYBDFN1WaifOdRQ6VpJ8JirXKfSzhCjzWu4Wm5aQcx1uymfpI0ph++ BxGaIEAeyZUU2MP167XJGexdxptt4nV2w1RXw3NtxSUyDEZESO11gUl5PyFKzDWp3r2B 66HQ== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r15-v6si1391505plj.96.2018.03.27.06.18.09; Tue, 27 Mar 2018 06:18:23 -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; 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 S1752958AbeC0NRD (ORCPT + 99 others); Tue, 27 Mar 2018 09:17:03 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55246 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752938AbeC0NQ7 (ORCPT ); Tue, 27 Mar 2018 09:16:59 -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 837F615AB; Tue, 27 Mar 2018 06:16:59 -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 DA8333F24A; Tue, 27 Mar 2018 06:16:56 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, cdall@kernel.org, marc.zyngier@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, ard.biesheuvel@linaro.org, peter.maydell@linaro.org, kristina.martsenko@arm.com, mark.rutland@arm.com, Suzuki K Poulose Subject: [kvmtool PATCH 20/17] kvmtool: arm64: Switch memory layout Date: Tue, 27 Mar 2018 14:15:30 +0100 Message-Id: <1522156531-28348-21-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 15 ++++++++++++--- arm/include/arm-common/kvm-arch.h | 11 ++++++----- arm/kvm.c | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/arm/aarch32/include/kvm/kvm-arch.h b/arm/aarch32/include/kvm/kvm-arch.h index cd31e72..2d62aab 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_MEMORY(...) ARM_LOMAP_MAX_MEMORY +#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 9de623a..bad35b9 100644 --- a/arm/aarch64/include/kvm/kvm-arch.h +++ b/arm/aarch64/include/kvm/kvm-arch.h @@ -1,14 +1,23 @@ #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 ARM64_MAX_MEMORY(phys_shift) \ + ((1ULL << (phys_shift)) - ARM64_MEMORY_AREA(phys_shift)) + +#define ARM_MEMORY_AREA(kvm) ((kvm)->cfg.arch.aarch32_guest ? \ + ARM32_MEMORY_AREA : \ + ARM64_MEMORY_AREA(kvm->cfg.arch.phys_shift)) + #define ARM_KERN_OFFSET(kvm) ((kvm)->cfg.arch.aarch32_guest ? \ 0x8000 : \ 0x80000) #define ARM_MAX_MEMORY(kvm) ((kvm)->cfg.arch.aarch32_guest ? \ - ARM_LOMAP_MAX_MEMORY : \ - ARM_HIMAP_MAX_MEMORY) + ARM32_MAX_MEMORY : \ + ARM64_MAX_MEMORY(kvm->cfg.arch.phys_shift)) -#include "arm-common/kvm-arch.h" #endif /* KVM__KVM_ARCH_H */ diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h index c83c45f..ca7ab0f 100644 --- a/arm/include/arm-common/kvm-arch.h +++ b/arm/include/arm-common/kvm-arch.h @@ -6,14 +6,15 @@ #include #include "arm-common/gic.h" - #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 ARM_LOMAP_MAX_MEMORY ((1ULL << 32) - ARM_MEMORY_AREA) -#define ARM_HIMAP_MAX_MEMORY ((1ULL << 40) - ARM_MEMORY_AREA) +#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) @@ -24,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 2ab436e..5701d41 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -30,7 +30,7 @@ void kvm__init_ram(struct kvm *kvm) u64 phys_start, phys_size; void *host_mem; - phys_start = ARM_MEMORY_AREA; + phys_start = ARM_MEMORY_AREA(kvm); phys_size = kvm->ram_size; host_mem = kvm->ram_start; -- 1.9.1