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 29238C54E67 for ; Wed, 27 Mar 2024 12:49:41 +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=Fuz4Kmqear+mRE0/l7xYasSszo/BFEeq/CQbMgh6bHk=; b=xYLH/BsGUOef0m +/y3LL3hh6rZBV1pDgKDHcLn+RUKNOhAocga118mowBWzDWoBpYxCahiEiHrTxz7tvtoPdAQ8vRv0 hdgFAEKPaeN7+4BxYTYEY7LAY4xJWPJvzHVWQStpRqCQnVnOSVUSLLu9TgyrhdPYWqR1zp2Ov8UGF NTI8l1YBNz6rlkqmh5224cKGhBIFWkMO1r0jzoqfzxyArOfAWKjCknR7mapsSHEltA3RmyWJUgEyX 04vq2FV3v8BtcqyvLRnkl4A91XlzUI358igdBwyMgxRdrxZ0wmAeVWLzK7/OTSn7SagNURywaP+RN yVJRLtjhCuGQ0e7mDoXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpSif-00000008zxA-3FCf; Wed, 27 Mar 2024 12:49:29 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpSiO-00000008znL-3HnH for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 12:49:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 3104BCE2615; Wed, 27 Mar 2024 12:49:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18E6DC433C7; Wed, 27 Mar 2024 12:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711543750; bh=objC47luTJxKbsIzJPJvLhwVeuYX+ge06C/74jvV0DM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nhGBex4AXUVbMACcE7T10JlD9cggBVLBRuupnanYXtoijba0MW5kUykotADa9ADk+ +/xqNVuiybdW7rh9txbbaIU0Ma3TWOQ68BnU00hmNGh0nQlcVA6I8AYChZxkhzyeWK dhUGah+FJS1PK/92Z7KfJxLkOEmwT3rbfpJdidVqJXj+xNviZAvjkWKJTkRn4mAbyu 31qaQowZ5WXU3zyfwlZ8yIsqCG3x4IXtzrgjKcfoLEpk99+ZCIiK421t2R1gNJJlbF MV7PBuNQjLe+pLI12s/jDI2UK2+4i0zorJPux7YCl5OkL4yR6YHHlG9hHXEBgep9AX CKGVrc9nwrkVA== From: Will Deacon To: kvmarm@lists.linux.dev Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas , Gavin Shan , Marc Zyngier , Mostafa Saleh , Oliver Upton , Quentin Perret , Raghavendra Rao Ananta , Ryan Roberts , Shaoqin Huang Subject: [PATCH v2 4/4] KVM: arm64: Ensure target address is granule-aligned for range TLBI Date: Wed, 27 Mar 2024 12:48:53 +0000 Message-Id: <20240327124853.11206-5-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240327124853.11206-1-will@kernel.org> References: <20240327124853.11206-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_054913_462590_CE6523B5 X-CRM114-Status: GOOD ( 11.60 ) 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 When zapping a table entry in stage2_try_break_pte(), we issue range TLB invalidation for the region that was mapped by the table. However, we neglect to align the base address down to the granule size and so if we ended up reaching the table entry via a misaligned address then we will accidentally skip invalidation for some prefix of the affected address range. Align 'ctx->addr' down to the granule size when performing TLB invalidation for an unmapped table in stage2_try_break_pte(). Cc: Raghavendra Rao Ananta Cc: Gavin Shan Cc: Shaoqin Huang Cc: Quentin Perret Fixes: defc8cc7abf0 ("KVM: arm64: Invalidate the table entries upon a range") Signed-off-by: Will Deacon --- arch/arm64/kvm/hyp/pgtable.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index a40dafc43bb6..5a59ef88b646 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -843,12 +843,15 @@ static bool stage2_try_break_pte(const struct kvm_pgtable_visit_ctx *ctx, * Perform the appropriate TLB invalidation based on the * evicted pte value (if any). */ - if (kvm_pte_table(ctx->old, ctx->level)) - kvm_tlb_flush_vmid_range(mmu, ctx->addr, - kvm_granule_size(ctx->level)); - else if (kvm_pte_valid(ctx->old)) + if (kvm_pte_table(ctx->old, ctx->level)) { + u64 size = kvm_granule_size(ctx->level); + u64 addr = ALIGN_DOWN(ctx->addr, size); + + kvm_tlb_flush_vmid_range(mmu, addr, size); + } else if (kvm_pte_valid(ctx->old)) { kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, mmu, ctx->addr, ctx->level); + } } if (stage2_pte_is_counted(ctx->old)) -- 2.44.0.396.g6e790dbe36-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel