All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] [MIPS] MT: Improved multithreading support.
@ 2019-08-14 13:29 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-08-14 13:29 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

[ This is ancient code, but the bug is straight forward -- dan ]

Hello Ralf Baechle,

The patch 41c594ab65fc: "[MIPS] MT: Improved multithreading support."
from Apr 5, 2006, leads to the following static checker warning:

	arch/mips/kernel/smp-mt.c:168 vsmp_boot_secondary()
	warn: potential pointer math issue

arch/mips/kernel/smp-mt.c
   142  static int vsmp_boot_secondary(int cpu, struct task_struct *idle)
   143  {
   144          struct thread_info *gp = task_thread_info(idle);
                ^^^^^^^^^^^^^^^^^^^^^^
gp is a thread_info struct pointer.

   145          dvpe();
   146          set_c0_mvpcontrol(MVPCONTROL_VPC);
   147  
   148          settc(cpu);
   149  
   150          /* restart */
   151          write_tc_c0_tcrestart((unsigned long)&smp_bootstrap);
   152  
   153          /* enable the tc this vpe/cpu will be running */
   154          write_tc_c0_tcstatus((read_tc_c0_tcstatus() & ~TCSTATUS_IXMT) | TCSTATUS_A);
   155  
   156          write_tc_c0_tchalt(0);
   157  
   158          /* enable the VPE */
   159          write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | VPECONF0_VPA);
   160  
   161          /* stack pointer */
   162          write_tc_gpr_sp( __KSTK_TOS(idle));
   163  
   164          /* global pointer */
   165          write_tc_gpr_gp((unsigned long)gp);
   166  
   167          flush_icache_range((unsigned long)gp,
   168                             (unsigned long)(gp + sizeof(struct thread_info)));
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This should almost certainly be "gp + 1" because of pointer math.

   169  
   170          /* finally out of configuration and into chaos */
   171          clear_c0_mvpcontrol(MVPCONTROL_VPC);
   172  
   173          evpe(EVPE_ENABLE);
   174  
   175          return 0;
   176  }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-14 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-14 13:29 [bug report] [MIPS] MT: Improved multithreading support Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.