lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <df16760f-b5fe-5af4-18a1-fbb450d772a4@arm.com>
Date:   Mon, 29 Apr 2019 16:12:03 +0100
From:   Robin Murphy <robin.murphy@....com>
To:     Julien Grall <julien.grall@....com>, linux-kernel@...r.kernel.org,
        iommu@...ts.linux-foundation.org
Cc:     logang@...tatee.com, douliyangs@...il.com,
        miquel.raynal@...tlin.com, marc.zyngier@....com,
        jason@...edaemon.net, tglx@...utronix.de, joro@...tes.org,
        bigeasy@...utronix.de, linux-rt-users@...r.kernel.org
Subject: Re: [PATCH v2 1/7] genirq/msi: Add a new field in msi_desc to store
 an IOMMU cookie

On 29/04/2019 15:44, Julien Grall wrote:
> When an MSI doorbell is located downstream of an IOMMU, it is required
> to swizzle the physical address with an appropriately-mapped IOVA for any
> device attached to one of our DMA ops domain.
> 
> At the moment, the allocation of the mapping may be done when composing
> the message. However, the composing may be done in non-preemtible
> context while the allocation requires to be called from preemptible
> context.
> 
> A follow-up change will split the current logic in two functions
> requiring to keep an IOMMU cookie per MSI.
> 
> A new field is introduced in msi_desc to store an IOMMU cookie. As the
> cookie may not be required in some configuration, the field is protected
> under a new config CONFIG_IRQ_MSI_IOMMU.
> 
> A pair of helpers has also been introduced to access the field.

Reviewed-by: Robin Murphy <robin.murphy@....com>

> Signed-off-by: Julien Grall <julien.grall@....com>
> 
> ---
>      Changes in v2:
>          - Update the commit message to use imperative mood
>          - Protect the field with a new config that will be selected by
>          IOMMU_DMA later on
>          - Add a set of helpers to access the new field
> ---
>   include/linux/msi.h | 26 ++++++++++++++++++++++++++
>   kernel/irq/Kconfig  |  3 +++
>   2 files changed, 29 insertions(+)
> 
> diff --git a/include/linux/msi.h b/include/linux/msi.h
> index 7e9b81c3b50d..82a308c19222 100644
> --- a/include/linux/msi.h
> +++ b/include/linux/msi.h
> @@ -77,6 +77,9 @@ struct msi_desc {
>   	struct device			*dev;
>   	struct msi_msg			msg;
>   	struct irq_affinity_desc	*affinity;
> +#ifdef CONFIG_IRQ_MSI_IOMMU
> +	const void			*iommu_cookie;
> +#endif
>   
>   	union {
>   		/* PCI MSI/X specific data */
> @@ -119,6 +122,29 @@ struct msi_desc {
>   #define for_each_msi_entry_safe(desc, tmp, dev)	\
>   	list_for_each_entry_safe((desc), (tmp), dev_to_msi_list((dev)), list)
>   
> +#ifdef CONFIG_IRQ_MSI_IOMMU
> +static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc)
> +{
> +	return desc->iommu_cookie;
> +}
> +
> +static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc,
> +					     const void *iommu_cookie)
> +{
> +	desc->iommu_cookie = iommu_cookie;
> +}
> +#else
> +static inline const void *msi_desc_get_iommu_cookie(struct msi_desc *desc)
> +{
> +	return NULL;
> +}
> +
> +static inline void msi_desc_set_iommu_cookie(struct msi_desc *desc,
> +					     const void *iommu_cookie)
> +{
> +}
> +#endif
> +
>   #ifdef CONFIG_PCI_MSI
>   #define first_pci_msi_entry(pdev)	first_msi_entry(&(pdev)->dev)
>   #define for_each_pci_msi_entry(desc, pdev)	\
> diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
> index 5f3e2baefca9..8fee06625c37 100644
> --- a/kernel/irq/Kconfig
> +++ b/kernel/irq/Kconfig
> @@ -91,6 +91,9 @@ config GENERIC_MSI_IRQ_DOMAIN
>   	select IRQ_DOMAIN_HIERARCHY
>   	select GENERIC_MSI_IRQ
>   
> +config IRQ_MSI_IOMMU
> +	bool
> +
>   config HANDLE_DOMAIN_IRQ
>   	bool
>   
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