From patchwork Wed Jun 21 17:50:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghavendra Rao Ananta X-Patchwork-Id: 13287830 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 58009EB64D8 for ; Wed, 21 Jun 2023 17:51:30 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version: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=bLy0u35oIRCIXdUi7qkBw8hcLKNVAU1VP09zW9JGGPA=; b=1GR0JbXA4A944y9G0QBg+fAsqp chm1jFGMLY+SDgUFIhjRyjLfnLNTMAinWyulg4O5QKvArVdYXym2KU9r7qbdy8y+xOf/3qh9ySmah iIySXT7nPlcRyhTyoRcDpY5oXg+u8hAMiJ2wsBugwYtVLWQCWpSJ0ignSB5YkPZgiVgXjPu0v0CXx DovUFF5+xx5poQw79evfHQ9h7zsSYNjfNMfrrkyJ+c4AFOdKYUNb8gw2aVHAxn/4QQHOEpgi/cZyn 7TY/u02XR6JUlns/3LOXLkWJ5Cyr0rLVGN+iNBuD6sI2YvrBEHOpDxW/ZoFXW1TZGpE0/fHEpC+y1 2UBJUpzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qC1yz-00FHdM-37; Wed, 21 Jun 2023 17:51:05 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qC1yR-00FH5N-1z for linux-arm-kernel@lists.infradead.org; Wed, 21 Jun 2023 17:50:36 +0000 Received: by mail-io1-xd4a.google.com with SMTP id ca18e2360f4ac-77e2c123e8aso472034339f.1 for ; Wed, 21 Jun 2023 10:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687369830; x=1689961830; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=kpR1MspLCCKbLGu542rFrU99snL12qe0SU5vnENHbnc=; b=obkQNETduI4Wdlr8DqbH6rQDpqF2mUi0lafiiZR1QXrNN2+tKemED10KMGrakG13Nq +F9e7JIuRjiRR9EfoJnua+9jPsENy4Tu90Vrn/2nK11OMp8Aj/golURDqyPfJ94Cfrxi hdWdLoNiohD/PMMDEG0mtQHMd7A92j4tIxNPh8D/cM9gYPH0WwqnOU4OcPsZKdr9HTOs pyGKjpe6+P6Xcb6ByP94N+J+yZmYDJogpjw8kcjVcP5B1YTqtAJdqi8Hp9kutYXKuAUx OCxMudA25zodKFZSyAwbz9vLyvHyzcqnxGuKjUldsdPVjyx7x6uGCQbzc3ZzHDMDOM0D Kg8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687369830; x=1689961830; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kpR1MspLCCKbLGu542rFrU99snL12qe0SU5vnENHbnc=; b=i8Eo1Ng0XLVYNcsXUfjXidNuL1BAZTC5G2yXL80eoGA4wYWYbEghKQHKvzqOlyZ+8r HCECdsStQsgbknoaILCsGvwJAfvCHZ1vhl1MKHzvC90TtVU7TLcQGKQMVAjevE+Gh8ow 1d+MbUCRcb/+uFefuQ3SA4ONtlEeLbFXWzQyxGp1LegPlvxLX0LneT1E7L2uWAKWBKuP iE/aUV/g75o29xOqLxY2C8LzoVy2vQym+p7eAsYUhf2l/gVaMUUcJayRLOW6jkNOz9Lc rdn2lsNYM8EVPbPgoF5Bi7ChM5JWqV8RPP9V3XA8fiOUVFtp00jEWzSxaDwbxHyqFhpd JV0A== X-Gm-Message-State: AC+VfDwKhZJoZH+wPwFi2p4kD188T8t4DKKpJ9dGgn4Fwy0M3nD5XB1Y upfj34boOG0ZDDljduRwBSnbrKQz2H6Z X-Google-Smtp-Source: ACHHUZ6lEejYkvXSZImNPgkcjtxASyr0tUJRYFuyzfo7eVoPr61PQ+mo3lAqnIjMYGuKsT4NfkEe3+3Un922 X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a05:6602:152:b0:777:b38d:2333 with SMTP id v18-20020a056602015200b00777b38d2333mr5713635iot.3.1687369830330; Wed, 21 Jun 2023 10:50:30 -0700 (PDT) Date: Wed, 21 Jun 2023 17:50:00 +0000 In-Reply-To: <20230621175002.2832640-1-rananta@google.com> Mime-Version: 1.0 References: <20230621175002.2832640-1-rananta@google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230621175002.2832640-10-rananta@google.com> Subject: [RESEND PATCH v5 09/11] KVM: arm64: Flush only the memslot after write-protect From: Raghavendra Rao Ananta To: Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose Cc: Paolo Bonzini , Sean Christopherson , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Colton Lewis , Raghavendra Rao Anata , David Matlack , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230621_105031_652210_E96FE668 X-CRM114-Status: GOOD ( 10.99 ) 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 After write-protecting the region, currently KVM invalidates the entire TLB entries using kvm_flush_remote_tlbs(). Instead, scope the invalidation only to the targeted memslot. If supported, the architecture would use the range-based TLBI instructions to flush the memslot or else fallback to flushing all of the TLBs. Signed-off-by: Raghavendra Rao Ananta Reviewed-by: Gavin Shan --- arch/arm64/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index c3ec2141c3284..94f10e670c100 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -992,7 +992,7 @@ static void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot) write_lock(&kvm->mmu_lock); stage2_wp_range(&kvm->arch.mmu, start, end); write_unlock(&kvm->mmu_lock); - kvm_flush_remote_tlbs(kvm); + kvm_flush_remote_tlbs_memslot(kvm, memslot); } /**