Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1471908ybi; Wed, 17 Jul 2019 16:06:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzELUkpam0WtLnzKsr4AEu7PCf3XBjiIHS2wkfj2Xu+MB8XJ+DCyUs0o2NuNuYYLce25m6w X-Received: by 2002:a63:dd16:: with SMTP id t22mr12223014pgg.140.1563404769258; Wed, 17 Jul 2019 16:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563404769; cv=none; d=google.com; s=arc-20160816; b=EcXAB2+gcBedKqGkiwaZAbtDfkpK0f0qAx1hnQqrPC6mrbBI1iDk7q89VkUR5OepCZ 124eyB1wiJ4xELKrdnOqE7XGJ4iBRE+iUxQeFOQ2tsISda/rPcvkLJKEZYCqI+TQmZs6 Lc4eqB0kZDYayMaOIVaszWMiKqBS9zoYyjgfJy9VVSLbq0KFalVKwn1kdnetMqIfEEcs wFcok9VnHQNz1BCdCteKA+UPPNiLDOVB7IhBGidYundxYAiWxNH2WcAcKdKjglnJpGNb ACTiUGY6qN60Cwerqrrkw+M9l/we6KZIT+aipVGB9Mp6BCZu91K22F8aUfJ74ERFhivV vxUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=q+lvflCmD4u6g4WZyXbUiFpdQBNgEAjywd7Hef4YhLw=; b=L/CoRyW7saRUyViehXJTRTVJeXXsUnMfY83c5U/6WVAaivc7WfpfTYO5AtGudpbja2 jUvboON03y1vWpWntKLM4SMuCt0aJfs6IVnFZdzYodLKv5cUT9kK90hDAzp7JvtXsZQp mTu3waSWHj2bUuEfCrPmLRgLEhDxYdjs1ZE8fGBfwXLj8yryEDw776hb/doDsKfBScvr MTPWPXQBP1V4tZBKl6hdGU1xW4Zu2vNSQkKH65HMUe+3qFL+ton9OPrFnyNxHJjMi11V agQs+4dvY7YObwdjKaVkCoZd/x6OTV03ouel1YC0NmD63r8m51P0zcWatYB17v0J1QiF GtAg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si254767pfa.89.2019.07.17.16.05.53; Wed, 17 Jul 2019 16:06:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731224AbfGQXDx (ORCPT + 99 others); Wed, 17 Jul 2019 19:03:53 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:55555 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727468AbfGQXDx (ORCPT ); Wed, 17 Jul 2019 19:03:53 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hnsxW-0006ey-Qb; Thu, 18 Jul 2019 01:03:39 +0200 Date: Thu, 18 Jul 2019 01:03:37 +0200 (CEST) From: Thomas Gleixner To: Dexuan Cui cc: Haiyang Zhang , KY Srinivasan , Stephen Hemminger , Sasha Levin , "linux-hyperv@vger.kernel.org" , Michael Kelley , Long Li , vkuznets , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "marcelo.cerri@canonical.com" , "driverdev-devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" Subject: Re: [PATCH] x86/hyper-v: Zero out the VP assist page to fix CPU offlining In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dexuan, On Thu, 4 Jul 2019, Dexuan Cui wrote: > When a CPU is being offlined, the CPU usually still receives a few > interrupts (e.g. reschedule IPIs), after hv_cpu_die() disables the > HV_X64_MSR_VP_ASSIST_PAGE, so hv_apic_eoi_write() may not write the EOI > MSR, if the apic_assist field's bit0 happens to be 1; as a result, Hyper-V > may not be able to deliver all the interrupts to the CPU, and the CPU may > not be stopped, and the kernel will hang soon. > > The VP ASSIST PAGE is an "overlay" page (see Hyper-V TLFS's Section > 5.2.1 "GPA Overlay Pages"), so with this fix we're sure the apic_assist > field is still zero, after the VP ASSIST PAGE is disabled. > > Fixes: ba696429d290 ("x86/hyper-v: Implement EOI assist") > Signed-off-by: Dexuan Cui > --- > arch/x86/hyperv/hv_init.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index 0e033ef11a9f..db51a301f759 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -60,8 +60,14 @@ static int hv_cpu_init(unsigned int cpu) > if (!hv_vp_assist_page) > return 0; > > + /* > + * The ZERO flag is necessary, because in the case of CPU offlining > + * the page can still be used by hv_apic_eoi_write() for a while, > + * after the VP ASSIST PAGE is disabled in hv_cpu_die(). > + */ > if (!*hvp) > - *hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL); > + *hvp = __vmalloc(PAGE_SIZE, GFP_KERNEL | __GFP_ZERO, > + PAGE_KERNEL); This is the allocation when the CPU is brought online for the first time. So what effect has zeroing at allocation time vs. offlining and potentially receiving IPIs? That allocation is never freed. Neither the comment nor the changelog make any sense to me. Thanks, tglx