From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796407483; b=TQ5UEZ7YnJhpIk5nNXlYAay9fTRXrAOR82sTRw0CCldrQQOLG1ZMCTCStuJmE6Lk6wJS 67AxR3eP/VYpUUY/Y0rM0eqBhXoxXFS+SCrP4tRr/t8G3Amh13H3TURoaVRj+woxbk7yR PB9FjynElmuv0XJYBHtI+m1+mzf7gvJvAgOk8k1md2sK9XbC9Ef6jpNoq+GLcVUAu/0Mp 0mXkwsQ4F6sWb3lATrCDR9wwvrwK29P9p22zR2VZXa8DwJsda5h5ANfQi/H2JldfDfXnY q1kO2Lz4Ao9UUBCYpmTeL0DliSj0Y4JMYOzEECa6yN930E4hsQeRMAvJD1FxZB/uTMA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796407483; 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=aud1sGIdLEvxmXmtKlu+ET7Kq2W1IvGsm0fsNDlhGX4=; b=SmF0E1DbqMEbqdjeSVyiVLKHyDKPz6EMCFwLjqOpy6yhyhtz9cB5RCunDfnKlaVngDmZ 6Hev3AjiimwoxIqR+e9ID2nzRMGqGJ4mr+PSmORg3dTDaaqRlgTANuTKfYYM6PAN2BT7E lfccyuIind776P+N4WJxv22ATNbuF9bozUz18YoRN2F5XD/K9cliLMk33oxMbwYJnM0op xHoSnGACvFq7fE04kNL/ICar4HT/mGJX7SWx/11GHov2Id7OlIptlcDhyEUOa/6gjS7Kp LWZBn3MNHIPNN31rasjEhk3K8ReeCDMg+2RjpsBSd8W5yh8WLPjR5RebkUtQnrMIuPw== 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=iPflQWuy; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 DAE48606BB73 for ; Fri, 4 Dec 2026 18:04:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DAE48606BB73 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=iPflQWuy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796407483; 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=aud1sGIdLEvxmXmtKlu+ET7Kq2W1IvGsm0fsNDlhGX4=; b=iPflQWuyO3av0P+AXiqyY3+aceDaB+Fx0DEfP+19G8fHkbYc/by2JzifKf4XqMJ/QF0AeN c2hTEYKM35pDa+D6PTTTGhaA65KJLfnnDr2zOBCNb1IpJBWenrX81hpjeCs+9e7zWkvMj1 XcQl6Z98QJwDBjrjLoQbgXhqJG2clnU= Received: from mx-prod-mc-03.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-43-_qgdfsn5OVaA5xhMQyo5PQ-1; Fri, 4 Dec 2026 18:04:39 +0000 X-MC-Unique: _qgdfsn5OVaA5xhMQyo5PQ-1 X-Mimecast-MFC-AGG-ID: _qgdfsn5OVaA5xhMQyo5PQ_1796407478 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C1B6193A3C8; Fri, 4 Dec 2026 18:04:38 +0000 (UTC) Received: from pbonzini-thinkpadx1carbon6th.rmtit.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C4B13003EA7; Fri, 4 Dec 2026 18:04:36 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH 6.1.y 07/24] KVM: x86/mmu: Propagate the return from kvm_zap_all_rmap_sptes() out of __rmap_add() Date: Fri, 4 Dec 2026 19:04:06 +0100 Message-ID: <20261204180423.2168641-8-pbonzini@redhat.com> In-Reply-To: <20261204180423.2168641-1-pbonzini@redhat.com> References: <20261204180423.2168641-1-pbonzini@redhat.com> X-Mailing-List: linux-kernel@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.4.1 on 10.30.177.4 From: Sean Christopherson [ Upstream commit 4e29a0c758a9ef3668f7e52305a6727796ff516b ] 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 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 1db7e30fca88..38704c8c1414 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -1615,10 +1615,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