x86-64

vmalloc_to_pfn returns 32 bit address on Linux 32 system. Why does it chop off higher bits of PAE physical address?

若如初见. 提交于 2019-12-01 22:03:21
问题 I'm using vmalloc_to_pfn() to get the physical address on a 32-bit PAE Linux system. It looks like vmalloc_to_pfn() returns "unsigned long" which means it is 32 bit on a 32 bit system, 64 bit on a 64-bit system. On 64-bit Linux, unsigned long is 64 bit and I've no issues. Problem: Using this function to convert virtual to physical: VA: 0xf8ab87fc PA using vmalloc_to_pfn: 0x36f7f7fc . But I'm actually expecting: 0x136f7f7fc . The physical address falls between 4 to 5 GB. But I can't get the

Conditional jump to register

佐手、 提交于 2019-12-01 21:39:58
I want to get these commands: jl some_label(%rip) # or jl *%rax in my asm program that I am writing for Intel x64 architecture. GCC says that "operand type mismatch for jl" when I try to compile this code. Michael Conditional jumps are relative on x86. You can use an "inverted" conditional jump followed by an unconditional jump: jge skip_jump jmp *%rax # AT&T syntax skip_jump: The equivalent NASM syntax is jmp rax . Either way, it sets RIP = RAX, so it's a register-indirect jump. Conditionally jumping over the indirect jmp rax is normally the way to go. Another option is to use cmov to modify

Error: operand size mismatch for `movq'

落花浮王杯 提交于 2019-12-01 21:25:08
问题 I'm trying to compile the following assembly... movq $0x3534373536383235, 0x000000000055638f8 movq $0x55638f8, %rdi retq The first line throws the error Error: operand size mismatch for 'movq' Which doesn't make sense to me, because they are both 8 byte numbers. I did a little research and movabsq was recommended, like so... movabsq $0x3534373536383235, 0x000000000055638f8 movq $0x55638f8, %rdi retq But this throws the error: Error: operand size mismatch for 'movabs' What am I missing? Here's

Why do 32-bit applications work on 64-bit x86 CPUs?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 20:53:45
32-bit application executables contain machine code for a 32-bit CPU, but the assembly and internal architecture (number of registers, register width, calling convention) of 32-bit and 64-bit Intel CPU's differ, so how can a 32-bit exe run on a 64-bit machine? Wikipedia's x86-64 article says: x86-64 is fully backwards compatible with 16-bit and 32-bit x86 code. Because the full x86 16-bit and 32-bit instruction sets remain implemented in hardware without any intervening emulation , existing x86 executables run with no compatibility or performance penalties, whereas existing applications that

With Hyper Threading, threads of one physical core are exchanging via what level of cache L1/L2/L3?

天大地大妈咪最大 提交于 2019-12-01 20:51:04
Does the Hyper Threading allow to use of L1-cache to exchange the data between the two threads, which are executed simultaneously on a single physical core, but in two virtual cores? With the proviso that both belong to the same process, i.e. in the same address space. Page 85 (2-55) - Intel® 64 and IA-32 Architectures Optimization Reference Manual : http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf 2.5.9 Hyper-Threading Technology Support in Intel® Microarchitecture Code Name Nehalem ... Deeper buffering and enhanced resource

vmalloc_to_pfn returns 32 bit address on Linux 32 system. Why does it chop off higher bits of PAE physical address?

五迷三道 提交于 2019-12-01 20:08:04
I'm using vmalloc_to_pfn() to get the physical address on a 32-bit PAE Linux system. It looks like vmalloc_to_pfn() returns "unsigned long" which means it is 32 bit on a 32 bit system, 64 bit on a 64-bit system. On 64-bit Linux, unsigned long is 64 bit and I've no issues. Problem: Using this function to convert virtual to physical: VA: 0xf8ab87fc PA using vmalloc_to_pfn: 0x36f7f7fc . But I'm actually expecting: 0x136f7f7fc . The physical address falls between 4 to 5 GB. But I can't get the exact physical address, I only get the chopped off 32-bit address. Is there another way to get true

ROL / ROR on variable using inline assembly in Objective-C

被刻印的时光 ゝ 提交于 2019-12-01 19:04:50
I would like to perform ROR and ROL operations on variables in an Objective-C program. However, I can't manage it – I am not an assembly expert. Here is what I have done so far: uint8_t v1 = ....; uint8_t v2 = ....; // v2 is either 1, 2, 3, 4 or 5 asm("ROR v1, v2"); the error I get is: Unknown use of instruction mnemonic with unknown size suffix How can I fix this? Edit: The code does not need to use inline assembly. However, I haven't found a way to do this using Objective-C / C++ / C instructions. To do this in standard C, you can do: var = (var << shift) | (var >> (sizeof(var)*CHAR_BIT

How to load address of function or label into register in GNU Assembler

前提是你 提交于 2019-12-01 19:01:06
I am trying to load the address of 'main' into a register (R10) in the GNU Assembler. I am unable to. Here I what I have and the error message I receive. main: lea main, %r10 I also tried the following syntax (this time using mov) main: movq $main, %r10 With both of the above I get the following error: /usr/bin/ld: /tmp/ccxZ8pWr.o: relocation R_X86_64_32S against symbol `main' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status Compiling with -fPIC does not resolve the

LLVM insertvalue bad optimized?

ε祈祈猫儿з 提交于 2019-12-01 18:37:19
问题 Should I avoid using the 'insertvalue' instruction combined with load and store when I emit LLVM code? I always get bad optimized native code when I use it. Look at the following example: ; ModuleID = 'mod' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-pc-linux-gnu" %A = type { i64, i64, i64, i64, i64, i64, i64, i64 } @aa = external global %A* define

How to detect architecture in NASM at compile time to have one source code for both x64 and x86?

 ̄綄美尐妖づ 提交于 2019-12-01 18:22:47
I am looking for some preprocessor functionality in nasm that would allow having one source code for both x86 and x64 architectures. I mean something in the vein of ifdef some_constant. Like C preprocessor uses if it wants to detect say if it's compiled on Windows or Linux. Edit I know about nasm flags. I use them. I just want to have the very same source code and expect preprocessor to handle it correctly based on those flags. I'd use ifdef ... else for stack operations and so one, having the core code same for both architectures. NASM cannot detect the architecture, but you can use the