Skip to content

Commit 1a5f3d2

Browse files
committed
Merge tag 'pull-xen-20250310' of https://xenbits.xen.org/git-http/people/aperard/qemu-dm into staging
Xen queue: * xen/passthrough: use gsi to map pirq when dom0 is PVH * Fix missing xenstore node from xen-block backend * Fix xen mapcache extraneous invalidate # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCgAdFiEE+AwAYwjiLP2KkueYDPVXL9f7Va8FAmfO+nEACgkQDPVXL9f7 # Va+QYggA9dmxMGDO05UEd2ZPv/Goub37Le44qBN4oeXizVRZgGUs2w9ETBXhPZus # 34aI8CTID4fcH4rgF4LgJ4XuyOxYwP1ot8EpDHQg+ji2nyHeMpAyePTfubprq17U # APN6Qqefd9X+TX+W9zUS5jV/AXO+apGX+tmVkVexFuy4gSRGSVCPoibHePtoLH9G # 3rSREjdEx7ByY6ieCV5x3zHPp5tmnLWeHpNCVc5x6NplBslQduBz6vOqLNWB1LKO # 3a/lYcvTn9PIla1zpvGNbeTsPv2lcdx3SccThcZmyTv2PDm1kzyUOIo1lSIP6bb3 # LjCl3dm1mfxAGEaZ+//rsRhTH8d5ew== # =K79y # -----END PGP SIGNATURE----- # gpg: Signature made Mon 10 Mar 2025 22:42:57 HKT # gpg: using RSA key F80C006308E22CFD8A92E7980CF5572FD7FB55AF # gpg: Good signature from "Anthony PERARD <[email protected]>" [unknown] # gpg: aka "Anthony PERARD <[email protected]>" [unknown] # gpg: aka "Anthony PERARD <[email protected]>" [unknown] # gpg: aka "Anthony PERARD <[email protected]>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 5379 2F71 024C 600F 778A 7161 D8D5 7199 DF83 42C8 # Subkey fingerprint: F80C 0063 08E2 2CFD 8A92 E798 0CF5 572F D7FB 55AF * tag 'pull-xen-20250310' of https://xenbits.xen.org/git-http/people/aperard/qemu-dm: xen: No need to flush the mapcache for grants hw/xen: Add "mode" parameter to xen-block devices xen/passthrough: use gsi to map pirq when dom0 is PVH Signed-off-by: Stefan Hajnoczi <[email protected]>
2 parents 920aa48 + 68adcc7 commit 1a5f3d2

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

hw/block/xen-block.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ static void xen_block_realize(XenDevice *xendev, Error **errp)
408408
}
409409

410410
xen_device_backend_printf(xendev, "info", "%u", blockdev->info);
411+
xen_device_backend_printf(xendev, "mode",
412+
(blockdev->info & VDISK_READONLY) ? "r" : "w");
411413

412414
xen_device_frontend_printf(xendev, "virtual-device", "%lu",
413415
vdev->number);

hw/xen/xen-mapcache.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ void xen_invalidate_map_cache(void)
700700
bdrv_drain_all();
701701

702702
xen_invalidate_map_cache_single(mapcache);
703-
xen_invalidate_map_cache_single(mapcache_grants);
704703
}
705704

706705
static uint8_t *xen_replace_cache_entry_unlocked(MapCache *mc,

hw/xen/xen_pt.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,57 @@ static void xen_pt_destroy(PCIDevice *d) {
766766
}
767767
/* init */
768768

769+
#if CONFIG_XEN_CTRL_INTERFACE_VERSION >= 42000
770+
static bool xen_pt_need_gsi(void)
771+
{
772+
FILE *fp;
773+
int len;
774+
/*
775+
* The max length of guest_type is "PVH"+'\n'+'\0', it is 5,
776+
* so here set the length of type to be twice.
777+
*/
778+
char type[10];
779+
const char *guest_type = "/sys/hypervisor/guest_type";
780+
781+
fp = fopen(guest_type, "r");
782+
if (!fp) {
783+
error_report("Cannot open %s: %s", guest_type, strerror(errno));
784+
return false;
785+
}
786+
787+
if (fgets(type, sizeof(type), fp)) {
788+
len = strlen(type);
789+
if (len) {
790+
type[len - 1] = '\0';
791+
if (!strcmp(type, "PVH")) {
792+
fclose(fp);
793+
return true;
794+
}
795+
}
796+
}
797+
798+
fclose(fp);
799+
return false;
800+
}
801+
802+
static int xen_pt_map_pirq_for_gsi(PCIDevice *d, int *pirq)
803+
{
804+
int gsi;
805+
XenPCIPassthroughState *s = XEN_PT_DEVICE(d);
806+
807+
gsi = xc_pcidev_get_gsi(xen_xc,
808+
PCI_SBDF(s->real_device.domain,
809+
s->real_device.bus,
810+
s->real_device.dev,
811+
s->real_device.func));
812+
if (gsi >= 0) {
813+
return xc_physdev_map_pirq_gsi(xen_xc, xen_domid, gsi, pirq);
814+
}
815+
816+
return gsi;
817+
}
818+
#endif
819+
769820
static void xen_pt_realize(PCIDevice *d, Error **errp)
770821
{
771822
ERRP_GUARD();
@@ -847,7 +898,16 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
847898
goto out;
848899
}
849900

901+
#if CONFIG_XEN_CTRL_INTERFACE_VERSION >= 42000
902+
if (xen_pt_need_gsi()) {
903+
rc = xen_pt_map_pirq_for_gsi(d, &pirq);
904+
} else {
905+
rc = xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq);
906+
}
907+
#else
850908
rc = xc_physdev_map_pirq(xen_xc, xen_domid, machine_irq, &pirq);
909+
#endif
910+
851911
if (rc < 0) {
852912
XEN_PT_ERR(d, "Mapping machine irq %u to pirq %i failed, (err: %d)\n",
853913
machine_irq, pirq, errno);

include/hw/pci/pci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ extern bool pci_available;
2323
#define PCI_SLOT_MAX 32
2424
#define PCI_FUNC_MAX 8
2525

26+
#define PCI_SBDF(seg, bus, dev, func) \
27+
((((uint32_t)(seg)) << 16) | \
28+
(PCI_BUILD_BDF(bus, PCI_DEVFN(dev, func))))
29+
2630
/* Class, Vendor and Device IDs from Linux's pci_ids.h */
2731
#include "hw/pci/pci_ids.h"
2832

0 commit comments

Comments
 (0)