All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: konrad.wilk@oracle.com
Cc: xen-devel@lists.xenproject.org
Subject: Re: xen/mmu: Copy and revector the P2M tree.
Date: Mon, 20 Jul 2015 13:03:52 +0300	[thread overview]
Message-ID: <20150720100352.GA4084@mwanda> (raw)

Hello Konrad Rzeszutek Wilk,

The patch 7f9140626c75: "xen/mmu: Copy and revector the P2M tree."
from Jul 26, 2012, leads to the following static checker warning:

	arch/x86/xen/mmu.c:1105 xen_cleanhighmap()
	warn: potential pointer math issue ('level2_kernel_pgt' is pointer to unsigned long)

arch/x86/xen/mmu.c
  1096  #ifdef CONFIG_X86_64
  1097  static void __init xen_cleanhighmap(unsigned long vaddr,
  1098                                      unsigned long vaddr_end)
  1099  {
  1100          unsigned long kernel_end = roundup((unsigned long)_brk_end, PMD_SIZE) - 1;
  1101          pmd_t *pmd = level2_kernel_pgt + pmd_index(vaddr);
  1102  
  1103          /* NOTE: The loop is more greedy than the cleanup_highmap variant.
  1104           * We include the PMD passed in on _both_ boundaries. */
  1105          for (; vaddr <= vaddr_end && (pmd < (level2_kernel_pgt + PAGE_SIZE));
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This pointer math is weird because we typically think of PAGE_SIZE as
a number of bytes but since level2_kernel_pgt is a pointer to unsigned
long, it looks like this loop can go through more iterations than
intended.

  1106                          pmd++, vaddr += PMD_SIZE) {
  1107                  if (pmd_none(*pmd))
  1108                          continue;
  1109                  if (vaddr < (unsigned long) _text || vaddr > kernel_end)
  1110                          set_pmd(pmd, __pmd(0));
  1111          }
  1112          /* In case we did something silly, we should crash in this function
  1113           * instead of somewhere later and be confusing. */
  1114          xen_mc_flush();
  1115  }

regards,
dan carpenter

             reply	other threads:[~2015-07-20 10:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20 10:03 Dan Carpenter [this message]
2015-08-07  0:23 ` xen/mmu: Copy and revector the P2M tree Dan Carpenter

Reply instructions:

You may reply publicly 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=20150720100352.GA4084@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=konrad.wilk@oracle.com \
    --cc=xen-devel@lists.xenproject.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.