Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/57189 )
Change subject: arch-x86: Refactor some legacy interrupt microcode.
......................................................................
arch-x86: Refactor some legacy interrupt microcode.
Using the bochs interrupt handling code as a guide, stop prechecking the
target stack before pushing to it. Instead, put the stack pointer and
stack segment info into temporaries and only update the live values once
the target stack has been successfully constructed. This simplifies and
consolidates the legacy interrupt handling microcode, and will hopefully
help make that code reusable in, for example, a far jump through a call
gate.
Change-Id: Ib7651543964b8d1e0125f3f63e1dbfdd13a0fdbe
---
M src/arch/x86/microcode/romutil.ucode
1 file changed, 70 insertions(+), 58 deletions(-)
diff --git a/src/arch/x86/microcode/romutil.ucode
b/src/arch/x86/microcode/romutil.ucode
index dc6e458..5ef5ef2 100644
--- a/src/arch/x86/microcode/romutil.ucode
+++ b/src/arch/x86/microcode/romutil.ucode
@@ -232,15 +232,30 @@
andi t5, t5, 0x3, dataSize=8
sub t0, t5, t10, flags=(EZF,), dataSize=8
+ # Set up a temporary stack pointer.
+ mov t6, rsp, rsp, dataSize=8
+
# We shouldn't modify CS here, but we need to so we have the right
# permissions for the stack accesses further down.
wrsel cs, t13, dataSize=8
wrdl cs, t3, t13, dataSize=8
- br "{start_label}_noStackSwitch", flags=(CEZF,)
+ br "{start_label}_stackSwitch", flags=(nCEZF,)
+
+ # Copy the stack segment info into hs.
+ rdsel t10, ss, dataSize=8
+ wrsel hs, t10, dataSize=8
+ rdattr t10, ss, dataSize=8
+ wrattr hs, t10, dataSize=8
+ rdbase t10, ss, dataSize=8
+ wrbase hs, t10, dataSize=8
+
+ br "{start_label}_dszIs4", flags=(CECF,)
+ br "{start_label}_dszIs2"
+
+{start_label}_stackSwitch:
# Get the new ESP from the TSS
- mov t6, rsp, rsp, dataSize=8
ld t6, tr, [8, t10, t0], 4, dataSize=4, addressSize=8, atCPL0=True
# Get the new SS from the TSS
ld t8, tr, [8, t10, t0], 8, dataSize=2, addressSize=8, atCPL0=True
@@ -250,80 +265,60 @@
m_read_descriptor desc="t12", selector="t8"
chks t0, t8, t12, SSCheck, dataSize=8
wrdl hs, t12, t8, dataSize=8
+ wrsel hs, t8, dataSize=8
- # Point of no return.
- rdsel t2, ss, dataSize=8
- wrdl ss, t12, t8, dataSize=8
- wrsel ss, t8, dataSize=8
-
- # Make sure the space on the stack is accessible.
br "{start_label}_dszIs4Switched", flags=(CECF,)
+ # Fall through to the switched stack, data size is 2 case.
- cda hs, [1, t0, t6], -2, dataSize=2, addressSize=ssz
- cda hs, [1, t0, t6], -{12 if with_ec else 10}, dataSize=2,
addressSize=ssz
+{start_label}_dszIs2Switched:
+ rdsel t2, ss, dataSize=8
st t2, hs, [1, t0, t6], -2, dataSize=2, addressSize=ssz
st rsp, hs, [1, t0, t6], -4, dataSize=2, addressSize=ssz
- rflags t10, dataSize=8
- st t10, hs, [1, t0, t6], -6, dataSize=2, addressSize=ssz
- st t1, hs, [1, t0, t6], -8, dataSize=2, addressSize=ssz
- st t7, hs, [1, t0, t6], -10, dataSize=2, addressSize=ssz
- subi t6, t6, {12 if with_ec else 10}, dataSize=ssz
- {"st t15, hs, [1, t0, t6], dataSize=2, addressSize=ssz" if with_ec
else ""}
- mov rsp, rsp, t6, dataSize=4
+ subi t6, t6, 4, dataSize=ssz
- br "{start_label}_doneWithStack"
+{start_label}_dszIs2:
+
+ rflags t10, dataSize=8
+ st t10, hs, [1, t0, t6], -2, dataSize=2, addressSize=ssz
+ st t1, hs, [1, t0, t6], -4, dataSize=2, addressSize=ssz
+ st t7, hs, [1, t0, t6], -6, dataSize=2, addressSize=ssz
+ subi t6, t6, {8 if with_ec else 6}, dataSize=ssz
+ {"st t15, hs, [1, t0, t6], " if with_ec else "#"} \
+ {"dataSize=2, addressSize=ssz" if with_ec else ""}
+
+ br "{start_label}_updateESP", flags=(CEZF,)
+ br "{start_label}_updateSS"
{start_label}_dszIs4Switched:
- cda hs, [1, t0, t6], -4, dataSize=4, addressSize=ssz
- cda hs, [1, t0, t6], -{24 if with_ec else 20}, dataSize=4,
addressSize=ssz
-
+ rdsel t2, ss, dataSize=8
st t2, hs, [1, t0, t6], -4, dataSize=4, addressSize=ssz
st rsp, hs, [1, t0, t6], -8, dataSize=4, addressSize=ssz
- rflags t10, dataSize=8
- st t10, hs, [1, t0, t6], -12, dataSize=4, addressSize=ssz
- st t1, hs, [1, t0, t6], -16, dataSize=4, addressSize=ssz
- st t7, hs, [1, t0, t6], -20, dataSize=4, addressSize=ssz
- subi t6, t6, {24 if with_ec else 20}, dataSize=ssz
- {"st t15, hs, [1, t0, t6], dataSize=4, addressSize=ssz" if with_ec
else ""}
- mov rsp, rsp, t6, dataSize=4
-
- br "{start_label}_doneWithStack"
-
-{start_label}_noStackSwitch:
-
- br "{start_label}_dszIs4", flags=(CECF,)
-
- cda ss, [1, t0, rsp], -2, dataSize=2, addressSize=ssz
- cda ss, [1, t0, rsp], -{8 if with_ec else 6}, dataSize=2,
addressSize=ssz
-
- # Point of no return.
- rflags t10, dataSize=8
- st t10, ss, [1, t0, rsp], -2, dataSize=2, addressSize=ssz
- st t1, ss, [1, t0, rsp], -4, dataSize=2, addressSize=ssz
- st t7, ss, [1, t0, rsp], -6, dataSize=2, addressSize=ssz
- subi rsp, rsp, {8 if with_ec else 6}, dataSize=ssz
- {"st t15, ss, [1, t0, rsp], " if with_ec else "#"} \
- {"dataSize=2, addressSize=ssz" if with_ec else ""}
-
- br "{start_label}_doneWithStack"
+ subi t6, t6, 8, dataSize=ssz
{start_label}_dszIs4:
- cda ss, [1, t0, rsp], -4, dataSize=4, addressSize=ssz
- cda ss, [1, t0, rsp], -{16 if with_ec else 12}, dataSize=4,
addressSize=ssz
-
- # Point of no return.
rflags t10, dataSize=8
- st t10, ss, [1, t0, rsp], -4, dataSize=4, addressSize=ssz
- st t1, ss, [1, t0, rsp], -8, dataSize=4, addressSize=ssz
- st t7, ss, [1, t0, rsp], -12, dataSize=4, addressSize=ssz
- subi rsp, rsp, {16 if with_ec else 12}, dataSize=ssz
- {"st t15, ss, [1, t0, rsp], " if with_ec else "#"} \
+ st t10, hs, [1, t0, t6], -4, dataSize=4, addressSize=ssz
+ st t1, hs, [1, t0, t6], -8, dataSize=4, addressSize=ssz
+ st t7, hs, [1, t0, t6], -12, dataSize=4, addressSize=ssz
+ subi t6, t6, {16 if with_ec else 12}, dataSize=ssz
+ {"st t15, ss, [1, t0, t6], " if with_ec else "#"} \
{"dataSize=4, addressSize=ssz" if with_ec else ""}
-{start_label}_doneWithStack:
+ br "{start_label}_updateESP", flags=(CEZF,)
+
+{start_label}_updateSS:
+ rdsel t10, hs, dataSize=8
+ wrsel ss, t10, dataSize=8
+ rdattr t10, hs, dataSize=8
+ wrattr ss, t10, dataSize=8
+ rdbase t10, hs, dataSize=8
+ wrbase ss, t10, dataSize=8
+
+{start_label}_updateESP:
+ mov rsp, rsp, t6, dataSize=4
wrip t0, t9, dataSize=8
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/57189
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib7651543964b8d1e0125f3f63e1dbfdd13a0fdbe
Gerrit-Change-Number: 57189
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s