[nasm:nasm-2.16.xx] x86: implement FRED: ERETS, ERETU, LKGS

nasm-bot for H. Peter Anvin hpa at zytor.com
Thu Dec 14 17:06:09 PST 2023


Commit-ID:  dd52f386b9503fce2be914ae6dc458640172b63e
Gitweb:     http://repo.or.cz/w/nasm.git?a=commitdiff;h=dd52f386b9503fce2be914ae6dc458640172b63e
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Thu, 14 Dec 2023 17:04:49 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Thu, 14 Dec 2023 17:04:49 -0800

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 at zytor.com>


---
 test/fred.asm | 34 ++++++++++++++++++++++++++++++++++
 x86/iflags.ph |  1 +
 x86/insns.dat | 11 ++++++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/test/fred.asm b/test/fred.asm
new file mode 100644
index 00000000..ac8f850e
--- /dev/null
+++ b/test/fred.asm
@@ -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
diff --git a/x86/iflags.ph b/x86/iflags.ph
index 35a672f0..ad92d9bd 100644
--- a/x86/iflags.ph
+++ b/x86/iflags.ph
@@ -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");
diff --git a/x86/insns.dat b/x86/insns.dat
index ae4c4b6a..a0498d76 100644
--- a/x86/insns.dat
+++ b/x86/insns.dat
@@ -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


More information about the Nasm-commits mailing list