Linux-MIPS Archive on lore.kernel.org
 help / color / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: ralf@linux-mips.org
Cc: linux-mips@vger.kernel.org
Subject: [bug report] [MIPS] MT: Improved multithreading support.
Date: Wed, 14 Aug 2019 16:29:24 +0300
Message-ID: <20190814132924.GA23964@mwanda> (raw)

[ 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

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190814132924.GA23964@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-mips@vger.kernel.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org linux-mips@archiver.kernel.org
	public-inbox-index linux-mips


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/ public-inbox