Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp936610pxb; Wed, 6 Apr 2022 04:48:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPpC4B7lTnavuNMVGigjFAkYr6Jy/zQWztNuC/Jq/tbJrRPB262kDoz5sRWNeSyIXqKVuH X-Received: by 2002:a17:902:6ac9:b0:156:a6ae:8806 with SMTP id i9-20020a1709026ac900b00156a6ae8806mr8071321plt.148.1649245696214; Wed, 06 Apr 2022 04:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649245696; cv=none; d=google.com; s=arc-20160816; b=l90hBnV63eMnEGo9O4QM+F9gON+k5AyvHi8bAbk+fJUwUAza6OqDIWZEVfW6HCsNLr kUex9FhZZbjFyP5lt+FrgOXPJR3Re84zJ4rETuLjX3+O0FiNueF3uLuV7guCBZ8DB66V rXAO/yE7vYALKn8YT1CtbjJQ8ribibX2kF0IfnkUAA1eoP54HWovqNMeAY8Ak2shyrkK qiJef2sIZgJYFS7C/qibuHrcAtnO3ngAI1szkvYv68y/Y7x+rHvP5C1oigxzC9Dwicht c6tXHk8RiNQBovesYsH4PErWgqgwcNOnQvm7GVor8J8cE7eBzMQbT42dglURLQcP9YQR xvhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RgVE3d1g0Giq1Ia3tAiUJx2FLUqtt967cNYNpyNRDzo=; b=McrK2HkJfMUzX9toKfRHfoFdqiwIR5YSWr4L8JG+AMULwcibvHfoYhrtyb5TyYb6kA gLBGITfE1/1HNGFw0Gn7Z93gC2JXqzS7Nwqrwh0grf+woaV/HdXT0wgkV8Q5W1bFY3TM n3RQen0HgH5+aIZ8lEsQK24Qa3mMCgkj3rqwVfGNLmPmlECcqG4jCA8IdknRZkqOTDPu X7okcxytgINMYXbvmBeFAOXb/b7/tj+ArWSPUq2ufeD5+8wwhhr6Q0ZBdX80zYFju/jO UtCt2P3iM+F/81R6lvBmPU5hkb186xFV+WFpVskvu+avIMoGhwhEkjMt0WJlMo456Rgx BXxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lNosqq45; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j5-20020a170902da8500b00153b2d164fesi15770331plx.262.2022.04.06.04.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:48:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lNosqq45; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C9E562E295; Wed, 6 Apr 2022 03:04:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1588521AbiDFAQS (ORCPT + 99 others); Tue, 5 Apr 2022 20:16:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348292AbiDEKqX (ORCPT ); Tue, 5 Apr 2022 06:46:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76E8A3BF9C; Tue, 5 Apr 2022 03:27:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 20914B81B18; Tue, 5 Apr 2022 10:27:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80C88C385A1; Tue, 5 Apr 2022 10:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649154423; bh=6s8Mzie2AFhL2yK/V+uTCor2gmt/8PXKkWyJk7em4Dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lNosqq45mn/5P0piyi39l5Mx/N0iPCjfmK/c9YZORABZGO5POfc/hLxZMHjDx6Ghm BrBRcheUB36A4uHc2SF/AiZMYtsjJBP4xWeg1uQFKUi2MHJcVj7dQT2wKCryYosOtm +tteDgC01msvK3vjGYRQIIesYCV3jQjMBxmttutQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li RongQing , Paolo Bonzini Subject: [PATCH 5.10 535/599] KVM: x86: fix sending PV IPI Date: Tue, 5 Apr 2022 09:33:49 +0200 Message-Id: <20220405070314.761817677@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Li RongQing commit c15e0ae42c8e5a61e9aca8aac920517cf7b3e94e upstream. If apic_id is less than min, and (max - apic_id) is greater than KVM_IPI_CLUSTER_SIZE, then the third check condition is satisfied but the new apic_id does not fit the bitmask. In this case __send_ipi_mask should send the IPI. This is mostly theoretical, but it can happen if the apic_ids on three iterations of the loop are for example 1, KVM_IPI_CLUSTER_SIZE, 0. Fixes: aaffcfd1e82 ("KVM: X86: Implement PV IPIs in linux guest") Signed-off-by: Li RongQing Message-Id: <1646814944-51801-1-git-send-email-lirongqing@baidu.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -532,7 +532,7 @@ static void __send_ipi_mask(const struct } else if (apic_id < min && max - apic_id < KVM_IPI_CLUSTER_SIZE) { ipi_bitmap <<= min - apic_id; min = apic_id; - } else if (apic_id < min + KVM_IPI_CLUSTER_SIZE) { + } else if (apic_id > min && apic_id < min + KVM_IPI_CLUSTER_SIZE) { max = apic_id < max ? max : apic_id; } else { ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,