Skip to content

[win/asan] GetInstructionSize: Add some more instructions. - #214707

Merged
zmodem merged 1 commit into
llvm:mainfrom
bernhardu:instruction-8D-45-XX-and-66-0f-ef-c0
Aug 21, 2026
Merged

zmodem merged 1 commit into
llvm:mainfrom
bernhardu:instruction-8D-45-XX-and-66-0f-ef-c0

Conversation

@bernhardu

Copy link
Copy Markdown
Contributor

Below instructions can be found in wine-11.14 Debian packages.

8D 45 XX :          lea eax, [ebp + XX]
66 0f ef c0 :       pxor xmm0, xmm0
41 B9 XX XX XX XX : mov r9d, XX XX XX XX
45 84 c9 :          test r9b,r9b

This patch also adds 80 3A XX to tests (followup of 3ca5b7d) and fixes the sorting of test lists.

==484==interception_win: unhandled instruction at 0x7bcb2264: 8d 45 f8 83 ec 18 8b 5d
        ntdll.dll`RtlExitUserThread:
            0x7bcb2264 <+4>:  8d 45 f8     lea    eax, [ebp - 0x8]

==484==interception_win: unhandled instruction at 0x7a5f2fe1: 66 0f ef c0 89 e5 53 83
        ucrtbase.dll`memset:
            0x7a5f2fe1 <+1>:  66 0f ef c0        pxor   xmm0, xmm0

==760==interception_win: unhandled instruction at 0x6fffffbe6b25: 41 b9 04 00 00 00 ba 0c
        ntdll.dll`RtlExitUserThread:
            0x6fffffbe6b25 <+5>:  41 b9 04 00 00 00  movl   $0x4, %r9d

==760==interception_win: unhandled instruction at 0x6fffffc342a4: 45 84 c9 74 45 0f 1f 80
        ntdll.dll`strpbrk:
            0x6fffffc342a4 <+4>:  45 84 c9              testb  %r9b, %r9b

```
8D 45 XX :          lea eax, [ebp + XX]
66 0f ef c0 :       pxor xmm0, xmm0
41 B9 XX XX XX XX : mov r9d, XX XX XX XX
45 84 c9 :          test r9b,r9b
```

They can be found in wine-11.14 Debian packages.

Also adds `80 3A XX` to tests (followup of 3ca5b7d)
and fixes the sorting of test lists.

```
==484==interception_win: unhandled instruction at 0x7bcb2264: 8d 45 f8 83 ec 18 8b 5d
        ntdll.dll`RtlExitUserThread:
            0x7bcb2264 <+4>:  8d 45 f8     lea    eax, [ebp - 0x8]

==484==interception_win: unhandled instruction at 0x7a5f2fe1: 66 0f ef c0 89 e5 53 83
        ucrtbase.dll`memset:
            0x7a5f2fe1 <+1>:  66 0f ef c0        pxor   xmm0, xmm0

==760==interception_win: unhandled instruction at 0x6fffffbe6b25: 41 b9 04 00 00 00 ba 0c
        ntdll.dll`RtlExitUserThread:
            0x6fffffbe6b25 <+5>:  41 b9 04 00 00 00  movl   $0x4, %r9d

==760==interception_win: unhandled instruction at 0x6fffffc342a4: 45 84 c9 74 45 0f 1f 80
        ntdll.dll`strpbrk:
            0x6fffffc342a4 <+4>:  45 84 c9              testb  %r9b, %r9b
```
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: bernhardu

Changes

Below instructions can be found in wine-11.14 Debian packages.

8D 45 XX :          lea eax, [ebp + XX]
66 0f ef c0 :       pxor xmm0, xmm0
41 B9 XX XX XX XX : mov r9d, XX XX XX XX
45 84 c9 :          test r9b,r9b

This patch also adds 80 3A XX to tests (followup of 3ca5b7d) and fixes the sorting of test lists.

