Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linux-6.6.y] iommu/vt-d: Add support for detecting ACPI namespace device in RMRR #261

Merged

Conversation

leoliu-oc
Copy link
Contributor

zhaoxin inclusion
category: feature
CVE: NA


As below, ZX-200 xHCI mcu is a RMRR ANDD device in some case.

[060h 0096 2] Subtable Type : 0001 [Reserved Memory Region
[062h 0098 2] Length : 0020

[064h 0100 2] Reserved : 0000
[066h 0102 2] PCI Segment Number : 0000
[068h 0104 8] Base Address : 00000000B5DA5000
[070h 0112 8] End Address (limit) : 00000000B5DDDFFF

[078h 0120 1] Device Scope Type : 05 [Namespace Device]
[079h 0121 1] Entry Length : 08
[07Ah 0122 2] Reserved : 0000
[07Ch 0124 1] Enumeration ID : 02
[07Dh 0125 1] PCI Bus Number : 09

[07Eh 0126 2] PCI Path : 12,00

iommu driver cannot find this device and build identity map for the RMRR region, DMAR faults would occur for xHCI controller.

Add func dmar_acpi_bus_add_dev to find the RMRR ANDD device.

Add func acpi_rmrr_andd_probe to build identity map for the RMRR region into the domain of the correspanding xHCI controller.

Add func iova_reserve_domain_addr to keep away from RMRR region when using dma iova.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xzl01 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot
Copy link

Hi @leoliu-oc. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.


ret = iommu_probe_device(dev);

iommu = device_lookup_iommu(dev, &bus, &devfn);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有报错 是不是使用了没定义的 device_lookup_iommu 函数?
drivers/iommu/intel/iommu.c: In function ‘acpi_rmrr_andd_probe’:
drivers/iommu/intel/iommu.c:3766:17: error: implicit declaration of function ‘device_lookup_iommu’; did you mean ‘device_to_iommu’? [-Werror=implicit-function-declaration]
3766 | iommu = device_lookup_iommu(dev, &bus, &devfn);
| ^~~~~~~~~~~~~~~~~~~
| device_to_iommu
drivers/iommu/intel/iommu.c:3766:15: error: assignment to ‘struct intel_iommu *’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion]
3766 | iommu = device_lookup_iommu(dev, &bus, &devfn);

Copy link
Contributor Author

@leoliu-oc leoliu-oc Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,这边测试时使用的是主线LTS-6.6分支源码,在最新主线源码中,device_to_iommu更新为了device_lookup_iommu。这边会修正后再提交。

zhaoxin inclusion
category: feature
CVE: NA

-----------------

As below, ZX-200 xHCI mcu is a RMRR ANDD device in some case.

[060h 0096   2]                Subtable Type : 0001 [Reserved Memory Region
[062h 0098   2]                       Length : 0020

[064h 0100   2]                     Reserved : 0000
[066h 0102   2]           PCI Segment Number : 0000
[068h 0104   8]                 Base Address : 00000000B5DA5000
[070h 0112   8]          End Address (limit) : 00000000B5DDDFFF

[078h 0120   1]            Device Scope Type : 05 [Namespace Device]
[079h 0121   1]                 Entry Length : 08
[07Ah 0122   2]                     Reserved : 0000
[07Ch 0124   1]               Enumeration ID : 02
[07Dh 0125   1]               PCI Bus Number : 09

[07Eh 0126   2]                     PCI Path : 12,00

iommu driver cannot find this device and build identity map for the RMRR
region, DMAR faults would occur for xHCI controller.

Add func dmar_acpi_bus_add_dev to find the RMRR ANDD device.

Add func acpi_rmrr_andd_probe to build identity map for the RMRR region
into the domain of the correspanding xHCI controller.

Add func iova_reserve_domain_addr to keep away from RMRR region when using
dma iova.

Signed-off-by: leoliu-oc <leoliu-oc@zhaoxin.com>
@opsiff
Copy link
Member

opsiff commented Jul 3, 2024

/ok-to-test

@opsiff opsiff merged commit 74f2cf3 into deepin-community:linux-6.6.y Jul 3, 2024
3 of 4 checks passed
@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • iova_reserve_domain_addr函数中,对cookie的检查可能不完整,应该考虑cookie为空的情况。
  • dmar_rmrr_acpi_insert_dev_scope函数中的path变量应该定义为struct acpi_dmar_pci_path *path类型,以避免类型不匹配的问题。
  • acpi_rmrr_andd_probe函数中的iommu_probe_device调用应该检查返回值,以确保设备正确地被 probed。
  • acpi_rmrr_andd_probe函数中的iommu_probe_device调用应该在iommu变量不为空的情况下使用,以避免潜在的空指针解引用问题。
  • acpi_rmrr_andd_probe函数中的acpi_rmrr_device_create_direct_mappings调用应该检查返回值,以确保映射成功创建。
  • dmar_rmrr_add_acpi_dev函数应该实现功能,而不是简单地返回0。
  • apply_zhaoxin_dmar_acpi_a_behavior函数中的条件判断应该使用include/linux/kconfig.h中的宏来简化代码。

是否建议立即修改:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants