Skip to content

Commit ee14769

Browse files
committed
proxyclient: only write rvbar if needed
Signed-off-by: Yureka <[email protected]>
1 parent b35f258 commit ee14769

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

proxyclient/m1n1/hv/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,15 @@ def remove_oslog(node):
17861786
continue
17871787
addr, size = cpu.cpu_impl_reg
17881788
print(f" {cpu.name}: [0x{addr:x}] = 0x{rvbar:x}")
1789+
# On some platforms (M4) iBoot already sets this
1790+
# to the m1n1 entrypoint and locks the register.
1791+
# Skip the write if the value is already correct.
1792+
val = self.p.read64(addr)
1793+
if val & 0xfffffffff000 == rvbar:
1794+
continue
1795+
if val & 1:
1796+
print(f"{hex(val & 0xfffffffff000)} != {hex(rvbar)}")
1797+
print("The cpu_impl_reg is already locked, this might fail...")
17891798
self.p.write64(addr, rvbar)
17901799

17911800
def _load_macho_symbols(self):

proxyclient/tools/chainload.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ def remove_oslog(node):
100100
continue
101101
addr, size = cpu.cpu_impl_reg
102102
print(f" {cpu.name}: [0x{addr:x}] = 0x{rvbar:x}")
103+
# On some platforms (M4) iBoot already sets this
104+
# to the m1n1 entrypoint and locks the register.
105+
# Skip the write if the value is already correct.
106+
val = p.read64(addr)
107+
if val & 0xfffffffff000 == rvbar:
108+
continue
109+
if val & 1:
110+
print(f"{hex(val & 0xfffffffff000)} != {hex(rvbar)}")
111+
print("The cpu_impl_reg is already locked, this might fail...")
103112
p.write64(addr, rvbar)
104113

105114
u.push_adt()

0 commit comments

Comments
 (0)