mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
msix: Assert that specified vector is in range
There were several different ways to deal with the situation where the vector specified for a msix function is out of bound: - early return a function and keep progresssing - propagate the error to the caller - mark msix unusable - assert it is in bound - just ignore An out-of-bound vector should not be specified if the device implementation is correct so let msix functions always assert that the specified vector is in range. An exceptional case is virtio-pci, which allows the guest to configure vectors. For virtio-pci, it is more appropriate to introduce its own checks because it is sometimes too late to check the vector range in msix functions. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20220829083524.143640-1-akihiko.odaki@daynix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Yuval Shaia <yuval.shaia.ml@gmail.com> Signed-off-by: Akihiko Odaki <<a href="mailto:akihiko.odaki@daynix.com" target="_blank">akihiko.odaki@daynix.com</a>><br>
This commit is contained in:
parent
3b3112501d
commit
15377f6e79
9 changed files with 74 additions and 107 deletions
|
@ -276,25 +276,18 @@ e1000e_unuse_msix_vectors(E1000EState *s, int num_vectors)
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
static void
|
||||
e1000e_use_msix_vectors(E1000EState *s, int num_vectors)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num_vectors; i++) {
|
||||
int res = msix_vector_use(PCI_DEVICE(s), i);
|
||||
if (res < 0) {
|
||||
trace_e1000e_msix_use_vector_fail(i, res);
|
||||
e1000e_unuse_msix_vectors(s, i);
|
||||
return false;
|
||||
}
|
||||
msix_vector_use(PCI_DEVICE(s), i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
e1000e_init_msix(E1000EState *s)
|
||||
{
|
||||
PCIDevice *d = PCI_DEVICE(s);
|
||||
int res = msix_init(PCI_DEVICE(s), E1000E_MSIX_VEC_NUM,
|
||||
&s->msix,
|
||||
E1000E_MSIX_IDX, E1000E_MSIX_TABLE,
|
||||
|
@ -305,9 +298,7 @@ e1000e_init_msix(E1000EState *s)
|
|||
if (res < 0) {
|
||||
trace_e1000e_msix_init_fail(res);
|
||||
} else {
|
||||
if (!e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM)) {
|
||||
msix_uninit(d, &s->msix, &s->msix);
|
||||
}
|
||||
e1000e_use_msix_vectors(s, E1000E_MSIX_VEC_NUM);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue