From patchwork Wed Mar 10 17:57:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12128929 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=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 838B7C433E0 for ; Wed, 10 Mar 2021 18:07:10 +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 945B264FB2 for ; Wed, 10 Mar 2021 18:07:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 945B264FB2 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=/jM+N60xCx+X5CQ8U0/QkoTPm76I6oa9sBdHtH4+4wk=; b=rE4WIwi8yx50Ev /uWMJBXiXarFEN3YYIcMagoHvtaxyLLlczW2de5WlDw2zm8RizIiH/vwCiAVztzXvChqBC0xSJFir WY0YjkhTZraTzwee8Id/aSubAsArJt2lGF8gxNebmKjbwzLRukPHUdNBOZoH31zmqXu02K1w9R+hJ 2G88Xleaf61bJzYP60qEMMdH/UdkZibVCa3ZzGRNAS1YEZHz6UtCCdV5m30Z+niGvcobz5bRzvCeH yos4CJVIaJuapC6a3HMtKrAFrgB0x2bfB4oI+9otadvt1eY6XW8661Jtlc1xT9Xjn2cAW5RT8Kzrp SxrOZd7ve+P6NFp62Icw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lK3Cy-007RIb-Eg; Wed, 10 Mar 2021 18:05:21 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lK36Z-007OMq-KM for linux-arm-kernel@lists.infradead.org; Wed, 10 Mar 2021 17:58:46 +0000 Received: by mail-qt1-x849.google.com with SMTP id w2so7730743qts.18 for ; Wed, 10 Mar 2021 09:58:42 -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=4oxp+YpplIoIB69u+tbsX2FMX4bca6h5fwiDtQ6/a1E=; b=vfNvL6VYP4cIvis4RUMqKQm+EjWb6Qdd5uxQRDjzD2jvaui8luwSb3kbZaVs7Cun3c I70CqF0WoKxquNq8GHLfoqZouqHwob9jrTw3fol8OJSK/TwkWGztOcvr42WqszU0moEe H1A8F/B1Tfh3dsLtou0ZuncYrXXuZK625m0AzBYrpPpIlL1jDNEpm3fusVFyhxTSEQLr 9SrqgMAJKv566vQ7PZQQcfFufCHMyYUsTWwpbZFUcqzB38QgZf896YlSPDkat+pg+eei OL16OP7Oedq8fTKRKJjFfbS+wpyjBA5hZtamumQ0v6fBmoQZrRQdY6ofweJTdrk80kOH KjfQ== 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=4oxp+YpplIoIB69u+tbsX2FMX4bca6h5fwiDtQ6/a1E=; b=peqcIuk6TCswugd1mS7HNhMXy/XrNl1ZOsGQqM2dIdShkRr0913v86kSgyjwPBl0CQ Ex8Q1gQmf9N2REtH63nzowJIlCmXzii5C7xow14g9cNmvSBwMUZ3baQwfsW7YUcnNj38 St79rFPXXjj+QzJk+2o8Z6qip4Zrq/USU8Qz8uSdKkhGF6DuZsxoNiT6ghAuOb3yyhVX iaKTlOgAbtVS/o3zNKNUqhyn0fSCSvG0edoLeRcFYup4qxuxBPNgCDEglpsKIvTRz/6O 6/oLjRF8Qz+lNI3HmU5HlrR3K4Qr4PjwKt2i+jG6+GYkMRDFuAdHlK7JHBKMmqgEZSj8 aDbQ== X-Gm-Message-State: AOAM5316lrpTDfQ6dxUqCZ5XEYDx2CtqcZcuzpYMrGx/72T6ShzI8t7I eBrv4lXEm/40K4QE4PMkEOpUwIrixCT6 X-Google-Smtp-Source: ABdhPJysjBX02XgOxXRd70RHGblWwl/bjhm+VVsnnUsNEc3jBBZ20r71lSy0Vi2+2+6+nm09mj60syhCGiEY X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a0c:f9cc:: with SMTP id j12mr3939245qvo.15.1615399122003; Wed, 10 Mar 2021 09:58:42 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:39 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-23-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 22/34] 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, 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210310_175843_811282_8458FD91 X-CRM114-Status: GOOD ( 10.71 ) 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);