GNTTABOP_setup_table yields -1 PFNs
[I asked on IRC and Andrew Cooper suggested posting the question here. I'm not subscribed to xen-devel@, so please cc me in replies.]
On a Xen 4.14 host (with extraversion=.0.88.g1d1d1f53), with version 1 grant tables, where GNTTABOP_query_size initially returns nr_frames=32 max_nr_frames=64, a NetBSD guest repeatedly queries GNTTABOP_setup_table for successively larger nr_frames from 1 up.
The guest initially gets arrays of valid-looking PFNs. But then at nr_frames=33, the PFNs [0] through [31] in the resulting array are valid but PFN [32] is -1, i.e., all bits set.
GNTTABOP_setup_table returned 0 and op.status = GNTST_okay, so it didn't fail -- it just returned an invalid PFN. And _after_ GNTTABOP_setup_table yields -1 as a PFN, GNTTABOP_query_size returns nr_frames=33 max_nr_frames=64, so the host thinks it has successfully allocated more frames.
What could cause the host to return a PFN -1? Is there anything the guest does that could provoke this? Are there any diagnostics that the guest could print to help track this down? (I don't control the host.) Should a guest just check for -1 and stop as if it had hit max_nr_frames?
(NetBSD then passes the PFN -1 on to HYPERVISOR_mmu_update, which fails with EINVAL, at which point NetBSD crashes;
<https://gnats.NetBSD.org/58395>. If I make NetBSD pretend the host had advertised max_nr_frames=32, everything works fine.
I'm guessing non-NetBSD guests will eventually crash when they see -1, but NetBSD sees it at boot while maybe it takes very heavy I/O load on Linux to make it reach nr_frames=33 in this setup.)
Quoted 4 lines · Taylor R Campbell
On a Xen 4.14 host (with extraversion=.0.88.g1d1d1f53), with version 1 grant tables, where
GNTTABOP_query_sizeinitially returns nr_frames=32 max_nr_frames=64, a NetBSD guest repeatedly queriesGNTTABOP_setup_tablefor successively largernr_framesfrom 1 up.
First question: Is there some earlier GNTTABOP_setup_table that you invoke? I'd expect (and also observe) nr_frames=1 initially.
Second: The version you name is pretty unclear from an upstream perspective. Leaving aside that 4.14 is out of support, it's entirely unclear whether you at least have all bug fixes in place that we have upstream (4.14.6). Without that it's hard to see what you're asking for.
Quoted 10 lines
The guest initially gets arrays of valid-looking PFNs. But then at nr_frames=33, the PFNs [0] through [31] in the resulting array are valid but PFN [32] is -1, i.e., all bits set.
GNTTABOP_setup_tablereturned 0 and op.status =GNTST_okay, so it didn't fail -- it just returned an invalid PFN. And _after_GNTTABOP_setup_tableyields -1 as a PFN,GNTTABOP_query_sizereturns nr_frames=33 max_nr_frames=64, so the host thinks it has successfully allocated more frames.
Quoted 5 lines
What could cause the host to return a PFN -1? Is there anything the guest does that could provoke this? Are there any diagnostics that the guest could print to help track this down? (I don't control the host.) Should a guest just check for -1 and stop as if it had hit
max_nr_frames?
I'm afraid for the moment, from just the information provided, I can't reproduce this using a simple patch on top of XTF's self-test (see below). Neither with a 64-bit PV guest, nor with a 32-bit one. I've been doing this with a pretty recent 4.19 Xen, though.
Jan
include/xen/grant_table.h +17 -0
@@ -275,6 +275,23 @@ struct gnttab_setup_table };/* +* GNTTABOP_query_size: Query the current and maximum sizes of the shared +* grant table. +* NOTES: +* 1. <dom> may be specified as DOMID_SELF. +* 2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF. +*/ +#define GNTTABOP_query_size 6 +struct gnttab_query_size { +/* IN parameters. */ +domid_t dom; +/* OUT parameters. */ +uint32_t nr_frames; +uint32_t max_nr_frames; +int16_t status;/* => enum grant_status */ +}; + +/* * GNTTABOP_unmap_and_replace: Destroy one or more grant-reference mappings * tracked by <handle> but atomically replace the page table entry with one * pointing to the machine address under <new_addr>. <new_addr> will be
tests/selftest/main.c +51 -0
57 lines not on this page · raw message
Quoted 30 lines · Jan Beulich
Quoted 4 lines · Taylor R Campbell
On a Xen 4.14 host (with extraversion=.0.88.g1d1d1f53), with version 1 grant tables, where
GNTTABOP_query_sizeinitially returns nr_frames=32 max_nr_frames=64, a NetBSD guest repeatedly queriesGNTTABOP_setup_tablefor successively largernr_framesfrom 1 up.First question: Is there some earlier
GNTTABOP_setup_tablethat you invoke? I'd expect (and also observe) nr_frames=1 initially.Second: The version you name is pretty unclear from an upstream perspective. Leaving aside that 4.14 is out of support, it's entirely unclear whether you at least have all bug fixes in place that we have upstream (4.14.6). Without that it's hard to see what you're asking for.
Quoted 10 lines
The guest initially gets arrays of valid-looking PFNs. But then at nr_frames=33, the PFNs [0] through [31] in the resulting array are valid but PFN [32] is -1, i.e., all bits set.
GNTTABOP_setup_tablereturned 0 and op.status =GNTST_okay, so it didn't fail -- it just returned an invalid PFN. And _after_GNTTABOP_setup_tableyields -1 as a PFN,GNTTABOP_query_sizereturns nr_frames=33 max_nr_frames=64, so the host thinks it has successfully allocated more frames.Quoted 5 lines
What could cause the host to return a PFN -1? Is there anything the guest does that could provoke this? Are there any diagnostics that the guest could print to help track this down? (I don't control the host.) Should a guest just check for -1 and stop as if it had hit
max_nr_frames?
Quoted 4 lines
I'm afraid for the moment, from just the information provided, I can't reproduce this using a simple patch on top of XTF's self-test (see below). Neither with a 64-bit PV guest, nor with a 32-bit one. I've been doing this with a pretty recent 4.19 Xen, though.
Doesn't reproduce for me with 4.14.6 either.
Jan
Quoted 11 lines
Date: Mon, 8 Jul 2024 11:09:21 +0200
From: Jan Beulich <[email protected]>Quoted 4 lines · Taylor R Campbell
On a Xen 4.14 host (with extraversion=.0.88.g1d1d1f53), with version 1 grant tables, where
GNTTABOP_query_sizeinitially returns nr_frames=32 max_nr_frames=64, a NetBSD guest repeatedly queriesGNTTABOP_setup_tablefor successively largernr_framesfrom 1 up.First question: Is there some earlier
GNTTABOP_setup_tablethat you invoke? I'd expect (and also observe) nr_frames=1 initially.
Not that the guest OS invokes. Perhaps the bootloader, pv-grub 0.97, might invoke GNTTABOP_setup_table? I looked around but couldn't find an obvious source for pv-grub 0.97.
Quoted 4 lines
Second: The version you name is pretty unclear from an upstream perspective. Leaving aside that 4.14 is out of support, it's entirely unclear whether you at least have all bug fixes in place that we have upstream (4.14.6). Without that it's hard to see what you're asking for.
It looks like it's based on commit:
commit 1d1d1f5391976456a79daac0dcfe7157da1e54f7
Author: Roger Pau Monné <[email protected]> Date: Tue Dec 1 15:34:55 2020 +0100
x86/vioapic: fix usage of index in place of GSI in vioapic_write_redirent
Does that help to narrow it down? (I don't know if I can rule out local changes, though.)
Quoted 23 lines · Taylor R Campbell
Quoted 11 lines
Date: Mon, 8 Jul 2024 11:09:21 +0200
From: Jan Beulich <[email protected]>Quoted 4 lines · Taylor R Campbell
On a Xen 4.14 host (with extraversion=.0.88.g1d1d1f53), with version 1 grant tables, where
GNTTABOP_query_sizeinitially returns nr_frames=32 max_nr_frames=64, a NetBSD guest repeatedly queriesGNTTABOP_setup_tablefor successively largernr_framesfrom 1 up.First question: Is there some earlier
GNTTABOP_setup_tablethat you invoke? I'd expect (and also observe) nr_frames=1 initially.Not that the guest OS invokes. Perhaps the bootloader, pv-grub 0.97, might invoke
GNTTABOP_setup_table? I looked around but couldn't find an obvious source for pv-grub 0.97.Quoted 4 lines
Second: The version you name is pretty unclear from an upstream perspective. Leaving aside that 4.14 is out of support, it's entirely unclear whether you at least have all bug fixes in place that we have upstream (4.14.6). Without that it's hard to see what you're asking for.
It looks like it's based on commit:
Quoted 7 lines
commit
1d1d1f5391976456a79daac0dcfe7157da1e54f7Author: Roger Pau Monné <[email protected]> Date: Tue Dec 1 15:34:55 2020 +0100x86/vioapic: fix usage of index in place of GSI in
vioapic_write_redirentDoes that help to narrow it down?
Only in so far as telling us that this looks to be far behind.
Quoted 1 line
(I don't know if I can rule out local changes, though.)
Which, however, would be relevant.
Any chance you could try, against the version you presently run, the XTF patch I sent earlier? Assumes of course you're at least lightly familiar with XTF (xenbits.xen.org/xtf.git).
Jan
Juergen Gross
maintainerQuoted 9 lines · Taylor R Campbell
Quoted 9 lines
Date: Mon, 8 Jul 2024 11:09:21 +0200
From: Jan Beulich <[email protected]>Quoted 4 lines · Taylor R Campbell
On a Xen 4.14 host (with extraversion=.0.88.g1d1d1f53), with version 1 grant tables, where
GNTTABOP_query_sizeinitially returns nr_frames=32 max_nr_frames=64, a NetBSD guest repeatedly queriesGNTTABOP_setup_tablefor successively largernr_framesfrom 1 up.
Quoted 6 lines
Quoted 2 lines
First question: Is there some earlier
GNTTABOP_setup_tablethat you invoke? I'd expect (and also observe) nr_frames=1 initially.Not that the guest OS invokes. Perhaps the bootloader, pv-grub 0.97, might invoke
GNTTABOP_setup_table? I looked around but couldn't find an obvious source for pv-grub 0.97.
This is based on Mini-OS, which does GNTTABOP_setup_table with nr_frames=1
Juergen
Quoted 5 lines · Taylor R Campbell
[I asked on IRC and Andrew Cooper suggested posting the question here. I'm not subscribed to xen-devel@, so please cc me in replies.]
On a Xen 4.14 host (with extraversion=.0.88.g1d1d1f53),
xen$ git describe 1d1d1f53
RELEASE-4.14.0-88-g1d1d1f539197
So it's a build of Xen from the staging-4.14 branch from a few weeks before RELEASE-4.14.1
I have a nagging feeling I recognise these symptoms, but I can't remember anything more about it.
~Andrew