diff mbox series

flask: label-pci: Allow specifying irq label

Message ID 20201019200318.103781-1-jandryuk@gmail.com (mailing list archive)
State New, archived
Headers show
Series flask: label-pci: Allow specifying irq label | expand

Commit Message

Jason Andryuk Oct. 19, 2020, 8:03 p.m. UTC
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.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/flask/utils/label-pci.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Jason Andryuk Jan. 20, 2021, 7:13 p.m. UTC | #1
On Mon, Oct 19, 2020 at 4:03 PM Jason Andryuk <jandryuk@gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> ---

Hi,

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

Thanks,
Jason


>  tools/flask/utils/label-pci.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/tools/flask/utils/label-pci.c b/tools/flask/utils/label-pci.c
> index 9ddb713cf4..897b772804 100644
> --- a/tools/flask/utils/label-pci.c
> +++ b/tools/flask/utils/label-pci.c
> @@ -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
>
dpsmith.dev Jan. 21, 2021, 1:32 a.m. UTC | #2
On 10/19/20 4:03 PM, Jason Andryuk wrote:
> 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.
> 
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
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.

Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>

v/r,
dps
diff mbox series

Patch

diff --git a/tools/flask/utils/label-pci.c b/tools/flask/utils/label-pci.c
index 9ddb713cf4..897b772804 100644
--- a/tools/flask/utils/label-pci.c
+++ b/tools/flask/utils/label-pci.c
@@ -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);