Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1247840

Re: [PATCH] iommu/vt-d: Use cmpxchg16b to update posted format IRTE atomically

From Joerg Roedel <joro@8bytes.org>
Newsgroups linux.kernel
Subject Re: [PATCH] iommu/vt-d: Use cmpxchg16b to update posted format IRTE atomically
Date 2015-10-15 16:30 +0200
Message-ID <qjRHz-AM-1@gated-at.bofh.it> (permalink)
References <qjGCt-1cI-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Oct 15, 2015 at 10:19:11AM +0800, Feng Wu wrote:
> If IRTE is in posted format, the 'pda' field goes across the 64-bit
> boundary, we need use cmpxchg16b to atomically update it. We only
> expose posted-interrupt when X86_FEATURE_CX16 is supported and use
> to update it atomically.
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
>  drivers/iommu/intel_irq_remapping.c | 33 ++++++++++++++++++++++++++++++---
>  1 file changed, 30 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
> index f15692a..b4f7569 100644
> --- a/drivers/iommu/intel_irq_remapping.c
> +++ b/drivers/iommu/intel_irq_remapping.c
> @@ -169,8 +169,26 @@ static int modify_irte(struct irq_2_iommu *irq_iommu,
>  	index = irq_iommu->irte_index + irq_iommu->sub_handle;
>  	irte = &iommu->ir_table->base[index];
>  
> -	set_64bit(&irte->low, irte_modified->low);
> -	set_64bit(&irte->high, irte_modified->high);
> +#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE)
> +	if ((irte->pst == 1) || (irte_modified->pst == 1)) {
> +		bool ret;
> +
> +		ret = cmpxchg_double(&irte->low, &irte->high,
> +				     irte->low, irte->high,
> +				     irte_modified->low, irte_modified->high);
> +		/*
> +		 * We use cmpxchg16 to atomically update the 128-bit IRTE,
> +		 * and it cannot be updated by the hardware or other processors
> +		 * behind us, so the return value of cmpxchg16 should be the
> +		 * same as the old value.
> +		 */
> +		BUG_ON(!ret);

Changed this to a WARN_ON, otherwise applied.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] iommu/vt-d: Use cmpxchg16b to update posted format IRTE atomically Feng Wu <feng.wu@intel.com> - 2015-10-15 04:40 +0200
  Re: [PATCH] iommu/vt-d: Use cmpxchg16b to update posted format IRTE  atomically Joerg Roedel <joro@8bytes.org> - 2015-10-15 16:30 +0200
    RE: [PATCH] iommu/vt-d: Use cmpxchg16b to update posted format IRTE  atomically "Wu, Feng" <feng.wu@intel.com> - 2015-10-16 03:10 +0200

csiph-web