From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C606C677F1 for ; Fri, 13 Jan 2023 17:38:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h6a797QJct5YRCCiNgEw5SHz8cz/p9ipuKrHMTIk+tg=; b=i2ymWxpyY39cYa K0E9Ql3ztUE69xTPqNNveiWq8hWw4dyXbsbh1YXzyowzPEFTOJgijyW3x9dII8NTWWeCuBAIhWCcr EqhQ6Ilk6vbHsE6wDAIAY1pM6blnYSlCV3PgFhFgRkG+ul3Sj75H3shi1Nn35PtJ3Vh85kVUd2jfQ GIpvhZklvbne/YHmf9ZdrfabU+4vmCTNvh7SX977eNn7YBuCYGCL9lczJ8yJn4pV0fyl+eAggNBwv LjhFcFQmNSn3/Yhz5h3hRzkPsa2KgulzyOZa1uIbA78op7rJ/5qcVcJ6UDbhd8jctxP6ck4M48WR+ 61BHTYkAjLr5skUwszCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGNzU-003opD-Cz; Fri, 13 Jan 2023 17:37:20 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGNo6-003iyQ-3A for linux-arm-kernel@lists.infradead.org; Fri, 13 Jan 2023 17:25:37 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 59ECE622C8; Fri, 13 Jan 2023 17:25:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6567C43392; Fri, 13 Jan 2023 17:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673630732; bh=LoXncN3HqQOIHm9k1BnKZI/cl3RYXnqq+AXVtd8dOYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzMKli9jERs4P3P0RkMXNDItMoYsKClau/cuXc57RXU77Mt0pJjFlnq9poeNqkNF7 IE9LQ3jWygyh+GHM5//mdcJ+OWHsh42WwOz9LmVP+Mg83TWh/2Firv7slpuio5THOY vLgbGXkdql2a8IBz81qBdxFTVJW7/vGLpmCiM6SSJ6+ihebeFU2ZAfn5XiQpaiXP3x TNslJJ/vRBKhTSGxRQfB8wJJGPdB/94WUJQ01suKyuxrfFECWSmjQN4WrzKdYKsVTc U642MyaWJOyVQFQSywrCyMxGKL4ettWs5ba5y932ltiALkCK9T8kQdALfnoiBs/4sf tphZGLmRIJ4zg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pGNo2-001bBu-ME; Fri, 13 Jan 2023 17:25:30 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Will Deacon , Catalin Marinas , Mark Rutland , James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu Subject: [PATCH 2/2] KVM: arm64: Remove VPIPT I-cache handling Date: Fri, 13 Jan 2023 17:25:23 +0000 Message-Id: <20230113172523.2063867-3-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230113172523.2063867-1-maz@kernel.org> References: <20230113172523.2063867-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230113_092534_269854_EA60A66F X-CRM114-Status: GOOD ( 24.98 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have some special handling for VPIPT I-cache in critical parts of the cache and TLB maintenance. Remove it. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_mmu.h | 3 +-- arch/arm64/kvm/hyp/nvhe/tlb.c | 35 -------------------------------- arch/arm64/kvm/hyp/vhe/tlb.c | 13 ------------ 3 files changed, 1 insertion(+), 50 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index e4a7e6369499..e79a37e22801 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -214,8 +214,7 @@ static inline void __invalidate_icache_guest_page(void *va, size_t size) if (icache_is_aliasing()) { /* any kind of VIPT cache */ icache_inval_all_pou(); - } else if (is_kernel_in_hyp_mode() || !icache_is_vpipt()) { - /* PIPT or VPIPT at EL2 (see comment in __kvm_tlb_flush_vmid_ipa) */ + } else { icache_inval_pou((unsigned long)va, (unsigned long)va + size); } } diff --git a/arch/arm64/kvm/hyp/nvhe/tlb.c b/arch/arm64/kvm/hyp/nvhe/tlb.c index d296d617f589..291789df24e3 100644 --- a/arch/arm64/kvm/hyp/nvhe/tlb.c +++ b/arch/arm64/kvm/hyp/nvhe/tlb.c @@ -84,28 +84,6 @@ void __kvm_tlb_flush_vmid_ipa(struct kvm_s2_mmu *mmu, dsb(ish); isb(); - /* - * If the host is running at EL1 and we have a VPIPT I-cache, - * then we must perform I-cache maintenance at EL2 in order for - * it to have an effect on the guest. Since the guest cannot hit - * I-cache lines allocated with a different VMID, we don't need - * to worry about junk out of guest reset (we nuke the I-cache on - * VMID rollover), but we do need to be careful when remapping - * executable pages for the same guest. This can happen when KSM - * takes a CoW fault on an executable page, copies the page into - * a page that was previously mapped in the guest and then needs - * to invalidate the guest view of the I-cache for that page - * from EL1. To solve this, we invalidate the entire I-cache when - * unmapping a page from a guest if we have a VPIPT I-cache but - * the host is running at EL1. As above, we could do better if - * we had the VA. - * - * The moral of this story is: if you have a VPIPT I-cache, then - * you should be running with VHE enabled. - */ - if (icache_is_vpipt()) - icache_inval_all_pou(); - __tlb_switch_to_host(&cxt); } @@ -144,18 +122,5 @@ void __kvm_flush_vm_context(void) { dsb(ishst); __tlbi(alle1is); - - /* - * VIPT and PIPT caches are not affected by VMID, so no maintenance - * is necessary across a VMID rollover. - * - * VPIPT caches constrain lookup and maintenance to the active VMID, - * so we need to invalidate lines with a stale VMID to avoid an ABA - * race after multiple rollovers. - * - */ - if (icache_is_vpipt()) - asm volatile("ic ialluis"); - dsb(ish); } diff --git a/arch/arm64/kvm/hyp/vhe/tlb.c b/arch/arm64/kvm/hyp/vhe/tlb.c index 24cef9b87f9e..fc3fcd29ccc3 100644 --- a/arch/arm64/kvm/hyp/vhe/tlb.c +++ b/arch/arm64/kvm/hyp/vhe/tlb.c @@ -146,18 +146,5 @@ void __kvm_flush_vm_context(void) { dsb(ishst); __tlbi(alle1is); - - /* - * VIPT and PIPT caches are not affected by VMID, so no maintenance - * is necessary across a VMID rollover. - * - * VPIPT caches constrain lookup and maintenance to the active VMID, - * so we need to invalidate lines with a stale VMID to avoid an ABA - * race after multiple rollovers. - * - */ - if (icache_is_vpipt()) - asm volatile("ic ialluis"); - dsb(ish); } -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel