@@ -274,6 +274,9 @@ event_dispatch:
274274 callr r1
275275
276276 /*
277+ * Coming back from the C-world, our thread info pointer
278+ * should be in the designated register (usually R19)
279+ *
277280 * If we were in kernel mode, we don't need to check scheduler
278281 * or signals if CONFIG_PREEMPT is not set. If set, then it has
279282 * to jump to a need_resched kind of block.
@@ -286,67 +289,43 @@ event_dispatch:
286289#endif
287290
288291 /* "Nested control path" -- if the previous mode was kernel */
289- R0 = memw(R29 + #_PT_ER_VMEST);
290292 {
291- P0 = tstbit(R0, #HVM_VMEST_UM_SFT );
292- if (!P0.new) jump: nt restore_all ;
293+ R0 = memw(R29 + #_PT_ER_VMEST );
294+ R16.L = #LO(do_work_pending) ;
293295 }
294- /*
295- * Returning from system call, normally coming back from user mode
296- */
297- return_from_syscall:
298- /* Disable interrupts while checking TIF */
299- R0 = #VM_INT_DISABLE
300- trap1(#HVM_TRAP1_VMSETIE)
301-
302- /*
303- * Coming back from the C-world, our thread info pointer
304- * should be in the designated register (usually R19)
305- */
306- #if CONFIG_HEXAGON_ARCH_VERSION < 4
307- R1.L = #LO(_TIF_ALLWORK_MASK)
308296 {
309- R1.H = #HI(_TIF_ALLWORK_MASK);
310- R0 = memw(THREADINFO_REG + #_THREAD_INFO_FLAGS);
311- }
312- #else
313- {
314- R1 = ##_TIF_ALLWORK_MASK;
315- R0 = memw(THREADINFO_REG + #_THREAD_INFO_FLAGS);
297+ P0 = tstbit(R0, #HVM_VMEST_UM_SFT);
298+ if (!P0.new) jump: nt restore_all;
299+ R16.H = #HI(do_work_pending);
300+ R0 = #VM_INT_DISABLE;
316301 }
317- #endif
318302
319303 /*
320- * Compare against the "return to userspace" _TIF_WORK_MASK
304+ * Check also the return from fork/system call, normally coming back from
305+ * user mode
306+ *
307+ * R16 needs to have do_work_pending, and R0 should have VM_INT_DISABLE
321308 */
322- R1 = and (R1,R0);
323- { P0 = cmp .eq(R1,#0); if (!P0.new) jump:t work_pending;}
324- jump restore_all; /* we're outta here! */
325309
326- work_pending:
310+ check_work_pending:
311+ /* Disable interrupts while checking TIF */
312+ trap1(#HVM_TRAP1_VMSETIE)
327313 {
328- P0 = tstbit(R1, #TIF_NEED_RESCHED);
329- if (!P0.new) jump: nt work_notifysig;
314+ R0 = R29; /* regs should still be at top of stack */
315+ R1 = memw(THREADINFO_REG + #_THREAD_INFO_FLAGS);
316+ callr R16;
330317 }
331- call schedule
332- jump return_from_syscall; /* check for more work */
333318
334- work_notifysig:
335- /* this is the part that's kind of fuzzy. */
336- R1 = and (R0, #(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME));
337- {
338- P0 = cmp .eq(R1, #0);
339- if P0.new jump: t restore_all;
340- }
341319 {
342- R1 = R0; /* unsigned long thread_info_flags */
343- R0 = R29; /* regs should still be at top of stack */
320+ P0 = cmp .eq(R0, #0); if (!P0.new) jump:nt check_work_pending;
321+ R0 = #VM_INT_DISABLE;
344322 }
345- call do_notify_resume
346323
347324restore_all:
348- /* Disable interrupts, if they weren't already, before reg restore. */
349- R0 = #VM_INT_DISABLE
325+ /*
326+ * Disable interrupts, if they weren't already, before reg restore.
327+ * R0 gets preloaded with #VM_INT_DISABLE before we get here.
328+ */
350329 trap1(#HVM_TRAP1_VMSETIE)
351330
352331 /* do the setregs here for VM 0.5 */
@@ -371,6 +350,7 @@ restore_all:
371350 trap1(#HVM_TRAP1_VMRTE)
372351 /* Notreached */
373352
353+
374354 .globl _K_enter_genex
375355_K_enter_genex:
376356 vm_event_entry(do_genex)
@@ -390,9 +370,12 @@ _K_enter_machcheck:
390370
391371 .globl ret_from_fork
392372ret_from_fork:
393- call schedule_tail
394- P0 = cmp .eq(R24, #0);
395- if P0 jump return_from_syscall
396- R0 = R25;
397- callr R24
398- jump return_from_syscall
373+ {
374+ call schedule_tail;
375+ R16.H = #HI(do_work_pending);
376+ }
377+ {
378+ R16.L = #LO(do_work_pending);
379+ R0 = #VM_INT_DISABLE;
380+ jump check_work_pending;
381+ }
0 commit comments