Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1648742pxy; Mon, 2 Aug 2021 07:03:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDNhk3CK9IQEftdQjvP+iF9Ggl1ID+GTFoW/6GeFVSMakx6Y+hZZzJt0vWiiRedUZvpiaj X-Received: by 2002:a17:906:828a:: with SMTP id h10mr15521839ejx.15.1627913038315; Mon, 02 Aug 2021 07:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913038; cv=none; d=google.com; s=arc-20160816; b=KHqs9mgrd2Yppk3eZpOSK/Le6Ss7OjBTHA2Xn23q7cQf55sY3hA1ACAIluNoVftlJf X9SMwhZbEW3q14zvOJDrv8hXips0cIhjqVARu5cBkne5GU2n8Ic+gV26EsTKHRE/N3x9 mktoL9u8tHA87NLGnuUFn3U61s2B6xXWR4fKoYYFeH68aOGu98hUqxY4dVheOSFlnZK4 g1Dfo6lCjSq7Rz5jx0hzVOx4tiklYCsKWeV9CplZ5Yw579PtARG+efeNc3yw0mWoVhbR LvnJby1GVIrCOqwE1L9fiR/LcGy0hLPbILqC0fA6icONFca5A77Nb9ansr6LxlYJ11J7 l1hw== 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=FzecgBJ9Zzyxuo0gz+8XmQb6ZKh1dgxUgNv3kpXvNV4=; b=uOhkQqGckRBfm2sZxyC/Csb1lgvbfhIp90jN0nLWaPX8ItdsKD6DouFaUW1zMepzvG BqvFLzOKw7HC0j6lYzASEH4mSSFuzX7qFSTrzwpfRP+4yWtpVz9l0ioyVLOpvlswt4Fe /NyqwcfT7m+kcP/+9GuHwe3mbox38RY6oF3Y3FqakLLpOMkIEYB35BoRkJzq0pkvrLVq 53WrQ6GrLfuVi6caonMujhlS3EJB9C3bsFSJuFGncld1g5RTYV93r0Df3QhoflEeQP+g 3BK2Ak3PbNzI+/lNRsoTWdLL0y8WMVckdIfNLR/DXuja+Np+PBXPo+TmGg3rrEY9FbmB yeJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XpempK6M; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si10022061edr.112.2021.08.02.07.03.35; Mon, 02 Aug 2021 07:03:58 -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=@linuxfoundation.org header.s=korg header.b=XpempK6M; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236536AbhHBN7i (ORCPT + 99 others); Mon, 2 Aug 2021 09:59:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:33468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235758AbhHBNyV (ORCPT ); Mon, 2 Aug 2021 09:54:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 858B66115B; Mon, 2 Aug 2021 13:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912363; bh=RUh4AusaX0Jn78izoGVYrMovVe91oBO13ieA2j5M3WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XpempK6MNjUJtMTHfxZl+7VbH/gJvredy6pPgwf6OBIUIgzaGt0kEhrYvSKN7/Uz9 CNuaeG3NDMM3pUvWeUoopnxSnnBamnV/r4yE52eltG6azW6YCy+kPitS3C0TtdEclh gDMlaElIi2opMOGseRacbx0a7z+aDjtaUDNO3H6U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Paolo Bonzini Subject: [PATCH 5.10 08/67] x86/kvm: fix vcpu-id indexed array sizes Date: Mon, 2 Aug 2021 15:44:31 +0200 Message-Id: <20210802134339.303797471@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134339.023067817@linuxfoundation.org> References: <20210802134339.023067817@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit 76b4f357d0e7d8f6f0013c733e6cba1773c266d3 upstream. KVM_MAX_VCPU_ID is the maximum vcpu-id of a guest, and not the number of vcpu-ids. Fix array indexed by vcpu-id to have KVM_MAX_VCPU_ID+1 elements. Note that this is currently no real problem, as KVM_MAX_VCPU_ID is an odd number, resulting in always enough padding being available at the end of those arrays. Nevertheless this should be fixed in order to avoid rare problems in case someone is using an even number for KVM_MAX_VCPU_ID. Signed-off-by: Juergen Gross Message-Id: <20210701154105.23215-2-jgross@suse.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/ioapic.c | 2 +- arch/x86/kvm/ioapic.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/arch/x86/kvm/ioapic.c +++ b/arch/x86/kvm/ioapic.c @@ -96,7 +96,7 @@ static unsigned long ioapic_read_indirec static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic) { ioapic->rtc_status.pending_eoi = 0; - bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID); + bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_ID + 1); } static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic); --- a/arch/x86/kvm/ioapic.h +++ b/arch/x86/kvm/ioapic.h @@ -43,13 +43,13 @@ struct kvm_vcpu; struct dest_map { /* vcpu bitmap where IRQ has been sent */ - DECLARE_BITMAP(map, KVM_MAX_VCPU_ID); + DECLARE_BITMAP(map, KVM_MAX_VCPU_ID + 1); /* * Vector sent to a given vcpu, only valid when * the vcpu's bit in map is set */ - u8 vectors[KVM_MAX_VCPU_ID]; + u8 vectors[KVM_MAX_VCPU_ID + 1]; };