Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp791935imm; Mon, 9 Jul 2018 10:42:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcDJUqA2zVep6zAD2kQoqyw1/s/mQBWWJgtEi8vCxP/M0OHoN4JTUpBQDvTZ/S2q45JAheb X-Received: by 2002:aa7:824d:: with SMTP id e13-v6mr5818925pfn.97.1531158122505; Mon, 09 Jul 2018 10:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531158122; cv=none; d=google.com; s=arc-20160816; b=dxSUoRxOKoz1a5FmsgBAkaVJ5QbT1yBK0l7/YPK/tAiXyRyzHDtrbWXcNCTOH5g3dP F7IBi71fLnjOEvDUSjcDliZhLQK9v4y7l4MWsS4mfZTzaUBsvcRtQ6pBXHIPAthGXvYR 46N/WXQPmxxh9t/44/kziVUfKnATQtRWpc6veThgGig81718IVTZQTsukDDsJmBv77fe 6YRL9OsMnv8nFKNv4a5JdQxeil9mMX88d3wlOCaRJWds0XX8NT8GFUY7UNebGHgPefqf qfDu80CHaTSbpgTTVN61NgSt5r4hiaEn1UxNTk+TdPPFb6umzIFS/tzXgiFF1X0PwyLO 3FJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=5m7e3pUL7aqPxDTAkkaqmMWZQ5gIlCn7STuCUTcmSvA=; b=Eh39zvP/ra40d0BEJK9BlVdTDrunicV4RGiqDs7Gy7ZsjiJJEPWSacULpLvri7FbiT XDyZlZ5Ez7nVWZgwEUEpbmvBE3hH5dfGA+uoLeHGgQcuQkLol57FQVvRvwUj4uYXbfSv nJJ4CR7o6u4+xVEHcTYcrXVu3vasodlakX0JOFKrVQbtz8iOaFqCekQdbrR56yE6riiK 9avsOX2NeH4QkSBI9F4YPdqq5oyxCUymykD7MWQo+VolyCuq11FfwCaEUnIxjMTmd0nU 4In769QvCjGUjl86qdU4Vw6mPJZgFPPVurZsmWahngP/o2NxU1A7lHpiLLDIg8UtStfs 4lDg== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si14737134plk.441.2018.07.09.10.41.47; Mon, 09 Jul 2018 10:42:02 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933969AbeGIRku (ORCPT + 99 others); Mon, 9 Jul 2018 13:40:50 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49154 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933795AbeGIRkU (ORCPT ); Mon, 9 Jul 2018 13:40:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A762A40201C9; Mon, 9 Jul 2018 17:40:19 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17A682156892; Mon, 9 Jul 2018 17:40:17 +0000 (UTC) From: Vitaly Kuznetsov To: x86@kernel.org Cc: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , devel@linuxdriverproject.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] x86/hyper-v: check for VP_INVAL in hyperv_flush_tlb_others() Date: Mon, 9 Jul 2018 19:40:12 +0200 Message-Id: <20180709174012.17429-3-vkuznets@redhat.com> In-Reply-To: <20180709174012.17429-1-vkuznets@redhat.com> References: <20180709174012.17429-1-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Jul 2018 17:40:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 09 Jul 2018 17:40:19 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 1268ed0c474a ("x86/hyper-v: Fix the circular dependency in IPI enlightenment") pre-filled hv_vp_index with VP_INVAL so it is now (theoretically) possible to observe hv_cpu_number_to_vp_number() returning VP_INVAL. We need to check for that in hyperv_flush_tlb_others(). Not checking for VP_INVAL on the first call site where we do if (hv_cpu_number_to_vp_number(cpumask_last(cpus)) >= 64) goto do_ex_hypercall; is OK, in case we're eligible for non-ex hypercall we'll catch the issue later in for_each_cpu() cycle and in case we'll be doing ex- hypercall cpumask_to_vpset() will fail. It would be nice to change hv_cpu_number_to_vp_number() return value's type to 'u32' but this will likely be a bigger change as all call sites need to be checked first. Fixes: 1268ed0c474a ("x86/hyper-v: Fix the circular dependency in IPI enlightenment") Signed-off-by: Vitaly Kuznetsov --- arch/x86/hyperv/mmu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index 453d2355cd61..1147e1fed7ff 100644 --- a/arch/x86/hyperv/mmu.c +++ b/arch/x86/hyperv/mmu.c @@ -111,6 +111,11 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus, for_each_cpu(cpu, cpus) { vcpu = hv_cpu_number_to_vp_number(cpu); + if (vcpu == VP_INVAL) { + local_irq_restore(flags); + goto do_native; + } + if (vcpu >= 64) goto do_ex_hypercall; -- 2.14.4