linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: [bug report] mshv: Add support for movable memory regions
Date: Wed, 10 Dec 2025 11:02:35 +0300	[thread overview]
Message-ID: <aTkpG8Edx_N3p5g4@stanley.mountain> (raw)

Hello Stanislav Kinsburskii,

Commit b9a66cd5ccbb ("mshv: Add support for movable memory regions")
from Dec 3, 2025 (linux-next), leads to the following Smatch static
checker warning:

	drivers/hv/mshv_regions.c:523 mshv_region_interval_invalidate()
	warn: passing uninitialized 'page_offset'

drivers/hv/mshv_regions.c
    486 static bool mshv_region_interval_invalidate(struct mmu_interval_notifier *mni,
    487                                             const struct mmu_notifier_range *range,
    488                                             unsigned long cur_seq)
    489 {
    490         struct mshv_mem_region *region = container_of(mni,
    491                                                       struct mshv_mem_region,
    492                                                       mni);
    493         u64 page_offset, page_count;
    494         unsigned long mstart, mend;
    495         int ret = -EPERM;
    496 
    497         if (mmu_notifier_range_blockable(range))
    498                 mutex_lock(&region->mutex);
    499         else if (!mutex_trylock(&region->mutex))
    500                 goto out_fail;

page_offset and page_count are uninitialized.

    501 
    502         mmu_interval_set_seq(mni, cur_seq);
    503 
    504         mstart = max(range->start, region->start_uaddr);
    505         mend = min(range->end, region->start_uaddr +
    506                    (region->nr_pages << HV_HYP_PAGE_SHIFT));
    507 
    508         page_offset = HVPFN_DOWN(mstart - region->start_uaddr);
    509         page_count = HVPFN_DOWN(mend - mstart);
    510 
    511         ret = mshv_region_remap_pages(region, HV_MAP_GPA_NO_ACCESS,
    512                                       page_offset, page_count);
    513         if (ret)
    514                 goto out_fail;
    515 
    516         mshv_region_invalidate_pages(region, page_offset, page_count);
    517 
    518         mutex_unlock(&region->mutex);
    519 
    520         return true;
    521 
    522 out_fail:
--> 523         WARN_ONCE(ret,
    524                   "Failed to invalidate region %#llx-%#llx (range %#lx-%#lx, event: %u, pages %#llx-%#llx, mm: %#llx): %d\n",
    525                   region->start_uaddr,
    526                   region->start_uaddr + (region->nr_pages << HV_HYP_PAGE_SHIFT),
    527                   range->start, range->end, range->event,
    528                   page_offset, page_offset + page_count - 1, (u64)range->mm, ret);
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    529         return false;
    530 }

regards,
dan carpenter

                 reply	other threads:[~2025-12-10  8:02 UTC|newest]

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

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=aTkpG8Edx_N3p5g4@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=skinsburskii@linux.microsoft.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).