Skip to content

Commit 1ab3dee

Browse files
noopwafeljannau
authored andcommitted
m1n1.hw.uat: support wider VA ranges
Signed-off-by: Alyssa Milburn <[email protected]>
1 parent a040c83 commit 1ab3dee

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

proxyclient/m1n1/hw/uat.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import struct
1212
from ..fw.agx.handoff import GFXHandoff
13+
from m1n1.constructutils import Ver
1314
from ..utils import *
1415
from ..malloc import Heap
1516
from enum import IntEnum
@@ -239,16 +240,22 @@ def closed(self):
239240
return False
240241

241242

243+
if Ver.check("G >= G15"):
244+
UAT_L0_OFF = 42
245+
else:
246+
UAT_L0_OFF = 39
247+
242248
class UAT(Reloadable):
243249
NUM_CONTEXTS = 64
244250

245251
PAGE_BITS = 14
246252
PAGE_SIZE = 1 << PAGE_BITS
247253

254+
# "size" is the number of entries at that level
248255
L0_SIZE = 2
249-
L0_OFF = 39
250-
L1_SIZE = 8
256+
L0_OFF = UAT_L0_OFF
251257
L1_OFF = 36
258+
L1_SIZE = 1 << (L0_OFF - L1_OFF)
252259
L2_OFF = 25
253260
L3_OFF = 14
254261

@@ -277,6 +284,8 @@ def __init__(self, iface, util=None, hv=None):
277284
self.shared_region = self.sgx_dev.gfx_shared_region_base
278285
self.gpu_region = self.sgx_dev.gpu_region_base
279286
self.ttbr0_base = self.u.memalign(self.PAGE_SIZE, self.PAGE_SIZE)
287+
# We reuse the TTBR1 which the firmware is using, because it also has the FW-side mappings.
288+
# The alternative would be to map self.sgx_dev.gfx_shared_l2_region_base into a new TTBR1.
280289
self.ttbr1_base = self.sgx_dev.gfx_shared_region_base
281290
self.handoff = GFXHandoff(self.u)
282291

@@ -499,8 +508,8 @@ def invalidate_cache(self):
499508

500509
def recurse_level(self, level, base, table, page_fn=None, table_fn=None):
501510
def extend(addr):
502-
if addr >= 0x80_00000000:
503-
addr |= 0xf00_00000000
511+
if addr >= (1 << UAT_L0_OFF):
512+
addr |= 0xffffffff_ffffffff ^ self.VA_MASK
504513
return addr
505514

506515
offset, size, ptecls = self.LEVELS[level]
@@ -539,7 +548,11 @@ def init(self):
539548

540549
print("[UAT] Initializing...")
541550

551+
#print(f"[UAT] TTBAT @ 0x{self.gpu_region:016x}")
552+
#print(f"[UAT] ASC carveout region @ 0x{self.shared_region:016x}")
553+
542554
# Clear out any stale kernel page tables
555+
# (The third entry is the TTBR1 shared L2 table, which is fine to keep.)
543556
self.p.memset64(self.ttbr1_base + 0x10, 0, 0x3ff0)
544557
self.u.inst("tlbi vmalle1os")
545558

0 commit comments

Comments
 (0)