* Re: [PATCH v4 0/7] hyperv: Introduce new way to manage hypercall args
From: Wei Liu @ 2025-08-12 23:58 UTC (permalink / raw)
To: mhklinux
Cc: kys, haiyangz, wei.liu, decui, tglx, mingo, bp, dave.hansen, hpa,
lpieralisi, kw, mani, robh, bhelgaas, arnd, x86, linux-hyperv,
linux-kernel, linux-pci, linux-arch
In-Reply-To: <20250718045545.517620-1-mhklinux@outlook.com>
On Thu, Jul 17, 2025 at 09:55:38PM -0700, mhkelley58@gmail.com wrote:
> From: Michael Kelley <mhklinux@outlook.com>
>
[...]
>
> Michael Kelley (7):
> Drivers: hv: Introduce hv_setup_*() functions for hypercall arguments
> x86/hyperv: Use hv_setup_*() to set up hypercall arguments -- part 1
> x86/hyperv: Use hv_setup_*() to set up hypercall arguments -- part 2
> Drivers: hv: Use hv_setup_*() to set up hypercall arguments
> PCI: hv: Use hv_setup_*() to set up hypercall arguments
> Drivers: hv: Use hv_setup_*() to set up hypercall arguments for mshv
> code
> Drivers: hv: Replace hyperv_pcpu_input/output_arg with hyperv_pcpu_arg
Queued for inclusion into hyperv-next. Thanks!
^ permalink raw reply
* Re: [RFC PATCH V6 0/4 Resend] x86/Hyper-V: Add AMD Secure AVIC for Hyper-V platform
From: Wei Liu @ 2025-08-12 23:47 UTC (permalink / raw)
To: Tianyu Lan
Cc: kys, haiyangz, wei.liu, decui, tglx, mingo, bp, dave.hansen, x86,
hpa, arnd, Neeraj.Upadhyay, kvijayab, Tianyu Lan, linux-arch,
linux-hyperv, linux-kernel
In-Reply-To: <20250806121855.442103-1-ltykernel@gmail.com>
On Wed, Aug 06, 2025 at 08:18:51PM +0800, Tianyu Lan wrote:
> From: Tianyu Lan <tiala@microsoft.com>
[...]
> Tianyu Lan (4):
> x86/hyperv: Don't use hv apic driver when Secure AVIC is available
> Drivers: hv: Allow vmbus message synic interrupt injected from Hyper-V
> x86/hyperv: Don't use auto-eoi when Secure AVIC is available
> x86/hyperv: Allow Hyper-V to inject STIMER0 interrupts
Are they still RFC? They look like ready to be merged.
Wei
^ permalink raw reply
* Re: [PATCH v2] clocksource: hyper-v: Skip unnecessary checks for the root partition
From: Nuno Das Neves @ 2025-08-12 20:30 UTC (permalink / raw)
To: Wei Liu, Linux on Hyper-V List
Cc: mhklinux, K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Daniel Lezcano, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
In-Reply-To: <20250812194846.2647201-1-wei.liu@kernel.org>
On 8/12/2025 2:48 PM, Wei Liu wrote:
> The HV_ACCESS_TSC_INVARIANT bit is always zero when Linux runs as the
> root partition. The root partition will see directly what the hardware
> provides.
>
> The old logic in ms_hyperv_init_platform caused the native TSC clock
> source to be incorrectly marked as unstable on x86. Fix it.
>
> Skip the unnecessary checks in code for the root partition. Add one
> extra comment in code to clarify the behavior.
>
> Signed-off-by: Wei Liu <wei.liu@kernel.org>
> ---
> v2: update the commit message and comments
> ---
> arch/x86/kernel/cpu/mshyperv.c | 11 ++++++++++-
> drivers/clocksource/hyperv_timer.c | 10 +++++++++-
> 2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index c78f860419d6..25773af116bc 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -565,6 +565,11 @@ static void __init ms_hyperv_init_platform(void)
> machine_ops.crash_shutdown = hv_machine_crash_shutdown;
> #endif
> #endif
> + /*
> + * HV_ACCESS_TSC_INVARIANT is always zero for the root partition. Root
> + * partition doesn't need to write to synthetic MSR to enable invariant
> + * TSC feature. It sees what the hardware provides.
> + */
> if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
> /*
> * Writing to synthetic MSR 0x40000118 updates/changes the
> @@ -636,8 +641,12 @@ static void __init ms_hyperv_init_platform(void)
> * TSC should be marked as unstable only after Hyper-V
> * clocksource has been initialized. This ensures that the
> * stability of the sched_clock is not altered.
> + *
> + * HV_ACCESS_TSC_INVARIANT is always zero for the root partition. No
> + * need to check for it.
> */
> - if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> + if (!hv_root_partition() &&
> + !(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> mark_tsc_unstable("running on Hyper-V");
>
> hardlockup_detector_disable();
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index 2edc13ca184e..ca39044a4a60 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -549,14 +549,22 @@ static void __init hv_init_tsc_clocksource(void)
> union hv_reference_tsc_msr tsc_msr;
>
> /*
> + * When running as a guest partition:
> + *
> * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
> * handles frequency and offset changes due to live migration,
> * pause/resume, and other VM management operations. So lower the
> * Hyper-V Reference TSC rating, causing the generic TSC to be used.
> * TSC_INVARIANT is not offered on ARM64, so the Hyper-V Reference
> * TSC will be preferred over the virtualized ARM64 arch counter.
> + *
> + * When running as the root partition:
> + *
> + * There is no HV_ACCESS_TSC_INVARIANT feature. Skip the unnecessary
> + * check.
> */
> - if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
> + if ((ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) ||
> + hv_root_partition()) {
> hyperv_cs_tsc.rating = 250;
> hyperv_cs_msr.rating = 245;
> }
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
^ permalink raw reply
* Re: [PATCH v2] clocksource: hyper-v: Skip unnecessary checks for the root partition
From: Wei Liu @ 2025-08-12 20:02 UTC (permalink / raw)
To: Linux on Hyper-V List
Cc: mhklinux, Wei Liu, K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Daniel Lezcano, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
In-Reply-To: <20250812194846.2647201-1-wei.liu@kernel.org>
On Tue, Aug 12, 2025 at 07:48:45PM +0000, Wei Liu wrote:
> The HV_ACCESS_TSC_INVARIANT bit is always zero when Linux runs as the
> root partition. The root partition will see directly what the hardware
> provides.
>
> The old logic in ms_hyperv_init_platform caused the native TSC clock
> source to be incorrectly marked as unstable on x86. Fix it.
>
> Skip the unnecessary checks in code for the root partition. Add one
> extra comment in code to clarify the behavior.
>
> Signed-off-by: Wei Liu <wei.liu@kernel.org>
> ---
> v2: update the commit message and comments
> ---
> arch/x86/kernel/cpu/mshyperv.c | 11 ++++++++++-
> drivers/clocksource/hyperv_timer.c | 10 +++++++++-
> 2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index c78f860419d6..25773af116bc 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -565,6 +565,11 @@ static void __init ms_hyperv_init_platform(void)
> machine_ops.crash_shutdown = hv_machine_crash_shutdown;
> #endif
> #endif
> + /*
> + * HV_ACCESS_TSC_INVARIANT is always zero for the root partition. Root
> + * partition doesn't need to write to synthetic MSR to enable invariant
> + * TSC feature. It sees what the hardware provides.
> + */
> if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
> /*
> * Writing to synthetic MSR 0x40000118 updates/changes the
> @@ -636,8 +641,12 @@ static void __init ms_hyperv_init_platform(void)
> * TSC should be marked as unstable only after Hyper-V
> * clocksource has been initialized. This ensures that the
> * stability of the sched_clock is not altered.
> + *
> + * HV_ACCESS_TSC_INVARIANT is always zero for the root partition. No
> + * need to check for it.
> */
> - if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> + if (!hv_root_partition() &&
> + !(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> mark_tsc_unstable("running on Hyper-V");
>
> hardlockup_detector_disable();
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index 2edc13ca184e..ca39044a4a60 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -549,14 +549,22 @@ static void __init hv_init_tsc_clocksource(void)
> union hv_reference_tsc_msr tsc_msr;
>
> /*
> + * When running as a guest partition:
> + *
> * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
> * handles frequency and offset changes due to live migration,
> * pause/resume, and other VM management operations. So lower the
> * Hyper-V Reference TSC rating, causing the generic TSC to be used.
> * TSC_INVARIANT is not offered on ARM64, so the Hyper-V Reference
> * TSC will be preferred over the virtualized ARM64 arch counter.
> + *
> + * When running as the root partition:
> + *
> + * There is no HV_ACCESS_TSC_INVARIANT feature. Skip the unnecessary
> + * check.
This comment needs to be changed.
* There is no HV_ACCESS_TSC_INVARIANT feature. Always lower the
* rating of the Hyper-V Reference TSC.
> */
> - if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
> + if ((ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) ||
> + hv_root_partition()) {
> hyperv_cs_tsc.rating = 250;
> hyperv_cs_msr.rating = 245;
> }
> --
> 2.43.0
>
^ permalink raw reply
* [PATCH v2] clocksource: hyper-v: Skip unnecessary checks for the root partition
From: Wei Liu @ 2025-08-12 19:48 UTC (permalink / raw)
To: Linux on Hyper-V List
Cc: mhklinux, Wei Liu, K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Daniel Lezcano, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
The HV_ACCESS_TSC_INVARIANT bit is always zero when Linux runs as the
root partition. The root partition will see directly what the hardware
provides.
The old logic in ms_hyperv_init_platform caused the native TSC clock
source to be incorrectly marked as unstable on x86. Fix it.
Skip the unnecessary checks in code for the root partition. Add one
extra comment in code to clarify the behavior.
Signed-off-by: Wei Liu <wei.liu@kernel.org>
---
v2: update the commit message and comments
---
arch/x86/kernel/cpu/mshyperv.c | 11 ++++++++++-
drivers/clocksource/hyperv_timer.c | 10 +++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index c78f860419d6..25773af116bc 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -565,6 +565,11 @@ static void __init ms_hyperv_init_platform(void)
machine_ops.crash_shutdown = hv_machine_crash_shutdown;
#endif
#endif
+ /*
+ * HV_ACCESS_TSC_INVARIANT is always zero for the root partition. Root
+ * partition doesn't need to write to synthetic MSR to enable invariant
+ * TSC feature. It sees what the hardware provides.
+ */
if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
/*
* Writing to synthetic MSR 0x40000118 updates/changes the
@@ -636,8 +641,12 @@ static void __init ms_hyperv_init_platform(void)
* TSC should be marked as unstable only after Hyper-V
* clocksource has been initialized. This ensures that the
* stability of the sched_clock is not altered.
+ *
+ * HV_ACCESS_TSC_INVARIANT is always zero for the root partition. No
+ * need to check for it.
*/
- if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
+ if (!hv_root_partition() &&
+ !(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
mark_tsc_unstable("running on Hyper-V");
hardlockup_detector_disable();
diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index 2edc13ca184e..ca39044a4a60 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -549,14 +549,22 @@ static void __init hv_init_tsc_clocksource(void)
union hv_reference_tsc_msr tsc_msr;
/*
+ * When running as a guest partition:
+ *
* If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
* handles frequency and offset changes due to live migration,
* pause/resume, and other VM management operations. So lower the
* Hyper-V Reference TSC rating, causing the generic TSC to be used.
* TSC_INVARIANT is not offered on ARM64, so the Hyper-V Reference
* TSC will be preferred over the virtualized ARM64 arch counter.
+ *
+ * When running as the root partition:
+ *
+ * There is no HV_ACCESS_TSC_INVARIANT feature. Skip the unnecessary
+ * check.
*/
- if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
+ if ((ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) ||
+ hv_root_partition()) {
hyperv_cs_tsc.rating = 250;
hyperv_cs_msr.rating = 245;
}
--
2.43.0
^ permalink raw reply related
* [PATCH net-next v4] net: mana: Use page pool fragments for RX buffers instead of full pages to improve memory efficiency.
From: Dipayaan Roy @ 2025-08-11 22:29 UTC (permalink / raw)
To: horms, kuba, kys, haiyangz, wei.liu, decui, andrew+netdev, davem,
edumazet, pabeni, longli, kotaranov, ast, daniel, hawk,
john.fastabend, sdf, lorenzo, michal.kubiak, ernis, shradhagupta,
shirazsaleem, rosenp, netdev, linux-hyperv, linux-rdma, bpf,
linux-kernel, dipayanroy
This patch enhances RX buffer handling in the mana driver by allocating
pages from a page pool and slicing them into MTU-sized fragments, rather
than dedicating a full page per packet. This approach is especially
beneficial on systems with large base page sizes like 64KB.
Key improvements:
- Proper integration of page pool for RX buffer allocations.
- MTU-sized buffer slicing to improve memory utilization.
- Reduce overall per Rx queue memory footprint.
- Automatic fallback to full-page buffers when:
* Jumbo frames are enabled (MTU > PAGE_SIZE / 2).
* The XDP path is active, to avoid complexities with fragment reuse.
Testing on VMs with 64KB pages shows around 200% throughput improvement.
Memory efficiency is significantly improved due to reduced wastage in page
allocations. Example: We are now able to fit 35 rx buffers in a single 64kb
page for MTU size of 1500, instead of 1 rx buffer per page previously.
Tested:
- iperf3, iperf2, and nttcp benchmarks.
- Jumbo frames with MTU 9000.
- Native XDP programs (XDP_PASS, XDP_DROP, XDP_TX, XDP_REDIRECT) for
testing the XDP path in driver.
- Memory leak detection (kmemleak).
- Driver load/unload, reboot, and stress scenarios.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Dipayaan Roy <dipayanroy@linux.microsoft.com>
---
Changes in v4:
- Better error handling in mana_xdp_set.
Changes in v3:
- Retained the pre-alloc rxbuf for driver reconfig paths
to better handle low memory scenario during reconfig.
Changes in v2:
- Fixed mana_xdp_set() to return error code on failure instead of
always returning 0.
- Moved all local variable declarations to the start of functions
in mana_get_rxbuf_cfg.
- Removed unnecessary parentheses and wrapped lines to <= 80 chars.
- Use mana_xdp_get() for checking bpf_prog.
- Factored repeated page put/free logic into a static helper function.
---
.../net/ethernet/microsoft/mana/mana_bpf.c | 42 ++++-
drivers/net/ethernet/microsoft/mana/mana_en.c | 151 ++++++++++++------
include/net/mana/mana.h | 4 +
3 files changed, 148 insertions(+), 49 deletions(-)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.c b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
index d30721d4516f..e616f4239294 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
@@ -174,6 +174,7 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
struct mana_port_context *apc = netdev_priv(ndev);
struct bpf_prog *old_prog;
struct gdma_context *gc;
+ int err;
gc = apc->ac->gdma_dev->gdma_context;
@@ -198,8 +199,43 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
if (old_prog)
bpf_prog_put(old_prog);
- if (apc->port_is_up)
+ if (apc->port_is_up) {
+ /* Re-create rxq's after xdp prog was loaded or unloaded.
+ * Ex: re create rxq's to switch from full pages to smaller
+ * size page fragments when xdp prog is unloaded and
+ * vice-versa.
+ */
+
+ /* Pre-allocate buffers to prevent failure in mana_attach */
+ err = mana_pre_alloc_rxbufs(apc, ndev->mtu, apc->num_queues);
+ if (err) {
+ NL_SET_ERR_MSG_MOD
+ (extack,
+ "XDP: Insufficient memory for tx/rx re-config");
+ return err;
+ }
+
+ err = mana_detach(ndev, false);
+ if (err) {
+ netdev_err(ndev,
+ "mana_detach failed at xdp set: %d\n", err);
+ NL_SET_ERR_MSG_MOD(extack,
+ "XDP: Re-config failed at detach");
+ goto err_dealloc_rxbuffs;
+ }
+
+ err = mana_attach(ndev);
+ if (err) {
+ netdev_err(ndev,
+ "mana_attach failed at xdp set: %d\n", err);
+ NL_SET_ERR_MSG_MOD(extack,
+ "XDP: Re-config failed at attach");
+ goto err_dealloc_rxbuffs;
+ }
+
mana_chn_setxdp(apc, prog);
+ mana_pre_dealloc_rxbufs(apc);
+ }
if (prog)
ndev->max_mtu = MANA_XDP_MTU_MAX;
@@ -207,6 +243,10 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
ndev->max_mtu = gc->adapter_mtu - ETH_HLEN;
return 0;
+
+err_dealloc_rxbuffs:
+ mana_pre_dealloc_rxbufs(apc);
+ return err;
}
int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
index a7973651ae51..3efe2e696589 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -56,6 +56,15 @@ static bool mana_en_need_log(struct mana_port_context *apc, int err)
return true;
}
+static void mana_put_rx_page(struct mana_rxq *rxq, struct page *page,
+ bool from_pool)
+{
+ if (from_pool)
+ page_pool_put_full_page(rxq->page_pool, page, false);
+ else
+ put_page(page);
+}
+
/* Microsoft Azure Network Adapter (MANA) functions */
static int mana_open(struct net_device *ndev)
@@ -629,21 +638,40 @@ static void *mana_get_rxbuf_pre(struct mana_rxq *rxq, dma_addr_t *da)
}
/* Get RX buffer's data size, alloc size, XDP headroom based on MTU */
-static void mana_get_rxbuf_cfg(int mtu, u32 *datasize, u32 *alloc_size,
- u32 *headroom)
+static void mana_get_rxbuf_cfg(struct mana_port_context *apc,
+ int mtu, u32 *datasize, u32 *alloc_size,
+ u32 *headroom, u32 *frag_count)
{
- if (mtu > MANA_XDP_MTU_MAX)
- *headroom = 0; /* no support for XDP */
- else
- *headroom = XDP_PACKET_HEADROOM;
+ u32 len, buf_size;
- *alloc_size = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + *headroom);
+ /* Calculate datasize first (consistent across all cases) */
+ *datasize = mtu + ETH_HLEN;
- /* Using page pool in this case, so alloc_size is PAGE_SIZE */
- if (*alloc_size < PAGE_SIZE)
- *alloc_size = PAGE_SIZE;
+ /* For xdp and jumbo frames make sure only one packet fits per page */
+ if (mtu + MANA_RXBUF_PAD > PAGE_SIZE / 2 || mana_xdp_get(apc)) {
+ if (mana_xdp_get(apc)) {
+ *headroom = XDP_PACKET_HEADROOM;
+ *alloc_size = PAGE_SIZE;
+ } else {
+ *headroom = 0; /* no support for XDP */
+ *alloc_size = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD +
+ *headroom);
+ }
- *datasize = mtu + ETH_HLEN;
+ *frag_count = 1;
+ return;
+ }
+
+ /* Standard MTU case - optimize for multiple packets per page */
+ *headroom = 0;
+
+ /* Calculate base buffer size needed */
+ len = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + *headroom);
+ buf_size = ALIGN(len, MANA_RX_FRAG_ALIGNMENT);
+
+ /* Calculate how many packets can fit in a page */
+ *frag_count = PAGE_SIZE / buf_size;
+ *alloc_size = buf_size;
}
int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu, int num_queues)
@@ -655,8 +683,9 @@ int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu, int num_qu
void *va;
int i;
- mana_get_rxbuf_cfg(new_mtu, &mpc->rxbpre_datasize,
- &mpc->rxbpre_alloc_size, &mpc->rxbpre_headroom);
+ mana_get_rxbuf_cfg(mpc, new_mtu, &mpc->rxbpre_datasize,
+ &mpc->rxbpre_alloc_size, &mpc->rxbpre_headroom,
+ &mpc->rxbpre_frag_count);
dev = mpc->ac->gdma_dev->gdma_context->dev;
@@ -1841,8 +1870,11 @@ static void mana_rx_skb(void *buf_va, bool from_pool,
drop:
if (from_pool) {
- page_pool_recycle_direct(rxq->page_pool,
- virt_to_head_page(buf_va));
+ if (rxq->frag_count == 1)
+ page_pool_recycle_direct(rxq->page_pool,
+ virt_to_head_page(buf_va));
+ else
+ page_pool_free_va(rxq->page_pool, buf_va, true);
} else {
WARN_ON_ONCE(rxq->xdp_save_va);
/* Save for reuse */
@@ -1858,33 +1890,46 @@ static void *mana_get_rxfrag(struct mana_rxq *rxq, struct device *dev,
dma_addr_t *da, bool *from_pool)
{
struct page *page;
+ u32 offset;
void *va;
-
*from_pool = false;
- /* Reuse XDP dropped page if available */
- if (rxq->xdp_save_va) {
- va = rxq->xdp_save_va;
- rxq->xdp_save_va = NULL;
- } else {
- page = page_pool_dev_alloc_pages(rxq->page_pool);
- if (!page)
+ /* Don't use fragments for jumbo frames or XDP where it's 1 fragment
+ * per page.
+ */
+ if (rxq->frag_count == 1) {
+ /* Reuse XDP dropped page if available */
+ if (rxq->xdp_save_va) {
+ va = rxq->xdp_save_va;
+ page = virt_to_head_page(va);
+ rxq->xdp_save_va = NULL;
+ } else {
+ page = page_pool_dev_alloc_pages(rxq->page_pool);
+ if (!page)
+ return NULL;
+
+ *from_pool = true;
+ va = page_to_virt(page);
+ }
+
+ *da = dma_map_single(dev, va + rxq->headroom, rxq->datasize,
+ DMA_FROM_DEVICE);
+ if (dma_mapping_error(dev, *da)) {
+ mana_put_rx_page(rxq, page, *from_pool);
return NULL;
+ }
- *from_pool = true;
- va = page_to_virt(page);
+ return va;
}
- *da = dma_map_single(dev, va + rxq->headroom, rxq->datasize,
- DMA_FROM_DEVICE);
- if (dma_mapping_error(dev, *da)) {
- if (*from_pool)
- page_pool_put_full_page(rxq->page_pool, page, false);
- else
- put_page(virt_to_head_page(va));
-
+ page = page_pool_dev_alloc_frag(rxq->page_pool, &offset,
+ rxq->alloc_size);
+ if (!page)
return NULL;
- }
+
+ va = page_to_virt(page) + offset;
+ *da = page_pool_get_dma_addr(page) + offset + rxq->headroom;
+ *from_pool = true;
return va;
}
@@ -1901,9 +1946,9 @@ static void mana_refill_rx_oob(struct device *dev, struct mana_rxq *rxq,
va = mana_get_rxfrag(rxq, dev, &da, &from_pool);
if (!va)
return;
-
- dma_unmap_single(dev, rxoob->sgl[0].address, rxq->datasize,
- DMA_FROM_DEVICE);
+ if (!rxoob->from_pool || rxq->frag_count == 1)
+ dma_unmap_single(dev, rxoob->sgl[0].address, rxq->datasize,
+ DMA_FROM_DEVICE);
*old_buf = rxoob->buf_va;
*old_fp = rxoob->from_pool;
@@ -2314,15 +2359,15 @@ static void mana_destroy_rxq(struct mana_port_context *apc,
if (!rx_oob->buf_va)
continue;
- dma_unmap_single(dev, rx_oob->sgl[0].address,
- rx_oob->sgl[0].size, DMA_FROM_DEVICE);
-
page = virt_to_head_page(rx_oob->buf_va);
- if (rx_oob->from_pool)
- page_pool_put_full_page(rxq->page_pool, page, false);
- else
- put_page(page);
+ if (rxq->frag_count == 1 || !rx_oob->from_pool) {
+ dma_unmap_single(dev, rx_oob->sgl[0].address,
+ rx_oob->sgl[0].size, DMA_FROM_DEVICE);
+ mana_put_rx_page(rxq, page, rx_oob->from_pool);
+ } else {
+ page_pool_free_va(rxq->page_pool, rx_oob->buf_va, true);
+ }
rx_oob->buf_va = NULL;
}
@@ -2428,11 +2473,22 @@ static int mana_create_page_pool(struct mana_rxq *rxq, struct gdma_context *gc)
struct page_pool_params pprm = {};
int ret;
- pprm.pool_size = mpc->rx_queue_size;
+ pprm.pool_size = mpc->rx_queue_size / rxq->frag_count + 1;
pprm.nid = gc->numa_node;
pprm.napi = &rxq->rx_cq.napi;
pprm.netdev = rxq->ndev;
pprm.order = get_order(rxq->alloc_size);
+ pprm.queue_idx = rxq->rxq_idx;
+ pprm.dev = gc->dev;
+
+ /* Let the page pool do the dma map when page sharing with multiple
+ * fragments enabled for rx buffers.
+ */
+ if (rxq->frag_count > 1) {
+ pprm.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
+ pprm.max_len = PAGE_SIZE;
+ pprm.dma_dir = DMA_FROM_DEVICE;
+ }
rxq->page_pool = page_pool_create(&pprm);
@@ -2471,9 +2527,8 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
rxq->rxq_idx = rxq_idx;
rxq->rxobj = INVALID_MANA_HANDLE;
- mana_get_rxbuf_cfg(ndev->mtu, &rxq->datasize, &rxq->alloc_size,
- &rxq->headroom);
-
+ mana_get_rxbuf_cfg(apc, ndev->mtu, &rxq->datasize, &rxq->alloc_size,
+ &rxq->headroom, &rxq->frag_count);
/* Create page pool for RX queue */
err = mana_create_page_pool(rxq, gc);
if (err) {
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index e1030a7d2daa..0921485565c0 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -65,6 +65,8 @@ enum TRI_STATE {
#define MANA_STATS_RX_COUNT 5
#define MANA_STATS_TX_COUNT 11
+#define MANA_RX_FRAG_ALIGNMENT 64
+
struct mana_stats_rx {
u64 packets;
u64 bytes;
@@ -328,6 +330,7 @@ struct mana_rxq {
u32 datasize;
u32 alloc_size;
u32 headroom;
+ u32 frag_count;
mana_handle_t rxobj;
@@ -510,6 +513,7 @@ struct mana_port_context {
u32 rxbpre_datasize;
u32 rxbpre_alloc_size;
u32 rxbpre_headroom;
+ u32 rxbpre_frag_count;
struct bpf_prog *bpf_prog;
--
2.43.0
^ permalink raw reply related
* [PATCH v5.10] uio_hv_generic: Fix another memory leak in error handling paths
From: Shivani Agarwal @ 2025-08-11 5:38 UTC (permalink / raw)
To: stable, gregkh
Cc: bcm-kernel-feedback-list, linux-kernel, ajay.kaher,
alexey.makhalov, tapas.kundu, kys, haiyangz, wei.liu, decui,
stephen, linux-hyperv, Christophe JAILLET, Shivani Agarwal
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
commit 0b0226be3a52dadd965644bc52a807961c2c26df upstream.
Memory allocated by 'vmbus_alloc_ring()' at the beginning of the probe
function is never freed in the error handling path.
Add the missing 'vmbus_free_ring()' call.
Note that it is already freed in the .remove function.
Fixes: cdfa835c6e5e ("uio_hv_generic: defer opening vmbus until first use")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0d86027b8eeed8e6360bc3d52bcdb328ff9bdca1.1620544055.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[Shivani: Modified to apply on 5.10.y]
Signed-off-by: Shivani Agarwal <shivani.agarwal@broadcom.com>
---
drivers/uio/uio_hv_generic.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index 6625d340f..865a5b289 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -306,7 +306,7 @@ hv_uio_probe(struct hv_device *dev,
pdata->recv_buf = vzalloc(RECV_BUFFER_SIZE);
if (pdata->recv_buf == NULL) {
ret = -ENOMEM;
- goto fail_close;
+ goto fail_free_ring;
}
ret = vmbus_establish_gpadl(channel, pdata->recv_buf,
@@ -366,6 +366,8 @@ hv_uio_probe(struct hv_device *dev,
fail_close:
hv_uio_cleanup(dev, pdata);
+fail_free_ring:
+ vmbus_free_ring(dev->channel);
return ret;
}
^ permalink raw reply related
* [PATCH] uio_hv_generic: Fix another memory leak in error handling paths
From: Shivani Agarwal @ 2025-08-11 5:37 UTC (permalink / raw)
To: stable, gregkh
Cc: bcm-kernel-feedback-list, linux-kernel, ajay.kaher,
alexey.makhalov, tapas.kundu, kys, haiyangz, wei.liu, decui,
stephen, linux-hyperv, Christophe JAILLET, Shivani Agarwal
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
commit 0b0226be3a52dadd965644bc52a807961c2c26df upstream.
Memory allocated by 'vmbus_alloc_ring()' at the beginning of the probe
function is never freed in the error handling path.
Add the missing 'vmbus_free_ring()' call.
Note that it is already freed in the .remove function.
Fixes: cdfa835c6e5e ("uio_hv_generic: defer opening vmbus until first use")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/0d86027b8eeed8e6360bc3d52bcdb328ff9bdca1.1620544055.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[Shivani: Modified to apply on 5.10.y]
Signed-off-by: Shivani Agarwal <shivani.agarwal@broadcom.com>
---
drivers/uio/uio_hv_generic.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index 6625d340f..865a5b289 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -306,7 +306,7 @@ hv_uio_probe(struct hv_device *dev,
pdata->recv_buf = vzalloc(RECV_BUFFER_SIZE);
if (pdata->recv_buf == NULL) {
ret = -ENOMEM;
- goto fail_close;
+ goto fail_free_ring;
}
ret = vmbus_establish_gpadl(channel, pdata->recv_buf,
@@ -366,6 +366,8 @@ hv_uio_probe(struct hv_device *dev,
fail_close:
hv_uio_cleanup(dev, pdata);
+fail_free_ring:
+ vmbus_free_ring(dev->channel);
return ret;
}
^ permalink raw reply related
* Re: [PATCH net,v2] hv_netvsc: Fix panic during namespace deletion with VF
From: patchwork-bot+netdevbpf @ 2025-08-08 20:50 UTC (permalink / raw)
To: Haiyang Zhang
Cc: linux-hyperv, netdev, haiyangz, kys, wei.liu, decui,
andrew+netdev, edumazet, kuba, pabeni, horms, davem, linux-kernel,
stable
In-Reply-To: <1754511711-11188-1-git-send-email-haiyangz@linux.microsoft.com>
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 6 Aug 2025 13:21:51 -0700 you wrote:
> From: Haiyang Zhang <haiyangz@microsoft.com>
>
> The existing code move the VF NIC to new namespace when NETDEV_REGISTER is
> received on netvsc NIC. During deletion of the namespace,
> default_device_exit_batch() >> default_device_exit_net() is called. When
> netvsc NIC is moved back and registered to the default namespace, it
> automatically brings VF NIC back to the default namespace. This will cause
> the default_device_exit_net() >> for_each_netdev_safe loop unable to detect
> the list end, and hit NULL ptr:
>
> [...]
Here is the summary with links:
- [net,v2] hv_netvsc: Fix panic during namespace deletion with VF
https://git.kernel.org/netdev/net/c/33caa208dba6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply
* Re: [PATCH] clocksource: hyper-v: Prefer architecture counter when running as root partition
From: Wei Liu @ 2025-08-08 20:19 UTC (permalink / raw)
To: Michael Kelley
Cc: wei.liu@kernel.org, Linux on Hyper-V List, K. Y. Srinivasan,
Haiyang Zhang, Dexuan Cui, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Daniel Lezcano, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
In-Reply-To: <SN6PR02MB41578685EF8F664D77DF2156D42CA@SN6PR02MB4157.namprd02.prod.outlook.com>
On Thu, Aug 07, 2025 at 08:27:32PM +0000, Michael Kelley wrote:
> From: wei.liu@kernel.org <wei.liu@kernel.org> Sent: Thursday, August 7, 2025 9:59 AM
> >
> > There is no HV_ACCESS_TSC_INVARIANT bit when Linux runs as the root
> > partition.
>
> Some clarifying questions here: When you say "there is no
> HV_ACCESS_TSC_INVARIANT bit", does that mean that bit 15 of the
> HV_PARTITION_PRIVILEGE_MASK is just unused and undefined?
The HV_ACCESS_TSC_INVARIANT bit is still defined, but it is always zero
for the root partition. I can modify the commit message and code comment
to clarify that.
>
> And what is the behavior if the root partition writes to
> HV_X64_MSR_TSC_INVARIANT_CONTROL? In a normal x86 guest,
> HV_X64_MSR_TSC_INVARIANT_CONTROL determines whether
> CPUID 0x80000007/EDX bit 8 is set. What will the root partition see
> for CPUID 0x80000007/EDX bit 8? Whatever the underlying hardware
> provides? See also the comment in ms_hyperv_init_platform().
>
The root partition sees whatever the underlying hardware provides. It
doesn't need to write write to that MSR.
I think it should be fine to skip the code in ms_hyperv_init_platform().
Thanks,
Wei
> Michael
>
> > The old logic caused the native TSC clock source to be
> > incorrectly marked as unstable on x86.
> >
> > The clock source driver runs on both x86 and ARM64. Change it to prefer
> > architectural counter when it runs on Linux root.
> >
> > Signed-off-by: Wei Liu <wei.liu@kernel.org>
> > ---
> > Cc: Michael Kelley <mhklinux@outlook.com>
> >
> > Pending further testing.
> >
> > The preference of architectural counter over Hyper-V Reference TSC for
> > Linux root is confirmed by the hypervisor team.
> > ---
> > arch/x86/kernel/cpu/mshyperv.c | 6 +++++-
> > drivers/clocksource/hyperv_timer.c | 10 +++++++++-
> > 2 files changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> > index fd708180d2d9..1713545dcf4a 100644
> > --- a/arch/x86/kernel/cpu/mshyperv.c
> > +++ b/arch/x86/kernel/cpu/mshyperv.c
> > @@ -966,8 +966,12 @@ static void __init ms_hyperv_init_platform(void)
> > * TSC should be marked as unstable only after Hyper-V
> > * clocksource has been initialized. This ensures that the
> > * stability of the sched_clock is not altered.
> > + *
> > + * The root partition doesn't see HV_ACCESS_TSC_INVARIANT.
> > + * No need to check for it.
> > */
> > - if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> > + if (!hv_root_partition() &&
> > + !(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> > mark_tsc_unstable("running on Hyper-V");
> >
> > hardlockup_detector_disable();
> > diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> > index f6415e726e96..59c3e09f1961 100644
> > --- a/drivers/clocksource/hyperv_timer.c
> > +++ b/drivers/clocksource/hyperv_timer.c
> > @@ -534,14 +534,22 @@ static void __init hv_init_tsc_clocksource(void)
> > union hv_reference_tsc_msr tsc_msr;
> >
> > /*
> > + * When running as a guest partition:
> > + *
> > * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
> > * handles frequency and offset changes due to live migration,
> > * pause/resume, and other VM management operations. So lower the
> > * Hyper-V Reference TSC rating, causing the generic TSC to be used.
> > * TSC_INVARIANT is not offered on ARM64, so the Hyper-V Reference
> > * TSC will be preferred over the virtualized ARM64 arch counter.
> > + *
> > + * When running as the root partition:
> > + *
> > + * There is no HV_ACCESS_TSC_INVARIANT feature. Always prefer the
> > + * architectural defined counter over the Hyper-V Reference TSC.
> > */
> > - if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
> > + if ((ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) ||
> > + hv_root_partition()) {
> > hyperv_cs_tsc.rating = 250;
> > hyperv_cs_msr.rating = 245;
> > }
> > --
> > 2.43.0
>
^ permalink raw reply
* RE: [PATCH] clocksource: hyper-v: Prefer architecture counter when running as root partition
From: Michael Kelley @ 2025-08-07 20:27 UTC (permalink / raw)
To: wei.liu@kernel.org, Linux on Hyper-V List
Cc: K. Y. Srinivasan, Haiyang Zhang, Dexuan Cui, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT), H. Peter Anvin,
Daniel Lezcano, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
In-Reply-To: <20250807165846.1804541-1-wei.liu@kernel.org>
From: wei.liu@kernel.org <wei.liu@kernel.org> Sent: Thursday, August 7, 2025 9:59 AM
>
> There is no HV_ACCESS_TSC_INVARIANT bit when Linux runs as the root
> partition.
Some clarifying questions here: When you say "there is no
HV_ACCESS_TSC_INVARIANT bit", does that mean that bit 15 of the
HV_PARTITION_PRIVILEGE_MASK is just unused and undefined?
And what is the behavior if the root partition writes to
HV_X64_MSR_TSC_INVARIANT_CONTROL? In a normal x86 guest,
HV_X64_MSR_TSC_INVARIANT_CONTROL determines whether
CPUID 0x80000007/EDX bit 8 is set. What will the root partition see
for CPUID 0x80000007/EDX bit 8? Whatever the underlying hardware
provides? See also the comment in ms_hyperv_init_platform().
Michael
> The old logic caused the native TSC clock source to be
> incorrectly marked as unstable on x86.
>
> The clock source driver runs on both x86 and ARM64. Change it to prefer
> architectural counter when it runs on Linux root.
>
> Signed-off-by: Wei Liu <wei.liu@kernel.org>
> ---
> Cc: Michael Kelley <mhklinux@outlook.com>
>
> Pending further testing.
>
> The preference of architectural counter over Hyper-V Reference TSC for
> Linux root is confirmed by the hypervisor team.
> ---
> arch/x86/kernel/cpu/mshyperv.c | 6 +++++-
> drivers/clocksource/hyperv_timer.c | 10 +++++++++-
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index fd708180d2d9..1713545dcf4a 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -966,8 +966,12 @@ static void __init ms_hyperv_init_platform(void)
> * TSC should be marked as unstable only after Hyper-V
> * clocksource has been initialized. This ensures that the
> * stability of the sched_clock is not altered.
> + *
> + * The root partition doesn't see HV_ACCESS_TSC_INVARIANT.
> + * No need to check for it.
> */
> - if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> + if (!hv_root_partition() &&
> + !(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
> mark_tsc_unstable("running on Hyper-V");
>
> hardlockup_detector_disable();
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index f6415e726e96..59c3e09f1961 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -534,14 +534,22 @@ static void __init hv_init_tsc_clocksource(void)
> union hv_reference_tsc_msr tsc_msr;
>
> /*
> + * When running as a guest partition:
> + *
> * If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
> * handles frequency and offset changes due to live migration,
> * pause/resume, and other VM management operations. So lower the
> * Hyper-V Reference TSC rating, causing the generic TSC to be used.
> * TSC_INVARIANT is not offered on ARM64, so the Hyper-V Reference
> * TSC will be preferred over the virtualized ARM64 arch counter.
> + *
> + * When running as the root partition:
> + *
> + * There is no HV_ACCESS_TSC_INVARIANT feature. Always prefer the
> + * architectural defined counter over the Hyper-V Reference TSC.
> */
> - if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
> + if ((ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) ||
> + hv_root_partition()) {
> hyperv_cs_tsc.rating = 250;
> hyperv_cs_msr.rating = 245;
> }
> --
> 2.43.0
^ permalink raw reply
* Re: [PATCH RFC net-next v4 00/12] vsock: add namespace support to vhost-vsock
From: Bobby Eshleman @ 2025-08-07 20:24 UTC (permalink / raw)
To: Stefano Garzarella
Cc: Shuah Khan, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Stefan Hajnoczi, Michael S. Tsirkin,
Jason Wang, Xuan Zhuo, Eugenio Pérez, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Bryan Tan, Vishnu Dasa,
Broadcom internal kernel review list, virtualization, netdev,
linux-kselftest, linux-kernel, kvm, linux-hyperv, berrange,
Bobby Eshleman
In-Reply-To: <27a6zuc6wwuixgozhkxxd2bmpiegiat4bkwghvjz6y3wugtjqm@az7j7et7hzpq>
On Thu, Aug 07, 2025 at 10:06:35AM +0200, Stefano Garzarella wrote:
> Hi Bobby,
>
...
>
> Thanks for your work!
>
> As I mentioned to you, I'll be off for the next 2 weeks, so I'll take a look
> when I'm back, but feel free to send new versions if you receive enough
> comments on this.
>
> Thanks,
> Stefano
>
Thanks Stefano, enjoy your time off!
Best,
Bobby
^ permalink raw reply
* [PATCH] clocksource: hyper-v: Prefer architecture counter when running as root partition
From: wei.liu @ 2025-08-07 16:58 UTC (permalink / raw)
To: Linux on Hyper-V List
Cc: Wei Liu, Michael Kelley, K. Y. Srinivasan, Haiyang Zhang,
Dexuan Cui, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
H. Peter Anvin, Daniel Lezcano,
open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)
From: Wei Liu <wei.liu@kernel.org>
There is no HV_ACCESS_TSC_INVARIANT bit when Linux runs as the root
partition. The old logic caused the native TSC clock source to be
incorrectly marked as unstable on x86.
The clock source driver runs on both x86 and ARM64. Change it to prefer
architectural counter when it runs on Linux root.
Signed-off-by: Wei Liu <wei.liu@kernel.org>
---
Cc: Michael Kelley <mhklinux@outlook.com>
Pending further testing.
The preference of architectural counter over Hyper-V Reference TSC for
Linux root is confirmed by the hypervisor team.
---
arch/x86/kernel/cpu/mshyperv.c | 6 +++++-
drivers/clocksource/hyperv_timer.c | 10 +++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index fd708180d2d9..1713545dcf4a 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -966,8 +966,12 @@ static void __init ms_hyperv_init_platform(void)
* TSC should be marked as unstable only after Hyper-V
* clocksource has been initialized. This ensures that the
* stability of the sched_clock is not altered.
+ *
+ * The root partition doesn't see HV_ACCESS_TSC_INVARIANT.
+ * No need to check for it.
*/
- if (!(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
+ if (!hv_root_partition() &&
+ !(ms_hyperv.features & HV_ACCESS_TSC_INVARIANT))
mark_tsc_unstable("running on Hyper-V");
hardlockup_detector_disable();
diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index f6415e726e96..59c3e09f1961 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -534,14 +534,22 @@ static void __init hv_init_tsc_clocksource(void)
union hv_reference_tsc_msr tsc_msr;
/*
+ * When running as a guest partition:
+ *
* If Hyper-V offers TSC_INVARIANT, then the virtualized TSC correctly
* handles frequency and offset changes due to live migration,
* pause/resume, and other VM management operations. So lower the
* Hyper-V Reference TSC rating, causing the generic TSC to be used.
* TSC_INVARIANT is not offered on ARM64, so the Hyper-V Reference
* TSC will be preferred over the virtualized ARM64 arch counter.
+ *
+ * When running as the root partition:
+ *
+ * There is no HV_ACCESS_TSC_INVARIANT feature. Always prefer the
+ * architectural defined counter over the Hyper-V Reference TSC.
*/
- if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) {
+ if ((ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) ||
+ hv_root_partition()) {
hyperv_cs_tsc.rating = 250;
hyperv_cs_msr.rating = 245;
}
--
2.43.0
^ permalink raw reply related
* Re: [PATCH RFC net-next v4 00/12] vsock: add namespace support to vhost-vsock
From: Stefano Garzarella @ 2025-08-07 8:06 UTC (permalink / raw)
To: Bobby Eshleman
Cc: Shuah Khan, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Stefan Hajnoczi, Michael S. Tsirkin,
Jason Wang, Xuan Zhuo, Eugenio Pérez, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Bryan Tan, Vishnu Dasa,
Broadcom internal kernel review list, virtualization, netdev,
linux-kselftest, linux-kernel, kvm, linux-hyperv, berrange,
Bobby Eshleman
In-Reply-To: <20250805-vsock-vmtest-v4-0-059ec51ab111@meta.com>
Hi Bobby,
On Tue, Aug 05, 2025 at 02:49:08PM -0700, Bobby Eshleman wrote:
>This series adds namespace support to vhost-vsock. It does not add
>namespaces to any of the guest transports (virtio-vsock, hyperv, or
>vmci).
>
>The current revision only supports two modes: local or global. Local
>mode is complete isolation of namespaces, while global mode is complete
>sharing between namespaces of CIDs (the original behavior).
>
>Future may include supporting a mixed mode, which I expect to be more
>complicated because socket lookups will have to include new logic and
>API changes to behave differently based on if the lookup is part of a
>mixed mode CID allocation, a global CID allocation, a mixed-to-global
>connection (allowed), or a global-to-mixed connection (not allowed).
>
>Modes are per-netns and write-once. This allows a system to configure
>namespaces independently (some may share CIDs, others are completely
>isolated). This also supports future mixed use cases, where there may
>be
>namespaces in global mode spinning up VMs while there are
>mixed mode namespaces that provide services to the VMs, but are not
>allowed to allocate from the global CID pool.
>
>Thanks again for everyone's help and reviews!
Thanks for your work!
As I mentioned to you, I'll be off for the next 2 weeks, so I'll take a
look when I'm back, but feel free to send new versions if you receive
enough comments on this.
Thanks,
Stefano
>
>Signed-off-by: Bobby Eshleman <bobbyeshleman@gmail.com>
>To: Stefano Garzarella <sgarzare@redhat.com>
>To: Shuah Khan <shuah@kernel.org>
>To: David S. Miller <davem@davemloft.net>
>To: Eric Dumazet <edumazet@google.com>
>To: Jakub Kicinski <kuba@kernel.org>
>To: Paolo Abeni <pabeni@redhat.com>
>To: Simon Horman <horms@kernel.org>
>To: Stefan Hajnoczi <stefanha@redhat.com>
>To: Michael S. Tsirkin <mst@redhat.com>
>To: Jason Wang <jasowang@redhat.com>
>To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
>To: Eugenio Pérez <eperezma@redhat.com>
>To: K. Y. Srinivasan <kys@microsoft.com>
>To: Haiyang Zhang <haiyangz@microsoft.com>
>To: Wei Liu <wei.liu@kernel.org>
>To: Dexuan Cui <decui@microsoft.com>
>To: Bryan Tan <bryan-bt.tan@broadcom.com>
>To: Vishnu Dasa <vishnu.dasa@broadcom.com>
>To: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
>Cc: virtualization@lists.linux.dev
>Cc: netdev@vger.kernel.org
>Cc: linux-kselftest@vger.kernel.org
>Cc: linux-kernel@vger.kernel.org
>Cc: kvm@vger.kernel.org
>Cc: linux-hyperv@vger.kernel.org
>Cc: berrange@redhat.com
>
>Changes in v4:
>- removed RFC tag
>- implemented loopback support
>- renamed new tests to better reflect behavior
>- completed suite of tests with permutations of ns modes and vsock_test
> as guest/host
>- simplified socat bridging with unix socket instead of tcp + veth
>- only use vsock_test for success case, socat for failure case (context
> in commit message)
>- lots of cleanup
>
>Changes in v3:
>- add notion of "modes"
>- add procfs /proc/net/vsock_ns_mode
>- local and global modes only
>- no /dev/vhost-vsock-netns
>- vmtest.sh already merged, so new patch just adds new tests for NS
>- Link to v2:
> https://lore.kernel.org/kvm/20250312-vsock-netns-v2-0-84bffa1aa97a@gmail.com
>
>Changes in v2:
>- only support vhost-vsock namespaces
>- all g2h namespaces retain old behavior, only common API changes
> impacted by vhost-vsock changes
>- add /dev/vhost-vsock-netns for "opt-in"
>- leave /dev/vhost-vsock to old behavior
>- removed netns module param
>- Link to v1:
> https://lore.kernel.org/r/20200116172428.311437-1-sgarzare@redhat.com
>
>Changes in v1:
>- added 'netns' module param to vsock.ko to enable the
> network namespace support (disabled by default)
>- added 'vsock_net_eq()' to check the "net" assigned to a socket
> only when 'netns' support is enabled
>- Link to RFC: https://patchwork.ozlabs.org/cover/1202235/
>
>---
>Bobby Eshleman (12):
> vsock: a per-net vsock NS mode state
> vsock: add net to vsock skb cb
> vsock: add netns to af_vsock core
> vsock/virtio: add netns to virtio transport common
> vhost/vsock: add netns support
> vsock/virtio: use the global netns
> hv_sock: add netns hooks
> vsock/vmci: add netns hooks
> vsock/loopback: add netns support
> selftests/vsock: improve logging in vmtest.sh
> selftests/vsock: invoke vsock_test through helpers
> selftests/vsock: add namespace tests
>
> MAINTAINERS | 1 +
> drivers/vhost/vsock.c | 48 +-
> include/linux/virtio_vsock.h | 12 +
> include/net/af_vsock.h | 59 +-
> include/net/net_namespace.h | 4 +
> include/net/netns/vsock.h | 21 +
> net/vmw_vsock/af_vsock.c | 204 +++++-
> net/vmw_vsock/hyperv_transport.c | 2 +-
> net/vmw_vsock/virtio_transport.c | 5 +-
> net/vmw_vsock/virtio_transport_common.c | 14 +-
> net/vmw_vsock/vmci_transport.c | 4 +-
> net/vmw_vsock/vsock_loopback.c | 59 +-
> tools/testing/selftests/vsock/vmtest.sh | 1088 ++++++++++++++++++++++++++-----
> 13 files changed, 1330 insertions(+), 191 deletions(-)
>---
>base-commit: dd500e4aecf25e48e874ca7628697969df679493
>change-id: 20250325-vsock-vmtest-b3a21d2102c2
>
>Best regards,
>--
>Bobby Eshleman <bobbyeshleman@meta.com>
>
^ permalink raw reply
* RE: [Update RFC PATCH V6 2/4] Drivers: hv: Allow vmbus message synic interrupt injected from Hyper-V
From: Michael Kelley @ 2025-08-07 4:13 UTC (permalink / raw)
To: Tianyu Lan, kys@microsoft.com, haiyangz@microsoft.com,
wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, arnd@arndb.de,
Neeraj.Upadhyay@amd.com, kvijayab@amd.com
Cc: Tianyu Lan, linux-arch@vger.kernel.org,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20250806160059.6244-1-ltykernel@gmail.com>
From: Tianyu Lan <ltykernel@gmail.com> Sent: Wednesday, August 6, 2025 9:01 AM
>
> When Secure AVIC is enabled, VMBus driver should
> call x2apic Secure AVIC interface to allow Hyper-V
> to inject VMBus message interrupt.
>
> Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
> Signed-off-by: Tianyu Lan <tiala@microsoft.com>
> ---
> Change since RFC V5:
> - Rmove extra line and move hv_enable_coco_interrupt()
> just after hv_set_msr() in the hv_synic_disable_regs().
>
> Change since RFC V4:
> - Change the order to call hv_enable_coco_interrupt()
> in the hv_synic_enable/disable_regs().
> - Update commit title "Drivers/hv:" to "Drivers: hv:"
>
> Change since RFC V3:
> - Disable VMBus Message interrupt via hv_enable_
> coco_interrupt() in the hv_synic_disable_regs().
> ---
> arch/x86/hyperv/hv_apic.c | 5 +++++
> drivers/hv/hv.c | 4 ++++
> drivers/hv/hv_common.c | 5 +++++
> include/asm-generic/mshyperv.h | 1 +
> 4 files changed, 15 insertions(+)
>
> diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
> index 01bc02cc0590..c9808a51fa37 100644
> --- a/arch/x86/hyperv/hv_apic.c
> +++ b/arch/x86/hyperv/hv_apic.c
> @@ -54,6 +54,11 @@ static void hv_apic_icr_write(u32 low, u32 id)
> wrmsrq(HV_X64_MSR_ICR, reg_val);
> }
>
> +void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set)
> +{
> + apic_update_vector(cpu, vector, set);
> +}
> +
> static u32 hv_apic_read(u32 reg)
> {
> u32 reg_val, hi;
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 308c8f279df8..355663a6e3b8 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -316,6 +316,8 @@ void hv_synic_enable_regs(unsigned int cpu)
> shared_sint.auto_eoi = hv_recommend_using_aeoi();
> hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
>
> + hv_enable_coco_interrupt(cpu, vmbus_interrupt, true);
> +
> /* Enable the global synic bit */
> sctrl.as_uint64 = hv_get_msr(HV_MSR_SCONTROL);
> sctrl.enable = 1;
> @@ -349,6 +351,8 @@ void hv_synic_disable_regs(unsigned int cpu)
> /* Disable the interrupt */
> hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
>
> + hv_enable_coco_interrupt(cpu, vmbus_interrupt, false);
> +
> simp.as_uint64 = hv_get_msr(HV_MSR_SIMP);
> /*
> * In Isolation VM, sim and sief pages are allocated by
> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> index 49898d10faff..0f024ab3d360 100644
> --- a/drivers/hv/hv_common.c
> +++ b/drivers/hv/hv_common.c
> @@ -716,6 +716,11 @@ u64 __weak hv_tdx_hypercall(u64 control, u64 param1, u64 param2)
> }
> EXPORT_SYMBOL_GPL(hv_tdx_hypercall);
>
> +void __weak hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set)
> +{
> +}
> +EXPORT_SYMBOL_GPL(hv_enable_coco_interrupt);
> +
> void hv_identify_partition_type(void)
> {
> /* Assume guest role */
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index a729b77983fa..7907c9878369 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -333,6 +333,7 @@ bool hv_is_isolation_supported(void);
> bool hv_isolation_type_snp(void);
> u64 hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_size);
> u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2);
> +void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set);
> void hyperv_cleanup(void);
> bool hv_query_ext_cap(u64 cap_query);
> void hv_setup_dma_ops(struct device *dev, bool coherent);
> --
> 2.25.1
>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
^ permalink raw reply
* Re: [PATCH RFC net-next v4 00/12] vsock: add namespace support to vhost-vsock
From: Bobby Eshleman @ 2025-08-06 21:31 UTC (permalink / raw)
To: Simon Horman
Cc: Stefano Garzarella, Shuah Khan, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Stefan Hajnoczi, Michael S. Tsirkin,
Jason Wang, Xuan Zhuo, Eugenio Pérez, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Bryan Tan, Vishnu Dasa,
Broadcom internal kernel review list, virtualization, netdev,
linux-kselftest, linux-kernel, kvm, linux-hyperv, berrange,
Bobby Eshleman
In-Reply-To: <20250806191348.GG61519@horms.kernel.org>
On Wed, Aug 06, 2025 at 08:13:48PM +0100, Simon Horman wrote:
> On Tue, Aug 05, 2025 at 03:03:37PM -0700, Bobby Eshleman wrote:
> > On Tue, Aug 05, 2025 at 02:49:08PM -0700, Bobby Eshleman wrote:
...
>
> Ack. But net-next is currently closed for the merge-window.
>
> So please don't post non-RFC patches for it until it reopens,
> around the 11th August.
Got it, thanks!
^ permalink raw reply
* Re: [PATCH RFC net-next v4 09/12] vsock/loopback: add netns support
From: Bobby Eshleman @ 2025-08-06 21:31 UTC (permalink / raw)
To: Simon Horman
Cc: Stefano Garzarella, Shuah Khan, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Stefan Hajnoczi, Michael S. Tsirkin,
Jason Wang, Xuan Zhuo, Eugenio Pérez, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Bryan Tan, Vishnu Dasa,
Broadcom internal kernel review list, virtualization, netdev,
linux-kselftest, linux-kernel, kvm, linux-hyperv, berrange,
Bobby Eshleman
In-Reply-To: <20250806191239.GF61519@horms.kernel.org>
On Wed, Aug 06, 2025 at 08:12:39PM +0100, Simon Horman wrote:
> On Tue, Aug 05, 2025 at 02:49:17PM -0700, Bobby Eshleman wrote:
> > From: Bobby Eshleman <bobbyeshleman@meta.com>
> >
...
>
> This change needs to be squashed into
> PATCH 3/12 vsock: add netns to af_vsock core
>
> To avoid build breakage.
>
> Likewise with the other change to vsock_loopback_seqpacket_allow below.
> And I think also for a number of other changes made by PATCH 3/12.
>
> Please make sure that patches don't introduce transient build failures.
> It breaks bisection.
Will do, thanks!
>
>
> On the topic of vsock_loopback_seqpacket_allow, also:
>
> * Please line wrap this so that the code is 80 columns wide or less,
> as is still preferred for Networking code.
>
> Flagged by checkpatch.pl --max-line-length=80
>
> * Can we move the definition of vsock_loopback_seqpacket_allow() here?
> The function itself is is trivial. And doing so would avoid a forward
> declaration.
>
> > static bool vsock_loopback_msgzerocopy_allow(void)
> > {
> > return true;
>
> ...
>
> > +int vsock_loopback_init_net(struct net *net)
> > +{
> > + net->vsock.loopback = kmalloc(GFP_KERNEL, sizeof(struct vsock_loopback));
> > + if (!net->vsock.loopback)
> > + return -ENOMEM;
> > +
> > + return vsock_loopback_init_vsock(net->vsock.loopback);
> > +}
> > +
> > +void vsock_loopback_exit_net(struct net *net)
> > +{
> > + vsock_loopback_deinit_vsock(net->vsock.loopback);
> > + kfree(net->vsock.loopback);
> > +}
>
> I think EXPORT_SYMBOL_GPL is needed for both vsock_loopback_exit_net and
> vsock_loopback_init_net for the case where CONFIG_VSOCKETS=m
>
> Also, in Kconfig VSOCKETS_LOOPBACK depends on VSOCKETS. But this code adds
> a reverse dependency. As it stands it's possible to configure VSOCKETS
> without VSOCKETS_LOOPBACK, which will not compile.
>
> Perhaps stub implementations of vsock_loopback_init_net and
> vsock_loopback_exit_net should be implemented in af_vsock.h if
> VSOCKETS_LOOPBACK is not enabled?
>
Roger that, makes sense. Thanks for the review!
Best,
Bobby
^ permalink raw reply
* [PATCH net,v2] hv_netvsc: Fix panic during namespace deletion with VF
From: Haiyang Zhang @ 2025-08-06 20:21 UTC (permalink / raw)
To: linux-hyperv, netdev
Cc: haiyangz, kys, wei.liu, decui, andrew+netdev, edumazet, kuba,
pabeni, horms, davem, linux-kernel, stable
From: Haiyang Zhang <haiyangz@microsoft.com>
The existing code move the VF NIC to new namespace when NETDEV_REGISTER is
received on netvsc NIC. During deletion of the namespace,
default_device_exit_batch() >> default_device_exit_net() is called. When
netvsc NIC is moved back and registered to the default namespace, it
automatically brings VF NIC back to the default namespace. This will cause
the default_device_exit_net() >> for_each_netdev_safe loop unable to detect
the list end, and hit NULL ptr:
[ 231.449420] mana 7870:00:00.0 enP30832s1: Moved VF to namespace with: eth0
[ 231.449656] BUG: kernel NULL pointer dereference, address: 0000000000000010
[ 231.450246] #PF: supervisor read access in kernel mode
[ 231.450579] #PF: error_code(0x0000) - not-present page
[ 231.450916] PGD 17b8a8067 P4D 0
[ 231.451163] Oops: Oops: 0000 [#1] SMP NOPTI
[ 231.451450] CPU: 82 UID: 0 PID: 1394 Comm: kworker/u768:1 Not tainted 6.16.0-rc4+ #3 VOLUNTARY
[ 231.452042] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.1 11/21/2024
[ 231.452692] Workqueue: netns cleanup_net
[ 231.452947] RIP: 0010:default_device_exit_batch+0x16c/0x3f0
[ 231.453326] Code: c0 0c f5 b3 e8 d5 db fe ff 48 85 c0 74 15 48 c7 c2 f8 fd ca b2 be 10 00 00 00 48 8d 7d c0 e8 7b 77 25 00 49 8b 86 28 01 00 00 <48> 8b 50 10 4c 8b 2a 4c 8d 62 f0 49 83 ed 10 4c 39 e0 0f 84 d6 00
[ 231.454294] RSP: 0018:ff75fc7c9bf9fd00 EFLAGS: 00010246
[ 231.454610] RAX: 0000000000000000 RBX: 0000000000000002 RCX: 61c8864680b583eb
[ 231.455094] RDX: ff1fa9f71462d800 RSI: ff75fc7c9bf9fd38 RDI: 0000000030766564
[ 231.455686] RBP: ff75fc7c9bf9fd78 R08: 0000000000000000 R09: 0000000000000000
[ 231.456126] R10: 0000000000000001 R11: 0000000000000004 R12: ff1fa9f70088e340
[ 231.456621] R13: ff1fa9f70088e340 R14: ffffffffb3f50c20 R15: ff1fa9f7103e6340
[ 231.457161] FS: 0000000000000000(0000) GS:ff1faa6783a08000(0000) knlGS:0000000000000000
[ 231.457707] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 231.458031] CR2: 0000000000000010 CR3: 0000000179ab2006 CR4: 0000000000b73ef0
[ 231.458434] Call Trace:
[ 231.458600] <TASK>
[ 231.458777] ops_undo_list+0x100/0x220
[ 231.459015] cleanup_net+0x1b8/0x300
[ 231.459285] process_one_work+0x184/0x340
To fix it, move the ns change to a workqueue, and take rtnl_lock to avoid
changing the netdev list when default_device_exit_net() is using it.
Cc: stable@vger.kernel.org
Fixes: 4c262801ea60 ("hv_netvsc: Fix VF namespace also in synthetic NIC NETDEV_REGISTER event")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
v2:
Moved the ns change to a workqueue as suggested by Jakub Kicinski.
---
drivers/net/hyperv/hyperv_net.h | 3 +++
drivers/net/hyperv/netvsc_drv.c | 29 ++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index cb6f5482d203..7397c693f984 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -1061,6 +1061,7 @@ struct net_device_context {
struct net_device __rcu *vf_netdev;
struct netvsc_vf_pcpu_stats __percpu *vf_stats;
struct delayed_work vf_takeover;
+ struct delayed_work vfns_work;
/* 1: allocated, serial number is valid. 0: not allocated */
u32 vf_alloc;
@@ -1075,6 +1076,8 @@ struct net_device_context {
struct netvsc_device_info *saved_netvsc_dev_info;
};
+void netvsc_vfns_work(struct work_struct *w);
+
/* Azure hosts don't support non-TCP port numbers in hashing for fragmented
* packets. We can use ethtool to change UDP hash level when necessary.
*/
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index f44753756358..39c892e46cb0 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2522,6 +2522,7 @@ static int netvsc_probe(struct hv_device *dev,
spin_lock_init(&net_device_ctx->lock);
INIT_LIST_HEAD(&net_device_ctx->reconfig_events);
INIT_DELAYED_WORK(&net_device_ctx->vf_takeover, netvsc_vf_setup);
+ INIT_DELAYED_WORK(&net_device_ctx->vfns_work, netvsc_vfns_work);
net_device_ctx->vf_stats
= netdev_alloc_pcpu_stats(struct netvsc_vf_pcpu_stats);
@@ -2666,6 +2667,8 @@ static void netvsc_remove(struct hv_device *dev)
cancel_delayed_work_sync(&ndev_ctx->dwork);
rtnl_lock();
+ cancel_delayed_work_sync(&ndev_ctx->vfns_work);
+
nvdev = rtnl_dereference(ndev_ctx->nvdev);
if (nvdev) {
cancel_work_sync(&nvdev->subchan_work);
@@ -2707,6 +2710,7 @@ static int netvsc_suspend(struct hv_device *dev)
cancel_delayed_work_sync(&ndev_ctx->dwork);
rtnl_lock();
+ cancel_delayed_work_sync(&ndev_ctx->vfns_work);
nvdev = rtnl_dereference(ndev_ctx->nvdev);
if (nvdev == NULL) {
@@ -2800,6 +2804,27 @@ static void netvsc_event_set_vf_ns(struct net_device *ndev)
}
}
+void netvsc_vfns_work(struct work_struct *w)
+{
+ struct net_device_context *ndev_ctx =
+ container_of(w, struct net_device_context, vfns_work.work);
+ struct net_device *ndev;
+
+ if (!rtnl_trylock()) {
+ schedule_delayed_work(&ndev_ctx->vfns_work, 1);
+ return;
+ }
+
+ ndev = hv_get_drvdata(ndev_ctx->device_ctx);
+ if (!ndev)
+ goto out;
+
+ netvsc_event_set_vf_ns(ndev);
+
+out:
+ rtnl_unlock();
+}
+
/*
* On Hyper-V, every VF interface is matched with a corresponding
* synthetic interface. The synthetic interface is presented first
@@ -2810,10 +2835,12 @@ static int netvsc_netdev_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
struct net_device *event_dev = netdev_notifier_info_to_dev(ptr);
+ struct net_device_context *ndev_ctx;
int ret = 0;
if (event_dev->netdev_ops == &device_ops && event == NETDEV_REGISTER) {
- netvsc_event_set_vf_ns(event_dev);
+ ndev_ctx = netdev_priv(event_dev);
+ schedule_delayed_work(&ndev_ctx->vfns_work, 0);
return NOTIFY_DONE;
}
--
2.34.1
^ permalink raw reply related
* Re: [PATCH RFC net-next v4 00/12] vsock: add namespace support to vhost-vsock
From: Simon Horman @ 2025-08-06 19:13 UTC (permalink / raw)
To: Bobby Eshleman
Cc: Stefano Garzarella, Shuah Khan, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Stefan Hajnoczi, Michael S. Tsirkin,
Jason Wang, Xuan Zhuo, Eugenio Pérez, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Bryan Tan, Vishnu Dasa,
Broadcom internal kernel review list, virtualization, netdev,
linux-kselftest, linux-kernel, kvm, linux-hyperv, berrange,
Bobby Eshleman
In-Reply-To: <aJJ/uWhqEu1TG1Kz@devvm6216.cco0.facebook.com>
On Tue, Aug 05, 2025 at 03:03:37PM -0700, Bobby Eshleman wrote:
> On Tue, Aug 05, 2025 at 02:49:08PM -0700, Bobby Eshleman wrote:
>
> ...
>
> >
> > Thanks again for everyone's help and reviews!
> >
> >
> > Changes in v4:
> > - removed RFC tag
>
> My bad, I didn't notice I still had the rfc tag before sending out with
> b4.
>
> This is ready for review and not really an RFC. All test cases passing,
> etc...
Ack. But net-next is currently closed for the merge-window.
So please don't post non-RFC patches for it until it reopens,
around the 11th August.
^ permalink raw reply
* Re: [PATCH RFC net-next v4 09/12] vsock/loopback: add netns support
From: Simon Horman @ 2025-08-06 19:12 UTC (permalink / raw)
To: Bobby Eshleman
Cc: Stefano Garzarella, Shuah Khan, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Stefan Hajnoczi, Michael S. Tsirkin,
Jason Wang, Xuan Zhuo, Eugenio Pérez, K. Y. Srinivasan,
Haiyang Zhang, Wei Liu, Dexuan Cui, Bryan Tan, Vishnu Dasa,
Broadcom internal kernel review list, virtualization, netdev,
linux-kselftest, linux-kernel, kvm, linux-hyperv, berrange,
Bobby Eshleman
In-Reply-To: <20250805-vsock-vmtest-v4-9-059ec51ab111@meta.com>
On Tue, Aug 05, 2025 at 02:49:17PM -0700, Bobby Eshleman wrote:
> From: Bobby Eshleman <bobbyeshleman@meta.com>
>
> Add NS support to vsock loopback. Sockets in a global mode netns
> communicate with each other, regardless of namespace. Sockets in a local
> mode netns may only communicate with other sockets within the same
> namespace.
>
> Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
...
> diff --git a/net/vmw_vsock/vsock_loopback.c b/net/vmw_vsock/vsock_loopback.c
...
> @@ -46,7 +57,7 @@ static int vsock_loopback_cancel_pkt(struct vsock_sock *vsk)
> return 0;
> }
>
> -static bool vsock_loopback_seqpacket_allow(u32 remote_cid);
> +static bool vsock_loopback_seqpacket_allow(struct vsock_sock *vsk, u32 remote_cid);
This change needs to be squashed into
PATCH 3/12 vsock: add netns to af_vsock core
To avoid build breakage.
Likewise with the other change to vsock_loopback_seqpacket_allow below.
And I think also for a number of other changes made by PATCH 3/12.
Please make sure that patches don't introduce transient build failures.
It breaks bisection.
On the topic of vsock_loopback_seqpacket_allow, also:
* Please line wrap this so that the code is 80 columns wide or less,
as is still preferred for Networking code.
Flagged by checkpatch.pl --max-line-length=80
* Can we move the definition of vsock_loopback_seqpacket_allow() here?
The function itself is is trivial. And doing so would avoid a forward
declaration.
> static bool vsock_loopback_msgzerocopy_allow(void)
> {
> return true;
...
> +int vsock_loopback_init_net(struct net *net)
> +{
> + net->vsock.loopback = kmalloc(GFP_KERNEL, sizeof(struct vsock_loopback));
> + if (!net->vsock.loopback)
> + return -ENOMEM;
> +
> + return vsock_loopback_init_vsock(net->vsock.loopback);
> +}
> +
> +void vsock_loopback_exit_net(struct net *net)
> +{
> + vsock_loopback_deinit_vsock(net->vsock.loopback);
> + kfree(net->vsock.loopback);
> +}
I think EXPORT_SYMBOL_GPL is needed for both vsock_loopback_exit_net and
vsock_loopback_init_net for the case where CONFIG_VSOCKETS=m
Also, in Kconfig VSOCKETS_LOOPBACK depends on VSOCKETS. But this code adds
a reverse dependency. As it stands it's possible to configure VSOCKETS
without VSOCKETS_LOOPBACK, which will not compile.
Perhaps stub implementations of vsock_loopback_init_net and
vsock_loopback_exit_net should be implemented in af_vsock.h if
VSOCKETS_LOOPBACK is not enabled?
...
--
pw-bot: changes-requested
^ permalink raw reply
* Re: [RFC PATCH V6 2/4 Resend] Drivers: hv: Allow vmbus message synic interrupt injected from Hyper-V
From: Tianyu Lan @ 2025-08-06 16:04 UTC (permalink / raw)
To: Michael Kelley
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
hpa@zytor.com, arnd@arndb.de, Neeraj.Upadhyay@amd.com, Tianyu Lan,
linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <SN6PR02MB41577D7BFC7FA078880979A5D42DA@SN6PR02MB4157.namprd02.prod.outlook.com>
On Wed, Aug 6, 2025 at 10:11 PM Michael Kelley <mhklinux@outlook.com> wrote:
>
> From: Tianyu Lan <ltykernel@gmail.com> Sent: Wednesday, August 6, 2025 5:19 AM
> >
> > When Secure AVIC is enabled, VMBus driver should
> > call x2apic Secure AVIC interface to allow Hyper-V
> > to inject VMBus message interrupt.
> >
> > Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
> > Signed-off-by: Tianyu Lan <tiala@microsoft.com>
> > ---
> > Change since RFC V5:
> > - Rmove extra line and move hv_enable_coco_interrupt()
> > just after hv_set_msr() in the hv_synic_disable_regs().
> >
> > Change since RFC V4:
> > - Change the order to call hv_enable_coco_interrupt()
> > in the hv_synic_enable/disable_regs().
> > - Update commit title "Drivers/hv:" to "Drivers: hv:"
> >
> > Change since RFC V3:
> > - Disable VMBus Message interrupt via hv_enable_
> > coco_interrupt() in the hv_synic_disable_regs().
> > ---
> > arch/x86/hyperv/hv_apic.c | 5 +++++
> > drivers/hv/hv.c | 7 ++++++-
> > drivers/hv/hv_common.c | 5 +++++
> > include/asm-generic/mshyperv.h | 1 +
> > 4 files changed, 17 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
> > index 01bc02cc0590..c9808a51fa37 100644
> > --- a/arch/x86/hyperv/hv_apic.c
> > +++ b/arch/x86/hyperv/hv_apic.c
> > @@ -54,6 +54,11 @@ static void hv_apic_icr_write(u32 low, u32 id)
> > wrmsrq(HV_X64_MSR_ICR, reg_val);
> > }
> >
> > +void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set)
> > +{
> > + apic_update_vector(cpu, vector, set);
> > +}
> > +
> > static u32 hv_apic_read(u32 reg)
> > {
> > u32 reg_val, hi;
> > diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> > index 308c8f279df8..d68a96de1626 100644
> > --- a/drivers/hv/hv.c
> > +++ b/drivers/hv/hv.c
> > @@ -312,10 +312,13 @@ void hv_synic_enable_regs(unsigned int cpu)
> > shared_sint.as_uint64 = hv_get_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT);
> >
> > shared_sint.vector = vmbus_interrupt;
> > +
>
> The spurious blank line is still here.
>
> > shared_sint.masked = false;
> > shared_sint.auto_eoi = hv_recommend_using_aeoi();
> > hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
> >
> > + hv_enable_coco_interrupt(cpu, vmbus_interrupt, true);
> > +
> > /* Enable the global synic bit */
> > sctrl.as_uint64 = hv_get_msr(HV_MSR_SCONTROL);
> > sctrl.enable = 1;
> > @@ -342,7 +345,6 @@ void hv_synic_disable_regs(unsigned int cpu)
> > union hv_synic_scontrol sctrl;
> >
> > shared_sint.as_uint64 = hv_get_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT);
> > -
> > shared_sint.masked = 1;
> >
> > /* Need to correctly cleanup in the case of SMP!!! */
> > @@ -350,6 +352,9 @@ void hv_synic_disable_regs(unsigned int cpu)
> > hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
> >
> > simp.as_uint64 = hv_get_msr(HV_MSR_SIMP);
> > +
> > + hv_enable_coco_interrupt(cpu, vmbus_interrupt, false);
> > +
>
> This line is still in the wrong place. Maybe you accidentally resent
> the previous version of the patch instead of the version with your
> intended changes?
>
> Michael
Hi Michael:
I just sent out an update version. Sorry for confusion.
--
Thanks
Tianyu Lan
^ permalink raw reply
* [Update RFC PATCH V6 2/4] Drivers: hv: Allow vmbus message synic interrupt injected from Hyper-V
From: Tianyu Lan @ 2025-08-06 16:00 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, tglx, mingo, bp, dave.hansen, x86,
hpa, arnd, Neeraj.Upadhyay, kvijayab
Cc: Tianyu Lan, linux-arch, linux-hyperv, linux-kernel
In-Reply-To: <SN6PR02MB41577D7BFC7FA078880979A5D42DA@SN6PR02MB4157.namprd02.prod.outlook.com>
From: Tianyu Lan <tiala@microsoft.com>
When Secure AVIC is enabled, VMBus driver should
call x2apic Secure AVIC interface to allow Hyper-V
to inject VMBus message interrupt.
Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Signed-off-by: Tianyu Lan <tiala@microsoft.com>
---
Change since RFC V5:
- Rmove extra line and move hv_enable_coco_interrupt()
just after hv_set_msr() in the hv_synic_disable_regs().
Change since RFC V4:
- Change the order to call hv_enable_coco_interrupt()
in the hv_synic_enable/disable_regs().
- Update commit title "Drivers/hv:" to "Drivers: hv:"
Change since RFC V3:
- Disable VMBus Message interrupt via hv_enable_
coco_interrupt() in the hv_synic_disable_regs().
---
arch/x86/hyperv/hv_apic.c | 5 +++++
drivers/hv/hv.c | 4 ++++
drivers/hv/hv_common.c | 5 +++++
include/asm-generic/mshyperv.h | 1 +
4 files changed, 15 insertions(+)
diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
index 01bc02cc0590..c9808a51fa37 100644
--- a/arch/x86/hyperv/hv_apic.c
+++ b/arch/x86/hyperv/hv_apic.c
@@ -54,6 +54,11 @@ static void hv_apic_icr_write(u32 low, u32 id)
wrmsrq(HV_X64_MSR_ICR, reg_val);
}
+void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set)
+{
+ apic_update_vector(cpu, vector, set);
+}
+
static u32 hv_apic_read(u32 reg)
{
u32 reg_val, hi;
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 308c8f279df8..355663a6e3b8 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -316,6 +316,8 @@ void hv_synic_enable_regs(unsigned int cpu)
shared_sint.auto_eoi = hv_recommend_using_aeoi();
hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
+ hv_enable_coco_interrupt(cpu, vmbus_interrupt, true);
+
/* Enable the global synic bit */
sctrl.as_uint64 = hv_get_msr(HV_MSR_SCONTROL);
sctrl.enable = 1;
@@ -349,6 +351,8 @@ void hv_synic_disable_regs(unsigned int cpu)
/* Disable the interrupt */
hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
+ hv_enable_coco_interrupt(cpu, vmbus_interrupt, false);
+
simp.as_uint64 = hv_get_msr(HV_MSR_SIMP);
/*
* In Isolation VM, sim and sief pages are allocated by
diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index 49898d10faff..0f024ab3d360 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -716,6 +716,11 @@ u64 __weak hv_tdx_hypercall(u64 control, u64 param1, u64 param2)
}
EXPORT_SYMBOL_GPL(hv_tdx_hypercall);
+void __weak hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set)
+{
+}
+EXPORT_SYMBOL_GPL(hv_enable_coco_interrupt);
+
void hv_identify_partition_type(void)
{
/* Assume guest role */
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index a729b77983fa..7907c9878369 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -333,6 +333,7 @@ bool hv_is_isolation_supported(void);
bool hv_isolation_type_snp(void);
u64 hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_size);
u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2);
+void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set);
void hyperv_cleanup(void);
bool hv_query_ext_cap(u64 cap_query);
void hv_setup_dma_ops(struct device *dev, bool coherent);
--
2.25.1
^ permalink raw reply related
* RE: [RFC PATCH V6 2/4 Resend] Drivers: hv: Allow vmbus message synic interrupt injected from Hyper-V
From: Michael Kelley @ 2025-08-06 14:11 UTC (permalink / raw)
To: Tianyu Lan, kys@microsoft.com, haiyangz@microsoft.com,
wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, arnd@arndb.de,
Neeraj.Upadhyay@amd.com
Cc: Tianyu Lan, linux-arch@vger.kernel.org,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20250806121855.442103-3-ltykernel@gmail.com>
From: Tianyu Lan <ltykernel@gmail.com> Sent: Wednesday, August 6, 2025 5:19 AM
>
> When Secure AVIC is enabled, VMBus driver should
> call x2apic Secure AVIC interface to allow Hyper-V
> to inject VMBus message interrupt.
>
> Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
> Signed-off-by: Tianyu Lan <tiala@microsoft.com>
> ---
> Change since RFC V5:
> - Rmove extra line and move hv_enable_coco_interrupt()
> just after hv_set_msr() in the hv_synic_disable_regs().
>
> Change since RFC V4:
> - Change the order to call hv_enable_coco_interrupt()
> in the hv_synic_enable/disable_regs().
> - Update commit title "Drivers/hv:" to "Drivers: hv:"
>
> Change since RFC V3:
> - Disable VMBus Message interrupt via hv_enable_
> coco_interrupt() in the hv_synic_disable_regs().
> ---
> arch/x86/hyperv/hv_apic.c | 5 +++++
> drivers/hv/hv.c | 7 ++++++-
> drivers/hv/hv_common.c | 5 +++++
> include/asm-generic/mshyperv.h | 1 +
> 4 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
> index 01bc02cc0590..c9808a51fa37 100644
> --- a/arch/x86/hyperv/hv_apic.c
> +++ b/arch/x86/hyperv/hv_apic.c
> @@ -54,6 +54,11 @@ static void hv_apic_icr_write(u32 low, u32 id)
> wrmsrq(HV_X64_MSR_ICR, reg_val);
> }
>
> +void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set)
> +{
> + apic_update_vector(cpu, vector, set);
> +}
> +
> static u32 hv_apic_read(u32 reg)
> {
> u32 reg_val, hi;
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 308c8f279df8..d68a96de1626 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -312,10 +312,13 @@ void hv_synic_enable_regs(unsigned int cpu)
> shared_sint.as_uint64 = hv_get_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT);
>
> shared_sint.vector = vmbus_interrupt;
> +
The spurious blank line is still here.
> shared_sint.masked = false;
> shared_sint.auto_eoi = hv_recommend_using_aeoi();
> hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
>
> + hv_enable_coco_interrupt(cpu, vmbus_interrupt, true);
> +
> /* Enable the global synic bit */
> sctrl.as_uint64 = hv_get_msr(HV_MSR_SCONTROL);
> sctrl.enable = 1;
> @@ -342,7 +345,6 @@ void hv_synic_disable_regs(unsigned int cpu)
> union hv_synic_scontrol sctrl;
>
> shared_sint.as_uint64 = hv_get_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT);
> -
> shared_sint.masked = 1;
>
> /* Need to correctly cleanup in the case of SMP!!! */
> @@ -350,6 +352,9 @@ void hv_synic_disable_regs(unsigned int cpu)
> hv_set_msr(HV_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
>
> simp.as_uint64 = hv_get_msr(HV_MSR_SIMP);
> +
> + hv_enable_coco_interrupt(cpu, vmbus_interrupt, false);
> +
This line is still in the wrong place. Maybe you accidentally resent
the previous version of the patch instead of the version with your
intended changes?
Michael
> /*
> * In Isolation VM, sim and sief pages are allocated by
> * paravisor. These pages also will be used by kdump
> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> index 49898d10faff..0f024ab3d360 100644
> --- a/drivers/hv/hv_common.c
> +++ b/drivers/hv/hv_common.c
> @@ -716,6 +716,11 @@ u64 __weak hv_tdx_hypercall(u64 control, u64 param1, u64
> param2)
> }
> EXPORT_SYMBOL_GPL(hv_tdx_hypercall);
>
> +void __weak hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set)
> +{
> +}
> +EXPORT_SYMBOL_GPL(hv_enable_coco_interrupt);
> +
> void hv_identify_partition_type(void)
> {
> /* Assume guest role */
> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
> index a729b77983fa..7907c9878369 100644
> --- a/include/asm-generic/mshyperv.h
> +++ b/include/asm-generic/mshyperv.h
> @@ -333,6 +333,7 @@ bool hv_is_isolation_supported(void);
> bool hv_isolation_type_snp(void);
> u64 hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_size);
> u64 hv_tdx_hypercall(u64 control, u64 param1, u64 param2);
> +void hv_enable_coco_interrupt(unsigned int cpu, unsigned int vector, bool set);
> void hyperv_cleanup(void);
> bool hv_query_ext_cap(u64 cap_query);
> void hv_setup_dma_ops(struct device *dev, bool coherent);
> --
> 2.25.1
>
^ permalink raw reply
* [RFC PATCH V6 4/4 Resend] x86/hyperv: Allow Hyper-V to inject STIMER0 interrupts
From: Tianyu Lan @ 2025-08-06 12:18 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, tglx, mingo, bp, dave.hansen, x86,
hpa, arnd, Neeraj.Upadhyay, kvijayab
Cc: Tianyu Lan, linux-arch, linux-hyperv, linux-kernel,
Michael Kelley
In-Reply-To: <20250806121855.442103-1-ltykernel@gmail.com>
From: Tianyu Lan <tiala@microsoft.com>
When Secure AVIC is enabled, call Secure AVIC
function to allow Hyper-V to inject STIMER0 interrupt.
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Signed-off-by: Tianyu Lan <tiala@microsoft.com>
---
arch/x86/hyperv/hv_init.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 3d1d3547095a..591338162420 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -132,6 +132,10 @@ static int hv_cpu_init(unsigned int cpu)
wrmsrq(HV_X64_MSR_VP_ASSIST_PAGE, msr.as_uint64);
}
+ /* Allow Hyper-V stimer vector to be injected from Hypervisor. */
+ if (ms_hyperv.misc_features & HV_STIMER_DIRECT_MODE_AVAILABLE)
+ apic_update_vector(cpu, HYPERV_STIMER0_VECTOR, true);
+
return hyperv_init_ghcb();
}
@@ -239,6 +243,9 @@ static int hv_cpu_die(unsigned int cpu)
*ghcb_va = NULL;
}
+ if (ms_hyperv.misc_features & HV_STIMER_DIRECT_MODE_AVAILABLE)
+ apic_update_vector(cpu, HYPERV_STIMER0_VECTOR, false);
+
hv_common_cpu_die(cpu);
if (hv_vp_assist_page && hv_vp_assist_page[cpu]) {
--
2.25.1
^ permalink raw reply related
* [RFC PATCH V6 3/4 Resend] x86/hyperv: Don't use auto-eoi when Secure AVIC is available
From: Tianyu Lan @ 2025-08-06 12:18 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui, tglx, mingo, bp, dave.hansen, x86,
hpa, arnd, Neeraj.Upadhyay, kvijayab
Cc: Tianyu Lan, linux-arch, linux-hyperv, linux-kernel,
Michael Kelley
In-Reply-To: <20250806121855.442103-1-ltykernel@gmail.com>
From: Tianyu Lan <tiala@microsoft.com>
Hyper-V doesn't support auto-eoi with Secure AVIC.
So set the HV_DEPRECATING_AEOI_RECOMMENDED flag to
force writing the EOI register after handling an
interrupt.
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Reviewed-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Signed-off-by: Tianyu Lan <tiala@microsoft.com>
---
Change since RFC V3:
- Update title prefix from "x86/Hyper-V" to "x86/hyperv"
---
arch/x86/kernel/cpu/mshyperv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index c78f860419d6..8f029650f16c 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -463,6 +463,8 @@ static void __init ms_hyperv_init_platform(void)
ms_hyperv.max_vp_index, ms_hyperv.max_lp_index);
hv_identify_partition_type();
+ if (cc_platform_has(CC_ATTR_SNP_SECURE_AVIC))
+ ms_hyperv.hints |= HV_DEPRECATING_AEOI_RECOMMENDED;
if (ms_hyperv.hints & HV_X64_HYPERV_NESTED) {
hv_nested = true;
--
2.25.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox