进程切换 之 switch_mm_irqs_off

博客内容主要涉及Linux内核中的进程切换过程,特别是`switch_mm_irqs_off`函数与`WRMSR`(Write to Model Specific Register)指令的使用。内容提到了在内核版本4.4引入的`switch_mm_irqs_off`函数,以及该函数在处理间接分支预测器(IBPB)时如何通过`wrmsr`接口写入Model Specific Register(MSR)。同时,文章讨论了`switch_mm_irqs_off`中可能导致异常的情况,如尝试写入保留或未实现的MSR地址,以及如何通过内核启动参数控制相关安全特性。
摘要由CSDN通过智能技术生成

 

 

   74.474853] ACPI: Low-level resume complete
[   74.480221] PM: Restoring platform NVS memory
[   74.489112] Enabling non-boot CPUs ...
[   74.493513] x86: Booting SMP configuration:
[   74.498341] smpboot: Booting Node 0 Processor 1 APIC 0x1
[   74.507285]  cache: parent cpu1 should not be sleeping
[   74.513420] CPU1 is up
[   74.516196] smpboot: Booting Node 0 Processor 2 APIC 0x2
[   74.525792]  cache: parent cpu2 should not be sleeping
[   74.532148] CPU2 is up
[   74.534929] smpboot: Booting Node 0 Processor 3 APIC 0x3
[   74.543873]  cache: parent cpu3 should not be sleeping
[   74.549929] CPU3 is up
[   74.552669] smpboot: Booting Node 0 Processor 4 APIC 0x4
[   74.562247]  cache: parent cpu4 should not be sleeping
[   74.568451] CPU4 is up
[   74.571326] smpboot: Booting Node 0 Processor 5 APIC 0x5
[   74.580175]  cache: parent cpu5 should not be sleeping
[   74.586215] CPU5 is up
[   74.588939] smpboot: Booting Node 0 Processor 6 APIC 0x6
[   74.598292]  cache: parent cpu6 should not be sleeping
[   74.604653] CPU6 is up
[   74.607406] smpboot: Booting Node 0 Processor 7 APIC 0x7
[   74.616139]  cache: parent cpu7 should not be sleeping
[   74.622206] CPU7 is up
[   74.624915] smpboot: Booting Node 0 Processor 8 APIC 0x8
[   74.634096]  cache: parent cpu8 should not be sleeping
[   74.640432] CPU8 is up
[   74.643389] smpboot: Booting Node 0 Processor 9 APIC 0x9
[   74.651888]  cache: parent cpu9 should not be sleeping
[   74.657977] CPU9 is up
[   74.660680] smpboot: Booting Node 0 Processor 10 APIC 0xa
[   74.669746]  cache: parent cpu10 should not be sleeping
[   74.676259] CPU10 is up
[   74.679161] smpboot: Booting Node 0 Processor 11 APIC 0xb
[   74.687636]  cache: parent cpu11 should not be sleeping
[   74.693824] CPU11 is up
[   74.696603] smpboot: Booting Node 0 Processor 12 APIC 0xc
[   74.702671] general protection fault: 0000 [#1] SMP NOPTI
[   74.708739] CPU: 8 PID: 0 Comm: swapper/8 Tainted: G           O      4.19.0-desktop-amd64 #3100
[   74.718575] Hardware name: Suma W3330H0/22DB4, BIOS CWTQ051207 06/02/2021
[   74.726191] RIP: 0010:switch_mm_irqs_off+0x3ec/0x4f0
[   74.731763] Code: 7d 08 49 83 c5 18 4c 89 fa 31 f6 e8 ce 56 99 00 49 8b 45 00 48 85 c0 75 e5 e9 73 ff ff ff b9 49 00 00 00 b8 01 00 00 00 31 d2 <0f> 30 e9 86 fc ff ff e9 81 00 00 00 48 c7 c2 e0 19 02 00 31 c0 65
[   74.752755] RSP: 0018:ffffa98a4329be30 EFLAGS: 00010046
[   74.758616] RAX: 0000000000000001 RBX: ffff8e3a8be02200 RCX: 0000000000000049
[   74.766619] RDX: 0000000000000000 RSI: ffff8e3a8be02200 RDI: ffff8e3a8ba2d880
[   74.774612] RBP: ffffffffbd07ca60 R08: ffff8e3a9ee22ae0 R09: 0000000000000000
[   74.782605] R10: 0000000000000000 R11: 0000001113e35491 R12: 0000000000000008
[   74.790598] R13: ffff8e3a8ba2d880 R14: ffffffffbd07ca60 R15: ffff8e3a8be02200
[   74.798598] FS:  0000000000000000(0000) GS:ffff8e3a9ee00000(0000) knlGS:0000000000000000
[   74.807662] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   74.814103] CR2: 0000000000000000 CR3: 000000062da0a000 CR4: 00000000003406e0
[   74.822096] Call Trace:
[   74.824865]  __schedule+0x260/0x840
[   74.828794]  schedule_idle+0x1e/0x40
[   74.832812]  do_idle+0x165/0x250
[   74.836450]  cpu_startup_entry+0x6f/0x80
[   74.840854]  start_secondary+0x1a4/0x200
[   74.845264]  secondary_startup_64+0xa4/0xb0
[   74.849963] Modules linked in: dm_mod bnep fuse cfg80211 st sr_mod amd64_edac_mod joydev cdrom edac_mce_amd kvm_amd bluetooth drbg ansi_cprng ecdh_generic rfkill nls_ascii nls_cp437 vfat fat snd_hda_codec_hdmi snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_timer snd kvm soundcore irqbypass sg pcspkr efi_pstore efivars k10temp ccp pcc_cpufreq evdev acpi_cpufreq mincores(O) i2c_dev vfs_monitor(O) binfmt_misc efivarfs ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 fscrypto ecb crypto_simd cryptd glue_helper aes_x86_64 btrfs xor zstd_compress raid6_pq libcrc32c crc32c_generic zstd_decompress xxhash amdgpu chash gpu_sched hid_generic usbhid hid sd_mod radeon i2c_algo_bit ahci ttm libahci drm_kms_helper libata r8169 realtek crc32c_intel scsi_mod drm libphy button
[   74.926832] ---[ end trace a4da77854ee63e9f ]---
[   74.932012] RIP: 0010:switch_mm_irqs_off+0x3ec/0x4f0
[   74.937582] Code: 7d 08 49 83 c5 18 4c 89 fa 31 f6 e8 ce 56 99 00 49 8b 45 00 48 85 c0 75 e5 e9 73 ff ff ff b9 49 00 00 00 b8 01 00 00 00 31 d2 <0f> 30 e9 86 fc ff ff e9 81 00 00 00 48 c7 c2 e0 19 02 00 31 c0 65
[   74.958575] RSP: 0018:ffffa98a4329be30 EFLAGS: 00010046
[   74.964434] RAX: 0000000000000001 RBX: ffff8e3a8be02200 RCX: 0000000000000049
[   74.972419] RDX: 0000000000000000 RSI: ffff8e3a8be02200 RDI: ffff8e3a8ba2d880
[   74.980412] RBP: ffffffffbd07ca60 R08: ffff8e3a9ee22ae0 R09: 0000000000000000
[   74.988405] R10: 0000000000000000 R11: 0000001113e35491 R12: 0000000000000008
[   74.996398] R13: ffff8e3a8ba2d880 R14: ffffffffbd07ca60 R15: ffff8e3a8be02200
[   75.004391] FS:  0000000000000000(0000) GS:ffff8e3a9ee00000(0000) knlGS:0000000000000000
[   75.013454] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   75.019893] CR2: 0000000000000000 CR3: 000000062da0a000 CR4: 00000000003406e0
[   75.027888] Kernel panic - not syncing: Attempted to kill the idle task!
[   76.307847] Shutting down cpus with NMI
[   76.312170] Kernel Offset: 0x3b000000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
[   76.324234] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---

 

$ cat obj.txt |grep switch_mm_irq
ffffffff8106d480 <switch_mm_irqs_off>:
ffffffff8106d4b5:       0f 84 1d 02 00 00       je     ffffffff8106d6d8 <switch_mm_irqs_off+0x258>
ffffffff8106d4c1:       74 43                   je     ffffffff8106d506 <switch_mm_irqs_off+0x86>
ffffffff8106d4cd:       74 37                   je     ffffffff8106d506 <switch_mm_irqs_off+0x86>
ffffffff8106d4cf:       e9 2d 00 00 00          jmpq   ffffffff8106d501 <switch_mm_irqs_off+0x81>
ffffffff8106d4ec:       74 0b    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

proware

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值