Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2826531pxv; Mon, 12 Jul 2021 02:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyL2/AAVNIPpGQKgKaKnPrWcqeWRE4J8N8UU+Mn7wn3cuNM5ZYn6vrCeE7yr0XjXgxqVg2 X-Received: by 2002:a92:1944:: with SMTP id e4mr36587929ilm.186.1626083694403; Mon, 12 Jul 2021 02:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083694; cv=none; d=google.com; s=arc-20160816; b=YqLpMezOV6aGtOzlSSP4AN5fpL1pnXFlh+FOtNET7PUyNBJn12IArlmaWQCxk7UpFf ezLVKYfoxLmld3LRQSe0Z/ikJaJcRszW6xRapYQZVjU4LY6OObHuWwuocYLKeNq5pLF4 nhET6Wg4kf0A4KLI+oDpwKQTb7QQdw5Vtwq9SxRx46acW4LeXy5WTq+Cxyk60SZ7Hsxk 8YfFPhYLMnPGFK7so1a3EIpZvispfrzvu5tIxlvjZyi5egqLIeDnxHvHvwM+VQD4lJ6x zPazkad9Cu8qwqN/AGdv6cYc/Z5tZVhaGktUCjT/UIyy8d8T01pg9BonDNetMIcEOcB5 cMLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qNcy1pBEgEjW2pSSAW86Y5hvgVgznN2g6PrI0+x9whQ=; b=yYntmI+nwCBR3KYXA3bWA2E+IraFm31sBS6IlxLPyfnkIJBaiHe0UyXpDttkVy0hc0 nNSZ3ZcT3fxV/VzgwomtyrzagYxS8jhmK9gWdL6GlrjXZkwzMU1kIzAMx3kQ2qpGqoGa 0Vt1CybkyNt6/TIA6Wwuk9gSJArdFaqIXNSNVB6/MbQIYEYmI5kjG7AeOWknnCimhQqJ KVwhrgBJTRdiBudq0uWAeT+KSSVUOTBF3eDnJZ/EzdlSN28H5yaqRNswyNxybvGLGjVY iZh9nXF7lyhAJfAsab6foqzgZ5J5l8TlKxm4GpwVNsxcQ1Mvg3dnU9rGGOI8Y017T4aj +qSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rTGl2ubu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v18si14454127ilc.155.2021.07.12.02.54.42; Mon, 12 Jul 2021 02:54:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rTGl2ubu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240735AbhGLG4X (ORCPT + 99 others); Mon, 12 Jul 2021 02:56:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:34412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236209AbhGLGkt (ORCPT ); Mon, 12 Jul 2021 02:40:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 37B0F61158; Mon, 12 Jul 2021 06:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071869; bh=snxuVAQdJaGJUmErd/dkBw9lbfOuMsq1syOtgVSthOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rTGl2ubuJdX5p5gcgoX8VGw3TX+sO1gI7dBpFmoknT5arwcodgNZyWzmqMAQhq9b1 7yOz5lBqRp/d9/AJQ4at5Hxvax+C2TNTdummIrZ/ZynO32IYRmTHZjncLBOBOwsfi1 TQZPveyihoFXZCLqqejEWQQGq6raQXsVeQKyXmhE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 256/593] KVM: nVMX: Dont clobber nested MMUs A/D status on EPTP switch Date: Mon, 12 Jul 2021 08:06:56 +0200 Message-Id: <20210712060911.242682972@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson [ Upstream commit 272b0a998d084e7667284bdd2d0c675c6a2d11de ] Drop bogus logic that incorrectly clobbers the accessed/dirty enabling status of the nested MMU on an EPTP switch. When nested EPT is enabled, walk_mmu points at L2's _legacy_ page tables, not L1's EPT for L2. This is likely a benign bug, as mmu->ept_ad is never consumed (since the MMU is not a nested EPT MMU), and stuffing mmu_role.base.ad_disabled will never propagate into future shadow pages since the nested MMU isn't used to map anything, just to walk L2's page tables. Note, KVM also does a full MMU reload, i.e. the guest_mmu will be recreated using the new EPTP, and thus any change in A/D enabling will be properly recognized in the relevant MMU. Fixes: 41ab93727467 ("KVM: nVMX: Emulate EPTP switching for the L1 hypervisor") Signed-off-by: Sean Christopherson Message-Id: <20210609234235.1244004-4-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/nested.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 8f1319b7d3bd..67554bc7adb2 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -5484,8 +5484,6 @@ static int nested_vmx_eptp_switching(struct kvm_vcpu *vcpu, { u32 index = kvm_rcx_read(vcpu); u64 new_eptp; - bool accessed_dirty; - struct kvm_mmu *mmu = vcpu->arch.walk_mmu; if (!nested_cpu_has_eptp_switching(vmcs12) || !nested_cpu_has_ept(vmcs12)) @@ -5494,13 +5492,10 @@ static int nested_vmx_eptp_switching(struct kvm_vcpu *vcpu, if (index >= VMFUNC_EPTP_ENTRIES) return 1; - if (kvm_vcpu_read_guest_page(vcpu, vmcs12->eptp_list_address >> PAGE_SHIFT, &new_eptp, index * 8, 8)) return 1; - accessed_dirty = !!(new_eptp & VMX_EPTP_AD_ENABLE_BIT); - /* * If the (L2) guest does a vmfunc to the currently * active ept pointer, we don't have to do anything else @@ -5509,8 +5504,6 @@ static int nested_vmx_eptp_switching(struct kvm_vcpu *vcpu, if (!nested_vmx_check_eptp(vcpu, new_eptp)) return 1; - mmu->ept_ad = accessed_dirty; - mmu->mmu_role.base.ad_disabled = !accessed_dirty; vmcs12->ept_pointer = new_eptp; kvm_make_request(KVM_REQ_MMU_RELOAD, vcpu); -- 2.30.2