Skip to content

Commit b4aa981

Browse files
gzhai7lijinxia
authored andcommitted
DM: make removing vGSI capability option as local
Current option of removing vGSI capability is global, which exposes vIOAPIC link for all ptdev even only one need this. This patch makes it as ptdev local option to lower the system level impact. To keep vGSI for MSI capable ptdev, just explicitly append ",keep_gsi" in option list, like "-s 14,passthru,0/e/0,keep_gsi" Signed-off-by: Edwin Zhai <edwin.zhai@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent dafca17 commit b4aa981

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

devicemodel/core/main.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ usage(int code)
137137
" -H: vmexit from the guest on hlt\n"
138138
" -l: LPC device configuration\n"
139139
" -m: memory size in MB\n"
140-
" -M: do not hide INTx link for MSI&INTx capable ptdev\n"
141140
" -p: pin 'vcpu' to 'hostcpu'\n"
142141
" -P: vmexit from the guest on pause\n"
143142
" -s: <slot,driver,configinfo> PCI slot config\n"
@@ -619,7 +618,6 @@ static struct option long_options[] = {
619618
{"kernel", required_argument, 0, 'k' },
620619
{"ramdisk", required_argument, 0, 'r' },
621620
{"bootargs", required_argument, 0, 'B' },
622-
{"ptdev_msi", no_argument, 0, 'M' },
623621
{"version", no_argument, 0, 'v' },
624622
{"gvtargs", required_argument, 0, 'G' },
625623
{"help", no_argument, 0, 'h' },
@@ -658,7 +656,7 @@ main(int argc, char *argv[])
658656
if (signal(SIGINT, sig_handler_term) == SIG_ERR)
659657
fprintf(stderr, "cannot register handler for SIGINT\n");
660658

661-
optstr = "abehuwxACHIMPSTWYvk:r:B:p:g:c:s:m:l:U:G:i:";
659+
optstr = "abehuwxACHIPSTWYvk:r:B:p:g:c:s:m:l:U:G:i:";
662660
while ((c = getopt_long(argc, argv, optstr, long_options,
663661
&option_idx)) != -1) {
664662
switch (c) {
@@ -774,9 +772,6 @@ main(int argc, char *argv[])
774772
exit(1);
775773
}
776774
break;
777-
case 'M':
778-
ptdev_prefer_msi(false);
779-
break;
780775
case 'v':
781776
print_version();
782777
break;

devicemodel/hw/pci/passthrough.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ static int memfd = -1;
8585
static int pciaccess_ref_cnt;
8686
static pthread_mutex_t ref_cnt_mtx = PTHREAD_MUTEX_INITIALIZER;
8787

88-
/* Prefer MSI over INTx for ptdev */
89-
static bool prefer_msi = true;
90-
9188
/* Not check reset capability before assign ptdev.
9289
* Set false by default, that is, always check.
9390
*/
@@ -112,12 +109,6 @@ struct passthru_dev {
112109
struct pci_device *phys_dev;
113110
};
114111

115-
void
116-
ptdev_prefer_msi(bool enable)
117-
{
118-
prefer_msi = enable;
119-
}
120-
121112
void ptdev_no_reset(bool enable)
122113
{
123114
no_reset = enable;
@@ -937,16 +928,28 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
937928
struct passthru_dev *ptdev;
938929
struct pci_device_iterator *iter;
939930
struct pci_device *phys_dev;
931+
char *opt;
932+
bool keep_gsi = false;
940933

941934
ptdev = NULL;
942935
error = -EINVAL;
943936

944-
if (opts == NULL ||
945-
sscanf(opts, "%x/%x/%x", &bus, &slot, &func) != 3) {
946-
warnx("invalid passthru options, %s", opts);
937+
if (opts == NULL) {
938+
warnx("Empty passthru options\n");
947939
return -EINVAL;
948940
}
949941

942+
opt = strsep(&opts, ",");
943+
if (sscanf(opt, "%x/%x/%x", &bus, &slot, &func) != 3) {
944+
warnx("Invalid passthru options, %s", opt);
945+
return -EINVAL;
946+
}
947+
948+
while ((opt = strsep(&opts, ",")) != NULL) {
949+
if (!strncmp(opt, "keep_gsi", 8))
950+
keep_gsi = true;
951+
}
952+
950953
if (vm_assign_ptdev(ctx, bus, slot, func) != 0) {
951954
warnx("PCI device at %x/%x/%x is not using the pt(4) driver",
952955
bus, slot, func);
@@ -1012,7 +1015,7 @@ passthru_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
10121015
* Forge Guest to use MSI/MSIX in this case to mitigate IRQ sharing
10131016
* issue
10141017
*/
1015-
if (error == IRQ_MSI && prefer_msi)
1018+
if (error == IRQ_MSI && !keep_gsi)
10161019
return 0;
10171020

10181021
/* Allocates the virq if ptdev only support INTx */

devicemodel/include/dm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@ int vmexit_task_switch(struct vmctx *ctx, struct vhm_request *vhm_req,
4848
void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len);
4949
void *dm_gpa2hva(uint64_t gpa, size_t size);
5050
int virtio_uses_msix(void);
51-
void ptdev_prefer_msi(bool enable);
5251
void ptdev_no_reset(bool enable);
5352
#endif

0 commit comments

Comments
 (0)