Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1643006pxy; Mon, 2 Aug 2021 06:57:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9frNv+wqqsGiO04rq/t0W2ttDR8+U1yJno6kqDvmK1/k7XOve2/qy9fk7fjqOf8v0i6kv X-Received: by 2002:a92:c52e:: with SMTP id m14mr1048055ili.257.1627912633714; Mon, 02 Aug 2021 06:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912633; cv=none; d=google.com; s=arc-20160816; b=DZZvc4uQMToii39pY7m0RJ3iIXrFmHBvd1VcvL3Uic5d/P8oPzOIaYZ00NSW9WVfaf sldfz54YBAQK+KKhcL1eXk6IVJg9/R2SiHEk5eFhxVgb4vNwAMyIR7E8NKL2wO4QNyW6 xbFqwJRSUYi9gaSa1WbRil2a0alUp04giJaSFsmw6UiEppHFQrsDJXTJyNTN1WB+7i0W DD2oKltuUAtgndpzuv9gAWk7Fo6Da5QpOHXhiDQhluR1zu+VnPq5PvBDKo5RrI5jRYlY VMCs5knixLAnDC5aop+kKWnuJo3jg1faAT7puAkVLm2eF2YvLC8MAtSPYRG/ftYLBwMj 2udw== 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=HnabpnZU9s61zP1aE0rkZAq1gcMKAePMc6/acPaeVKtDIoVbQMEmGHMeLlyM1vRuhc OV4fW084AEG1Bx3QB72vvG/4XPo4JhZ1dc0E2UjxaWj2XdjuZJg6wk1FXNpvggPpSB0F BQyMTAlKonqtSq7II8t8Ryd+DD9HIe4oNGapsxDxq5dvm+xqd9RiD9ZxbxZul4lQp15i hlmO2WaucBTJzky+GqVlqpVcMuWg0R/5qW3oy06OScnUJZzCBJUMA7b5pG7YzBPHowvF DhqKApOT5xJ/QTA6vtJfZtfxN93/j3tMn+op0q1wmXNcpBKVkmXv91S1/Jyvokkbi9R/ eD9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pWUBmbe7; 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 u6si8967457ilq.19.2021.08.02.06.57.01; Mon, 02 Aug 2021 06:57:13 -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=pWUBmbe7; 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 S235877AbhHBNyc (ORCPT + 99 others); Mon, 2 Aug 2021 09:54:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234335AbhHBNts (ORCPT ); Mon, 2 Aug 2021 09:49:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D2D2060FF2; Mon, 2 Aug 2021 13:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912178; bh=RUh4AusaX0Jn78izoGVYrMovVe91oBO13ieA2j5M3WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pWUBmbe7rMfJpqm6z2XYyohA2EGOtoLzRbRw5z+OiT4stuhcLNv8VWNiXeoPYkFiS nwVYUmV2B9Bd8jsmGkmYMstOn3iIRA2pd5v5DEu8HbWgJE1Ft8v7g1XH7nK7jMxssz 99033Vo35MEslJNbk0Ae7ZeXAwHNZpBouZV96fUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Paolo Bonzini Subject: [PATCH 4.19 05/30] x86/kvm: fix vcpu-id indexed array sizes Date: Mon, 2 Aug 2021 15:44:43 +0200 Message-Id: <20210802134334.254730840@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134334.081433902@linuxfoundation.org> References: <20210802134334.081433902@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]; };