Skip to content

Commit

Permalink
xen/pt: Emulate multifunction bit in header type
Browse files Browse the repository at this point in the history
The intention of the code appears to have been to unconditionally set
the multifunction bit but since the emulation mask is 0x00 it has no
effect. Instead, emulate the bit and set it based on the multifunction
property of the PCIDevice (which can be set using QAPI).

This allows making passthrough devices appear as functions in a Xen
guest.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-Id: <20231103172601.1319375-1-ross.lagerwall@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
  • Loading branch information
rosslagerwall authored and anthonyper-ctx committed Mar 12, 2024
1 parent 8f3f329 commit 25b2873
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hw/xen/xen_pt_config_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ static int xen_pt_header_type_reg_init(XenPCIPassthroughState *s,
uint32_t *data)
{
/* read PCI_HEADER_TYPE */
*data = reg->init_val | 0x80;
*data = reg->init_val;
if ((PCI_DEVICE(s)->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) {
*data |= PCI_HEADER_TYPE_MULTI_FUNCTION;
}
return 0;
}

Expand Down Expand Up @@ -677,7 +680,7 @@ static XenPTRegInfo xen_pt_emu_reg_header0[] = {
.size = 1,
.init_val = 0x00,
.ro_mask = 0xFF,
.emu_mask = 0x00,
.emu_mask = PCI_HEADER_TYPE_MULTI_FUNCTION,
.init = xen_pt_header_type_reg_init,
.u.b.read = xen_pt_byte_reg_read,
.u.b.write = xen_pt_byte_reg_write,
Expand Down

0 comments on commit 25b2873

Please sign in to comment.