IOMMU打开 关闭

目录

1. 背景介绍

2. Arm iommu 打开

2.1 打开  iommu

2.2 生成配置

2.3 查看配置是否生效

3. X86 iommu 打开

3.1 打开  iommu

3.2 生成配置

3.3 查看配置是否生效


1. 背景介绍

打开关闭iommu

2. Arm iommu 打开

2.1 打开  iommu

开启/关闭iommu

1、ARM服务器上开启IOMMU

# 修改GRUB配置文件(通常在/etc/default/grub) 文件中“GRUB_CMDLINE_LINUX”对应行,添加“iommu.passthrough=0 iommu=on"

[root@localhost ~]# 
[root@localhost ~]# cat /etc/default/grub 
GRUB_TIMEOUT=5
#
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"

GRUB_CMDLINE_LINUX="crashkernel=1024M,high rd.lvm.lv=klas/root rd.lvm.lv=klas/swap video=VGA-1:640x480-32@60me rhgb quiet  smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me iommu=pt isolcpus=1,3 nohz_full=1,3 rcu_nocbs=1,3 idle=poll default_hugepagesz=2M hugepagesz=2M hugepages=1024"
GRUB_DISABLE_RECOVERY="true"
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-4.19.90-23.8.v2101.ky10.aarch64 root=/dev/mapper/klas-root ro crashkernel=1024M,high rd.lvm.lv=klas/root rd.lvm.lv=klas/swap video=VGA-1:640x480-32@60me rhgb quiet smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me iommu=pt isolcpus=1,3 nohz_full=1,3 rcu_nocbs=1,3 idle=poll default_hugepagesz=2M hugepagesz=2M hugepages=1024
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# vi /etc/default/grub 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cat /etc/default/grub 
GRUB_TIMEOUT=5
#
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"

GRUB_CMDLINE_LINUX="crashkernel=1024M,high rd.lvm.lv=klas/root rd.lvm.lv=klas/swap video=VGA-1:640x480-32@60me rhgb quiet  smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me iommu=pt isolcpus=1,3 nohz_full=1,3 rcu_nocbs=1,3 idle=poll default_hugepagesz=2M hugepagesz=2M hugepages=1024 iommu.passthrough=0 iommu=on"
GRUB_DISABLE_RECOVERY="true"
[root@localhost ~]# 


2.2 生成配置

注意“grub.cfg”所在目录在不同版本系统中会有所不同

执行“grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg” 生成配置,然后重启系统
 
注意“grub.cfg”所在目录在不同版本系统中会有所不同,


