summaryrefslogtreecommitdiff
path: root/src/arch/x86/isa/insts
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2007-12-01 23:05:01 -0800
committerGabe Black <gblack@eecs.umich.edu>2007-12-01 23:05:01 -0800
commitfe833dd2c33818a1f92f87ea26b17e6b85d3976e (patch)
treed87babd2357acd86c2617460f704b911d8480945 /src/arch/x86/isa/insts
parentdc6f96017135da7f3beae5055195de3cf8e47c6c (diff)
downloadgem5-fe833dd2c33818a1f92f87ea26b17e6b85d3976e.tar.xz
X86: First crack at far returns. This is grossly approximate.
--HG-- extra : convert_revision : 23da0338af1f7663ae5ddf2289fb45dd32f37c42
Diffstat (limited to 'src/arch/x86/isa/insts')
-rw-r--r--src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py b/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py
index 8993f5ac4..0b2e81cbd 100644
--- a/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py
+++ b/src/arch/x86/isa/insts/general_purpose/control_transfer/xreturn.py
@@ -77,4 +77,36 @@ def macroop RET_NEAR_I
add rsp, rsp, t2
wripi t1, 0
};
+
+def macroop RET_FAR {
+ .adjust_env oszIn64Override
+
+ # Get the return RIP
+ ld t1, ss, [1, t0, rsp]
+
+ # Get the return CS
+ ld t2, ss, [1, t0, rsp], dsz
+
+ # Get the rpl
+ andi t3, t2, 0x3
+
+ # Get the cpl
+
+ # Here we'd check if we're changing priviledge levels. We'll just hope
+ # that doesn't happen yet.
+
+ # Do stuff if they're equal
+ chks t4, t2, flags=(EZF,)
+ fault "new GeneralProtection(0)", flags=(CEZF,)
+ ld t3, flatseg, [1, t0, t4], addressSize=8, dataSize=8
+ wrdl cs, t3, t2
+ # There should be validity checks on the RIP checks here, but I'll do
+ # that later.
+ wrip t0, t1
+ bri t0, label("end")
+
+ # Do other stuff if they're not.
+end:
+ fault "NoFault"
+};
'''