From patchwork Mon Mar 15 14:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12139699 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=ham 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 AF422C433E0 for ; Mon, 15 Mar 2021 14:43:56 +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 893DE64EE5 for ; Mon, 15 Mar 2021 14:43:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 893DE64EE5 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=rkx1buwKVkwEf57JnGvN9Bv4u1sHNH8PuDyznyr4f+w=; b=ViiVsPo3sqS9g8 SMq+QadavbB3Dd01R8hUQ1HVyEHmjMOSejdG6j7DSIEjC5GFZ5Rp7Hsdr0Zhd+kL9n5C6ZzbTYAt7 P/15zqGaKnW6XnyZif62unXfp7PeFb/I050qZxfMSjDW314gk2w9numqa0yNwFHAbUPmkGbDr33Kr seF6ZaDo6tGJGgBhlgdYH5T2I0cJ9lm+3KedEBh2+Nt1AVcCOCefMX6sfKKLZTpHHu7iQNbQ/D8N1 brR98RTUg0HOtIT9mvLOKKRD2JYhycFyeE9cxkz0ESaminI/xHNsZPvO/YEpAP5JEirs0CN6aWIng 9apVinH0U7SZW8vxaCmw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lLoPv-00G8HB-Nd; Mon, 15 Mar 2021 14:41:59 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lLoKb-00G5ti-SB for linux-arm-kernel@lists.infradead.org; Mon, 15 Mar 2021 14:36:31 +0000 Received: by mail-wm1-x34a.google.com with SMTP id a68so2306619wme.1 for ; Mon, 15 Mar 2021 07:36:28 -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=GjgSG2oEX6Y5d63Q6T6vut7ZZTlqBxwi5efWbFs4G3E=; b=Aa8fUv21ijIEQhNQRFlfwR/ZR0ql0KDFcjJ2wWkBRKMMqZHPVWvEVhkPGuKSA25VmE IB3ju2RX15BiJq/PiF0wmfJ37jVOYGLAr2w7w7MrpAOVvSBID3xTJO2yLASU+Xutfl65 yWDDZ/PPzZua3NRiptTTgpjqlmJgF8nVbFUFCm6QIWv9aUUjNyjFUQQYKv5FeFufo1fv EwZiUFJ60WQQfevwMGcHLKIDQzqK77UgnIbGPwyVsX65v3xp006rtl2UcTE67DymvaWJ J2xmcWsgDLnKDpC5CLUerUWv9iB4quj0WrhNx4vMoV1rWtAHo60X1w2vzNYZUB2FMgHk d2wQ== 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=GjgSG2oEX6Y5d63Q6T6vut7ZZTlqBxwi5efWbFs4G3E=; b=O5zMEgWjkcKojruq57hvHLXN955DO8pWOi8QnRl/xQKAnv/tKY4gp7Wqi0b95OSDJF D8pIIhh6OZmJEC0xHJJQkrZwmTafHjhyAOhHsW5EKg+eD/dVD+m6HJh5kDriRnI/+W3+ xHlYJ15Owt9RcsfPBUeRJI/Ix8HkzfIhhVPIBi8HGfO+9eraOWEnf/SX7gNqKuvlZnRM Gnnm30sZ3OeSN21mDEv9wvOYd3araP3uR9POXVbTO6osSIVEYMD+SkuN5I20Z2UqL7sI p2AyRmu+UtL4e2SMXvfnugYPI9V6nOlZp87Kf7g61KzcUV2jUf3cT1zvjq6trdx3LhjT pzjQ== X-Gm-Message-State: AOAM533A8JZWF5o789hMIVLE7C6ZuChZjPMxOik7AggmPHWFDQghdeyD z9IV6348yhPCQQgejxqXs6Jou249GnjK X-Google-Smtp-Source: ABdhPJxRVdeyBsJa/HlT/zZefSVJKkc7JEEzUjQpsvXHTeJJD8923jx01t3RtCKophvOBQkDzIaQSSKtF6NW 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 w64mr1121799wmb.0.1615818987813; Mon, 15 Mar 2021 07:36:27 -0700 (PDT) Date: Mon, 15 Mar 2021 14:35:23 +0000 In-Reply-To: <20210315143536.214621-1-qperret@google.com> Message-Id: <20210315143536.214621-24-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 23/36] KVM: arm64: Refactor __load_guest_stage2() 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_143630_043099_4B496D07 X-CRM114-Status: GOOD ( 10.46 ) 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 Refactor __load_guest_stage2() to introduce __load_stage2() which will be re-used when loading the host stage 2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_mmu.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 6f743e20cb06..9d64fa73ee67 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -270,9 +270,9 @@ static __always_inline u64 kvm_get_vttbr(struct kvm_s2_mmu *mmu) * Must be called from hyp code running at EL2 with an updated VTTBR * and interrupts disabled. */ -static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu) +static __always_inline void __load_stage2(struct kvm_s2_mmu *mmu, unsigned long vtcr) { - write_sysreg(kern_hyp_va(mmu->arch)->vtcr, vtcr_el2); + write_sysreg(vtcr, vtcr_el2); write_sysreg(kvm_get_vttbr(mmu), vttbr_el2); /* @@ -283,6 +283,11 @@ static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu) asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT)); } +static __always_inline void __load_guest_stage2(struct kvm_s2_mmu *mmu) +{ + __load_stage2(mmu, kern_hyp_va(mmu->arch)->vtcr); +} + static inline struct kvm *kvm_s2_mmu_to_kvm(struct kvm_s2_mmu *mmu) { return container_of(mmu->arch, struct kvm, arch);