[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# ls /boot/grub*/grub.cfg 2>/dev/null || ls /boot/efi/EFI/*/grub.cfg 2>/dev/null
/boot/efi/EFI/kylin/grub.cfg     # 如果回显是/boot/grub2/grub.cfg,下面命令同步修改
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# grub2-mkconfig -o /boot/efi/EFI/kylin/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.19.90-23.8.v2101.ky10.aarch64
Found initrd image: /boot/initramfs-4.19.90-23.8.v2101.ky10.aarch64.img
Found linux image: /boot/vmlinuz-0-rescue-375913e1d4ba4c028b029fe067c61af0
Found initrd image: /boot/initramfs-0-rescue-375913e1d4ba4c028b029fe067c61af0.img
Found Kylin V10 (V10) on /dev/mapper/klas00-root
Adding boot menu entry for EFI firmware configuration
done
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# reboot

重启后,继续检查

2.3 查看配置是否生效

执行“cat /proc/cmdline”,查看配置是否生效
 
# cat /proc/cmdline


[root@localhost ~]# 
[root@localhost ~]# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-4.19.90-23.8.v2101.ky10.aarch64 root=/dev/mapper/klas-root ro crashkernel=1024M,high rd.lvm.lv=klas/root rd.lvm.lv=klas/swap video=VGA-1:640x480-32@60me rhgb quiet smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off video=VGA-1:640x480-32@60me iommu=pt isolcpus=1,3 nohz_full=1,3 rcu_nocbs=1,3 idle=poll default_hugepagesz=2M hugepagesz=2M hugepages=1024 iommu.passthrough=0 iommu=on
[root@localhost ~]# 

3. X86 iommu 打开

3.1 打开  iommu

1.  查询cpu 型号:

[root@localhost ~]# 
[root@localhost ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                40
On-line CPU(s) list:   0-39
Thread(s) per core:    2
Core(s) per socket:    10
座:                 2
NUMA 节点:         2
厂商 ID:           GenuineIntel
CPU 系列:          6
型号:              85
型号名称:        Intel(R) Xeon(R) Silver 4210R CPU @ 2.40GHz    # cpu Inter
.......  
.......  
.......  


2. 根据cpu 型号添加 字段
# CPU inter: intel_iommu=on  iommu=pt
# CPU AMD: amd_iommu=on iommu=pt


[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# vi  /etc/default/grub
[root@localhost ~]# 
[root@localhost ~]# cat  /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet isolcpus=1-3 default_hugepagesz=2M hugepagesz=2M hugepages=1024 intel_iommu=on iommu=pt"
GRUB_DISABLE_RECOVERY="true"
intel_iommu=on
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 


3.2 生成配置



3. 生成配置,然后重启系统
 
注意“grub.cfg”所在目录在不同版本系统中会有所不同,

[root@localhost ~]# 
[root@localhost ~]# ls /boot/grub*/grub.cfg 2>/dev/null
/boot/grub2/grub.cfg
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# ls /boot/efi/EFI/*/grub.cfg 2>/dev/null
/boot/efi/EFI/centos/grub.cfg    
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 

# X86 Centos 上以下2个路径都需要执行:
Path_1: grub2-mkconfig -o /boot/grub2/grub.cfg 
Path_2:grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.62.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.62.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.36.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.36.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-52d1fe1020fe44b2a095ce3f94ace989
Found initrd image: /boot/initramfs-0-rescue-52d1fe1020fe44b2a095ce3f94ace989.img
done
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg 
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.62.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.62.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.36.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.36.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-52d1fe1020fe44b2a095ce3f94ace989
Found initrd image: /boot/initramfs-0-rescue-52d1fe1020fe44b2a095ce3f94ace989.img
done
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-1160.62.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet isolcpus=1-3 default_hugepagesz=512M hugepagesz=512M hugepages=6
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# reboot

重启后,继续检查

3.3 查看配置是否生效

[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# cat /proc/cmdline 
BOOT_IMAGE=/vmlinuz-3.10.0-1160.62.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet isolcpus=1-3 default_hugepagesz=2M hugepagesz=2M hugepages=1024 intel_iommu=on iommu=pt
[root@localhost ~]# 

# 查看dmesg 信息

[root@localhost ~]# 
[root@localhost ~]# dmesg|grep -Ei iommu
[    0.000000] Command line: BOOT_IMAGE=(hd0,gpt2)/vmlinuz-4.18.0-348.7.1.el8_5.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto resume=/dev/mapper/cl-swap intel_iommu=on transparent_hugepage=never rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet intel_iommu=on iommu=pt
[    0.000000] Kernel command line: BOOT_IMAGE=(hd0,gpt2)/vmlinuz-4.18.0-348.7.1.el8_5.x86_64 root=/dev/mapper/cl-root ro crashkernel=auto resume=/dev/mapper/cl-swap inteliommu=on transparent_hugepage=never rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet intel_iommu=on iommu=pt
[    0.000000] DMAR: IOMMU enabled            # iommu on
[    0.000000] DMAR: IOMMU enabled
[    0.001025] DMAR-IR: IOAPIC id 2 under DRHD base  0xfed91000 IOMMU 1
[    0.209225] pci 0000:00:02.0: Skip IOMMU disabling for graphics
[    0.228003] iommu: Default domain type: Passthrough (set via kernel command line)
[    0.853220] DMAR: IOMMU feature fl1gp_support inconsistent
[    0.853220] DMAR: IOMMU feature pgsel_inv inconsistent
[    0.853220] DMAR: IOMMU feature nwfs inconsistent
[    0.853221] DMAR: IOMMU feature dit inconsistent
[    0.853221] DMAR: IOMMU feature sc_support inconsistent
[    0.853222] DMAR: IOMMU feature dev_iotlb_support inconsistent
[    0.853635] pci 0000:00:00.0: Adding to iommu group 0
[    0.853642] pci 0000:00:01.0: Adding to iommu group 1
[    0.853649] pci 0000:00:02.0: Adding to iommu group 2
[    0.853654] pci 0000:00:0a.0: Adding to iommu group 3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值