Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp863684pja; Wed, 1 Apr 2020 10:02:29 -0700 (PDT) X-Google-Smtp-Source: APiQypIfReRFuGYVkF0QQlynqexxUdMyFlvzMoPdsYMQtlInDVejy5iWJLnU7BMu+3w0LsRxYF4t X-Received: by 2002:a54:4797:: with SMTP id o23mr3353917oic.12.1585760548916; Wed, 01 Apr 2020 10:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585760548; cv=none; d=google.com; s=arc-20160816; b=YaJBt91EgX5lJyITClnbPVEzXvAWps65EGukP7N965bVcRDKiVQCA9F2hG8RmwOnS6 sxH2Akcs1AX69QaLaqAA/S/6GB3pJbi2yeSMKbfpgBggBqQB8cf1NRe93aeseNYqxt2i 4hCYlQRNcnNWMORxi0WNmpjaoCvsvBWyD571qGym/7TKSZdhARgIzTLOWhbzPK/SWnrr ZtflALjMTVDZxk9B6pFpy9QPWf44xiuG6Xb7KFbkalQ4JGBwJWBVvh0YhhIUI7UHEaLD YNnvmS+BxE1sj1iYYws4WzAsXnJQAOYZTvQdLTyEJFa7rXzoJNB1XpbDySjnFIsTMvsh zuhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=20aYqLJXb6GP2LpSfVyBw9b1MWMElE97X/Nd1bQu44Q=; b=AQJNeyWrAJhVqUaRZ+dymj2dkXD7Ccvs0HO8YUdhNIxevTV6y2Y1XAKzilZaOyqJr/ UvDlKtmj0b5pYpQLPtQ43HKZ7rH/gIcwYj0PU0YtMXHe6uOnG26BS6zamYAKRiJ/+XAo vWhZY02UppokNPhftck5h0tDfeonVcD+/FBT0gU3AC+5OWMBXoZ8QxCZXfEo3ZCngu4O uqwd0Q6uK/Gc98s3E8XsZYVlD/8Nf96rS4VgyHPQQBvcAnm0CufWDkhXauxQxwKxD53t AGF+qCEM05zpVkEXFzFq7DceSlTGN5qHkt6ywOszMxCwoxFWJYv0mxVtGWlkTgmV7ssk lRNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w73si1138426oiw.206.2020.04.01.10.02.10; Wed, 01 Apr 2020 10:02:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732687AbgDAPSU (ORCPT + 99 others); Wed, 1 Apr 2020 11:18:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:42676 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732504AbgDAPSU (ORCPT ); Wed, 1 Apr 2020 11:18:20 -0400 IronPort-SDR: AEMiQJr9fWk8kXqf9Q3lbKKQODIEFcyiXHB6M2cDgwDQigXgehRS5m+IE7fy6rrZrkLUOpBsXi 13m9209APCaA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2020 08:18:19 -0700 IronPort-SDR: OIR3dx6bgM/ubb1jkXpAKqvwRt7zK6DexWasa4lQsxqVDbAS4kpU8Wbo/8vsUgCubA7WbHEOW4 HLIY0+xM/k8Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,332,1580803200"; d="scan'208";a="450596783" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by fmsmga006.fm.intel.com with ESMTP; 01 Apr 2020 08:18:19 -0700 Date: Wed, 1 Apr 2020 08:18:19 -0700 From: Sean Christopherson To: Vitaly Kuznetsov Cc: Paolo Bonzini , Jim Mattson , Wanpeng Li , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: VMX: fix crash cleanup when KVM wasn't used Message-ID: <20200401151819.GH31660@linux.intel.com> References: <20200401081348.1345307-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200401081348.1345307-1-vkuznets@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 01, 2020 at 10:13:48AM +0200, Vitaly Kuznetsov wrote: > 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 > --- > arch/x86/kvm/vmx/vmx.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 3aba51d782e2..39a5dde12b79 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -2257,10 +2257,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)); > - > r = kvm_cpu_vmxon(phys_addr); > if (r) > return r; > @@ -8006,7 +8002,7 @@ module_exit(vmx_exit); > > static int __init vmx_init(void) > { > - int r; > + int r, cpu; > > #if IS_ENABLED(CONFIG_HYPERV) > /* > @@ -8060,6 +8056,12 @@ static int __init vmx_init(void) > return r; > } > > + 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)); Hmm, part of me thinks the posted interrupt per_cpu variables should continue to be initialized during hardware_enable(). But it's a small part of me :-) Reviewed-by: Sean Christopherson > + } > + > #ifdef CONFIG_KEXEC_CORE > rcu_assign_pointer(crash_vmclear_loaded_vmcss, > crash_vmclear_local_loaded_vmcss); > -- > 2.25.1 >