From patchwork Fri Mar 19 10:01:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12150553 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, URIBL_BLOCKED,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 C64C9C433DB for ; Fri, 19 Mar 2021 10:09:51 +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 552C964E3F for ; Fri, 19 Mar 2021 10:09:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 552C964E3F 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=wz9KI14JGoW34lZI5wURp+8RkEYkGMNOw5e1qatNuDY=; b=X+tj8u4vp9oUJS zrwV+okZDhn1H5mAQJU726OrnxgAaHAkGYFwUwwqG6eY9xvklAKzrDG4NclrhWsnFums6YkMCrYBy DLGq5gn61mmXc4Hkd1Ialz3LVQEWphoo46vxQjvPjzxGTITtVcoHLgAfZkLdZzks3Pre3uWDtxNGD y2HVXD+QiDaLwp5tzm7nX0/Fnn1Y9qrP92a6vXoreAGCMZpkO/q6uopM5SYEM5WE0zODMGth4dY9D mCZj0u725hLDXpAXeXFmQ7RBBbM8dtK21pOAYlyVx7+NBd4SKNu9hNnHcj30qnHgwbADRiB+5N1yb c5guOupM5OktvnCXWb7Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNC35-0072ms-Jg; Fri, 19 Mar 2021 10:08:08 +0000 Received: from mail-qk1-x74a.google.com ([2607:f8b0:4864:20::74a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNBxf-0070HM-Tq for linux-arm-kernel@lists.infradead.org; Fri, 19 Mar 2021 10:02:34 +0000 Received: by mail-qk1-x74a.google.com with SMTP id h19so879626qkk.4 for ; Fri, 19 Mar 2021 03:02:30 -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=egb02c7V9fvdN7WOXzwFb5kKzAOfcqS5h587DWzcb1I=; b=RHzxQVC7PH0LASuJE6U3fv++yW5YHh8BJCOwMVgSyTDZQFMzMQvrM7TpUSeKOT+Nnu TGk4thOV33wh5AfReIMRUKsd8Zca+cuku8eMOaJNPj7xHz7/Z2ejyA8xxkB6JDZ/79ud 3bOMqu3ibXrt2O4F3R+mUBLNVJjYE5cTuyvaz4DRrwmHLFP7XlK5sKr8YOyEoXdeHzqz x1z6IxJ1fINSyUYVdeGIFAsDHC/iZEwNLUGNVxaptnk6ZuTbnBYrARoCi5ZQNZwPMtoK a2nLj4yuXlwk4j9G2v3LdE2ri9DYCPkHH2PcMi1YjOZ3JyY7845lgbcbe4Npw/pbIdtW 0ifg== 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=egb02c7V9fvdN7WOXzwFb5kKzAOfcqS5h587DWzcb1I=; b=l5fZxCLI01Ml+/LVHalD8KXXkitJygZpZK+cML0mBjCk2+9drVMSBGCq4GxYHUQRB2 qMLXtOci4u1jobuwBpsH93DSedVAVOpAvuUm4F2VMPWjhgX6Ca+zCIu3Dwp8fG6P67WL vQC+E89i+Oa40M3x3uV49cHF8nczoUZVFtE6DYk0Qp3Je70AzJoCTbjk50bFjMripG78 Icz6omJ+jRnPtvuRJ6duJaIbfo1cosifZZ7EL/RENCz6ZgLBXid/WzsY5GziTLD0Uofa nQoGtTbLfOQUA7BET2DU8x2YYkTUWNmYUklhO3y6ZXC8rSkXMnmsQmDRCpSQpqytp9gy k2Fw== X-Gm-Message-State: AOAM533NM6Q1CbEcrT6woZdP8urK2exfJkrs8hd7eFVlGzs871p5fbni 4GpErlQ7dyj1BWoCzFtxhGoN2ote6GnL X-Google-Smtp-Source: ABdhPJz0+lRse/fC/9bfjvhPpWRqFXSdRhXcvHkUB+NIzOTvxstqkUj+p5UmowzmUqVZALblAELLxYV022ha X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a0c:bd82:: with SMTP id n2mr8548505qvg.62.1616148150010; Fri, 19 Mar 2021 03:02:30 -0700 (PDT) Date: Fri, 19 Mar 2021 10:01:27 +0000 In-Reply-To: <20210319100146.1149909-1-qperret@google.com> Message-Id: <20210319100146.1149909-20-qperret@google.com> Mime-Version: 1.0 References: <20210319100146.1149909-1-qperret@google.com> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v6 19/38] 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-20210319_100232_358325_D21FC641 X-CRM114-Status: GOOD ( 13.27 ) 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 82aca35a22f6..ea95bbc6ba80 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -880,11 +880,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; @@ -897,7 +897,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 de0ad79d2c90..d6eb1fb21232 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;