From patchwork Tue Mar 2 14:59:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12113607 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=-16.8 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 26E5DC433DB for ; Wed, 3 Mar 2021 14:06:27 +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 D959B64E7C for ; Wed, 3 Mar 2021 14:06:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D959B64E7C 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=Xf2C4vXfQRS+a3VyDL+G2Z1+BLgZq9P7Nkm9E60QK8o=; b=d4a95oaIY1J+wA VbeQsRMC7h1F5VnTVoVdOEFFKyLdReSjEbG19KOv8GlGjqzqATlqP3bNBfbwnNJMmmqB3JN3Q1Iig InYyDaDje4+Q/jQP5CT+QSgYz/tWr+gMOjbQ/DEVRL6UHCS8KtgnwFGTArTytytlO7GWXmFzSers1 amwYzg2gAsIj6z/i0UPiFUrPTN8Ej/R1XssCezfKgWuZeZ8fAMO+hZZLjEBbhzNo4cuwLJgDFnyyN N8YAlGqSg63P1t5+szGOxbxXon+YgxTyYGWliMK3pRaejcfgbgOGlzKNgcZN8zQl7zWgiP14t2XzT bZyTTKXgfAgn+6UrPk0g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHS5k-0052LQ-Nu; Wed, 03 Mar 2021 14:03:08 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHS3R-0051p6-Pc for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 14:00:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=G2AeCN7EWhkuYtFbkPhDKNEy1oVSwJAjORcxRM9VGLM=; b=VCMwmVpWmgTZ93ZYERr6qGqw2E 7fGUxhohhwhpK/HKMuarjrXsTt18jdg71+ASwE6AtlYf8n/62M42tqRJar0N7lLxYNhLWZ4JoJmsQ YK2qGB+gfNDIqUpXVGoKBFQb0uKmQ0jBWi45/x6hvtHuZfZoHl73q0V0T9+At/PfwpYOswEGZ0jHf awVJ9iMqULXUcFYm34OX6X7zP55OwloKav85eS61p1DmydAgn85R0QzJf4btrTQDgDii8B4OXAM69 EESbSSLukfTqyYfCL1TYFhaCRxRKqSKPXV6kSUSIsI2cyGLekyKcLI2U610KR0mZ2Mu6In0KG7CPj s+HC+WSQ==; Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH6XK-00HJKP-B2 for linux-arm-kernel@lists.infradead.org; Tue, 02 Mar 2021 15:02:13 +0000 Received: by mail-wr1-x449.google.com with SMTP id f3so4384475wrt.14 for ; Tue, 02 Mar 2021 07:01:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=G2AeCN7EWhkuYtFbkPhDKNEy1oVSwJAjORcxRM9VGLM=; b=Dt0TxCXfs9c8jH2bVodVvIJerD5ufsP7ZFcR78FzQli/GcMwnUQb9f1H+QfiLX46BM 2Fb6lkOenRdyIPSYRLBFiuqS9jrfJxP3AY2xLec7qqciaO5yu+6Simfe8Mx9bfqQmGqz 6znfOSv6M9SiQhinpKMc1WKEI0hAgIcSppjPBroVtDfipQDXbG7fAZNBsRLkK7pzwkr6 C21ukzmfaq6LTMD814VkT42lxaZvxsN5wPoYRFXyus1F/Yi0LAthE+VMNbfcNW2LbVSb ms8jbMf49WD8yLYKISSizdbQgNBbKlpR2ugbE8R0HcQnaEk0BBl2KMImZCWPE3WpvvLw uUdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=G2AeCN7EWhkuYtFbkPhDKNEy1oVSwJAjORcxRM9VGLM=; b=mRM6mr6gcqA16tufUICKn/txFODciFQB53+dNN1OVH/CmXgCtb/2xrYapzSb8KsXFR JvMIZXixq2JZuqo+sY5oWe86njNuIkrn/jcT1rzFvbFXszSjTkDCx51m49mdDlZBOdmU SIJ62V8U0Xe0ZRZ+nh0myYZgGVntxZaE7FX0c7WFkusAfkPy/QMKcczdgIfeqPvSImpi K4fOVUowzNk6CWadlNmu8jfmv5jXA8CKXoNvNdPcKwjTy6AyDBEpXjCXK0HD2BL6v6wF baoYMh3jW2OwBW4mytHEv5wfwlgum3iMRK87X3Cw+nYQKSlEu0VngDHfzpWTy3QW2jH8 nLmg== X-Gm-Message-State: AOAM531ICWXuBhZjq9f4OqeL8HFOiDONd+kVwvURJrnHKuCsZNVC10sT 97/Y5awHajo10I99IUfYYgx+qTY4K8dt X-Google-Smtp-Source: ABdhPJwLj20ogsXve2nNaQuzCTevuLCR5AMDfnsGA+66q9RbQn2Lw/suoS7gkshS8KR9yQywFM1C2SmNTxIY X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a1c:8041:: with SMTP id b62mr4675280wmd.0.1614697244902; Tue, 02 Mar 2021 07:00:44 -0800 (PST) Date: Tue, 2 Mar 2021 14:59:47 +0000 In-Reply-To: <20210302150002.3685113-1-qperret@google.com> Message-Id: <20210302150002.3685113-18-qperret@google.com> Mime-Version: 1.0 References: <20210302150002.3685113-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v3 17/32] 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, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, qperret@google.com, robh+dt@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_150213_421002_439A1DA3 X-CRM114-Status: GOOD ( 12.17 ) 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 7898610fbeeb..a8255d55c168 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;