Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp242999pxf; Wed, 10 Mar 2021 05:30:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbhJbsbehbJjEhlupVZ/otdKm0wFAYPIeCx2wArqWdho2YaqiA8X9ukn6HsHM8BdctQXvu X-Received: by 2002:a17:906:780b:: with SMTP id u11mr3754175ejm.492.1615383023030; Wed, 10 Mar 2021 05:30:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383023; cv=none; d=google.com; s=arc-20160816; b=t8om03xJmnCRDKan3KgIdaCpW7TyjKlrVycaEeCmlI0wmx6xAc3o/azOWA2Rrn/viV ZlzylD05Y5wc+fZl4tIf1R+9gDd3g0xaZIbNuTr2FP/yJdYSb6OfXU55vdXid6f6vryh fTdci0Eiumwu9tjMq63SnPcSEBOkSesNMqM9hYsN963vJUdorbKEaVerOVjjEEOqxdHZ rALQK1zMLQFoONIXfWfyiAcsZmrU+tdG0tQERsxKp6mB+75DgeKOoDf+5wC0kjBDk+N4 q1B4VHK1xQcM1hWpvQp1ezdt5dImeUWOSu7S6EqHVO7Px7isIiwFbPf0nHgwpwVFYBwl Q+Kw== 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=9rGzJgSxAVr6DeIuBj2VIbiGWm+sAY/yd5jT1z9q+JA=; b=NZbrx+S8QqoX0skTDHuSxZSf72jnH/rOQ7WnFdLkBGyRzc3JhAlMLhx4m7jPQoCQiW PS/DlQS9jSPeJJav5/Bq+vtJ09oui1OW2q6xeuz9A03Pjv/4etbUPkrndtnrL5+mT1gz Rud1J/DYT/Rp7eJ8LpjAasAa4uglnz9M72wBBM52YWAfXyfL/ctGUwBTigrAOnxbHle+ RbfR7jylG70SMvLZDGdKSrj5YBJ7cKNAL78Ugbny+FleVqvQ8cYejPDglkXeOH7fi4Lp udNHdGF3pi5O9IrD8bLp4bzCbcC2y8tHaUa/l2wwdYHJpXIcbW/FsWE3JgZFkiTBXjjc oZqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lzXZt1nB; 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 a9si7743089edr.332.2021.03.10.05.30.00; Wed, 10 Mar 2021 05:30:23 -0800 (PST) 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=lzXZt1nB; 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 S233779AbhCJN1G (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:46406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233116AbhCJNY4 (ORCPT ); Wed, 10 Mar 2021 08:24:56 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4DD2F64FDC; Wed, 10 Mar 2021 13:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382695; bh=SepQaMUdyw+wXVXxQkT2aGfO9aqL0FWamdd103kuQ4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzXZt1nBvMHuiebGYbRNaZIsX/IY7RorLQQtUQx3Jm/b+eAkLmP622BszHiM0KnAA zerb44aSqKsHJvXi74LTKpSAuGNhwBEgcaQaXBhTppQyzmCeyuKxY9NVTFdsO3jwa+ MbzktzBRr4kJJLmCuYN/6Xup/stBsCJyG3U2HnkA= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Babu Moger , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.11 34/36] KVM: SVM: Clear the CR4 register on reset Date: Wed, 10 Mar 2021 14:23:47 +0100 Message-Id: <20210310132321.596264492@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132320.510840709@linuxfoundation.org> References: <20210310132320.510840709@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: Greg Kroah-Hartman From: Babu Moger [ Upstream commit 9e46f6c6c959d9bb45445c2e8f04a75324a0dfd0 ] This problem was reported on a SVM guest while executing kexec. Kexec fails to load the new kernel when the PCID feature is enabled. When kexec starts loading the new kernel, it starts the process by resetting the vCPU's and then bringing each vCPU online one by one. The vCPU reset is supposed to reset all the register states before the vCPUs are brought online. However, the CR4 register is not reset during this process. If this register is already setup during the last boot, all the flags can remain intact. The X86_CR4_PCIDE bit can only be enabled in long mode. So, it must be enabled much later in SMP initialization. Having the X86_CR4_PCIDE bit set during SMP boot can cause a boot failures. Fix the issue by resetting the CR4 register in init_vmcb(). Signed-off-by: Babu Moger Message-Id: <161471109108.30811.6392805173629704166.stgit@bmoger-ubuntu> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/svm/svm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 825ef6d281c9..6a0670548125 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1205,6 +1205,7 @@ static void init_vmcb(struct vcpu_svm *svm) init_sys_seg(&save->ldtr, SEG_TYPE_LDT); init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); + svm_set_cr4(&svm->vcpu, 0); svm_set_efer(&svm->vcpu, 0); save->dr6 = 0xffff0ff0; kvm_set_rflags(&svm->vcpu, 2); -- 2.30.1