From patchwork Tue Nov 17 18:15:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 11913215 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.7 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 4F2A1C2D0E4 for ; Tue, 17 Nov 2020 18:23:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 C93572467A for ; Tue, 17 Nov 2020 18:23:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nf1ZHCwR"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qMufXY54" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C93572467A 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id: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=cj6yRN4YXLD/lI086KrGT1ghvD84Qc93Nlc+cxBGKlk=; b=nf1ZHCwR0QzXAVIB9/Iyv6M08 2UR7OTWygS1pyiGu8LQrepZhJ3AITm3TKSsaa4g9i2i7b/SxX02+csZ8d/HOiXhARpt7S0AWa8uMI Ib2Pn0wG3Dm0nbeFOrwEZPJAnExtzMxu78/kRuUn2ij91oXwMomcncjwV6EnmpDHwu0lqoOI5T50D U4mnPXLRaKTyMhGL1uJOh5qJxWaUEwH5dAe2QOa/WrbXVVGl6rSmBazikwPTfLSgPUUE76D9/nfuZ kLs1ccN7ml817vhBw1pMXMVFKU0CQ9/Zk3gM0uG+rzdPn00ZVsRdpoQUEgXOSBzfAXd0jfUusuhbt mAD9Pz0Vw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kf5bx-0004Wo-FH; Tue, 17 Nov 2020 18:21:49 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kf5XM-0002PU-OM for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2020 18:17:11 +0000 Received: by mail-qv1-xf49.google.com with SMTP id du18so4733484qvb.14 for ; Tue, 17 Nov 2020 10:17:02 -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=EZMTqnbgaQsSDAJvbG1XxJlQ79bagawpZ079qLuIDUc=; b=qMufXY54r9Tw35ml8YyFoPlAwDp0r3TGxMAr86L/dQTFHJDmLAygkajnXncZ6HZQ2k 2xNFCfSX0DlCJ065rQ8Hi/6WXafc8DZpYAgTbrHNf1F1+kiPJ8hWXMEfKskS2nWCZ28N d6WRT972maQTo7niliiLO+H94x2r+g8fAK7s9FPaTTY/iyAoYE1MDxxbQz54qAtI0Y+m znuZs/tR2Yho5nq/SRXBlObO0lJOH1SQLeHUCqGq5p7mvYw44FJLW6qMUDQPvqKKmxBc dSxg2dX0HlCBEbRqk9LUZzg4OxnawJSbHzk/FpR0msYJGzYoMIUPRFdwMuqNJdYFlZhs xGnQ== 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=EZMTqnbgaQsSDAJvbG1XxJlQ79bagawpZ079qLuIDUc=; b=DbP5ZSSqt4UwI86FaahsVxTPoe1twI/tLmrPwmA5WgoA/Uys2+5/qPPEbPrGang3fE gdg8pZjXwRhtgTnSZMmBibiRgtGDIFHI0NLhEVuMZU1tpA6jvhJSI5LkD0J5mQwMfPDg C9ugYgB/7miCHqEbRBlzWAExJoFqYNYjrC9H1ISoD6U+IyHp9zbCGY7U2uk5r6+CAwZQ UpYppxh/v0ZuK4yeZc12zgKXZiibrGHRIJmWsL3iTY7TcVHYBeNpl5ewBsa+5l/MMeAi RQTB+yMju0kb04vEYk5W4gdL2xWjODZMfQ0gZJ+xX8UAta2XqpkxFQq+Cj4GpW9VKeA4 70kg== X-Gm-Message-State: AOAM532OFPV3vybkU4ng4YME9+84sAuIPmjWTnDNd+fsHWO3isxR1Lr/ zUA3/0QJRqpI6lH/yeAONK7Twa8P4WTW X-Google-Smtp-Source: ABdhPJxEnDzHoSiNaMlrXnG6cnHtgZaXnUxTO1bmEfh2lGjsMU/qzCf4IQGItC9HE+ZfEJGOV/17H4jHf0yD X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:f693:9fff:fef4:a7ef]) (user=qperret job=sendgmr) by 2002:a05:6214:612:: with SMTP id z18mr817548qvw.41.1605637021225; Tue, 17 Nov 2020 10:17:01 -0800 (PST) Date: Tue, 17 Nov 2020 18:15:58 +0000 In-Reply-To: <20201117181607.1761516-1-qperret@google.com> Message-Id: <20201117181607.1761516-19-qperret@google.com> Mime-Version: 1.0 References: <20201117181607.1761516-1-qperret@google.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [RFC PATCH 18/27] KVM: arm64: Use kvm_arch for stage 2 pgtable From: Quentin Perret To: Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Rob Herring , Frank Rowand X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201117_131704_888066_35FEF09B X-CRM114-Status: GOOD ( 14.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , Quentin Perret , android-kvm@google.com, open list , kernel-team@android.com, "open list:KERNEL VIRTUAL MACHINE FOR ARM64 \(KVM/arm64\)" , "moderated list:ARM64 PORT \(AARCH64 ARCHITECTURE\)" 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. 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 45acc9dc6c45..8e8f1d2c5e0e 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -151,12 +151,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 61a8a34ddfdb..96a25d0b7b6e 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -855,11 +855,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; @@ -872,7 +872,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 5c2e0feb9689..384f2acc0115 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -461,7 +461,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;