Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3983166pxb; Mon, 4 Oct 2021 14:23:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb+exWvK7UJ7RpVuiG7IinRJhLTEf9afJ7AHkXQZDVxpitS45m8y8/FasXsFkIZjFhl/AN X-Received: by 2002:a17:902:b188:b029:11b:1549:da31 with SMTP id s8-20020a170902b188b029011b1549da31mr1716520plr.7.1633382630858; Mon, 04 Oct 2021 14:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633382630; cv=none; d=google.com; s=arc-20160816; b=yVMr9aoLMEEm0V1ZxJdxQfFJxktSuh78dm5TRfVHOqq9G7ngi8lrDcF/xp7bYwaDFN 5+KS/Y8YPs0f3KAwgdFx5TgOAsnEdrlPZCji5wBeb/0+eMrlKxdWv+GwNZMjj8ZTLkuB 6qnSwZffVcFWZtPTDMfgdeF+2t3hexK4tR+lxqwcQHQWsB4YZNBiXifpUevUeo+8Alqg g4bOW8321epddcq8CIfaz3FESJDdbDcBnAXJqGZJOFPkSkbB5SUsHAGwixL/RFKkNW3H pOnUGVfZZfhPplGtUuJIZ4Pt8HO6vkEEFcwmzIPAIobwQQ4on7tr976Mb1QOVJ6VR3NO yzVg== 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=Ago2LwM+2e3a0nEiIfLCVhmmRSLIcm4Dfxy/SNdl7SE=; b=iAaE2tUDrY4q6IH0zPdSFvrcQtPR7PD0lxtHzUht5r5VFgu0D7E01ciKkE6+1Z+vWT bXi/+04fS3GX/Jca/K1K3Z1Q4vlN9dbJQBnAVw04s2tbFhxeWdSKpQR99wkejcRATDrX Hb00QICRAg4PxyTEOu8RwIL9ZiTJJxM0f2ZRG9clJ+FlXzzo2OHnjIoWK+iQLLPCfyNI rilGo0XlEsx90Fucdjhxh2NJd8S68lTidQ1S5Ux7v8qJKICRs2lI347BrSf9KnkOeREB bWGU4PypA7rsuUJnEdK61Vxl6Y/f0lC+N9mCIAnKiaZH8f5S+03+QhpaOxDut0Cdml4K GDbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uc4dORGu; 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 i1si19410010pfu.229.2021.10.04.14.23.38; Mon, 04 Oct 2021 14:23:50 -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=uc4dORGu; 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 S236577AbhJDNdt (ORCPT + 99 others); Mon, 4 Oct 2021 09:33:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:47126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237044AbhJDNb2 (ORCPT ); Mon, 4 Oct 2021 09:31:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2E8D463215; Mon, 4 Oct 2021 13:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353246; bh=UPMXDFjMj4uUQEIY9z8v9Xv8Ch6dZZuSXPPiC+3LamM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uc4dORGuejC3shWoOQCYwo0KBv3u6EmUgKV3bMg7yh5xy+ZbjKncRoFj/iOb5Usf5 ekpQVIT46IRxNSyRFZXFy5bEhNRa9uCyG7g81P5pfQfTLCWroSSN+ZuMSKj/I/kIiS 9Bz4uK7ZPo7oUW28eqjHgUPgev9AzXiOJZwwTZHI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.14 052/172] KVM: x86: Clear KVMs cached guest CR3 at RESET/INIT Date: Mon, 4 Oct 2021 14:51:42 +0200 Message-Id: <20211004125046.675618539@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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 commit 03a6e84069d1870f5b3d360e64cb330b66f76dee upstream. Explicitly zero the guest's CR3 and mark it available+dirty at RESET/INIT. Per Intel's SDM and AMD's APM, CR3 is zeroed at both RESET and INIT. For RESET, this is a nop as vcpu is zero-allocated. For INIT, the bug has likely escaped notice because no firmware/kernel puts its page tables root at PA=0, let alone relies on INIT to get the desired CR3 for such page tables. Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20210921000303.400537-3-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10873,6 +10873,9 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcp static_call(kvm_x86_vcpu_reset)(vcpu, init_event); + vcpu->arch.cr3 = 0; + kvm_register_mark_dirty(vcpu, VCPU_EXREG_CR3); + /* * Reset the MMU context if paging was enabled prior to INIT (which is * implied if CR0.PG=1 as CR0 will be '0' prior to RESET). Unlike the