4545 * number in the case where we decode a system call (trap0(#1)).
4646 */
4747
48+ #if CONFIG_HEXAGON_ARCH_VERSION < 4
4849#define save_pt_regs()\
49- memd (R0 + # _PT_R3130 ) = R31 :30 ; \
50+ memd(R0 + #_PT_R3130) = R31:30; \
51+ { memw(R0 + #_PT_R2928) = R28; \
52+ R31 = memw(R0 + #_PT_ER_VMPSP); }\
53+ { memw(R0 + #(_PT_R2928 + 4)) = R31; \
54+ R31 = ugp; } \
55+ { memd(R0 + #_PT_R2726) = R27:26; \
56+ R30 = gp ; } \
57+ memd(R0 + #_PT_R2524) = R25:24; \
58+ memd(R0 + #_PT_R2322) = R23:22; \
59+ memd(R0 + #_PT_R2120) = R21:20; \
60+ memd(R0 + #_PT_R1918) = R19:18; \
61+ memd(R0 + #_PT_R1716) = R17:16; \
62+ memd(R0 + #_PT_R1514) = R15:14; \
63+ memd(R0 + #_PT_R1312) = R13:12; \
64+ { memd(R0 + #_PT_R1110) = R11:10; \
65+ R15 = lc0; } \
66+ { memd(R0 + #_PT_R0908) = R9:8; \
67+ R14 = sa0; } \
68+ { memd(R0 + #_PT_R0706) = R7:6; \
69+ R13 = lc1; } \
70+ { memd(R0 + #_PT_R0504) = R5:4; \
71+ R12 = sa1; } \
72+ { memd(R0 + #_PT_GPUGP) = R31:30; \
73+ R11 = m1; \
74+ R2.H = #HI(_THREAD_SIZE); } \
75+ { memd(R0 + #_PT_LC0SA0) = R15:14; \
76+ R10 = m0; \
77+ R2.L = #LO(_THREAD_SIZE); } \
78+ { memd(R0 + #_PT_LC1SA1) = R13:12; \
79+ R15 = p3:0 ; \
80+ R2 = neg (R2); } \
81+ { memd(R0 + #_PT_M1M0) = R11:10; \
82+ R14 = usr; \
83+ R2 = and (R0,R2); } \
84+ { memd(R0 + #_PT_PREDSUSR) = R15:14; \
85+ THREADINFO_REG = R2; } \
86+ { r24 = memw(THREADINFO_REG + #_THREAD_INFO_PT_REGS); \
87+ memw(THREADINFO_REG + #_THREAD_INFO_PT_REGS) = R0; \
88+ R2 = #-1; } \
89+ { memw(R0 + #_PT_SYSCALL_NR) = R2; \
90+ R30 = #0; }
91+ #else
92+ /* V4+ */
93+ /* the # ## # syntax inserts a literal ## */
94+ #define save_pt_regs()\
95+ { memd(R0 + #_PT_R3130) = R31:30; \
96+ R30 = memw(R0 + #_PT_ER_VMPSP); }\
5097 { memw(R0 + #_PT_R2928) = R28; \
51- R31 = memw (R0 + # _PT_ER_VMPSP ); }\
52- { memw (R0 + # (_PT_R2928 + 4 )) = R31 ; \
53- R31 = ugp ; } \
54- { memd (R0 + # _PT_R2726 ) = R27 :26 ; \
55- R30 = gp ; } \
56- memd (R0 + # _PT_R2524 ) = R25 :24 ; \
57- memd (R0 + # _PT_R2322 ) = R23 :22 ; \
58- memd (R0 + # _PT_R2120 ) = R21 :20 ; \
59- memd (R0 + # _PT_R1918 ) = R19 :18 ; \
60- memd (R0 + # _PT_R1716 ) = R17 : 16 ; \
61- memd (R0 + # _PT_R1514 ) = R15 :14 ; \
62- memd (R0 + # _PT_R1312 ) = R13 :12 ; \
98+ memw(R0 + #(_PT_R2928 + 4)) = R30; }\
99+ { R31: 30 = C11:10 ; \
100+ memd(R0 + #_PT_R2726) = R27:26; \
101+ memd(R0 + #_PT_R2524) = R25:24; }\
102+ { memd(R0 + #_PT_R2322) = R23:22; \
103+ memd(R0 + #_PT_R2120) = R21:20; }\
104+ { memd(R0 + #_PT_R1918) = R19:18; \
105+ memd(R0 + #_PT_R1716) = R17:16; }\
106+ { memd(R0 + #_PT_R1514) = R15:14; \
107+ memd(R0 + #_PT_R1312) = R13:12; \
108+ R17: 16 = C13:12 ; }\
63109 { memd(R0 + #_PT_R1110) = R11:10; \
64- R15 = lc0 ; } \
65- { memd (R0 + # _PT_R0908 ) = R9 : 8 ; \
66- R14 = sa0 ; } \
110+ memd(R0 + #_PT_R0908) = R9:8; \
111+ R15: 14 = C1:0 ; } \
67112 { memd(R0 + #_PT_R0706) = R7:6; \
68- R13 = lc1 ; } \
69- { memd (R0 + # _PT_R0504 ) = R5 :4 ; \
70- R12 = sa1 ; } \
71- { memd (R0 + # _PT_UGPGP ) = R31 :30 ; \
72- R11 = m1 ; \
73- R2. H = # HI (_THREAD_SIZE ); } \
74- { memd (R0 + # _PT_LC0SA0 ) = R15 :14 ; \
75- R10 = m0 ; \
76- R2. L = # LO (_THREAD_SIZE ); } \
77- { memd (R0 + # _PT_LC1SA1 ) = R13 :12 ; \
78- R15 = p3 :0 ; \
79- R2 = neg (R2 ); } \
113+ memd(R0 + #_PT_R0504) = R5:4; \
114+ R13: 12 = C3:2 ; } \
115+ { memd(R0 + #_PT_GPUGP) = R31:30; \
116+ memd(R0 + #_PT_LC0SA0) = R15:14; \
117+ R11: 10 = C7:6 ; }\
118+ { THREADINFO_REG = and (R0, # ## #-_THREAD_SIZE); \
119+ memd(R0 + #_PT_LC1SA1) = R13:12; \
120+ R15 = p3:0 ; }\
80121 { memd(R0 + #_PT_M1M0) = R11:10; \
81- R14 = usr ; \
82- R2 = and (R0 ,R2 ); } \
83- { memd (R0 + # _PT_PREDSUSR ) = R15 :14 ; \
84- THREADINFO_REG = R2 ; } \
122+ memw(R0 + #_PT_PREDSUSR + 4) = R15; }\
85123 { r24 = memw(THREADINFO_REG + #_THREAD_INFO_PT_REGS); \
86124 memw(THREADINFO_REG + #_THREAD_INFO_PT_REGS) = R0; \
87125 R2 = #-1; } \
88126 { memw(R0 + #_PT_SYSCALL_NR) = R2; \
127+ memd(R0 + #_PT_CS1CS0) = R17:16; \
89128 R30 = #0; }
129+ #endif
90130
91131/*
92132 * Restore registers and thread_info.regs state. THREADINFO_REG
93133 * is assumed to still be sane, and R24 to have been correctly
94134 * preserved. Don't restore R29 (SP) until later.
95135 */
96136
137+ #if CONFIG_HEXAGON_ARCH_VERSION < 4
97138#define restore_pt_regs() \
98139 { memw(THREADINFO_REG + #_THREAD_INFO_PT_REGS) = R24; \
99140 R15: 14 = memd(R0 + #_PT_PREDSUSR); } \
121162 R23: 22 = memd(R0 + #_PT_R2322); } \
122163 { R25: 24 = memd(R0 + #_PT_R2524); \
123164 R27: 26 = memd(R0 + #_PT_R2726); } \
124- R31 :30 = memd (R0 + # _PT_UGPGP ); \
165+ R31: 30 = memd(R0 + #_PT_GPUGP ); \
125166 { R28 = memw(R0 + #_PT_R2928); \
126167 ugp = R31; } \
127168 { R31: 30 = memd(R0 + #_PT_R3130); \
128169 gp = R30; }
170+ #else
171+ /* V4+ */
172+ #define restore_pt_regs() \
173+ { memw(THREADINFO_REG + #_THREAD_INFO_PT_REGS) = R24; \
174+ R15: 14 = memd(R0 + #_PT_PREDSUSR); } \
175+ { R11: 10 = memd(R0 + #_PT_M1M0); \
176+ R13: 12 = memd(R0 + #_PT_LC1SA1); \
177+ p3: 0 = R15; } \
178+ { R15: 14 = memd(R0 + #_PT_LC0SA0); \
179+ R3: 2 = memd(R0 + #_PT_R0302); \
180+ usr = R14; } \
181+ { R5: 4 = memd(R0 + #_PT_R0504); \
182+ R7: 6 = memd(R0 + #_PT_R0706); \
183+ C7: 6 = R11:10 ; }\
184+ { R9: 8 = memd(R0 + #_PT_R0908); \
185+ R11: 10 = memd(R0 + #_PT_R1110); \
186+ C3: 2 = R13:12 ; }\
187+ { R13: 12 = memd(R0 + #_PT_R1312); \
188+ R15: 14 = memd(R0 + #_PT_R1514); \
189+ C1: 0 = R15:14 ; }\
190+ { R17: 16 = memd(R0 + #_PT_R1716); \
191+ R19: 18 = memd(R0 + #_PT_R1918); } \
192+ { R21: 20 = memd(R0 + #_PT_R2120); \
193+ R23: 22 = memd(R0 + #_PT_R2322); } \
194+ { R25: 24 = memd(R0 + #_PT_R2524); \
195+ R27: 26 = memd(R0 + #_PT_R2726); } \
196+ R31: 30 = memd(R0 + #_PT_CS1CS0); \
197+ { C13: 12 = R31:30 ; \
198+ R31: 30 = memd(R0 + #_PT_GPUGP) ; \
199+ R28 = memw(R0 + #_PT_R2928); }\
200+ { C11: 10 = R31:30 ; \
201+ R31: 30 = memd(R0 + #_PT_R3130); }
202+ #endif
129203
130204 /*
131205 * Clears off enough space for the rest of pt_regs; evrec is a part
139213 * Need to save off R0, R1, R2, R3 immediately.
140214 */
141215
216+ #if CONFIG_HEXAGON_ARCH_VERSION < 4
142217#define vm_event_entry(CHandler) \
143218 { \
144219 R29 = add (R29, #-(_PT_REGS_SIZE)); \
158233 R1.H = #HI(CHandler); \
159234 jump event_dispatch; \
160235 }
236+ #else
237+ /* V4+ */
238+ /* turn on I$ prefetch early */
239+ /* the # ## # syntax inserts a literal ## */
240+ #define vm_event_entry(CHandler) \
241+ { \
242+ R29 = add (R29, #-(_PT_REGS_SIZE)); \
243+ memd(R29 + #(_PT_R0100 + -_PT_REGS_SIZE)) = R1:0; \
244+ memd(R29 + #(_PT_R0302 + -_PT_REGS_SIZE)) = R3:2; \
245+ R0 = usr; \
246+ } \
247+ { \
248+ memw(R29 + #_PT_PREDSUSR) = R0; \
249+ R0 = setbit(R0, #16); \
250+ } \
251+ usr = R0; \
252+ R1: 0 = G1:0 ; \
253+ { \
254+ memd(R29 + #_PT_ER_VMEL) = R1:0; \
255+ R1 = # ## #(CHandler); \
256+ R3: 2 = G3:2 ; \
257+ } \
258+ { \
259+ R0 = R29; \
260+ memd(R29 + #_PT_ER_VMPSP) = R3:2; \
261+ jump event_dispatch; \
262+ }
263+ #endif
161264
162265.text
163266 /*
@@ -184,8 +287,10 @@ event_dispatch:
184287
185288 /* "Nested control path" -- if the previous mode was kernel */
186289 R0 = memw(R29 + #_PT_ER_VMEST);
187- P0 = tstbit (R0 , # HVM_VMEST_UM_SFT );
188- if ! P0 jump restore_all ;
290+ {
291+ P0 = tstbit(R0, #HVM_VMEST_UM_SFT);
292+ if (!P0.new) jump: nt restore_all;
293+ }
189294 /*
190295 * Returning from system call, normally coming back from user mode
191296 */
@@ -198,11 +303,18 @@ return_from_syscall:
198303 * Coming back from the C-world, our thread info pointer
199304 * should be in the designated register (usually R19)
200305 */
306+ #if CONFIG_HEXAGON_ARCH_VERSION < 4
201307 R1.L = #LO(_TIF_ALLWORK_MASK)
202308 {
203309 R1.H = #HI(_TIF_ALLWORK_MASK);
204310 R0 = memw(THREADINFO_REG + #_THREAD_INFO_FLAGS);
205311 }
312+ #else
313+ {
314+ R1 = ##_TIF_ALLWORK_MASK;
315+ R0 = memw(THREADINFO_REG + #_THREAD_INFO_FLAGS);
316+ }
317+ #endif
206318
207319 /*
208320 * Compare against the "return to userspace" _TIF_WORK_MASK
@@ -222,10 +334,14 @@ work_pending:
222334work_notifysig:
223335 /* this is the part that's kind of fuzzy. */
224336 R1 = and (R0, #(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME));
225- P0 = cmp . eq (R1 , # 0 );
226- if P0 jump restore_all
227- R1 = R0 ; /* unsigned long thread_info_flags */
228- R0 = R29 ; /* regs should still be at top of stack */
337+ {
338+ P0 = cmp .eq(R1, #0);
339+ if P0.new jump: t restore_all;
340+ }
341+ {
342+ R1 = R0; /* unsigned long thread_info_flags */
343+ R0 = R29; /* regs should still be at top of stack */
344+ }
229345 call do_notify_resume
230346
231347restore_all:
@@ -235,14 +351,23 @@ restore_all:
235351
236352 /* do the setregs here for VM 0.5 */
237353 /* R29 here should already be pointing at pt_regs */
238- R1 :0 = memd (R29 + # _PT_ER_VMEL );
239- R3 :2 = memd (R29 + # _PT_ER_VMPSP );
354+ {
355+ R1: 0 = memd(R29 + #_PT_ER_VMEL);
356+ R3: 2 = memd(R29 + #_PT_ER_VMPSP);
357+ }
358+ #if CONFIG_HEXAGON_ARCH_VERSION < 4
240359 trap1(#HVM_TRAP1_VMSETREGS);
360+ #else
361+ G1: 0 = R1:0 ;
362+ G3: 2 = R3:2 ;
363+ #endif
241364
242365 R0 = R29
243366 restore_pt_regs()
244- R1 :0 = memd (R29 + # _PT_R0100 );
245- R29 = add (R29 , # _PT_REGS_SIZE );
367+ {
368+ R1: 0 = memd(R29 + #_PT_R0100);
369+ R29 = add (R29, #_PT_REGS_SIZE);
370+ }
246371 trap1(#HVM_TRAP1_VMRTE)
247372 /* Notreached */
248373
0 commit comments