Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1639447ybz; Thu, 16 Apr 2020 12:47:14 -0700 (PDT) X-Google-Smtp-Source: APiQypLYCGHb4NeIB6Uf7fbymZbCwG6X94EqA7t+TCkpuB/oFzJEGAd5WRf7q2mcc2fJxUBi+hDS X-Received: by 2002:a50:ed19:: with SMTP id j25mr30390063eds.264.1587066433988; Thu, 16 Apr 2020 12:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587066433; cv=none; d=google.com; s=arc-20160816; b=jhFXCnZS/rHRTp5O5KCcVH+FIYizNqjvtII4URkEfeJgvN/Vj3sS17SyHGgaQc8OGq 0b4GF2JbU/q63lmdViBZ7hV2LO/vR06MCipWvKxai7ry+/+pLtEhVYH79JJxwZrfgMOP T/X8JT0SrYzS3Oytdj1YhvacEyGBcGD6tDl7BejHbGKNLndWFIeFvAfMLm2G6j18S5L5 UMcG0i20BPt3OLy1MXdRXMO9G2/nvs4VvxHe/G42/UGDdH1xZDuqWqmYXsqt/NKGvzeW FlRFZINKVpNBvRlhGhPlKOU2iaO3mOtsI90K2bdE3Q4dYTnf952jgEMKItxdPR6K1B2e hB5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=23cxxgS1YXT6Bggeaoc6KYiQd+1TjF2Gr0+Z4cAqnF8=; b=ei5wL7T4sSwq47jSnAbw/PH/3yqsTMQ2hohf8GQPkY2yXtQD92cNKq6N+8hCPamay4 m6q/miy3chSrNJFZQh1Vw00niQuTrjKZ5Ky2UiW7RRsugqhtj1Oee7sFa8zK8hd/V/OJ yFGhGsV8N7nr3VeQqQ+Y8tt9K330H3vV2Jqbf71g+yDjTbB0adZwkbUfN86LDe/Qmnaf 9Nynztq6+LYqtOKvGy/evD7ZuI2a+So9Y7agBr0ruTaVHeMJ9LvOvtx2i2/ti2D+S5ka 6wclv3vw/jl2A7iMgT1/NrqP9eysXgFjgOr/E+BE4ymL4nLnlQS7vVE6CJnmty55J4Om 0e9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bvYc46qR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q13si6621810eds.115.2020.04.16.12.46.46; Thu, 16 Apr 2020 12:47:13 -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=@kernel.org header.s=default header.b=bvYc46qR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896981AbgDPNem (ORCPT + 99 others); Thu, 16 Apr 2020 09:34:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:38740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2895952AbgDPN3J (ORCPT ); Thu, 16 Apr 2020 09:29:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BB40721D79; Thu, 16 Apr 2020 13:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587043749; bh=jU2NGxoZVfqGEeV789O2fBDa8eNmaSTF3BTMq0ydWxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bvYc46qRBpPM+/I2TOvC5FDWN57abOAyWvlKLP7W2zeZDijjzRoYmCR/d/NA0TYI4 LNeuNuUIIsQsjzk429YwkCBRvtM+vKkqYyoLTAYourgc4BdP0DBBIWfqfYrBuCSh4f EjbQe+Hz5Gkheyp7bhFgY60iRkFYX1xjNGawcaPo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Subject: [PATCH 4.19 085/146] KVM: VMX: fix crash cleanup when KVM wasnt used Date: Thu, 16 Apr 2020 15:23:46 +0200 Message-Id: <20200416131254.426476528@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131242.353444678@linuxfoundation.org> References: <20200416131242.353444678@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vitaly Kuznetsov commit dbef2808af6c594922fe32833b30f55f35e9da6d upstream. If KVM wasn't used at all before we crash the cleanup procedure fails with BUG: unable to handle page fault for address: ffffffffffffffc8 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 23215067 P4D 23215067 PUD 23217067 PMD 0 Oops: 0000 [#8] SMP PTI CPU: 0 PID: 3542 Comm: bash Kdump: loaded Tainted: G D 5.6.0-rc2+ #823 RIP: 0010:crash_vmclear_local_loaded_vmcss.cold+0x19/0x51 [kvm_intel] The root cause is that loaded_vmcss_on_cpu list is not yet initialized, we initialize it in hardware_enable() but this only happens when we start a VM. Previously, we used to have a bitmap with enabled CPUs and that was preventing [masking] the issue. Initialized loaded_vmcss_on_cpu list earlier, right before we assign crash_vmclear_loaded_vmcss pointer. blocked_vcpu_on_cpu list and blocked_vcpu_on_cpu_lock are moved altogether for consistency. Fixes: 31603d4fc2bb ("KVM: VMX: Always VMCLEAR in-use VMCSes during crash with kexec support") Signed-off-by: Vitaly Kuznetsov Message-Id: <20200401081348.1345307-1-vkuznets@redhat.com> Reviewed-by: Sean Christopherson Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4398,10 +4398,6 @@ static int hardware_enable(void) !hv_get_vp_assist_page(cpu)) return -EFAULT; - INIT_LIST_HEAD(&per_cpu(loaded_vmcss_on_cpu, cpu)); - INIT_LIST_HEAD(&per_cpu(blocked_vcpu_on_cpu, cpu)); - spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu)); - rdmsrl(MSR_IA32_FEATURE_CONTROL, old); test_bits = FEATURE_CONTROL_LOCKED; @@ -14554,7 +14550,7 @@ module_exit(vmx_exit); static int __init vmx_init(void) { - int r; + int r, cpu; #if IS_ENABLED(CONFIG_HYPERV) /* @@ -14605,6 +14601,12 @@ static int __init vmx_init(void) } } + for_each_possible_cpu(cpu) { + INIT_LIST_HEAD(&per_cpu(loaded_vmcss_on_cpu, cpu)); + INIT_LIST_HEAD(&per_cpu(blocked_vcpu_on_cpu, cpu)); + spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu)); + } + #ifdef CONFIG_KEXEC_CORE rcu_assign_pointer(crash_vmclear_loaded_vmcss, crash_vmclear_local_loaded_vmcss);