Page MenuHomeFreeBSD

gnu binutils: FSGSBASE assembly/disassembly
ClosedPublic

Authored by rlibby on Sep 3 2017, 11:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 24 2024, 12:28 AM
Unknown Object (File)
Nov 22 2024, 1:37 AM
Unknown Object (File)
Nov 19 2024, 8:28 AM
Unknown Object (File)
Nov 19 2024, 8:20 AM
Unknown Object (File)
Nov 18 2024, 11:58 AM
Unknown Object (File)
Oct 15 2024, 4:44 PM
Unknown Object (File)
Sep 25 2024, 8:59 AM
Unknown Object (File)
Sep 24 2024, 4:08 PM
Subscribers

Details

Summary

Enable the in-tree binutils to assemble and disassemble amd64 FSGSBASE instructions (rdfsbase, rdgsbase, wrfsbase, wrgsbase), used in the base system since r322763.

This gives one last gasp for in-tree gcc, and provides a small enhancement for in-tree binutils objdump.

Test Plan

buildworld, inspect amd64_{get,set}_{fs,gs}base.o, compare to clang

Also an ad-hoc test that the instructions are assembled and disassembled as expected:

% /usr/obj/usr/src/freebsd/gnu/usr.bin/binutils/as/as -g fsgstest.s -o fsgstest.binutils.o
% /usr/obj/usr/src/freebsd/gnu/usr.bin/binutils/objdump/objdump -dS fsgstest.binutils.o

fsgstest.binutils.o:     file format elf64-x86-64-freebsd

Disassembly of section .text:

0000000000000000 <wrfsbase>:
wrfsbase:
	wrfsbase %rax
   0:	f3 48 0f ae d0       	wrfsbase %rax
	wrfsbase %rdx
   5:	f3 48 0f ae d2       	wrfsbase %rdx
	wrfsbaseq %rax
   a:	f3 48 0f ae d0       	wrfsbase %rax
	wrfsbasel %eax
   f:	f3 0f ae d0          	wrfsbase %eax
	wrfsbase %eax
  13:	f3 0f ae d0          	wrfsbase %eax

0000000000000017 <rdfsbase>:
rdfsbase:
	rdfsbase %rax
  17:	f3 48 0f ae c0       	rdfsbase %rax
	rdfsbase %rdx
  1c:	f3 48 0f ae c2       	rdfsbase %rdx
	rdfsbaseq %rax
  21:	f3 48 0f ae c0       	rdfsbase %rax
	rdfsbasel %eax
  26:	f3 0f ae c0          	rdfsbase %eax
	rdfsbase %eax
  2a:	f3 0f ae c0          	rdfsbase %eax

000000000000002e <wrgsbase>:
wrgsbase:
	wrgsbase %rax
  2e:	f3 48 0f ae d8       	wrgsbase %rax
	wrgsbase %rdx
  33:	f3 48 0f ae da       	wrgsbase %rdx
	wrgsbaseq %rax
  38:	f3 48 0f ae d8       	wrgsbase %rax
	wrgsbasel %eax
  3d:	f3 0f ae d8          	wrgsbase %eax
	wrgsbase %eax
  41:	f3 0f ae d8          	wrgsbase %eax

0000000000000045 <rdgsbase>:
rdgsbase:
	rdgsbase %rax
  45:	f3 48 0f ae c8       	rdgsbase %rax
	rdgsbase %rdx
  4a:	f3 48 0f ae ca       	rdgsbase %rdx
	rdgsbaseq %rax
  4f:	f3 48 0f ae c8       	rdgsbase %rax
	rdgsbasel %eax
  54:	f3 0f ae c8          	rdgsbase %eax
	rdgsbase %eax
  58:	f3 0f ae c8          	rdgsbase %eax

Additionally I checked that the instructions are rejected in 32-bit mode (as --32) and that the l suffix instruction rejects a 64-bit register and the q suffix rejects a 32-bit register.

Finally llvm-objdump produces the same output after assembly by binutils as after assembly by llvm:

% diff test.llvm-objdump.binutils.txt test.llvm-objdump.clang.txt 
2c2
< fsgstest.binutils.o:	file format ELF64-x86-64
---
> fsgstest.clang.o:	file format ELF64-x86-64
%

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Typo, s/modrm.rm/modrm.reg/

bde will be very happy.

Please merge this to stable/11.

This revision is now accepted and ready to land.Sep 4 2017, 8:15 AM
This revision was automatically updated to reflect the committed changes.