All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Kevin Tian <kevin.tian@intel.com>, Ian Jackson <iwj@xenproject.org>
Subject: [PATCH 1/4][4.15?] VT-d: correct off-by-1 in number-of-IOMMUs check
Date: Thu, 18 Mar 2021 11:13:22 +0100	[thread overview]
Message-ID: <68084b4f-bcd2-59dd-bea7-781b8aa75ef7@suse.com> (raw)
In-Reply-To: <c19fe2b5-b682-374c-d30f-83fb8b367286@suse.com>

Otherwise, if we really run on a system with this many IOMMUs,
entering/leaving S3 would overrun iommu_state[].

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
There are more anomalies here, but since we were asked to not make any
cosmetic changes for patches to have a chance to go into 4.15, I've put
off correcting even the most obvious things (scope of MAX_IOMMUS and
nr_iommus) for a later patch.

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1168,10 +1168,10 @@ int __init iommu_alloc(struct acpi_drhd_
     unsigned long sagaw, nr_dom;
     int agaw;
 
-    if ( nr_iommus > MAX_IOMMUS )
+    if ( nr_iommus >= MAX_IOMMUS )
     {
         dprintk(XENLOG_ERR VTDPREFIX,
-                 "IOMMU: nr_iommus %d > MAX_IOMMUS\n", nr_iommus);
+                "IOMMU: nr_iommus %d > MAX_IOMMUS\n", nr_iommus + 1);
         return -ENOMEM;
     }
 



  reply	other threads:[~2021-03-18 10:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 10:12 [PATCH 0/4][4.15?] VT-d: mostly S3 related corrections Jan Beulich
2021-03-18 10:13 ` Jan Beulich [this message]
2021-03-23 13:31   ` [PATCH 1/4][4.15?] VT-d: correct off-by-1 in number-of-IOMMUs check Ian Jackson
2021-03-18 10:13 ` [PATCH 2/4][4.15?] VT-d: leave FECTL write to vtd_resume() Jan Beulich
2021-03-18 10:14 ` [PATCH 3/4][4.15?] VT-d: re-order register restoring in vtd_resume() Jan Beulich
2021-03-18 10:15 ` [PATCH 4/4][4.15?] VT-d: restore flush hooks when disabling qinval Jan Beulich
2021-03-23  8:12 ` [PATCH 0/4][4.15?] VT-d: mostly S3 related corrections Tian, Kevin
2021-03-23 13:27   ` Jan Beulich
2021-03-23 13:37     ` Ian Jackson
2021-03-30 12:22       ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68084b4f-bcd2-59dd-bea7-781b8aa75ef7@suse.com \
    --to=jbeulich@suse.com \
    --cc=iwj@xenproject.org \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.