1. 09 8月, 2022 14 次提交
  2. 06 8月, 2022 1 次提交
    • O
      !53 Help to merge the bus lock detection and ratelimit feature for OpenEuler · c6897937
      openeuler-ci-bot 提交于
      Merge Pull Request from: @etzhao 
       
      Hi,
      
      Bus lock detection and ratelimit feature for OpenEuler backporting was tested Okay, help to review and merge
      
      Title: bus lock detection and ratelimit feature for OpenEuler.
      
      Content:
      Bus locks degrade performance for the whole system, not just for the CPU
      that requested the bus lock. Two CPU features "#AC for split lock" and
      "#DB for bus lock" provide hooks so that the operating system may choose
      one of several mitigation strategies.
      
      bus lock feature to cover additional situations with new options to
      mitigate.
      
      This patch set enables the bus lock detection functions and will limite 
      the warning message output rate to desired number.
      Intel-kernel issue:
      #I5G10C:SPR:Bus lock detection and ratelimit support
      
      Test:
      Bus lock detection/split lock disable test for OpenEuler
      
      Check If the CPU has the bus lock detection or split lock feature
      #cat /proc/cpuinfo |grep bus_lock_detect
      bus_lock_detect
      
      #cat /proc/cpuinfo |grep split_lock_detect
      split_lock_detect
      
      The result shows the "bus_lock_detect" or "split_lock_detect" pass
      
      warn mode, default is warn mode without any parameters to kernel command line.
      split lock detection is enabled by kernel
      
      dmesg |grep '#AC'
      [ 0.000000] x86/split lock detection: #AC: crashing the kernel on kernel split_locks and warning on user-space split_locks
      
      (seeing above, pass, or fail)
      
      Note the under default "warn" mode, bus lock detect handler is disabled, handled by split lock handler.
      
      #wget http://linux-os.sc.intel.com/~fyu/projects/split_lock/tests/split_lock_test_user.c
      #gcc -o split_lock_test_user split_lock_test_user.c
      
      #./split_lock_test_user
      This test both split lock(cross cache line) and bus lock (explict lock instruction)
      [67152.780022] x86/split lock detection: #AC: split_lock_test/284139 took a split_lock trap at address: 0x4011ab
      (seeing this, pass, or fail)
      
      Modify the split_lock_test_user.c to only trigger bus lock with 64 bytes aligned WB cached memory
      
      + /* iptr = (int *)(cptr + 61); */
      
       test_sigbus(iptr);
      
       free(cptr);
      
       return 0;
      }
      
      gcc -o split_lock_test_user split_lock_test_user.c
      #./split_lock_test_user
      #see dmesg, no warning message.
      
      Under your kernel source git repo directory.
      #git am 0001-x86-split-lock-vmdos-Test-split-lock-and-vmdos.patch
      #make
      #cd arch/x86/kernel/cpu/
      #insmod ./test_split_lock_drv.ko
      
      Got following panic message and panic pass or fail.
      
      [ 327.415019] split lock test: split lock address=0xff722131cce07bbd
      [ 327.415025] Split lock detected
      : 0000 [#1] SMP NOPTI
      [ 327.415048] CPU: 46 PID: 4952 Comm: insmod Tainted: G S
      [ 327.415069] Hardware name: Intel Corporation EAGLESTREAM/EAGLESTREAM,
      [ 327.415093] RIP: 0010:init_module+0x40/0x85 [test_split_lock_drv]
      [ 327.415107] Code: ec c0 00 00 00 65 48 8b 04 25 28 00 00 00 48 89 84 24 b8 00 00 00 31 c0 48 8d 74 24 3d c7 44 24 3d 00 00 00 00 e8 22 41 b2 d8 0f ba 6c 24 3d 00 83 7c 24 3d 01 75 0e 48 c7 c7 70 50 42 c0 e8
      [ 327.415156] RSP: 0018:ff722131cce07b80 EFLAGS: 00010246
      [ 327.415801] RAX: 0000000000000036 RBX: ffffffffc0424000 RCX: 0000000000000000
      [ 327.416431] RDX: 0000000000000000 RSI: ff1928e73ef98860 RDI: ff1928e73ef98860
      [ 327.417052] RBP: ff722131cce07c68 R08: 0000000000000000 R09: c0000000fffeffff
      [ 327.417674] R10: 0000000000000001 R11: ff722131cce07950 R12: 0000000000000000
      [ 327.418293] R13: ff722131cce07d68 R14: ff722131cce07e70 R15: ffffffffc0426000
      [ 327.418907] FS: 00007fdb99824740(0000) GS:ff1928e73ef80000(0000) knlGS:0000000000000000
      [ 327.419535] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 327.420169] CR2: 000055e9f3d8a068 CR3: 000000017cbbc003 CR4: 0000000000771ee0
      [ 327.420808] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [ 327.421441] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
      
      Verify ratelimit (raltelimit implies the warn mode of bus lock detect with ratelimit feature)
      Append "split_lock_detect=ratelimit:2" to kernel command line
      See dmesg
      
      [ 0.000000] x86/split lock detection: #DB: setting system wide bus lock rate limit to 2/sec
      modify the split_lock_test_user.c to add while(1) loop, trigger bus lock forever without interval.
      
      void test_sigbus(int *iptr)
      {
      pid_t pid;
      
          pid = fork();
          if (pid)
                  return;
      
          /*
           * The locked instruction will trigger #AC and kernel will deliver
           * SIGBUS to this process. The SIGBUS handler in this process will
           * verify that the signal is delivered and the process is killed then.
           */
        +  while(1)
             do_split_locked_inst(iptr);
      }
      
      Re-run the ./split_lock_test
      see dmesg to know the warning message is limited to 2 times per second or fail.
      
      [ 1274.605344] x86/split lock detection: #DB: split_lock_test/23868 took a bus_lock trap at address: 0x4011af
      [ 1275.617334] x86/split lock detection: #DB: split_lock_test/23868 took a bus_lock trap at address: 0x4011af
      
      Fatal mode
      Append split_lock_detect=fatal to kernel command line
      see dmesg
      [ 0.000000] x86/split lock detection: #AC: crashing the kernel on kernel split_locks and sending SIGBUS on user-space split_locks
      Run
      #./split_lock_test
      
      ./split_lock_test_user
      Caught SIGBUS/#AC due to split locked access
      (seeing above message pass, or fail)
      
      #cd arch/x86/kernel/cpu/
      #insmod ./test_split_lock_drv.ko
      Got following panic message and panic pass or fail.
      
      [ 327.415019] split lock test: split lock address=0xff722131cce07bbd
      [ 327.415025] Split lock detected
      : 0000 [#1] SMP NOPTI
      [ 327.415048] CPU: 46 PID: 4952 Comm: insmod Tainted: G S
      [ 327.415069] Hardware name: Intel Corporation EAGLESTREAM
      [ 327.415093] RIP: 0010:init_module+0x40/0x85 [test_split_lock_drv]
      [ 327.415107] Code: ec c0 00 00 00 65 48 8b 04 25 28 00 00 00 48 89 84 24 b8 00 00 00 31 c0 48 8d 74 24 3d c7 44 24 3d 00 00 00 00 e8 22 41 b2 d8 0f ba 6c 24 3d 00 83 7c 24 3d 01 75 0e 48 c7 c7 70 50 42 c0 e8
      [ 327.415156] RSP: 0018:ff722131cce07b80 EFLAGS: 00010246
      [ 327.415801] RAX: 0000000000000036 RBX: ffffffffc0424000 RCX: 0000000000000000
      [ 327.416431] RDX: 0000000000000000 RSI: ff1928e73ef98860 RDI: ff1928e73ef98860
      [ 327.417052] RBP: ff722131cce07c68 R08: 0000000000000000 R09: c0000000fffeffff
      [ 327.417674] R10: 0000000000000001 R11: ff722131cce07950 R12: 0000000000000000
      [ 327.418293] R13: ff722131cce07d68 R14: ff722131cce07e70 R15: ffffffffc0426000
      [ 327.418907] FS: 00007fdb99824740(0000) GS:ff1928e73ef80000(0000) knlGS:0000000000000000
      [ 327.419535] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 327.420169] CR2: 000055e9f3d8a068 CR3: 000000017cbbc003 CR4: 0000000000771ee0
      [ 327.420808] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [ 327.421441] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
      
      Known issue:
      No
      
      Default config change:
      No
      
      Thanks,
      Ethan 
       
      Link:https://gitee.com/openeuler/kernel/pulls/53 
      Reviewed-by: Zheng Zengkai <zhengzengkai@huawei.com> 
      Reviewed-by: Liu Chao <liuchao173@huawei.com> 
      Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com> 
      c6897937
  3. 05 8月, 2022 1 次提交
  4. 04 8月, 2022 24 次提交