[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/3] AMD/IOMMU: iommu_enable vs iommu_intremap


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 2 Nov 2021 15:59:26 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S++vtPwOdNCj2y2NfpBgHT5ySSjxkdoiNpJml/6d3AI=; b=bIZsZ0QoW9PW5S4VOFeZdKO3PoWVdkNGbztVlkjUKI0ghITxZlCTkJIZD4keh5YjI7KfNBZ3EjRHCrSgw1cuyQxT10fsZCH+f/cRVuQOh8DqXA+oqVa3iIlcx7sU3cqWwzcDMWqxB93UuqU+Y4h5gEthf6OWvHAqT/s4pCUAT2TSxrQUQ5w6x3whR81O3hHcIxVWyKNvolbQZ/NveSWAlb2lllwAXvXKepT0KSY8MG+4v6sOx0vo0OdbxnYnk7wKAAfe32g6i43ndci5pdm8jvZJH4l5Gbu/8hx4RI/8HkUPmzBP/XGbWrkc9vTI7KoocinjQQaMlRk4HcNQxu2XUw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h+8WRUuhrO2B4mYjNcl7MNqxUBRyQKX4rTa6o6n1VCCnIIjaYi1nqgtn0/8zQR4UNfjbem+Egu4YTXpFLBq+PSCZaEQS9YdHFsFeYgQNPVqg1vWKLqXvCQT+0+Nb4SbNwwTVNXX4iP1jQQ3VpZuqkHs3YYyX1gxXAWhr6q290vuZZd1ZB8G4yfYW4eBOqz0uOxtZr2OzkN/P0x7zg5495QA9BfZkybjCz8pgLa0Wb5jWWQBsdOJ6V0nyUCz2pfH+0F3wrY7L1hZH9ELEkqC4pPIRz0BGZYK92I/jLRvX7krPCOqaeI/b7qV1sXgA568KqY4IxwsiFZM7bxMIwmZ9Kg==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Tue, 02 Nov 2021 15:00:12 +0000
  • Ironport-data: A9a23:N7zQMaiEOzwZZ+4hs6wllSE7X161lBcKZh0ujC45NGQN5FlHY01je htvXTjUbKuCMDOnfYx2YIy09EIGv8LVzNYyHlFk+Xo9Hyob9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oAMKRCQ7InQLlbGILes1htZGEk0F0/NtTo5w7Rg29cw24Dja++wk YiaT/P3aQfNNwFcagr424rbwP+4lK2v0N+wlgVWicFj5DcypVFMZH4sDfjZw0/DaptVBoaHq 9Prl9lVyI97EyAFUbtJmp6jGqEDryW70QKm0hK6UID66vROS7BbPg/W+5PwZG8O4whlkeydx /0dkMHrbhwYA5eSlecMVR5bNyUgZ5ZvreqvzXiX6aR/zmXDenrohf5vEFs3LcsT/eMf7WNmr KJCbmpXN1ba2rzwkOnTpupE36zPKOHxO4wSoDd4xCzxBvc6W5HTBa7N4Le02R9t2JAQQKiAP qL1bxJPSg7uPTltOm0NN7sh2/W0hiTzKzRh/Qf9Sa0fvDGIkV0ZPKLWGMXRUsyHQ4NShEnwj nrP4mDREhwcctuFxlKt8Hihm+vOliPTQ58JGfuz8fsCqE2ewCkfBQMbUXO/oOKlkQiuVtRHM UsW9yEy668o+ySWosLVBkPi5iTe51h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rREGgP1/qG/9SkIVyCygc/79 YgT0EdMqyKMbESt6+Ti2PUf6dCsbu6GeKT9J3jJhxWPGZXgtRbnn5E43GgYytLrWd9dP4EPa vZwvACiyureHwRYMj+LGICRfL/q9rCk4+jSQIaBjY8gTP+zQ+A2frfKVy1zx0eWzRAzfMJ6m 7eiTH04a2lrrWS1gLc7WnO9J5b8eGRieerRfb8yPT9GA+czjpAV74RHIFqewpF5t1H3Wxa1e UkZS1QZvibpUmhJl1d6iGdpTUImAxemkMKj2Xo2kcL6PaJNw7TB6d69PJkWwqc5Ew6sN5m1q VXm2qfqppMFBvF2D/w/t7SSnhR5weJSFcZ4KUuZkZkIMEjgX5q3Psi1VIQFI1FEDPx6YghHu UrBMbA5OxOeVffa3zCpGFgzNGlQ3x2R369Mwc/k93Q1yITkGFyzkMeysBalnAc9IglQ50B4+ jfKKxnmLxHU8dTZ6NgA+UKR9exFwX2MF7xGXPXJU6iGLAMOnrLpZKy6LIp5PuycJhN15c2kI SpaiIRiYfzQTOmNSSj5uw/zvn9ehTKYd228LAt23FQgMyJeIbW
  • Ironport-sdr: mS4kfjS1rtxCVtOIOgesasxYRTT25Qh50f+zHYqn+SuUHbWb1CJ4xy4G9vnCupfEmNp5wADdPt Y85QkBBm8nkzHlWjTM+lEzwXq2D0RfDiDYmW+L4iCdLC9EyKOxdoy4MmeOC72DdnLCIeXnvos/ 6olRUOuCNf4rZzeOtJMrvlZX5ocp0VjIs8BLkgOpSsW8zDrBTKnuT2ZgXIvB8MF1adX+N9Kfjc GooFOUUybgYe3nOi2z0+5taHc4/1PViLx03kTmnWz2QuK3p8PVezTSkdY8+ydTEtn2HWEgjqfe unQH9tiULvj9cwiaWvDAcppH
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Nov 02, 2021 at 03:00:24PM +0100, Jan Beulich wrote:
> On 02.11.2021 12:03, Roger Pau Monné wrote:
> > On Tue, Nov 02, 2021 at 11:13:08AM +0100, Jan Beulich wrote:
> >> On 25.10.2021 12:28, Roger Pau Monné wrote:
> >>> On Thu, Oct 21, 2021 at 11:59:02AM +0200, Jan Beulich wrote:
> >>>> The two are really meant to be independent settings; iov_supports_xt()
> >>>> using || instead of && was simply wrong. The corrected check is,
> >>>> however, redundant, just like the (correct) one in iov_detect(): These
> >>>> hook functions are unreachable without acpi_ivrs_init() installing the
> >>>> iommu_init_ops pointer, which it does only upon success. (Unlike for
> >>>> VT-d there is no late clearing of iommu_enable due to quirks, and any
> >>>> possible clearing of iommu_intremap happens only after iov_supports_xt()
> >>>> has run.)
> >>>>
> >>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> >>>> ---
> >>>> In fact in iov_detect() it could be iommu_enable alone which gets
> >>>> checked, but this felt overly aggressive to me. Instead I'm getting the
> >>>> impression that the function may wrongly not get called when "iommu=off"
> >>>> but interrupt remapping is in use: We'd not get the interrupt handler
> >>>> installed, and hence interrupt remapping related events would never get
> >>>> reported. (Same on VT-d, FTAOD.)
> >>>
> >>> I've spend a non-trivial amount of time looking into this before
> >>> reading this note. AFAICT you could set iommu=off and still get x2APIC
> >>> enabled and relying on interrupt remapping.
> >>
> >> Right, contrary to ...
> >>
> >>>> For iov_supports_xt() the question is whether, like VT-d's
> >>>> intel_iommu_supports_eim(), it shouldn't rather check iommu_intremap
> >>>> alone (in which case it would need to remain a check rather than getting
> >>>> converted to ASSERT()).
> >>>
> >>> Hm, no, I don't think so. I think iommu_enable should take precedence
> >>> over iommu_intremap, and having iommu_enable == false should force
> >>> interrupt remapping to be reported as disabled. Note that disabling it
> >>> in iommu_setup is too late, as the APIC initialization will have
> >>> already taken place.
> >>>
> >>> It's my reading of the command line parameter documentation that
> >>> setting iommu=off should disable all usage of the IOMMU, and that
> >>> includes the interrupt remapping support (ie: a user should not need
> >>> to set iommu=off,no-intremap)
> >>
> >> ... that documentation. But I think it's the documentation that
> >> wants fixing, such that iommu=off really only control DMA remap.
> > 
> > IMO I think it's confusing to have sub-options that could be enabled
> > when you set the global one to off. I would expect `iommu=off` to
> > disable all the iommu related options, and I think it's fair for
> > people to expect that behavior.
> > 
> > I'm unsure whether it's fair to change the documentation now, we
> > should instead fix the code, so that people using `iommu=off` get the
> > expected behavior. Then we would likely need to introduce a way to
> > disable just dma remapping (dmaremap, similar to intremap). That
> > would make a much better and saner interface IMO.
> 
> But from an x2APIC perspective it is a problem to have "iommu=off"
> also turn off intremap.

I think we could log a message in that case? (x2APIC could be enabled
but iommu explicitly disabled)

And maybe expand the documentation to notice that disabling the iommu
or interrupt remapping will disable x2APIC support.

> And indeed the option has never (fully)
> worked that way: It clears iommu_enable, but not iommu_intremap
> (nor any of the other sub-options, but there it's less of a problem
> because they're not used in isolation), and iommu_intremap only
> may have happened to either get turned off later or to not get
> evaluated in at least some of the case.

While I understand there's some baggage here, I'm not sure keeping the
current behavior is correct. I would rather have iommu=off to cover
all iommu functionality, and then we should add dmaremap sub-option to
disable remapping only. I think that would be a sane and logic
interface for users to understand.

We should also note the implications of disabling interrupt remapping
regarding x2APIC support in the documentation.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.