iommu分析之---iommu的内核参数解析

更新时间:2023-07-20 09:19:28 阅读: 评论:0

iommu分析之---iommu的内核参数解析iommu的两⼤功能,⼀个是dma 映射,⼀个是中断的映射。本⽂简单描述对应的内核参数解析。
1、在iommu 内核参数的解析的 x86架构整体部分
iommu=  [x86] off
force
noforce
biomerge
panic
nopanic
merge
nomerge
soft            //caq:没有iommu硬件,使⽤软件来达到iommu的功能,主要是针对bounce buffering
pt  [x86]
nopt  [x86]
nobypass [PPC/POWERNV] Disable IOMMU bypass, using IOMMU for PCI devices.
对应的代码解析为:
static __init int iommu_tup(char *p)
{
iommu_merge = 1;//caq:默认使能sg合并
找实习if (!p)
return -EINVAL;
while (*p) {
if (!strncmp(p, "off", 3))//caq:不要iommu功能,不管是硬件的iommu还是 swiotlb
no_iommu = 1;
/* gart_par_options has more force support */
if (!strncmp(p, "force", 5))//caq: 强制使⽤硬件IOMMU,即使硬件可能有缺陷或者机器内存很少
force_iommu = 1;
if (!strncmp(p, "noforce", 7)) {//caq:默认就是⾮强制,此时会设置 force_iommu 为0
iommu_merge = 0;
force_iommu = 0;
}
if (!strncmp(p, "biomerge", 8)) {//caq:和 merge 参数⼀样
iommu_merge = 1;
force_iommu = 1;
}
if (!strncmp(p, "panic", 5))//caq:dma_map_area overflow时是否触发panic
panic_on_overflow = 1;
if (!strncmp(p, "nopanic", 7))//caq:dma_map_area overflow 时是否关闭panic
panic_on_overflow = 0;
if (!strncmp(p, "merge", 5)) {//caq:会强制iommu,并且要求"scatter-gather"合并
iommu_merge = 1;
force_iommu = 1;
}
if (!strncmp(p, "nomerge", 7))//caq:禁⽌"scatter-gather"合并,主要⽤于分散聚集dma
iommu_merge = 0;
if (!strncmp(p, "forcesac", 8))//caq:过期的参数了
pr_warn("forcesac option ignored.\n");
if (!strncmp(p, "allowdac", 8))//caq:同上
pr_warn("allowdac option ignored.\n");
if (!strncmp(p, "nodac", 5))//caq:同上
pr_warn("nodac option ignored.\n");
if (!strncmp(p, "udac", 6)) {//caq: udac ⼀般也不配置,这样disable_dac_quirk 默认为0
disable_dac_quirk = true;//caq:将32位PCI地址⽤两个时钟周期推⼊64位地址,这就是DAC的作⽤。
return 1;
}
#ifdef CONFIG_SWIOTLB
if (!strncmp(p, "soft", 4))//caq:使⽤ swiotlb ,主要⽤于bounce buffering,拷贝+sync
swiotlb = 1;
#endif
if (!strncmp(p, "pt", 2))
iommu_pass_through = 1;//caq:设置为pt,则使能 iommu_pass_through
if (!strncmp(p, "nopt", 4))//caq:设置了nopt,则关闭 iommu_pass_through
iommu_pass_through = 0;
gart_par_options(p);
#ifdef CONFIG_CALGARY_IOMMU
if (!strncmp(p, "calgary", 7))//caq:IBM Calgary 的⽀持,我们⼀般⽤不到
u_calgary = 1;
#endif /* CONFIG_CALGARY_IOMMU */
p += strcspn(p, ",");
if (*p == ',')
++p;
}
return 0;
}
另外还有⼀个参数
iommu.passthrough= [ARM64] Configure DMA to bypass the IOMMU by default.
Format: { "0" | "1" } 0 - U IOMMU translation for DMA. 1 - Bypass the IOMMU for DMA.
unt - U IOMMU translation for DMA.经济英语
虽然写的是arm64,但是实际代码的作⽤区域是:
static int __init iommu_t_def_domain_type(char *str)
{
bool pt;
int ret;
ret = kstrtobool(str, &pt);
if (ret)
return ret;
污染英文
iommu_def_domain_type = pt ? IOMMU_DOMAIN_IDENTITY : IOMMU_DOMAIN_DMA;//为0则us IOMMU
肝爽颗粒说明书
return 0;
}
early_param("iommu.passthrough", iommu_t_def_domain_type);//caq:是否设定iommu.default_domain的是否bypass---注意,并不⼀定指arm64 2、在iommu 内核参数的解析的 intel 硬件部分:
intel_iommu= [DMAR] Intel IOMMU driver (DMAR) option
on
Enable intel iommu driver.
off
Disable intel iommu driver.
igfx_off [Default Off]
By default, gfx is mapped as normal device. If a gfx
device has a dedicated DMAR unit, the DMAR unit is
bypasd by not enabling DMAR with this option. In
this ca, gfx device will u physical address for
DMA.
forcedac [x86_64]
With this option iommu will not optimize to look
for io virtual address below 32-bit forcing dual
address cycle on pci bus for cards supporting greater
than 32-bit addressing. The default is to look
for translation below 32-bit and if not available
then look in the higher range.
张重新strict [Default Off]
With this option on every unmap_single operation will
result in a hardware IOTLB flush operation as oppod
to batching them for performance.
sp_off [Default Off]
By default, super page will be supported if Intel IOMMU
has the capability. With this option, super page will
not be supported.
ecs_off [Default Off]
By default, extended context tables will be supported if
the hardware advertis that it has support both for the
extended tables themlves, and also PASID support. With
this option t, extended tables will not be ud even
on hardware which claims to support them.
tboot_noforce [Default Off]
Do not force the Intel IOMMU enabled under tboot.
By default, tboot will force Intel IOMMU on, which
could harm performance of some high-throughput
devices like 40GBit network cards, even if identity
mapping is enabled.
Note that using this option lowers the curity
provided by tboot becau it makes the system
vulnerable to DMA attacks.
对应的内核代码
static int __init intel_iommu_tup(char *str)//caq:cmdline参数设定
{
if (!str)
return -EINVAL;
while (*str) {
if (!strncmp(str, "on", 2)) {//caq:开启 intel_iommu 驱动
dmar_disabled = 0;
pr_info("IOMMU enabled\n");
} el if (!strncmp(str, "off", 3)) {//caq:关闭 inetl_iommu 驱动
dmar_disabled = 1;
pr_info("IOMMU disabled\n");
} el if (!strncmp(str, "igfx_off", 8)) {//caq:开启则意味着:allows the GPU to access the physical memory directly without going through the DMAR
dmar_map_gfx = 0;
pr_info("Disable GFX device mapping\n");
} el if (!strncmp(str, "forcedac", 8)) {//caq:强制PCI设备使⽤DAC,从⽽禁⽌进⾏地址转换
pr_info("Forcing DAC for PCI devices\n");
dmar_forcedac = 1;
} el if (!strncmp(str, "strict", 6)) {//caq:带strict 参数,禁⽌批量刷写IOTLB
pr_info("Disable batched IOTLB flush\n");
intel_iommu_strict = 1;
} el if (!strncmp(str, "sp_off", 6)) {//caq:关闭super page⽀持(默认值为开启),⾮4k的page叫超级页  pr_info("Disable supported super page\n");
intel_iommu_superpage = 0;
} el if (!strncmp(str, "ecs_off", 7)) {//caq:ecs 就是 extended context
printk(KERN_INFO
"Intel-IOMMU: disable extended context table support\n");
intel_iommu_ecs = 0;
} el if (!strncmp(str, "pasid28", 7)) {//caq: pasid ⽀持
printk(KERN_INFO
"Intel-IOMMU: enable pre-production PASID support\n");
intel_iommu_pasid28 = 1;
七年级上册地理期中试卷iommu_identity_mapping |= IDENTMAP_GFX;
} el if (!strncmp(str, "tboot_noforce", 13)) {//caq:安全boot
printk(KERN_INFO
"Intel-IOMMU: not forcing on after tboot. This could expo curity risk for tboot\n");
intel_iommu_tboot_noforce = 1;
}
str += strcspn(str, ",");
投资啦
while (*str == ',')
str++;
}
return 0;
传感器网络
}

本文发布于:2023-07-20 09:19:28,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1088860.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:硬件   参数   解析   内核   强制   对应
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图