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

bionic bionic-unit-tests-static tsts result #16

Open
oy456xd opened this issue Feb 22, 2024 · 2 comments
Open

bionic bionic-unit-tests-static tsts result #16

oy456xd opened this issue Feb 22, 2024 · 2 comments

Comments

@oy456xd
Copy link

oy456xd commented Feb 22, 2024

qemu android loongarch full system

command : run bionic-unit-tests-static directly

[==========] 2953 tests from 156 test suites ran. (501803 ms total)
[  PASSED  ] 2919 tests.
[  SKIPPED ] 26 tests, listed below:
[  SKIPPED ] aeabi.read_tp
[  SKIPPED ] getauxval.arm_has_AT_HWCAP2
[  SKIPPED ] heap_tagging_level.tagged_pointer_dies
[  SKIPPED ] heap_tagging_level.sync_async_bad_accesses_die
[  SKIPPED ] heap_tagging_level.tagging_level_transitions
[  SKIPPED ] heap_tagging_level.tagging_level_transition_sync_none
[  SKIPPED ] libgen.basename_r
[  SKIPPED ] libgen.dirname_r
[  SKIPPED ] malloc.pvalloc_std
[  SKIPPED ] malloc.pvalloc_overflow
[  SKIPPED ] malloc.valloc_std
[  SKIPPED ] malloc.valloc_overflow
[  SKIPPED ] malloc.disable_mte
[  SKIPPED ] membarrier.private_expedited_sync_core
[  SKIPPED ] pthread.pthread_mutex_pi_count_limit
[  SKIPPED ] pthread.pthread_mutex_owner_tid_limit
[  SKIPPED ] pthread.pthread_mutex_lock_null_32
[  SKIPPED ] pthread.pthread_mutex_unlock_null_32
[  SKIPPED ] pty.bug_28979140
[  SKIPPED ] sys_msg.smoke
[  SKIPPED ] sys_sem.smoke
[  SKIPPED ] sys_shm.smoke
[  SKIPPED ] wctype.towlower
[  SKIPPED ] wctype.towlower_l
[  SKIPPED ] wctype.towupper
[  SKIPPED ] wctype.towupper_l
[  SLOW    ] 17 tests, listed below:
[  SLOW    ] malloc_iterate.malloc_disable_prevents_allocs (2042 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.memcpy (14127 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.memset (22436 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.memmove (41492 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.bcopy (41888 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.strcat_overread (13424 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.strlcat_overread (13482 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.strcmp_align (3194 ms, exceeded 2000 ms)
[  SLOW    ] string_nofortify.memcmp_align (2001 ms, exceeded 2000 ms)
[  SLOW    ] string.memcpy (14194 ms, exceeded 2000 ms)
[  SLOW    ] string.memset (22495 ms, exceeded 2000 ms)
[  SLOW    ] string.memmove (42222 ms, exceeded 2000 ms)
[  SLOW    ] string.bcopy (41892 ms, exceeded 2000 ms)
[  SLOW    ] string.strcat_overread (15733 ms, exceeded 2000 ms)
[  SLOW    ] string.strlcat_overread (13618 ms, exceeded 2000 ms)
[  SLOW    ] string.strcmp_align (3350 ms, exceeded 2000 ms)
[  SLOW    ] time.clock (5029 ms, exceeded 2000 ms)
[  FAILED  ] 6 tests, listed below:
[  FAILED  ] fenv.feenableexcept_fegetexcept
[  FAILED  ] sys_ptrace.watchpoint_stress
[  FAILED  ] sys_ptrace.watchpoint_imprecise
[  FAILED  ] sys_ptrace.hardware_breakpoint

17 SLOW TESTS
 4 FAILED TESTS
  YOU HAVE 2 DISABLED TESTS

fenv.feenableexcept_fegetexcept
See #8 (comment)

如下3 fails: 测试代码对应函数中没有larch实现支持, 暂不能说明bionic相关功能存在问题
[ FAILED ] sys_ptrace.watchpoint_stress
[ FAILED ] sys_ptrace.watchpoint_imprecise
[ FAILED ] sys_ptrace.hardware_breakpoint
set_breakpoint 和 set_watchpoint 等(?).
qemu not support hw watch point register ???

kernel ptrace code:

        if (!cpu_has_watch || boot_cpu_data.watch_reg_use_cnt == 0)
                return -EIO;

the cpu_has_watch and boot_cpu_data.watch_reg_use_cnt are both 0, which cause EIO error.
See #16 (comment)

@oy456xd
Copy link
Author

oy456xd commented Mar 3, 2024

qemu not support hw watch point register??

tst failed info: (the following error can be reproduced by adding the follow kernel and bionic-xxx-xxx-xxx-static patches)

Note: Google Test filter = sys_ptrace.watchpoint_stress
[==========] Running 1 test from 1 test suite (1 job).
[ 1426.314305][  T479] ttttttttttttttttttt
[ 1426.314532][  T478] ttttttttttttttttttt
[ 1426.314628][  T478] The unsigned value is: 0, -- 0
[ 1426.315641][  T478] ttttttttttttttttttt
[ RUN      ] sys_ptrace.watchpoint_stress
bionic/tests/sys_ptrace_test.cpp:(142) Failure in test sys_ptrace.watchpoint_stress
Expected equality of these values:
  0
  ptrace(0xd1, child, &dreg_state, nullptr)
    Which is: -1
I/O error
bionic/tests/sys_ptrace_test.cpp:(204) Failure in test sys_ptrace.watchpoint_stress
Value of: (((status) & 0x7f) == 0x7f)
  Actual: false
Expected: true
Status was: 0
sys_ptrace.watchpoint_stress exited with exitcode 1.
[  FAILED  ] sys_ptrace.watchpoint_stress (43 ms)
[==========] 1 test from 1 test suite ran. (46 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] sys_ptrace.watchpoint_stress

 1 FAILED TEST

add tst code in kernel_common:

diff --git a/arch/loongarch/kernel/ptrace.c b/arch/loongarch/kernel/ptrace.c
index b819b12275..3f842c7465 100644
--- a/arch/loongarch/kernel/ptrace.c
+++ b/arch/loongarch/kernel/ptrace.c
@@ -603,10 +603,16 @@ static int ptrace_set_watch_regs(struct task_struct *child,
        unsigned long maskt[NUM_WATCH_REGS];
        unsigned char irwt[NUM_WATCH_REGS];
 
+       printk("The unsigned value is: %llu, -- %u\n", cpu_has_watch, boot_cpu_data.watch_reg_use_cnt);
        if (!cpu_has_watch || boot_cpu_data.watch_reg_use_cnt == 0)
+       {
                return -EIO;
+       }
+       printk("The unsigned value is: %ld\n", access_ok(addr, sizeof(struct pt_watch_regs)));
        if (!access_ok(addr, sizeof(struct pt_watch_regs)))
+       {
                return -EIO;
+       }
 
        __get_user(cnt, &addr->max_valid);
        cnt = min(boot_cpu_data.watch_reg_use_cnt, cnt);
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index aab480e24b..f57f88df32 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1268,9 +1268,11 @@ int ptrace_request(struct task_struct *child, long request,
 SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
                unsigned long, data)
 {
+
        struct task_struct *child;
        long ret;
 
+       printk("ttttttttttttttttttt\n");
        if (request == PTRACE_TRACEME) {
                ret = ptrace_traceme();
                if (!ret)
@@ -1415,9 +1417,11 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
 COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid,
                       compat_long_t, addr, compat_long_t, data)
 {
+
        struct task_struct *child;
        long ret;
 
+       printk("ttttttttttttttttttt\n");
        if (request == PTRACE_TRACEME) {
                ret = ptrace_traceme();
                goto out;

try to add support of sys_ptrace.*, the code are as follows:

diff --git a/tests/sys_ptrace_test.cpp b/tests/sys_ptrace_test.cpp
index 168c84072..6d98a0760 100644
--- a/tests/sys_ptrace_test.cpp
+++ b/tests/sys_ptrace_test.cpp
@@ -130,6 +130,17 @@ static void set_watchpoint(pid_t child, uintptr_t address, size_t size) {
 
   ASSERT_EQ(0, ptrace(PTRACE_SETREGSET, child, NT_ARM_HW_WATCH, &iov)) << strerror(errno);
 #endif
+#elif defined(__loongarch64)
+
+  pt_watch_regs dreg_state;
+  memset(&dreg_state, 0, sizeof dreg_state);
+  dreg_state.max_valid = 1;
+  dreg_state.style = pt_watch_style_la64;
+  dreg_state.la64[0].addr = reinterpret_cast<uintptr_t>(address);
+  dreg_state.la64[0].irw = LA_WATCH_W; // todo fix
+
+  ASSERT_EQ(0, ptrace(PTRACE_SET_WATCH_REGS, child, &dreg_state, nullptr)) << strerror(errno);
+  UNUSED(size);
 #elif defined(__i386__) || defined(__x86_64__)
   ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[0]), address)) << strerror(errno);
   errno = 0;
@@ -232,13 +243,13 @@ TEST(sys_ptrace, watchpoint_stress) {
   for (size_t cpu = 0; cpu < CPU_SETSIZE; ++cpu) {
     if (!CPU_ISSET(cpu, &available_cpus)) continue;
 
-    run_watchpoint_stress<uint8_t>(cpu);
+    // run_watchpoint_stress<uint8_t>(cpu);
     if (::testing::Test::IsSkipped()) {
       // Only check first case, since all others would skip for same reason.
       return;
     }
-    run_watchpoint_stress<uint16_t>(cpu);
-    run_watchpoint_stress<uint32_t>(cpu);
+    // run_watchpoint_stress<uint16_t>(cpu);
+    // run_watchpoint_stress<uint32_t>(cpu);
 #if defined(__LP64__)
     run_watchpoint_stress<uint64_t>(cpu);
 #endif
@@ -318,6 +329,17 @@ static void set_breakpoint(pid_t child) {
 
   ASSERT_EQ(0, ptrace(PTRACE_SETREGSET, child, NT_ARM_HW_BREAK, &iov)) << strerror(errno);
 #endif
+#elif defined(__loongarch64)
+  address &= ~3; // todo need or not?
+
+  pt_watch_regs dreg_state;
+  memset(&dreg_state, 0, sizeof dreg_state);
+  dreg_state.max_valid = 1;
+  dreg_state.style = pt_watch_style_la64;
+  dreg_state.la64[0].addr = reinterpret_cast<uintptr_t>(address);
+  dreg_state.la64[0].irw = LA_WATCH_I; // todo fix
+
+  ASSERT_EQ(0, ptrace(PTRACE_SET_WATCH_REGS, child, &dreg_state, nullptr)) << strerror(errno);
 #elif defined(__i386__) || defined(__x86_64__)
   ASSERT_EQ(0, ptrace(PTRACE_POKEUSER, child, offsetof(user, u_debugreg[0]), address))
       << strerror(errno);

@foxsen
Copy link
Contributor

foxsen commented Mar 3, 2024

目前上游的qemu确实不支持硬件watchpoint,这部分需要在真机上测试,可以先更测试代码,我随后在真机试试

oy456xd pushed a commit that referenced this issue Mar 4, 2024
These codes need to be further tested and verified on a real device.

See: #16 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants