Commit Graph

10 Commits

Author SHA1 Message Date
Ruslan Bukin
dc08d52d1e smmu: fix FDT and !FDT builds.
Reviewed by:	andrew
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D37762
2022-12-21 15:53:09 +00:00
Ruslan Bukin
4b4e8cb53a smmu: set guest address space range to 48-bit, which is a hardware
limit in our configuration.

Reviewed by:	andrew
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D37756
2022-12-21 15:53:05 +00:00
Alan Cox
4670f90846 iommu_gas: Eliminate redundant parameters and push down lock acquisition
Since IOMMU map entries store a reference to the domain in which they
reside, there is no need to pass the domain to iommu_gas_free_entry(),
iommu_gas_free_space(), and iommu_gas_free_region().

Push down the acquisition and release of the IOMMU domain lock into
iommu_gas_free_space() and iommu_gas_free_region().

Both of these changes allow for simplifications in the callers of the
functions without really complicating the functions themselves.
Moreover, the latter change eliminates the direct use of the IOMMU
domain lock from the x86-specific DMAR code.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35995
2022-07-30 14:28:48 -05:00
Alan Cox
8bc3673847 iommu_gas: Eliminate a possible case of use-after-free
Eliminate a possible case of use-after-free in an error handling path
after a mapping failure.  Specifically, eliminate IOMMU_MAP_ENTRY_QI_NF
and instead perform the IOTLB invalidation synchronously.  Otherwise,
when iommu_domain_unload_entry() is called and told not to free the
IOMMU map entry, the caller could free the entry before dmar_qi_task()
is finished with it.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35878
2022-07-25 11:14:58 -05:00
Ruslan Bukin
41ce5498f8 Add OFW support to arm64's IOMMU framework.
This is needed to support non-PCI devices like memory-mapped
display controllers.
Split-out some initialization code from iommu_ctx_alloc() into
iommu_ctx_init() method so we could pass controller's MD-data
obtained from DTS to the driver prior to a CTX initialization.

Tested on Morello SoC.

Sponsored by:	UKRI
2022-05-18 14:11:23 +01:00
Ruslan Bukin
0a8e88fa73 Change __unused to __diagused.
Pointed out by:	jhb
Sponsored by:	UKRI
2022-05-09 11:24:47 +01:00
Ruslan Bukin
7d0bbf43fd Change iommu list lock to SX as we need a sleepable lock so we
can call to ofw_bus_iommu_map().

Sponsored by:	UKRI
2022-05-07 11:15:07 +01:00
Ruslan Bukin
59446e8ac0 Fix !INVARIANTS build.
Sponsored by:	UKRI
2022-05-07 10:45:33 +01:00
Ruslan Bukin
6ff004272a Return error code from IOMMU_MAP and fix build.
Sponsored by:	UKRI
2022-05-07 10:24:30 +01:00
Ruslan Bukin
4cc8701067 Introduce IOMMU support for arm64 platform.
This adds an arm64 iommu interface and a driver for Arm System Memory
Management Unit version 3.2 (ARM SMMU v3.2) specified in ARM IHI 0070C
document.

Hardware overview is provided in the header of smmu.c file.

The support is disabled by default. To enable add 'options IOMMU' to your
kernel configuration file.

The support was developed on Arm Neoverse N1 System Development Platform
(ARM N1SDP), kindly provided by ARM Ltd.

Currently, PCI-based devices and ACPI platforms are supported only.
The support was tested on IOMMU-enabled Marvell SATA controller,
Realtek Ethernet controller and a TI xHCI USB controller with a low to
medium load only.

Many thanks to Konstantin Belousov for help forming the generic IOMMU
framework that is vital for this project; to Andrew Turner for adding
IOMMU support to MSI interrupt code; to Mark Johnston for help with SMMU
page management; to John Baldwin for explaining various IOMMU bits.

Reviewed by:	mmel
Relnotes:	yes
Sponsored by:	DARPA / AFRL
Sponsored by:	Innovate UK (Digital Security by Design programme)
Differential Revision:	https://reviews.freebsd.org/D24618
2020-11-16 21:55:52 +00:00