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

RE: [PATCH 5/9] VT-d: clear_fault_bits() should clear all fault bits


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Thu, 24 Jun 2021 05:26:36 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.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-SenderADCheck; bh=djNODLt35QTS7t4/ieOj6WwOOJ4gFG8CEHvyfn7Wtwk=; b=R17Jc8jviyBSOGeil5OyOY/TaduKjaLW83qR/GDamiNGJlfKgFwIvQJ1npXaSBU4+oBRmxms6YyenS3bbKTyxp7bC2nVFHK4Tqa3Tm9VzxanJDt5eRPz1AXyd8ml5eHh9wgov838G2CMBiNlu0xfdCg4OA1+/AYqE4QoPVLdvQGTlcjCIl12rl8kyc/BnhsdVDIv3wtnrK4F8qBQ3m4yY/ve5LxjX779ej5JAdJsakERQWCYpaCCsaqltwGq6DznEMgbBNqzc10VJIuQG2eD+pLy5H3d1rU9dNyEwvZLsz73M1aOSMz652j63IhFOetE8ql8FvT8UzleyQRbGudgzQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SuqeXCJ26dDwO9w8fYLtlzYR73+yzpadYsvkGsRdztLHbGJXVUgDAZIJOaTBvdcmPZW04p+r6C6+eQpsd9yIfdrLKJBqyvMv3Mxbjnq1tjnNwsEC4HFWHKm6YG69tSyKaUBc/T6cEoJNltqJ+N0UQYYJlz0GhQJvwutZo1HqZLjcMd83MK1t64UeOtJG/WPHwjqDWsOaxgDYQ/Z2gRVtprFeGB4Aygs4p2lIX5R95026+s8XZUZDMtv6sEA9LLHSA89h8Gm9c7t/0QrAgauihDZeS3Kc+rOvG09TFrIkYRHr1tMbI+Kygj+Pk/tEX4nHEeduLPNHHgraoeyZQ2oLiQ==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=intel.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, "Cooper, Andrew" <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 24 Jun 2021 05:26:46 +0000
  • Dlp-product: dlpe-windows
  • Dlp-reaction: no-action
  • Dlp-version: 11.5.1.3
  • Ironport-sdr: szcB3hnL/FVTFBdCh/BhP9GK0vJ1zZQ6fFitURnykpUzOwM7IGglChAjdGax+7Xk5ZvQlKN/2H NeuxJcUZY51g==
  • Ironport-sdr: I43Owi9I8MA/hGYTbm3W8sUPPIcksCmsgDtFkKeA2umb/RHqsDk1MV32VWi1KmMR9HdjiIrost bDxmtjDGgSFA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXXRHg+9thH88smkqcPcG6zIlV0KsiuMOg
  • Thread-topic: [PATCH 5/9] VT-d: clear_fault_bits() should clear all fault bits

> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Wednesday, June 9, 2021 5:29 PM
> 
> If there is any way for one fault to be left set in the recording
> registers, there's no reason there couldn't also be multiple ones. If
> PPF set set (being the OR or all F fields), simply loop over the entire
> range of fault recording registers, clearing F everywhere.
> 
> Since PPF is a r/o bit, also remove it from DMA_FSTS_FAULTS (arguably
> the constant's name is ambiguous as well).
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

> 
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -2094,13 +2094,23 @@ static int __hwdom_init setup_hwdom_devi
> 
>  void clear_fault_bits(struct vtd_iommu *iommu)
>  {
> -    u64 val;
>      unsigned long flags;
> 
>      spin_lock_irqsave(&iommu->register_lock, flags);
> -    val = dmar_readq(iommu->reg, cap_fault_reg_offset(iommu->cap) + 8);
> -    dmar_writeq(iommu->reg, cap_fault_reg_offset(iommu->cap) + 8, val);
> +
> +    if ( dmar_readl(iommu->reg, DMAR_FSTS_REG) & DMA_FSTS_PPF )
> +    {
> +        unsigned int reg = cap_fault_reg_offset(iommu->cap);
> +        unsigned int end = reg + cap_num_fault_regs(iommu->cap);
> +
> +        do {
> +           dmar_writel(iommu->reg, reg + 12, DMA_FRCD_F);
> +           reg += PRIMARY_FAULT_REG_LEN;
> +        } while ( reg < end );
> +    }
> +
>      dmar_writel(iommu->reg, DMAR_FSTS_REG, DMA_FSTS_FAULTS);
> +
>      spin_unlock_irqrestore(&iommu->register_lock, flags);
>  }
> 
> --- a/xen/drivers/passthrough/vtd/iommu.h
> +++ b/xen/drivers/passthrough/vtd/iommu.h
> @@ -174,9 +174,8 @@
>  #define DMA_FSTS_IQE (1u << 4)
>  #define DMA_FSTS_ICE (1u << 5)
>  #define DMA_FSTS_ITE (1u << 6)
> -#define DMA_FSTS_FAULTS (DMA_FSTS_PFO | DMA_FSTS_PPF |
> DMA_FSTS_AFO | \
> -                         DMA_FSTS_APF | DMA_FSTS_IQE | DMA_FSTS_ICE | \
> -                         DMA_FSTS_ITE)
> +#define DMA_FSTS_FAULTS (DMA_FSTS_PFO | DMA_FSTS_AFO |
> DMA_FSTS_APF | \
> +                         DMA_FSTS_IQE | DMA_FSTS_ICE | DMA_FSTS_ITE)
>  #define dma_fsts_fault_record_index(s) (((s) >> 8) & 0xff)
> 
>  /* FRCD_REG, 32 bits access */


 


Rackspace

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