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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBB25C433F5 for ; Thu, 12 May 2022 10:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352545AbiELKOr (ORCPT ); Thu, 12 May 2022 06:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240772AbiELKOe (ORCPT ); Thu, 12 May 2022 06:14:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 229C6644C0 for ; Thu, 12 May 2022 03:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652350472; 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=PPUrfpTKF1ogdDfODf+4Ux6BqBNq8Ze3rzmWyPbynzA=; b=DCbQP1NP0Yu4ETs54/6UPUar7dKrZAzXoxfQ/DzXuPv0U7vbvRHhois0r1gFUXFX5kbAZA RMGa5w4WOZmiFpYGOVDcI2cFRq9Bl3ZiS43dnnSuGcerwJUW+ZPj+7HZRng+K/JjwPccrQ 7FRWY2Ms6zk3yOTzM9Iq8WkduA1knds= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-47-rzFv9KAfPH2IcNiYLA30Ig-1; Thu, 12 May 2022 06:14:28 -0400 X-MC-Unique: rzFv9KAfPH2IcNiYLA30Ig-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51E0D85A5BC; Thu, 12 May 2022 10:14:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id D729115392CD; Thu, 12 May 2022 10:14:23 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Wanpeng Li , Dave Hansen , Joerg Roedel , Sean Christopherson , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Paolo Bonzini , Jim Mattson , x86@kernel.org, Ingo Molnar , Borislav Petkov , Vitaly Kuznetsov , Thomas Gleixner , Maxim Levitsky Subject: [PATCH] KVM: x86: fix a typo in __try_cmpxchg_user that caused cmpxchg to be not atomic Date: Thu, 12 May 2022 13:14:20 +0300 Message-Id: <20220512101420.306759-1-mlevitsk@redhat.com> In-Reply-To: <20220202004945.2540433-5-seanjc@google.com> References: <20220202004945.2540433-5-seanjc@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixes: 1c2361f667f36 ("KVM: x86: Use __try_cmpxchg_user() to emulate atomic accesses") Signed-off-by: Maxim Levitsky --- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Yes, this is the root cause of the TDP mmu leak I was doing debug of in the last week. Non working cmpxchg on which TDP mmu relies makes it install two differnt shadow pages under same spte. diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8ee8c91fa7625..79cabd3d97d22 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7329,7 +7329,7 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt, goto emul_write; hva = kvm_vcpu_gfn_to_hva(vcpu, gpa_to_gfn(gpa)); - if (kvm_is_error_hva(addr)) + if (kvm_is_error_hva(hva)) goto emul_write; hva += offset_in_page(gpa); -- 2.26.3