x86: implement FRED: ERETS, ERETU, LKGS

Kind of embarrassing... I had not implemented the FRED instruction,
despite personally being one of the architects of FRED ;)

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2023-12-14 17:04:49 -08:00
parent 84191667f9
commit dd52f386b9
3 changed files with 45 additions and 1 deletions

34
test/fred.asm Normal file
View file

@ -0,0 +1,34 @@
bits 64
default rel
section .text
erets:
erets
eretu:
eretu
%macro lgs 1
mov gs,%1
lkgs %1
%endmacro
lkgs:
lgs [foo]
lgs ax
lgs word [foo]
lgs eax
%ifdef ERROR
lgs dword [foo]
%endif
lgs rax
%ifdef ERROR
lgs qword [foo]
%endif
align 8
section .data
alignb 8
foo:
dq 0

View file

@ -100,6 +100,7 @@ if_("AMXTILE", "AMX tile configuration instructions");
if_("AMXBF16", "AMX bfloat16 multiplication");
if_("AMXINT8", "AMX 8-bit integer multiplication");
if_("FRED", "Flexible Return and Exception Delivery (FRED)");
if_("LKGS", "Load User GS from Kernel (LKGS)");
if_("RAOINT", "Remote atomic operations (RAO-INT)");
if_("UINTR", "User interrupts");
if_("CMPCCXADD", "CMPccXADD instructions");

View file

@ -1,6 +1,6 @@
;; --------------------------------------------------------------------------
;;
;; Copyright 1996-2022 The NASM Authors - All Rights Reserved
;; Copyright 1996-2023 The NASM Authors - All Rights Reserved
;; See the file AUTHORS included with the NASM distribution for
;; the specific copyright holders.
;;
@ -6361,6 +6361,15 @@ UIRET void [ f3 0f 01 ec ] UINTR,FUTURE,LONG
CMPccXADD mem32,reg32,reg32 [mrv: vex.128.66.0f38.w0 e0+c /r] CMPCCXADD,FUTURE,LONG,SD
CMPccXADD mem64,reg64,reg64 [mrv: vex.128.66.0f38.w1 e0+c /r] CMPCCXADD,FUTURE,LONG,SQ
;# Flexible Return and Exception Delivery
ERETS void [ f2 0f 01 ca ] FRED,FUTURE,PRIV,LONG
ERETU void [ f3 0f 01 ca ] FRED,FUTURE,PRIV,LONG
LKGS mem [m: f2 0f 00 /6 ] LKGS,FUTURE,PRIV,LONG,SW
LKGS reg16 [m: f2 0f 00 /6 ] LKGS,FUTURE,PRIV,LONG
LKGS reg32 [m: f2 0f 00 /6 ] LKGS,FUTURE,PRIV,LONG,ND
LKGS reg64 [m: o64nw f2 0f 00 /6 ] LKGS,FUTURE,PRIV,LONG,ND,OPT
LKGS reg64 [m: o64 f2 0f 00 /6 ] LKGS,FUTURE,PRIV,LONG
;# WRMSRNS and MSRLIST instructions
WRMSRNS void [ np 0f 01 c6 ] WRMSRNS,FUTURE,PRIV,LONG
RDMSRLIST void [ f2 0f 01 c6 ] MSRLIST,FUTURE,PRIV,LONG