Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796407183; b=OFuyf5LBgIejBzUb7JTDSJ0fdmvPZkzb/MVeg7BAt2xS5njKP228JL033/W9BynQwCJg KCJFn9UO0Qv4gmAO44vkdjA4veFZa5Bc1jkY+KvlVTqhTer+J7415lMUmN7ySEarTYIpH H6g8GsF9XYsTUTXTueqq6crLcij1TWOiqTie+IaOM3Q1xKLcC+KW+LelIuIyu51gb848P abGUU3tg+7G+UiZuboSe/2L5VuJGyYuYlqA2ReJSY37kFPkfLsSK9gLgGmwhjJgB+x/yL rPT9lwMlhu2M/qSRA8SDeDWStgfvWvLfgi4RzrwLIH1+9MskGJyCoAo4gp5U3yZZ+Wg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796407183; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=hp7SmYzUzk8RZ9NLlr2PDcHFiqQGpdo73kwrM4Lo6cI=; b=3fL+Is8pdDiyLHeZpdmRwSH0OJxT+7zfAMjfCA8PO+wNRDAmhR3u9Ll2atUnPPy+NgE6 BlhT9bUtd6gQ7VpJH9OEWH5jfby+sckFaD39Y2CvmCNtQJUvVwrpl3edcnOIMWINbI5/S epiKieudEDTVWnE9HY/3+rYzrqvMPwpnnmYHg9S04QQHz/Ywip1ZVddzpMnx59YXkwVtl j3v2An0ZvzPWsiAiAQHGMlyVhoO6mEm9W5a9uKTEsYQvE6zr0Uqn/NSZzK5HegHI7eToy Y5/AHl9AzzTgfyJZxdpiDnrsbRLwEsm9WlAfu9enUPF4VeuoNoln/ccTg8wzr9CN7rQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b="cUA/U6sa"; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDB74606A33F for ; Fri, 4 Dec 2026 17:59:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DDB74606A33F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cUA/U6sa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796407183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hp7SmYzUzk8RZ9NLlr2PDcHFiqQGpdo73kwrM4Lo6cI=; b=cUA/U6saZmvM3PAw2hvgxbcf7fda5GOsQ6QzN3jycl1n07uEBB198HAXgbsTdeoLPnio6c gP/hgui/u8b8bfXz5Lv4Xw8AFbzzMpnYo3hwXMFJDPHhBuluq/JMfm/s/hNFHil91rHqfk 93qpRYtIqkThC/dnvAGqlwiQUIO8PFI= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS with 8BITMIME (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-348-rOFk3hyaNz2Vf-nz8p8UYA-1; Fri, 4 Dec 2026 17:59:37 +0000 X-MC-Unique: rOFk3hyaNz2Vf-nz8p8UYA-1 X-Mimecast-MFC-AGG-ID: rOFk3hyaNz2Vf-nz8p8UYA_1796407176 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D225418F52C1; Fri, 4 Dec 2026 17:59:36 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C2BE1BBA; Fri, 4 Dec 2026 17:59:35 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH 02/17] KVM: x86/mmu: Propagate the return from kvm_zap_all_rmap_sptes() out of __rmap_add() Date: Fri, 4 Dec 2026 18:59:15 +0100 Message-ID: <20261204175930.2154542-3-pbonzini@redhat.com> In-Reply-To: <20261204175930.2154542-1-pbonzini@redhat.com> References: <20261204175930.2154542-1-pbonzini@redhat.com> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 From: Sean Christopherson When recycling all rmaps, propagate the result of kvm_zap_all_rmap_sptes() out of __rmap_add() instead of unconditionally returning "true", to make it more obvious why a TLB flush is required. Barring a KVM bug elsewhere that corrupts the rmaps (mmu_lock is held for write), it's impossible for kvm_zap_all_rmap_sptes() to return "false". And if rmaps are corrupted, KVM has far bigger problems then potentially leaving behind stale TLB entries. Assuming there are no egregious, fatals bug elsewhere in KVM, no functional change intended. Signed-off-by: Sean Christopherson Link: https://patch.msgid.link/20261113155010.442816-3-seanjc@google.com Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 1fae6743aacd..d21bf4208714 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -1754,10 +1754,9 @@ static bool __rmap_add(struct kvm *kvm, if (rmap_count > kvm->stat.max_mmu_rmap_size) kvm->stat.max_mmu_rmap_size = rmap_count; - if (rmap_count > RMAP_RECYCLE_THRESHOLD) { - kvm_zap_all_rmap_sptes(kvm, rmap_head); - return true; - } + if (rmap_count > RMAP_RECYCLE_THRESHOLD) + return kvm_zap_all_rmap_sptes(kvm, rmap_head); + return false; } -- 2.56.1