What’s the purpose of the UD2 opcode in the Linux kernel?

It’s the BUG() macro from include/asm-i386/bug.h. /* * Tell the user there is some problem. * The offending file and line are encoded after the “officially * undefined” opcode for parsing in the trap handler. */ #ifdef CONFIG_DEBUG_BUGVERBOSE #define BUG() \ __asm__ __volatile__( “ud2\n” \ “\t.word %c0\n” \ “\t.long %c1\n” \ : : “i” (__LINE__), … Read more

Difference in performance between MSVC and GCC for highly optimized matrix multplication code

Since we’ve covered the alignment issue, I would guess it’s this: http://en.wikipedia.org/wiki/Out-of-order_execution Since g++ issues a standalone load instruction, your processor can reorder the instructions to be pre-fetching the next data that will be needed while also adding and multiplying. MSVC throwing a pointer at mul makes the load and mul tied to the same … Read more

Analyzing a crash in Windows: what does the error message tell us?

The 64-bit time stamp is the time application’s primary thread was created in 100-nanosecond intervals since January 1, 1601 (UTC) (this is known as FILETIME). The 32-bit timestamp is indeed in time_t format (it tells the time the module was created and is stored in the module’s header). I’d say 0x0002d160 is an offset from … Read more

‘Correct’ unsigned integer comparison

Well, you’ve correctly typified the situation: C/C++ have no way of doing a full signed int/unsigned int comparison with a single compare. I would be surprised if promotion to int64 was faster than doing two comparisons. In my experience, compilers are quite good at realizing that a subexpression like that is pure (has no side … Read more

Useless test instruction?

That must be the thread-local handshake poll. Look where %r11 is read from. If it is read from some offset off the %r15 (thread-local storage), that’s the guy. See the example here: 0.31% ↗ …70: movzbl 0x94(%r9),%r10d 0.19% │ …78: mov 0x108(%r15),%r11 ; read the thread-local page addr 25.62% │ …7f: add $0x1,%rbp 35.10% │ … Read more

movq (%rsp), %rsp assembly stack pointer load?

movq (assuming you’re talking about x86) is a move of a quadword (64-bit value). This particular instruction: movq (%rsp), %rsp looks very much like code that will walk up through stack frames. This particular instruction grabs the quadword pointed to by the current stack pointer, and loads it into the stack pointer, overwriting it. By … Read more

Intel x86 vs x64 system call

General part EDIT: Linux irrelevant parts removed While not totally wrong, narrowing down to int 0x80 and syscall oversimplifies the question as with sysenter there is at least a 3rd option. Using 0x80 and eax for syscall number, ebx, ecx, edx, esi, edi, and ebp to pass parameters is just one of many possible other … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)