Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp478507pxf; Wed, 10 Mar 2021 10:00:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjfBkcBpagejx55dtenB6MV2oX1ESOo1vWempyPxU0F10SwHgivOEXN31i3Ow+IbyXgYVO X-Received: by 2002:a17:906:fcc7:: with SMTP id qx7mr4952395ejb.486.1615399232733; Wed, 10 Mar 2021 10:00:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615399232; cv=none; d=google.com; s=arc-20160816; b=b8u5zkbB+rUQQ0ttL3szZ7nE/2Jn/T8Zm7/cs9OazIcoddYjpKNglD2mfMTiOjsMKa qVzEyeckB744ghDQMuhUdtJ/ajlQ/KZ3qQvQuZEBzNToLuz2RDNoNf9jCXjjUhCCgdw0 vvNMjB2GWyMxD2TGtON+ilafSn8/i4FdpUMaf3n5oj4BeizFqk7JZOEDx9MnAFPwMHEi Oyao1f6LaqDHS55AmtybTmYgEZOK4TWXjXMqgUgVYEl0gr5D+J532SNHmwpbcgYgLhuJ yqxYBYYs+/31b4SwFsAq2s3Jwh6/fzlBlh3zfQwyPdyidcQWutQkFF+x1NCcBA82KQ6U 3CFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=W4XDH/01AoBIjD0ZOe4o0NanGmxh9U/l/TLYQRWS474=; b=ZBdNmeKdX2YyGRm2Ix/74bWstMIx0hABUmYik9ZOSVCyiUYn6q1dAOJ1AsHOW0CvbO deWGD2SN2VDPKc+m9bXe3ypUe+udhHovOqBmC1x0qw01hzu6G1macbMtvWjBWl1yn7/x /Wul9WoGBT7LXftfyak85QHfJqSZLfySwV5TAtyHWBXorrTJyb6zW+57yb3x32EwBJJl rRBObJLLPBhKoXtXbkvcBgunFshdFd81lMtIfjU8GOVBrwrBqoEQe9Hx/cWrHQoB/nie mZ/MTzdCxp7K4asuTqa9SAGeceS8OXxqyJp1mDR22Mm32EwhJwI+bkV0q+SuMf3LLp7c tDZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rVjU1ZdV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si51138edo.504.2021.03.10.10.00.10; Wed, 10 Mar 2021 10:00:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rVjU1ZdV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233887AbhCJR7D (ORCPT + 99 others); Wed, 10 Mar 2021 12:59:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233698AbhCJR6e (ORCPT ); Wed, 10 Mar 2021 12:58:34 -0500 Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96141C061760 for ; Wed, 10 Mar 2021 09:58:34 -0800 (PST) Received: by mail-wr1-x449.google.com with SMTP id m9so8330486wrx.6 for ; Wed, 10 Mar 2021 09:58:34 -0800 (PST) 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=W4XDH/01AoBIjD0ZOe4o0NanGmxh9U/l/TLYQRWS474=; b=rVjU1ZdVfExOrksCAL4Z1GT3PZeMJZ0h7ZAPKRQHJAIJfJW7tDOd2AASJ2mux0qrYN 1rULuskHCPdzDmo6vhlNkqJ/NlPUZ0ntL5GCYmSFrx0kYMwpJauRJZYDlNha8olzUJoz vrlLbUG+29hP5ULy+oYpA47soaUj6+UVCe12tmvosC6BUnX26weFobSb5dSstRjH65vm pNoPXQw3J40BAazYKB+sE+NwpC1+hccrTonWnW+TgO27u5e+KJUPqpIRT8UY7Uq6RA0R dq/NXsI7zetZ9lQVfui0ouUnpss4a1IHVw+0U9BDGZeEmnpbFqBu3D1IWJHbM+U2WvCv ySuQ== 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=W4XDH/01AoBIjD0ZOe4o0NanGmxh9U/l/TLYQRWS474=; b=M5aMKUc50JaUMa5/htmXApRfzl5ujGxZDCg45Vqv3olxxLzKVCJh/KHt5tCawfZDxp zP7niPNIsoxhuWkVgTqKGsasoSBp+7qOAhUooDRrmziAfRYxlL6lnEuq1Qdv3xiiwTro k2UWawg+GnjVBCLJ1leSxOh0BboHi+Ue78MQd1lpnGiWpzB8uhqb++UDWhnbmRvGubfQ GfWNnrlDj8ORe0tNCUnRA7hd4VV5xS/L38dDwG9XlnFsWIDQ6E+AfkFsVoEvtNDcwEhl pPnJbfoPzRLwpY8LyvGoCGqO33NdNa724crL+bxbZOtIv9JURuXxb1VmKX3Ch8JuCIKb p00g== X-Gm-Message-State: AOAM531lycSHVCxgYYG8VMiOpwYdFDsPSvGFQ39yCsFkEvgmRB+yiqZR hPvJ+YI8onUV+0n50AOFWu9LUGGXdpDS X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a1c:6243:: with SMTP id w64mr1336047wmb.0.1615399113037; Wed, 10 Mar 2021 09:58:33 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:35 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-19-qperret@google.com> Mime-Version: 1.0 References: <20210310175751.3320106-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v4 18/34] 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, ardb@kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; -- 2.30.1.766.gb4fecdf3b7-goog