==484==interception_win: unhandled instruction at 0x7bcb2264: 8d 45 f8 83 ec 18 8b 5d
        ntdll.dll`RtlExitUserThread:
            0x7bcb2264 &lt;+4&gt;:  8d 45 f8     lea    eax, [ebp - 0x8]

==484==interception_win: unhandled instruction at 0x7a5f2fe1: 66 0f ef c0 89 e5 53 83
        ucrtbase.dll`memset:
            0x7a5f2fe1 &lt;+1&gt;:  66 0f ef c0        pxor   xmm0, xmm0

==760==interception_win: unhandled instruction at 0x6fffffbe6b25: 41 b9 04 00 00 00 ba 0c
        ntdll.dll`RtlExitUserThread:
            0x6fffffbe6b25 &lt;+5&gt;:  41 b9 04 00 00 00  movl   $0x4, %r9d

==760==interception_win: unhandled instruction at 0x6fffffc342a4: 45 84 c9 74 45 0f 1f 80
        ntdll.dll`strpbrk:
            0x6fffffc342a4 &lt;+4&gt;:  45 84 c9              testb  %r9b, %r9b

Full diff: https://github.com/llvm/llvm-project/pull/214707.diff

2 Files Affected:

  • (modified) compiler-rt/lib/interception/interception_win.cpp (+8)
  • (modified) compiler-rt/lib/interception/tests/interception_win_test.cpp (+6-1)
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index 19bccb3566d72..86a622ed48b50 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -685,6 +685,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0x758B:  // 8B 75 XX : mov XX(%ebp), esp
     case 0xE483:  // 83 E4 XX : and esp, XX
     case 0xEC83:  // 83 EC XX : sub esp, XX
+    case 0x458D:  // 8D 45 XX : lea eax, [ebp + XX]
     case 0xC1F6:  // F6 C1 XX : test cl, XX
       return 3;
 
@@ -705,6 +706,11 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
       return 7;
   }
 
