Skip to contentSkip to conversation

x86-64: allow using RIP-relative addressing for per-CPU data

PATCH In review Jan Beulich 2 participants 4 messages Nov 4, 2014 – Nov 5, 2014

lore
Share & tools
lore
#0 lore raw

cover x86-64: allow using RIP-relative addressing for per-CPU data

Observing that per-CPU data (in the SMP case) is reachable by exploiting 64-bit address wraparound, these two patches arrange for using the one byte shorter RIP-relative addressing forms for the majority of per-CPU accesses.

1: handle PC-relative relocations on per-CPU data 2: use RIP-relative addressing for most per-CPU accesses

#1 lore raw
Quoted 10 lines · Jan Beulich

Observing that per-CPU data (in the SMP case) is reachable by exploiting 64-bit address wraparound, these two patches arrange for using the one byte shorter RIP-relative addressing forms for the majority of per-CPU accesses.

1: handle PC-relative relocations on per-CPU data 2: use RIP-relative addressing for most per-CPU accesses

I'm lost here. Can you give an example of a physical and virtual address of an instruction, the address within the gs segment, and why the relocations are backwards?

--Andy

#2 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line

Andy Lutomirski <[email protected]> 11/04/14 8:33 PM >>>

Quoted 8 lines · Jan Beulich

Observing that per-CPU data (in the SMP case) is reachable by exploiting 64-bit address wraparound, these two patches arrange for using the one byte shorter RIP-relative addressing forms for the majority of per-CPU accesses.

1: handle PC-relative relocations on per-CPU data 2: use RIP-relative addressing for most per-CPU accesses

Quoted 6 lines
Quoted 2 lines

I'm lost here. Can you give an example of a physical and virtual address of an instruction, the address within the gs segment, and why the relocations are backwards?

When an instruction using RIP relative addressing gets moved up in address space, the distance to the target address decreases. I.e. it's the opposite of a normal, non-PC-relative base relocation (where the target address increases together with the instruction getting moved up).

Jan

#3 lore raw
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line

Andy Lutomirski <[email protected]> 11/04/14 8:33 PM >>>

Quoted 10 lines · Jan Beulich

Observing that per-CPU data (in the SMP case) is reachable by exploiting 64-bit address wraparound, these two patches arrange for using the one byte shorter RIP-relative addressing forms for the majority of per-CPU accesses.

1: handle PC-relative relocations on per-CPU data 2: use RIP-relative addressing for most per-CPU accesses

Quoted 9 lines
Quoted 3 lines

I'm lost here. Can you give an example of a physical and virtual address of an instruction, the address within the gs segment, and why the relocations are backwards?

When an instruction using RIP relative addressing gets moved up in address space, the distance to the target address decreases. I.e. it's the opposite of a normal, non-PC-relative base relocation (where the target address increases together with the instruction getting moved up).

Duh. Thanks :)

--Andy