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

Re: [PATCH 2/2] iommu/amd-vi: do not zero IOMMU MMIO region


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 6 May 2026 11:20:41 +0200
  • 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=arcselector10001; 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=YPHHiUiuLqgfish+YgdymKrKWY6+zChykta0zLxzCAs=; b=B47ioxsamy78zfe4kB/dOpo/+HXEYA9WwwZHWVKKP7bsjg64WtOl9aIC/yvYhzF12Yuusnj0shLVl6fSNLpeprm31hiI5iQQNEbnUys0jMkw9ujPRW5gGePLBrwoRBsiH44JfuT/qinteLdO3KaRYm7nvqfuyPmZp+fi1KslAaZ6LzRnAyOx2LFgdeqviK/40lEafCW1TSBc3KgUoFNAeU9a7fBEpgE8L958sug4FMz+nmtp6iya06NsvYnc3rwYFEkHHXW+CGhLz7O6KXXc8zNpWt/vnFDgSB5bfKxCMv7ovMqfCgVesqtpNi1znlaaBceF7PGa1aT4oy1eJNlk+g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EvqPwXoDLrhkk+X74SOSuu/s64FsSwTypKH58C3d43I65+f6nAGNzoS6brCv9qNMZ+wa0Z4oh6ufHhC6vrJ1wpJAAtwWFIHE+H6ksZ8VidTUFrdpUpIXYaD8giGM5ZdczdxxqoVZ/TattXW/CaBXVpp/bi9dEabaiKbbkMB2HH3yQmrgQ7BmESpFBEW6XJVXFvpsrb+0xNnORaGLM0JzoEeoZtjQN2/rCmGZ5qrzqdNua3U1vfRpWxfv3IZEVjqcu0V9iG8JMt3SKdBL8wc4/ITRXh4k9adDMhrh3xB2madzv4iVo1QePaFfw84KLZJcjuqyRFPsXMM2oAoOExFXBA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 06 May 2026 09:25:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, May 06, 2026 at 11:17:25AM +0200, Jan Beulich wrote:
> On 06.05.2026 10:43, Roger Pau Monné wrote:
> > On Wed, May 06, 2026 at 10:28:52AM +0200, Jan Beulich wrote:
> >> On 06.05.2026 09:37, Roger Pau Monne wrote:
> >>> @@ -1381,6 +1372,11 @@ static int __init amd_iommu_prepare_one(struct 
> >>> amd_iommu *iommu)
> >>>      if ( amd_iommu_max_paging_mode < amd_iommu_min_paging_mode )
> >>>          return -ERANGE;
> >>>  
> >>> +    /* Read current control register and forcefully disable the IOMMU. */
> >>> +    iommu->ctrl.raw = readq(iommu->mmio_base + 
> >>> IOMMU_CONTROL_MMIO_OFFSET);
> >>> +    disable_iommu(iommu, true);
> >>
> >> Don't you also need to pre-fill iommu->features?
> > 
> > Indeed, that's done just ahead of this chunk, in the
> > get_iommu_features() call.
> > 
> >> And with that field's use in
> >> disable_iommu(), won't we be at risk of leaving stuff enabled which we are
> >> entirely unaware of?
> > 
> > Possibly, yes, that's always a risk.
> > 
> >> Even if we fully cleared the control register (which
> >> would eliminate the need to fetch features), down the road a 2nd control
> >> register could appear.
> > 
> > We do clear the control register, it's indirectly done by us setting
> > iommu->ctrl.raw = 0 after the disable_iommu() call.
> > 
> > I did wonder about just doing a write of 0 to the control register,
> > but I think it's best if we try to gracefully disable the features (as
> > done in disable_iommu()), and then reset the cached control state to
> > 0.  Future writes to the control register will clear any bits not
> > directly set by Xen.
> 
> Maybe better to explicitly write out that 0 right away, even if you want
> to keep using disable_iommu()?

Yeah, I also considered that.  So after disable_iommu() set the cached
control state to 0 and also zero the control register right there.
Can do in the next version, unless there are further objections.

Thanks, Roger.



 


Rackspace

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