From patchwork Mon Mar 15 14:35:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12139693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 613FAC433DB for ; Mon, 15 Mar 2021 14:42:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B261A64E69 for ; Mon, 15 Mar 2021 14:42:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B261A64E69 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:References:Mime-Version: Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FR4R0a/iekly1dJgWzPb/H79IxkV/8xkS4NTWf4TA7Q=; b=nhxt2ojht+2zHT mjwlCQsHJ8zbiMJtYaSfdCsC/UDg/8Dmz5/pRLWEs39EdaUG3xNmRU2ZKWzt5hDtI8XKJQxC0ufJI BpgcmfbGf6NgwYFq2V3LrMEu3KQEQ0h04JbvAP/q1Om79ZEp8lV7+sIGEo7DKPz7hP7IGZ4910v2x b9UWXT3dfMaR2NxudOYn/sE0c5DoyofEBZP6jWG1DV15sS0SldLa4E/KnOso8q441QqIQV+lO+kmB I+1KsaFZPZqiyv6+hxqENfnUxxshu1xX2abtj+OKH1hKciCBb8dntI6jR8XDCqmqMAdwjyMU41eIH 6TILfIY0Vrt/lMMfBS8Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lLoOf-00G7kH-0A; Mon, 15 Mar 2021 14:40:41 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lLoKT-00G5rL-Ob for linux-arm-kernel@lists.infradead.org; Mon, 15 Mar 2021 14:36:25 +0000 Received: by mail-wm1-x349.google.com with SMTP id l16so4440648wmc.0 for ; Mon, 15 Mar 2021 07:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=C6KpCcTRnCYarFzZrDiCs6UZvyZciG+7JjV9Q7PoyaI=; b=P814LMHE708YU1dGW/jDEo5VsnhvkFROtTZHgzQNY1Dn3LMnbt32+SJl7Wvc11N4up KnFYEFSsvsuZb1t/D0wp7r9YQ8NCqrAGclgG+p9d/gHcnIti24WYqZeWVu6fgLaeAhvH Yi0jCxJBjK3Ny7DuCEEYRuO/8ioArjzAp1AZVNsiExg4e/8QIcJwp3/gVdT1OLCRMkt/ BMfe3DsEe1ClC3dVp1Lt8ZquDiLSV2FsBK5cXyaEf56tTD+0BRnlbGDX4Vb2FnA4KpZ5 nQgq6JwqPh6hD3Dnu0ihNSqkPoHf+/p/BpFdBm/7ka8HllP5cIFThKuX8918YhF2Ezcw cDuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=C6KpCcTRnCYarFzZrDiCs6UZvyZciG+7JjV9Q7PoyaI=; b=e15MVfcSWviLtaPyvzkqHBQyB1u4oEr1Q3zqv92yQIypoH+naZ11Ib3rcqOv811EJb UJX4nnPneJXhp3w2qoUMW8aPqKu7aC6kJG0HknrgD8oTghgaErPE0gcjxcWCZAIxxDCF fr/gbC7jqCzgASVarMEtzWbJMojgjbYV5JeApDnMV0EihgfL98P2JZAXaSnVuMatzXsn nfjH3j9PJpyO33F1L8Z/Sz2RSYimo8gWkpUVpgIv34fGVXUTIYPQgsvWZUvRx5EcTygl 3Qm6bfzImMVjPz7LSUhXbdZ27xnjfglGGjzSAvv4PdKShMwzQ61PLN7KMd6jUZXj0bV0 siZA== X-Gm-Message-State: AOAM532qurdS1TTD4aMagF2P8fj1qGrt6YbNAe6JTBBdTmOt82lAko4g k5wUWK+sn92bcTcwpcbvqE32nK7e5NMS X-Google-Smtp-Source: ABdhPJzRBtldTOkH0W/vDm3F+7uze08V/P4VTcnguwv+nWgiCeLo1XU4pLBls5abZRNCUe1W8S9/XRsfRz92 X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a1c:9a09:: with SMTP id c9mr15248wme.172.1615818979871; Mon, 15 Mar 2021 07:36:19 -0700 (PDT) Date: Mon, 15 Mar 2021 14:35:19 +0000 In-Reply-To: <20210315143536.214621-1-qperret@google.com> Message-Id: <20210315143536.214621-20-qperret@google.com> Mime-Version: 1.0 References: <20210315143536.214621-1-qperret@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v5 19/36] KVM: arm64: Use kvm_arch for stage 2 pgtable From: Quentin Perret To: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Cc: android-kvm@google.com, seanjc@google.com, mate.toth-pal@arm.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, tabba@google.com, ardb@kernel.org, mark.rutland@arm.com, dbrazdil@google.com, qperret@google.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210315_143623_744900_C311C5BC X-CRM114-Status: GOOD ( 13.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to make use of the stage 2 pgtable code for the host stage 2, use struct kvm_arch in lieu of struct kvm as the host will have the former but not the latter. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_pgtable.h | 5 +++-- arch/arm64/kvm/hyp/pgtable.c | 6 +++--- arch/arm64/kvm/mmu.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index bf7a3cc49420..7945ec87eaec 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -162,12 +162,13 @@ int kvm_pgtable_hyp_map(struct kvm_pgtable *pgt, u64 addr, u64 size, u64 phys, /** * kvm_pgtable_stage2_init() - Initialise a guest stage-2 page-table. * @pgt: Uninitialised page-table structure to initialise. - * @kvm: KVM structure representing the guest virtual machine. + * @arch: Arch-specific KVM structure representing the guest virtual + * machine. * @mm_ops: Memory management callbacks. * * Return: 0 on success, negative error code on failure. */ -int kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm *kvm, +int kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm_arch *arch, struct kvm_pgtable_mm_ops *mm_ops); /** diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 7ce0969203e8..3d79c8094cdd 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -879,11 +879,11 @@ int kvm_pgtable_stage2_flush(struct kvm_pgtable *pgt, u64 addr, u64 size) return kvm_pgtable_walk(pgt, addr, size, &walker); } -int kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm *kvm, +int kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm_arch *arch, struct kvm_pgtable_mm_ops *mm_ops) { size_t pgd_sz; - u64 vtcr = kvm->arch.vtcr; + u64 vtcr = arch->vtcr; u32 ia_bits = VTCR_EL2_IPA(vtcr); u32 sl0 = FIELD_GET(VTCR_EL2_SL0_MASK, vtcr); u32 start_level = VTCR_EL2_TGRAN_SL0_BASE - sl0; @@ -896,7 +896,7 @@ int kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm *kvm, pgt->ia_bits = ia_bits; pgt->start_level = start_level; pgt->mm_ops = mm_ops; - pgt->mmu = &kvm->arch.mmu; + pgt->mmu = &arch->mmu; /* Ensure zeroed PGD pages are visible to the hardware walker */ dsb(ishst); diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 9d331bf262d2..41f9c03cbcc3 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -457,7 +457,7 @@ int kvm_init_stage2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu) if (!pgt) return -ENOMEM; - err = kvm_pgtable_stage2_init(pgt, kvm, &kvm_s2_mm_ops); + err = kvm_pgtable_stage2_init(pgt, &kvm->arch, &kvm_s2_mm_ops); if (err) goto out_free_pgtable;