Linux-HyperV List
 help / color / mirror / Atom feed
From: Yuho Choi <oss.patchbox@gmail.com>
To: Haiyang Zhang <haiyangz@microsoft.com>, Dexuan Cui <decui@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>, linux-hyperv@vger.kernel.org
Subject: net: mana: HWC memory after a failed DESTROY_HWC
Date: Sun,  1 Nov 2026 23:06:26 -0500	[thread overview]
Message-ID: <20261102040629.368393-2-oss.patchbox@gmail.com> (raw)

Hi Haiyang, Dexuan,

I have a question about the HWC teardown in mana_hwc_destroy_channel()
(drivers/net/ethernet/microsoft/mana/hw_channel.c, v7.4-rc1).

The function sends DESTROY_HWC but does not check the result, and then
frees the HWC queues and message buffers:

	if (gc->max_num_cqs > 0) {
		mana_smc_teardown_hwc(&gc->shm_channel, false);
		gc->max_num_cqs = 0;
	}

	if (hwc->txq)
		mana_hwc_destroy_wq(hwc, hwc->txq);
	...

mana_smc_teardown_hwc() itself says that waiting for the response "is
required to ensure hardware invalidates MST entries before software
frees memory". So I wonder what happens when the teardown fails, i.e.
when the PF returns an error (-EPROTO) or does not answer in time
(-ETIMEDOUT):

1. Can the hardware still write EQEs, CQEs or HWC responses to these
   pages after the driver has freed them?

2. Or is the function always reset in that case, so that nothing can
   reach the memory anymore? One case I have in mind is
   mana_serv_reset(), which calls mana_gd_suspend() while the HWC is
   not responding, so the teardown there may often fail.

If (1) is possible, I have a patch ready that keeps the HWC rings and
message buffers allocated when the teardown fails, leaking a few pages
instead of freeing memory the hardware may still use, and I would be
glad to send it. If (2) always holds, there is nothing to fix and I
will drop it.

This came from code inspection as part of ongoing, not yet published
research, and I have not reproduced it. I used an LLM to help with the
analysis and this mail.

Thanks,
Yuho

                 reply	other threads:[~2026-11-02  4:06 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=20261102040629.368393-2-oss.patchbox@gmail.com \
    --to=oss.patchbox@gmail.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=wei.liu@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox