Skip to contentSkip to conversation

flask: label-pci: Allow specifying irq label

PATCH In review Jason Andryuk 2 participants 3 messages Oct 19, 2020 – Jan 21, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 flask: label-pci: Allow specifying irq label

IRQs can be shared, so uniquely labeling doesn't always work. You run into issues if you have domA_t allowed access to device_A_t and domB_t to device_B_t. The shared IRQ can only be labeled one of device_A_t or device_B_t, and assignment of the second device fails since domA_t doesn't have permission for device_B_t and vice versa.

Add the ability to specify an irq label to flask-label-pci. A shared_irq_t can then be used to for the PIRQ. The default remains to use the device label if an IRQ label isn't specified.

---
 tools/flask/utils/label-pci.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
tools/flask/utils/label-pci.c +10 -3
index 9ddb713cf4..897b772804 100644
@@ -28,7 +28,7 @@
 
 static void usage (int argCnt, char *argv[])
 {
-	fprintf(stderr, "Usage: %s SBDF label\n", argv[0]);
+	fprintf(stderr, "Usage: %s SBDF label <irq_label>\n", argv[0]);
 	exit(1);
 }
 
@@ -39,12 +39,19 @@ int main (int argCnt, char *argv[])
 	int seg, bus, dev, fn;
 	uint32_t sbdf;
 	uint64_t start, end, flags;
+	char *pirq_label;
 	char buf[1024];
 	FILE *f;
 
-	if (argCnt != 3)
+	if (argCnt < 3 || argCnt > 4)
 		usage(argCnt, argv);
 
+	if (argCnt == 4) {
+	    pirq_label = argv[3];
+	} else {
+	    pirq_label = argv[2];
+	}
+
 	xch = xc_interface_open(0,0,0);
 	if ( !xch )
 	{
@@ -107,7 +114,7 @@ int main (int argCnt, char *argv[])
 	if (fscanf(f, "%" SCNu64, &start) != 1)
 		start = 0;
 	if (start) {
-		ret = xc_flask_add_pirq(xch, start, argv[2]);
+		ret = xc_flask_add_pirq(xch, start, pirq_label);
 		if (ret) {
 			fprintf(stderr, "xc_flask_add_pirq %"PRIu64" failed: %d\n",
 					start, ret);
Signature · 1 line
2.26.2
#1 lore raw
Quoted 7 lines · Jason Andryuk

IRQs can be shared, so uniquely labeling doesn't always work. You run into issues if you have domA_t allowed access to device_A_t and domB_t to device_B_t. The shared IRQ can only be labeled one of device_A_t or device_B_t, and assignment of the second device fails since domA_t doesn't have permission for device_B_t and vice versa.

Quoted 6 lines

Add the ability to specify an irq label to flask-label-pci. A shared_irq_t can then be used to for the PIRQ. The default remains to use the device label if an IRQ label isn't specified.

---

Hi,

This is useful to me and was posted before the 4.15 cut off. Can it make it into the release?

Thanks,
Jason

Quoted 49 lines
 tools/flask/utils/label-pci.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
tools/flask/utils/label-pci.c +10 -4
index 9ddb713cf4..897b772804 100644
@@ -28,7 +28,7 @@
 
 static void usage (int argCnt, char *argv[])
 {
-       fprintf(stderr, "Usage: %s SBDF label\n", argv[0]);
+       fprintf(stderr, "Usage: %s SBDF label <irq_label>\n", argv[0]);
        exit(1);
 }
 
@@ -39,12 +39,19 @@ int main (int argCnt, char *argv[])
        int seg, bus, dev, fn;
        uint32_t sbdf;
        uint64_t start, end, flags;
+       char *pirq_label;
        char buf[1024];
        FILE *f;
 
-       if (argCnt != 3)
+       if (argCnt < 3 || argCnt > 4)
                usage(argCnt, argv);
 
+       if (argCnt == 4) {
+           pirq_label = argv[3];
+       } else {
+           pirq_label = argv[2];
+       }
+
        xch = xc_interface_open(0,0,0);
        if ( !xch )
        {
@@ -107,7 +114,7 @@ int main (int argCnt, char *argv[])
        if (fscanf(f, "%" SCNu64, &start) != 1)
                start = 0;
        if (start) {
-               ret = xc_flask_add_pirq(xch, start, argv[2]);
+               ret = xc_flask_add_pirq(xch, start, pirq_label);
                if (ret) {
                        fprintf(stderr, "xc_flask_add_pirq %"PRIu64" failed: %d\n",
                                        start, ret);
--

2.26.2

Reviewed-by Daniel P. Smith on v1 1/1
#2 lore raw
In reply to Jason Andryuk
Quoted 11 lines · Jason Andryuk

IRQs can be shared, so uniquely labeling doesn't always work. You run into issues if you have domA_t allowed access to device_A_t and domB_t to device_B_t. The shared IRQ can only be labeled one of device_A_t or device_B_t, and assignment of the second device fails since domA_t doesn't have permission for device_B_t and vice versa.

Add the ability to specify an irq label to flask-label-pci. A shared_irq_t can then be used to for the PIRQ. The default remains to use the device label if an IRQ label isn't specified.

I don't think it should block this from going in but it probably would be good to get an update into docs/misc/xsm-flask.txt on how to appropriately use this expansion.

v/r,
dps