Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1647404pxy; Mon, 2 Aug 2021 07:02:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTSkpAKWaKlHwgPlkHVmt3iahHoptBT8VeTeKZO7RdRN9xsp6N3r/z9xxTOSZk6cW5q6db X-Received: by 2002:a05:6602:3304:: with SMTP id b4mr1555996ioz.186.1627912955219; Mon, 02 Aug 2021 07:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912955; cv=none; d=google.com; s=arc-20160816; b=T/FPf5Hkj0ixIbHCI3BOUaluYFTD/vq+I8VnjPQzahtuAWyQwycJfua0xMYgaI+ycx Gaj0JJM9n0Sflm4UZr6RgUnjP5vqf2/bHZwV0tYrCyvadzfr1CF+7f5bF2j5p+fSNdWk Qv272wpDA5GuExNML7ndQLItNXugS68av01hkG+LdetnXyvrnYCEoM6DyX5jj/Q9e6JA 9/ZL5UJ9/2CB/a7rTdhFERgnA7PJ3zjy8ysMtQbl9aw9OaOgnHVqggxqABJPI/yJlS0S Sb7FRaLAZ7zWBTYo2SaaEqoOiGcvP7S4XEfGha+Gyy95zBVdw8KsMhgsp3TiQ6FWxyFa wq3Q== 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=MyCa0S2FtzUK8wq3jzMRJMxChCl0cWqk0jcRsPCtaBk=; b=dtFMXZxONq6fc2y8VtxvWSFQA0Bnh6T5fBlEMFGn54HFKOeFJzGIUXi1/FsUXLdcvy V3t/fAlCkk6d0OCuMAD2N4d86v3nTICU6gTjcAs96jvcQC2H/ZXLli9SvfN0edbLEpbB dw4w9w4/EuMMh21e4mQ0XX5D0NpUUnbbPA+n+PoIj9SS5e0HcV/D8edVlxI+gXA1z8GI HFwfEMq0wAYu/M/EjQQUTT1PzD8zZSAuGgzybfzCXT7JjEPEH6iDUDv7VnzBTfD3tIeg zQqSEKWuzbFi3ebDpB/pgE8f4wKWLB5mlwvpvqWYAuV2PKLiscvvUzcFOtnMwD9UhmI6 mLxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mo+lvmKy; 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 m13si12977436jam.59.2021.08.02.07.02.18; Mon, 02 Aug 2021 07:02:35 -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=Mo+lvmKy; 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 S236308AbhHBN7T (ORCPT + 99 others); Mon, 2 Aug 2021 09:59:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:33684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235379AbhHBNxF (ORCPT ); Mon, 2 Aug 2021 09:53:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 83AB561152; Mon, 2 Aug 2021 13:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912324; bh=kLQyYho5OEJBNTSuOy5Qaz0n86WVDzpbQPXSzpVPAZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mo+lvmKyj3/4ZpU/tXhQ3NZY9X1gBm8cfFKSpMLL8OyZeBvpsmYlVNtQwzTnqx1LZ S6BIKMlaCSWOXsbHrO/ZBuq1voPVEaUsR4LmtsDaSSe2phmooyQvg3NELkOUmvaDay d8TWTFqiejlIEUGT88yzJdc6fEnrTOODbSfXGDyg= 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.4 06/40] x86/kvm: fix vcpu-id indexed array sizes Date: Mon, 2 Aug 2021 15:44:46 +0200 Message-Id: <20210802134335.604829665@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134335.408294521@linuxfoundation.org> References: <20210802134335.408294521@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 @@ -91,7 +91,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]; };