From patchwork Mon Mar 15 14:35:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12139659 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=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 36FC8C433E9 for ; Mon, 15 Mar 2021 14:40:45 +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 0F47D64E86 for ; Mon, 15 Mar 2021 14:40:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F47D64E86 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=7Q0LqgdHO8g8LiQ5Jw1pFZL7hmMskcmxiCoLCOrSzuY=; b=NPZH1oAILaQAYU v0zV32l3dAlQcKQJJ4VcfJ67vqFfX22KBnDp07f/paxlwK0Xq1EqtWjdXoAdOvi/YL81N43slV6Dg wsD3b7Fsv7uGg8I95K65iTcu1RIzIMbnTEQjRxM3ig2A4Xf+JoVVNuRmvZBJugaP9smvfHoc64q5+ gK1XM0qR8UfUTqiScynncMSpoFDWubFGLulhrEHDf2T1IB3Rx92zyAv3z+MlerxW07QqjJH+YBBe6 cm6zqM4kEmNgihRG85NdFdEIeRu8JcBnsSnHZgPShchYWuSAY/E2DsUdPGI8VwlkLzxx9Uk3UPStE kV0Zi9xF0l0+q+VMiX4w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lLoMv-00G6zO-W5; Mon, 15 Mar 2021 14:38:54 +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 1lLoKJ-00G5me-6S for linux-arm-kernel@lists.infradead.org; Mon, 15 Mar 2021 14:36:13 +0000 Received: by mail-wm1-x34a.google.com with SMTP id c7so8283936wml.8 for ; Mon, 15 Mar 2021 07:36:09 -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=82gUjSiOy75013Ao/6wOddaZLFu0pa6owwuj1ggeuy4=; b=CD9bFfHL7VhMeePH17RF85emad8M7ZhRkOPIKahkEZ7HAAfIyxJpxFRokWpU32rFK1 CzmaNCf+CCicqi+lk0p6Kvc37kc5L8PrGXpJcG/3oWqxwsDB5902k+kIYrZlNy95lekM IzF3use+ujY9UWJXdWi56mWRemJDlG7Xu98WTdWA1GndJDFoMBWOXaNzo8YUBErWGIwp CoqIM3BZqmueTp6q1/MpOuU+qpqIOJpDiIHw0PyfeAoZ0zn5Rg0Q9nChCJG0uflFusau 3eMHJJHLViXpQmyPsZ8hZuLTpesIibwx+AcCBPlYjSON+7OmBlaQApjjCUAD5AfBNss+ OlNg== 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=82gUjSiOy75013Ao/6wOddaZLFu0pa6owwuj1ggeuy4=; b=j5wE4mp0PHpQHKNCN6B6fS5s0VK5N5j2vvTgs1bjSLzxbzKW+tSHOQHJqtzUgNP8fv QGZ4lp2RvlWfrXI/a/TfniwBnU/zAXkHX3ljfxisbCPUclBrdHC4UtdF4DXXY5fPlfdT G1JpgQEvmXjqotULiKeQLxx7O7DVX+EbMhCqn1BYvieHHQh5/z7lhqCg3a16Fmq5NdF9 JUgdIqkwimtLU9rFpTQmKmltfR2GdKXSbQ+mB99uTDq521ShXQRhOiSS/DTzRB51nUPU 2DPkqm8U1+P3JZxjVv3K18XXL8q9EZmlp+gdBvoP2SpzJloK+Ldn0FP+fPMfujghKIr1 FgTg== X-Gm-Message-State: AOAM530HYqrJNiMPhpTXHnuDa9/R9HVwfarj8nUb9Gpxs+OFtr8sBZ8e Eqokf8OrBDhnnTPAQOlU+BZCRJZD0Sy9 X-Google-Smtp-Source: ABdhPJx9xRKDOfRDFlI/TfqGPcgwP0Fg2uHLCHIdGqPsMxwfgsZghPG6ZkVnzBXOgz/h4g5be4yqugrc6gdm X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a7b:c188:: with SMTP id y8mr33590wmi.76.1615818969596; Mon, 15 Mar 2021 07:36:09 -0700 (PDT) Date: Mon, 15 Mar 2021 14:35:14 +0000 In-Reply-To: <20210315143536.214621-1-qperret@google.com> Message-Id: <20210315143536.214621-15-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 14/36] KVM: arm64: Provide __flush_dcache_area at EL2 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_143611_846494_210C741B X-CRM114-Status: GOOD ( 15.58 ) 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 We will need to do cache maintenance at EL2 soon, so compile a copy of __flush_dcache_area at EL2, and provide a copy of arm64_ftr_reg_ctrel0 as it is needed by the read_ctr macro. Signed-off-by: Quentin Perret --- arch/arm64/include/asm/kvm_cpufeature.h | 2 ++ arch/arm64/kvm/hyp/nvhe/Makefile | 3 ++- arch/arm64/kvm/hyp/nvhe/cache.S | 13 +++++++++++++ arch/arm64/kvm/sys_regs.c | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/kvm/hyp/nvhe/cache.S diff --git a/arch/arm64/include/asm/kvm_cpufeature.h b/arch/arm64/include/asm/kvm_cpufeature.h index 3fd9f60d2180..efba1b89b8a4 100644 --- a/arch/arm64/include/asm/kvm_cpufeature.h +++ b/arch/arm64/include/asm/kvm_cpufeature.h @@ -13,3 +13,5 @@ #define KVM_HYP_CPU_FTR_REG(name) extern struct arm64_ftr_reg kvm_nvhe_sym(name) #endif #endif + +KVM_HYP_CPU_FTR_REG(arm64_ftr_reg_ctrel0); diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile index 6894a917f290..42dde4bb80b1 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -13,7 +13,8 @@ lib-objs := clear_page.o copy_page.o memcpy.o memset.o lib-objs := $(addprefix ../../../lib/, $(lib-objs)) obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o \ - hyp-main.o hyp-smp.o psci-relay.o early_alloc.o stub.o page_alloc.o + hyp-main.o hyp-smp.o psci-relay.o early_alloc.o stub.o page_alloc.o \ + cache.o obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ ../fpsimd.o ../hyp-entry.o ../exception.o obj-y += $(lib-objs) diff --git a/arch/arm64/kvm/hyp/nvhe/cache.S b/arch/arm64/kvm/hyp/nvhe/cache.S new file mode 100644 index 000000000000..36cef6915428 --- /dev/null +++ b/arch/arm64/kvm/hyp/nvhe/cache.S @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Code copied from arch/arm64/mm/cache.S. + */ + +#include +#include +#include + +SYM_FUNC_START_PI(__flush_dcache_area) + dcache_by_line_op civac, sy, x0, x1, x2, x3 + ret +SYM_FUNC_END_PI(__flush_dcache_area) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 6c5d133689ae..3ec34c25e877 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2783,6 +2783,7 @@ struct __ftr_reg_copy_entry { u32 sys_id; struct arm64_ftr_reg *dst; } hyp_ftr_regs[] __initdata = { + CPU_FTR_REG_HYP_COPY(SYS_CTR_EL0, arm64_ftr_reg_ctrel0), }; void __init setup_kvm_el2_caps(void)