+  switch (*(u32*)(address)) {
+    case 0xc0ef0f66:  // 66 0f ef c0 : pxor xmm0, xmm0
+      return 4;
+  }
+
   switch (0x000000FF & *(u32 *)address) {
     case 0xc2:  // C2 XX XX : ret XX (needed for registering weak functions)
       return 3;
@@ -771,6 +777,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
         *rel_offset = 2;
       FALLTHROUGH;
     case 0xB841:  // 41 B8 XX XX XX XX : mov r8d, XX XX XX XX
+    case 0xB941:  // 41 B9 XX XX XX XX : mov r9d, XX XX XX XX
       return 6;
 
     case 0x7E81:  // 81 7E YY XX XX XX XX  cmp DWORD PTR [rsi+YY], XX XX XX XX
@@ -844,6 +851,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0xd23345:    // 45 33 d2 : xor r10d, r10d
     case 0xdb3345:    // 45 33 db : xor r11d, r11d
     case 0xc08445:    // 45 84 c0 : test r8b,r8b
+    case 0xc98445:    // 45 84 c9 : test r9b,r9b
     case 0xd28445:    // 45 84 d2 : test r10b,r10b
     case 0xdb8548:    // 48 85 db : test rbx, rbx
     case 0xdb854d:    // 4d 85 db : test r11, r11
diff --git a/compiler-rt/lib/interception/tests/interception_win_test.cpp b/compiler-rt/lib/interception/tests/interception_win_test.cpp
index e3dc4cfbe9b2c..054d5405971dd 100644
--- a/compiler-rt/lib/interception/tests/interception_win_test.cpp
+++ b/compiler-rt/lib/interception/tests/interception_win_test.cpp
@@ -841,11 +841,11 @@ const struct InstructionSizeData {
     { 1, {0xCC}, 0, "CC : int 3  i.e. registering weak functions)"},
     { 2, {0x31, 0xC0}, 0, "31 C0 : xor eax, eax"},
     { 2, {0x31, 0xC9}, 0, "31 C9 : xor ecx, ecx"},
-    { 2, {0x33, 0xFF}, 0, "33 FF : xor edi, edi"},
     { 2, {0x31, 0xD2}, 0, "31 D2 : xor edx, edx"},
     { 2, {0x33, 0xC0}, 0, "33 C0 : xor eax, eax"},
     { 2, {0x33, 0xC9}, 0, "33 C9 : xor ecx, ecx"},
     { 2, {0x33, 0xD2}, 0, "33 D2 : xor edx, edx"},
+    { 2, {0x33, 0xFF}, 0, "33 FF : xor edi, edi"},
     { 2, {0x66, 0x90}, 0, "66 90 : xchg %ax,%ax (Two-byte NOP)"},
     { 2, {0x6A, 0x71}, 0, "6A XX : push XX"},
     { 2, {0x84, 0xC0}, 0, "84 C0 : test al,al"},
@@ -860,12 +860,15 @@ const struct InstructionSizeData {
     { 2, {0x8B, 0xEC}, 0, "8B EC : mov ebp, esp"},
     { 2, {0x8B, 0xFF}, 0, "8B FF : mov edi, edi"},
     { 3, {0x80, 0x39, 0x72}, 0, "80 39 XX : cmp BYTE PTR [rcx], XX"},
+    { 3, {0x80, 0x3A, 0x72}, 0, "80 3A XX : cmp BYTE PTR [rdx], XX"},
     { 3, {0x83, 0xE4, 0x72}, 0, "83 E4 XX : and esp, XX"},
     { 3, {0x83, 0xEC, 0x72}, 0, "83 EC XX : sub esp, XX"},
     { 3, {0x8B, 0x4D, 0x72}, 0, "8B 4D XX : mov XX(%ebp), ecx"},
     { 3, {0x8B, 0x55, 0x72}, 0, "8B 55 XX : mov XX(%ebp), edx"},
     { 3, {0x8B, 0x75, 0x72}, 0, "8B 75 XX : mov XX(%ebp), esp"},
+    { 3, {0x8D, 0x45, 0x72}, 0, "8D 45 XX : lea eax, [ebp + XX]"},
     { 3, {0xc2, 0x71, 0x72}, 0, "C2 XX XX : ret XX (needed for registering weak functions)"},
+    { 4, {0x66, 0x0f, 0xef, 0xc0}, 0, "66 0f ef c0 : pxor xmm0, xmm0"},
     { 4, {0x8D, 0x4C, 0x24, 0x73}, 0, "8D 4C 24 XX : lea ecx, [esp + XX]"},
     { 4, {0xFF, 0x74, 0x24, 0x73}, 0, "FF 74 24 XX : push qword ptr [rsp + XX]"},
     { 5, {0x68, 0x71, 0x72, 0x73, 0x74}, 0, "68 XX XX XX XX : push imm32"},
@@ -911,6 +914,7 @@ const struct InstructionSizeData {
     { 3, {0x45, 0x33, 0xd2}, 0, "45 33 d2 : xor r10d, r10d"},
     { 3, {0x45, 0x33, 0xdb}, 0, "45 33 db : xor r11d, r11d"},
     { 3, {0x45, 0x84, 0xc0}, 0, "45 84 c0 : test r8b,r8b"},
+    { 3, {0x45, 0x84, 0xc9}, 0, "45 84 c9 : test r9b,r9b"},
     { 3, {0x45, 0x84, 0xd2}, 0, "45 84 d2 : test r10b,r10b"},
     { 3, {0x48, 0x29, 0xd1}, 0, "48 29 d1 : sub rcx, rdx"},
     { 3, {0x48, 0x2b, 0xca}, 0, "48 2b ca : sub rcx, rdx"},
@@ -1007,6 +1011,7 @@ const struct InstructionSizeData {
     { 5, {0x83, 0x44, 0x72, 0x73, 0x74}, 0, "83 44 72 XX YY : add DWORD PTR [rdx+rsi*2+XX],YY"},
     { 5, {0x83, 0x64, 0x24, 0x73, 0x74}, 0, "83 64 24 XX YY : and DWORD PTR [rsp+XX], YY"},
     { 6, {0x41, 0xB8, 0x72, 0x73, 0x74, 0x75}, 0, "41 B8 XX XX XX XX : mov r8d, XX XX XX XX"},
+    { 6, {0x41, 0xB9, 0x72, 0x73, 0x74, 0x75}, 0, "41 B9 XX XX XX XX : mov r9d, XX XX XX XX"},
     { 6, {0x48, 0x83, 0x64, 0x24, 0x74, 0x75}, 0, "48 83 64 24 XX YY : and QWORD PTR [rsp + XX], YY"},
     { 6, {0x66, 0x81, 0x78, 0x73, 0x74, 0x75}, 0, "66 81 78 XX YY YY : cmp WORD PTR [rax+XX], YY YY"},
     { 6, {0x66, 0x81, 0x79, 0x73, 0x74, 0x75}, 0, "66 81 79 XX YY YY : cmp WORD PTR [rcx+XX], YY YY"},

@bernhardu

Copy link
Copy Markdown
Contributor Author

CC: @zmodem

@zmodem zmodem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay, I was out for a couple of weeks.

lgtm

@zmodem
zmodem merged commit 5af1c55 into llvm:main Aug 21, 2026
15 checks passed
@bernhardu

Copy link
Copy Markdown
Contributor Author

Apologies for the delay, I was out for a couple of weeks.

lgtm

No problem, thanks for reviewing and merging.

@bernhardu
bernhardu deleted the instruction-8D-45-XX-and-66-0f-ef-c0 branch August 21, 2026 22:12
@mstorsjo

Copy link
Copy Markdown
Member

Would fixes like this be relevant for backporting? It doesn't fix any regression, but it's a fairly low risk improvement AFAIK?

@bernhardu

Copy link
Copy Markdown
Contributor Author

Would fixes like this be relevant for backporting? It doesn't fix any regression, but it's a fairly low risk improvement AFAIK?

I would welcome it to get these fixes faster into stable releases.
Would this be only the two steps described here? https://llvm.org/docs/GitHub.html#releases
(While it looks editing milestones need more permissions than mine.)

@mstorsjo

Copy link
Copy Markdown
Member

/cherry-pick 5af1c55

@llvmbot

llvmbot commented Aug 31, 2026

Copy link
Copy Markdown
Member

/pull-request #219898

@mstorsjo

Copy link
Copy Markdown
Member

I would welcome it to get these fixes faster into stable releases. Would this be only the two steps described here? https://llvm.org/docs/GitHub.html#releases

Yes, exactly, it's enough to just set a milestone and do the slash-cherry-pick command.

(While it looks editing milestones need more permissions than mine.)

Yeah, possibly. If there are other PRs we should attempt to backport (or perhaps start with another one?) feel free to ping me there so we can get it done in the right sequence.

tru pushed a commit that referenced this pull request Sep 5, 2026
Below instructions can be found in wine-11.14 Debian packages.

```
8D 45 XX :          lea eax, [ebp + XX]
66 0f ef c0 :       pxor xmm0, xmm0
41 B9 XX XX XX XX : mov r9d, XX XX XX XX
45 84 c9 :          test r9b,r9b
```

This patch also adds `80 3A XX` to tests (followup of 3ca5b7d) and
fixes the sorting of test lists.

```
==484==interception_win: unhandled instruction at 0x7bcb2264: 8d 45 f8 83 ec 18 8b 5d
        ntdll.dll`RtlExitUserThread:
            0x7bcb2264 <+4>:  8d 45 f8     lea    eax, [ebp - 0x8]

==484==interception_win: unhandled instruction at 0x7a5f2fe1: 66 0f ef c0 89 e5 53 83
        ucrtbase.dll`memset:
            0x7a5f2fe1 <+1>:  66 0f ef c0        pxor   xmm0, xmm0

==760==interception_win: unhandled instruction at 0x6fffffbe6b25: 41 b9 04 00 00 00 ba 0c
        ntdll.dll`RtlExitUserThread:
            0x6fffffbe6b25 <+5>:  41 b9 04 00 00 00  movl   $0x4, %r9d

==760==interception_win: unhandled instruction at 0x6fffffc342a4: 45 84 c9 74 45 0f 1f 80
        ntdll.dll`strpbrk:
            0x6fffffc342a4 <+4>:  45 84 c9              testb  %r9b, %r9b
```

(cherry picked from commit 5af1c55)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

4 participants