Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp738677pxu; Wed, 6 Jan 2021 03:07:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvYu+eBh1bg7V54J9MyHGX5Ezc6/rMaossxza3WGvagOp71G1ksak3cVzdEs7BmvHXB2N4 X-Received: by 2002:a17:906:3101:: with SMTP id 1mr2538403ejx.115.1609931249984; Wed, 06 Jan 2021 03:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609931249; cv=none; d=google.com; s=arc-20160816; b=qjyYkd+AAUdlmqULwPahyBWG+41/hxHiUasj7hi+AjauW8tITuUQzCLxEMms5lj9Ny 6z3abzt2LNtDOXnqPMFDRMjVx9cpU3FqD7noxq4m9t0LK9eUnTcp8BCVG/HYPiCJO4sa WqdJa4N2fbG+bfpEUZwJX6AGoBQLptFH6gOwrDQ9lyt0mNy20mO7H74jWMhJg3zU71IE u8wVWHOqZzI0ugz3TggfC7E9oXhlp85OWLawH8EnOfVtYdUYQCuw9ObCsBgdfQiT3NwD GP+capbSWF7MruKCl2dnP/TNnH+5p5YH3QWM0zQStZPlBth3PaJCfUea3b+Dd5fyc5Kh eI9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ERKXqQidLzskfZDszvErSOtk7AjjY2xYUr+92HjKwIk=; b=fTSchcFl4YzZmbx1/EZT37CXVLB1vLYrBO5E1AJQm4+LutEPQ406UevfQdw6ctVcV3 HV2UabpTT4MKoUnBCbCTUme0n3Sl0fws0QiXd0o//Dw8mNm/yPTnZOt5vw+qI4QJjM8n e42JB5TUQJ37uNI8CV7NwfRG2XzhAHPeeqyzPCm+XXIfSrIP+yhK2f2hWSM4Eyk3Mn/9 ELvXz7HsMDsYy866pFEfT57gjN0U/UZwUiS4nkkOPdsH6VVvOUqohBJJLpu1ewCxh3ay dULS23Ec4sWl1thAybKT7kQ830DJWyqJOAWr7qRavSrgCCgAPKlGGDwHOlbMuGB4UTiJ iu9g== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 11si754483ejw.721.2021.01.06.03.07.04; Wed, 06 Jan 2021 03:07:29 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726389AbhAFLFV (ORCPT + 99 others); Wed, 6 Jan 2021 06:05:21 -0500 Received: from mail-wr1-f49.google.com ([209.85.221.49]:46202 "EHLO mail-wr1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725822AbhAFLFU (ORCPT ); Wed, 6 Jan 2021 06:05:20 -0500 Received: by mail-wr1-f49.google.com with SMTP id d13so1993898wrc.13; Wed, 06 Jan 2021 03:05:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ERKXqQidLzskfZDszvErSOtk7AjjY2xYUr+92HjKwIk=; b=aC3gbCwm+A8U7a1vITiDwHxhTFVQFjJxC1MWNGVegBAkU40oLzsbO8G5a1G9vnS71X +AH51Zbg5HeGh16LemqGywLA2YfpSFKWV3DTwykbR0KtT8buaFpRVWNVfz46H5lT5Jag NsND9KFQmCi7NPmi7Grw/mCbOQZiYyZsaybPdXv4gt2P5ZaDsEQaXoonLu3E7FNsiM/1 PTMry+0shYMurTp5qtQm0nKI1IsIdUbR9E9G6XurPm+QtpVGCpwSq5QwyBSe+wuaQgnY aMe9TubDglTlKymLVrleHtKVke2z4406a9et+X7pKjU//ZTBX0GxHlAEsAZ4ej49HjRM qkcw== X-Gm-Message-State: AOAM531466CDt0pmfEtuAbqV/YhAzBmsn939YSuW/JqlecYnTo/3iSgW Ot3C6oubLziqM9Ng3hmRSIr2Yt8MmnM= X-Received: by 2002:a05:6000:1188:: with SMTP id g8mr3889805wrx.111.1609931077934; Wed, 06 Jan 2021 03:04:37 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id k6sm2711898wmf.25.2021.01.06.03.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 03:04:37 -0800 (PST) Date: Wed, 6 Jan 2021 11:04:35 +0000 From: Wei Liu To: Michael Kelley Cc: Wei Liu , Linux on Hyper-V List , "stable@kernel.org" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH] x86/hyperv: check cpu mask after interrupt has been disabled Message-ID: <20210106110435.cajpxwbew4t5afye@liuwe-devbox-debian-v2> References: <20210105175043.28325-1-wei.liu@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 05, 2021 at 06:20:05PM +0000, Michael Kelley wrote: > From: Wei Liu Sent: Tuesday, January 5, 2021 9:51 AM > > > > We've observed crashes due to an empty cpu mask in > > hyperv_flush_tlb_others. Obviously the cpu mask in question is changed > > between the cpumask_empty call at the beginning of the function and when > > it is actually used later. > > > > One theory is that an interrupt comes in between and a code path ends up > > changing the mask. Move the check after interrupt has been disabled to > > see if it fixes the issue. > > > > Signed-off-by: Wei Liu > > Cc: stable@kernel.org > > --- > > arch/x86/hyperv/mmu.c | 12 +++++++++--- > > 1 file changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c > > index 5208ba49c89a..2c87350c1fb0 100644 > > --- a/arch/x86/hyperv/mmu.c > > +++ b/arch/x86/hyperv/mmu.c > > @@ -66,11 +66,17 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus, > > if (!hv_hypercall_pg) > > goto do_native; > > > > - if (cpumask_empty(cpus)) > > - return; > > - > > local_irq_save(flags); > > > > + /* > > + * Only check the mask _after_ interrupt has been disabled to avoid the > > + * mask changing under our feet. > > + */ > > + if (cpumask_empty(cpus)) { > > + local_irq_restore(flags); > > + return; > > + } > > + > > flush_pcpu = (struct hv_tlb_flush **) > > this_cpu_ptr(hyperv_pcpu_input_arg); > > > > -- > > 2.20.1 > > Reviewed-by: Michael Kelley > Applied to hyperv-fixes. Wei.