Re: [PATCH v2 1/2] xen: don't allow gnttab_dma_[alloc|free]_pages() in PV guest
From: Jürgen Groß
Date: Tue Nov 10 2026 - 05:31:21 EST
On 10.11.26 10:59, Andrew Cooper wrote:
On 10/11/2026 9:56 am, Juergen Gross wrote:I'd rather have it spammy than buried somewhere in the logs.
Today gnttab_dma_alloc_pages() or gnttab_dma_free_pages are never
called when running as a PV guest, but this holds for in-tree callers
only.
Bail out early when being called in PV mode in order to ensure no out
of tree module or future use cases are violating this assumption.
This enables to safely remove PV-only code from both functions.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
drivers/xen/grant-table.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index 604c4eea5930..56a497987942 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -1063,6 +1063,9 @@ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args)
size_t size;
int i, ret;
+ if (WARN_ON(xen_pv_domain()))
+ return -EINVAL;
This will get very spammy if hit. WARN_ON_ONCE() ?
Additionally I expect any illegal user giving up quite fast if no allocation
at all for DMA is working. :-)
Juergen
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature