Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2177117ybg; Fri, 5 Jun 2020 07:29:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvIx9LOZKDWLhp5d8ndYdBjeOfrVvsZVorT8blEQr5Rz2psaNiJ7rRCYTRwRRRLh3+bzup X-Received: by 2002:a17:906:2484:: with SMTP id e4mr9472963ejb.155.1591367363713; Fri, 05 Jun 2020 07:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591367363; cv=none; d=google.com; s=arc-20160816; b=lnaTpHg+/emlAFxlzXHXx5/lN3/X1iCG7/CTIe6ap6Fioy2FDjWktEgx4pObbjocZc VKAJjkx0Fokm+cCtVJfoR3OZDYXODRcsN8ipYJKx9Rk4v2ZZvPwxGxE8Jlc3N9G4cb1q PnpAk9Romv1bcV0/SWlpRP8+qctgBOi+SnmmCJ0DF36Sq3l6vvidZppmcb5eW84ZyU3a D1m7l5B0VvBqCmNxArW02PsjNNzXag/imRpVnQQpW5+NEN88xRIpWxMNWIrlMpxk81FE P9zgE6s/n6B1dOaUMKxNoVzt5ts2UV7DQx7ikP5XYYOHR2qfB39XqajeuLDNbeSslE7q c4wA== 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=gOWdhKI+SMm8zA4uIFnWieSYPF0TQ6YFQk0Ceh55MCQ=; b=e8gWFVNF4B3tgFbwpAeElmOoKXJwCzv1MuNxgeu2ls7lNAqA3l6WA5EAV0lViXkBPt TRZLT8nICQ8t28gP+qb7x3P2XTcPDdq5QC48tr5xOHlgzri6qv+QfOS9IRbfAjpqIwi6 UFftWjo4q2DxymE5CI/2blYEIKfZfs4KpGUur4yo47cx6LIkdmt3UCpcLotr2flzeFGF Ln0upkTFA6LkuYOW/9ilNYKg0vI10ZEVL733BOQlqRghE/XEKPucQlZr1Y7YM6dRKZC4 A/M1aXrgD1hZp/H3jzqYFcSccBiCj0CDp2xAVPb5JXHLNEO3aNgrt6Ns2t436TJ17lyM 0aKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y58PH5Uy; 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 t4si4031890edt.0.2020.06.05.07.29.01; Fri, 05 Jun 2020 07:29:23 -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=Y58PH5Uy; 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 S1728666AbgFEOYW (ORCPT + 99 others); Fri, 5 Jun 2020 10:24:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:47060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728496AbgFEORg (ORCPT ); Fri, 5 Jun 2020 10:17:36 -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 11E64208B6; Fri, 5 Jun 2020 14:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591366655; bh=6zwGUGo6IJLz1UzgMnCPHNAuZNi38tSvN2PQ+FnbxdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y58PH5Uy6N7d7r56oZcYtUWWx13jyHJbPNQQtgLrJ1nUXWP48ztkeMPcr/2ZaPw8h 4PLXzTYg+/XMxZS1Wm4aL0rOF1HUJybTtt/Nws+lA+Xf2mzCeymEqfVNbCrK9Yz9ra 2J/Q9n7PKTQ1mbeROcM2JnkYRw2wvHmCmwk/Di8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Dexuan Cui , Tianyu Lan , Wei Liu , Sasha Levin Subject: [PATCH 5.6 09/43] x86/hyperv: Properly suspend/resume reenlightenment notifications Date: Fri, 5 Jun 2020 16:14:39 +0200 Message-Id: <20200605140153.012469521@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200605140152.493743366@linuxfoundation.org> References: <20200605140152.493743366@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 [ Upstream commit 38dce4195f0daefb566279fd9fd51e1fbd62ae1b ] Errors during hibernation with reenlightenment notifications enabled were reported: [ 51.730435] PM: hibernation entry [ 51.737435] PM: Syncing filesystems ... ... [ 54.102216] Disabling non-boot CPUs ... [ 54.106633] smpboot: CPU 1 is now offline [ 54.110006] unchecked MSR access error: WRMSR to 0x40000106 (tried to write 0x47c72780000100ee) at rIP: 0xffffffff90062f24 native_write_msr+0x4/0x20) [ 54.110006] Call Trace: [ 54.110006] hv_cpu_die+0xd9/0xf0 ... Normally, hv_cpu_die() just reassigns reenlightenment notifications to some other CPU when the CPU receiving them goes offline. Upon hibernation, there is no other CPU which is still online so cpumask_any_but(cpu_online_mask) returns >= nr_cpu_ids and using it as hv_vp_index index is incorrect. Disable the feature when cpumask_any_but() fails. Also, as we now disable reenlightenment notifications upon hibernation we need to restore them on resume. Check if hv_reenlightenment_cb was previously set and restore from hv_resume(). Signed-off-by: Vitaly Kuznetsov Reviewed-by: Dexuan Cui Reviewed-by: Tianyu Lan Link: https://lore.kernel.org/r/20200512160153.134467-1-vkuznets@redhat.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- arch/x86/hyperv/hv_init.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index fd51bac11b46..acf76b466db6 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -226,10 +226,18 @@ static int hv_cpu_die(unsigned int cpu) rdmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl)); if (re_ctrl.target_vp == hv_vp_index[cpu]) { - /* Reassign to some other online CPU */ + /* + * Reassign reenlightenment notifications to some other online + * CPU or just disable the feature if there are no online CPUs + * left (happens on hibernation). + */ new_cpu = cpumask_any_but(cpu_online_mask, cpu); - re_ctrl.target_vp = hv_vp_index[new_cpu]; + if (new_cpu < nr_cpu_ids) + re_ctrl.target_vp = hv_vp_index[new_cpu]; + else + re_ctrl.enabled = 0; + wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl)); } @@ -293,6 +301,13 @@ static void hv_resume(void) hv_hypercall_pg = hv_hypercall_pg_saved; hv_hypercall_pg_saved = NULL; + + /* + * Reenlightenment notifications are disabled by hv_cpu_die(0), + * reenable them here if hv_reenlightenment_cb was previously set. + */ + if (hv_reenlightenment_cb) + set_hv_tscchange_cb(hv_reenlightenment_cb); } /* Note: when the ops are called, only CPU0 is online and IRQs are disabled. */ -- 2.25.1