Skip to contentSkip to conversation

acpi: Prevent GPL-only code from seeping into non-GPL binaries

PATCH Superseded Boris Ostrovsky 4 participants 19 messages Sep 23, 2016 – Sep 27, 2016

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 acpi: Prevent GPL-only code from seeping into non-GPL binaries

Some code (specifically, introduced by commit 801d469ad ("[HVM] ACPI support patch 3 of 4: ACPI _PRT table.")) has only been licensed under GPLv2. We want to prevent this code from showing up in non-GPL binaries which might become possible after we make ACPI builder code available to users other than hvmloader.

There are two pieces that we need to be careful about:
(1) A small chunk of code in dsdt.asl that implements _PIC method
(2) A chunk of ASL generator in mk_dsdt.c that describes with PCI interrupt routing.

This code will now be generated by a GPL-only script which will be invoked only when ACPI builder's Makefile is called with GPL variable set.

We also strip license header from generated ASL files to prevent inadverent use of those files with incorrect license.

---
Changes in v6:
* Replaced script's printf in most case with "here document" (for multi-line text) or echo for single line. Left printf for formatted output. (Note that in one case paramter expansion is necessary and so delimiter word is intentionally not quoted).
* Replaced bash arrays with ${string:index:size} syntax.
* Style adjustments as requested by Jan.

I am sending only this patch from series. A couple of patches are affected by changes here. I will re-send the whole series if needed.

 tools/firmware/hvmloader/Makefile                |   3 +
 tools/firmware/hvmloader/acpi/Makefile           |  14 ++-
 tools/firmware/hvmloader/acpi/dsdt.asl           |  14 ---
 tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh | 116 +++++++++++++++++++++++
 tools/firmware/hvmloader/acpi/mk_dsdt.c          |  68 +------------
 5 files changed, 131 insertions(+), 84 deletions(-)
 create mode 100755 tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh
tools/firmware/hvmloader/Makefile +3 -0
index 9f7357f..a1844d0 100644
@@ -65,6 +65,9 @@ ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
 ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
 endif
 
+# Certain parts of ACPI builder are GPL-only
+export GPL := y
+
 .PHONY: all
 all: subdirs-all
 	$(MAKE) hvmloader
tools/firmware/hvmloader/acpi/Makefile +11 -3
index f63e734..c23626d 100644
@@ -17,7 +17,8 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
+C_SRC-$(GPL) = build.c dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c
+C_SRC = build.c static_tables.c $(C_SRC-y)
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
 CFLAGS += $(CFLAGS_xeninclude)
@@ -36,18 +37,25 @@ ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
 mk_dsdt: mk_dsdt.c
 	$(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
-dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt
+ifeq ($(GPL),y)
+dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh mk_dsdt
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
+	# Strip license comment
+	sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX)
+	$(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)
 	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
 	./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)
 	mv -f $@.$(TMP_SUFFIX) $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
-dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl mk_dsdt
+dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl gpl/mk_dsdt_gpl.sh mk_dsdt
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
+	sed -i '1,/\*\//{/\/\*/,/\*\//d}' $@.$(TMP_SUFFIX)
+	$(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)
 	cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX)
 	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@.$(TMP_SUFFIX)
 	mv -f $@.$(TMP_SUFFIX) $@
+endif
 
 $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
 	iasl -vs -p $* -tc $*.asl
tools/firmware/hvmloader/acpi/dsdt.asl +0 -14
index 4f6db79..13811cf 100644
@@ -26,20 +26,6 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
     Name (\APCL, 0x00010000)
     Name (\PUID, 0x00)
 
-    /* _S3 and _S4 are in separate SSDTs */
-    Name (\_S5, Package (0x04)
-    {
-        0x00,  /* PM1a_CNT.SLP_TYP */
-        0x00,  /* PM1b_CNT.SLP_TYP */
-        0x00,  /* reserved */
-        0x00   /* reserved */
-    })
-
-    Name(PICD, 0)
-    Method(_PIC, 1)
-    {
-        Store(Arg0, PICD) 
-    }
 
     Scope (\_SB)
     {
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +116 -0

116 lines not on this page · raw message

tools/firmware/hvmloader/acpi/mk_dsdt.c +1 -67

80 lines not on this page · raw message

Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.09.16 at 21:14, <[email protected]> wrote:

Changes in v6:
* Replaced script's printf in most case with "here document" (for multi-line text) or echo for single line. Left printf for formatted output. (Note that in one case paramter expansion is necessary and so delimiter word is intentionally not quoted).
* Replaced bash arrays with ${string:index:size} syntax.

Without having looked at the patch in full yet - is this any more portable than the previous approach? I can't see any mention of it in SUSv6 / SUSv7 either.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.09.16 at 21:14, <[email protected]> wrote:

Changes in v6:
* Replaced script's printf in most case with "here document" (for multi-line text) or echo for single line. Left printf for formatted output. (Note that in one case paramter expansion is necessary and so delimiter word is intentionally not quoted).
* Replaced bash arrays with ${string:index:size} syntax.

Without having looked at the patch in full yet - is this any more portable than the previous approach? I can't see any mention of it in SUSv6 / SUSv7 either.

I can't say for sure but I remember seeing this construct long time ago.

Of course, this being bash, there are at least 3 ways of doing the same thing so I can also do

    link=`echo "A B C D" | cut  -d" " -f $i`

Will SUSv6 understand this? I don't have access to anything older than fedora 13.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 26.09.16 at 14:49, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.09.16 at 21:14, <[email protected]> wrote:

Changes in v6:
* Replaced script's printf in most case with "here document" (for multi-line text) or echo for single line. Left printf for formatted output. (Note that in one case paramter expansion is necessary and so delimiter word is intentionally not quoted).
* Replaced bash arrays with ${string:index:size} syntax.

Without having looked at the patch in full yet - is this any more portable than the previous approach? I can't see any mention of it in SUSv6 / SUSv7 either.

Quoted 8 lines

I can't say for sure but I remember seeing this construct long time ago.

Of course, this being bash, there are at least 3 ways of doing the same thing so I can also do

    link=`echo "A B C D" | cut  -d" " -f $i`

Will SUSv6 understand this?

Yes, it looks like it will. But you could have checked yourself.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 26.09.16 at 14:49, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.09.16 at 21:14, <[email protected]> wrote:

Changes in v6:
* Replaced script's printf in most case with "here document" (for multi-line text) or echo for single line. Left printf for formatted output. (Note that in one case paramter expansion is necessary and so delimiter word is intentionally not quoted).
* Replaced bash arrays with ${string:index:size} syntax.

Without having looked at the patch in full yet - is this any more portable than the previous approach? I can't see any mention of it in SUSv6 / SUSv7 either.

I can't say for sure but I remember seeing this construct long time ago.

Quoted 7 lines
Quoted 6 lines

Of course, this being bash, there are at least 3 ways of doing the same thing so I can also do

    link=`echo "A B C D" | cut  -d" " -f $i`

Will SUSv6 understand this?

Yes, it looks like it will. But you could have checked yourself.

Yes, I could. But somehow I thought you were referring to a SUSE product instead of the UNIX spec.

Anyway, I will hold off re-sending the patch with this fixed until you review the one I sent.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 26.09.16 at 15:43, <[email protected]> wrote:
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 26.09.16 at 14:49, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.09.16 at 21:14, <[email protected]> wrote:

Changes in v6:
* Replaced script's printf in most case with "here document" (for multi-line text) or echo for single line. Left printf for formatted output. (Note that in one case paramter expansion is necessary and so delimiter word is intentionally not quoted).
* Replaced bash arrays with ${string:index:size} syntax.

Without having looked at the patch in full yet - is this any more portable than the previous approach? I can't see any mention of it in SUSv6 / SUSv7 either.

I can't say for sure but I remember seeing this construct long time ago.

Of course, this being bash, there are at least 3 ways of doing the same thing so I can also do

    link=`echo "A B C D" | cut  -d" " -f $i`

Will SUSv6 understand this?

Quoted 8 lines
Quoted 1 line

Yes, it looks like it will. But you could have checked yourself.

Yes, I could. But somehow I thought you were referring to a SUSE product instead of the UNIX spec.

Anyway, I will hold off re-sending the patch with this fixed until you review the one I sent.

Oh, I've looked over it already, and it looks reasonable once the comments already given by others have got addressed.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw
In reply to Boris Ostrovsky

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh

Quoted 6 lines · Boris Ostrovsky
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +0 -0
new file mode 100755
index 0000000..28a0dd7
@@ -0,0 +1,116 @@

#!/bin/sh ?

Quoted 34 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +34 -0
+# This program is free software; you can redistribute it and/or modify it
+# under the terms and conditions of the GNU General Public License,
+# version 2, as published by the Free Software Foundation.
+#
+# This program is distributed in the hope it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; If not, see <http://www.gnu.org/licenses/>.
+#
+
+cat <<'EndOfASL'
+    /* Beginning of GPL-only code */
+
+    /* _S3 and _S4 are in separate SSDTs */
+    Name (\_S5, Package (0x04) {
+        0x00,  /* PM1a_CNT.SLP_TYP */
+        0x00,  /* PM1b_CNT.SLP_TYP */
+        0x00,  /* reserved */
+        0x00   /* reserved */
+    })
+    Name(PICD, 0)
+    Method(_PIC, 1) {
+        Store(Arg0, PICD)
+    }
+EndOfASL
+
+# PCI-ISA link definitions
+# BUFA: List of ISA IRQs available for linking to PCI INTx.
+# BUFB: IRQ descriptor for returning from link-device _CRS methods.
+cat <<'EndOfASL'
+    Scope ( \_SB.PCI0 )  {

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 44

Quoted 10 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +10 -0
+        Name ( BUFA, ResourceTemplate() { IRQ(Level, ActiveLow, Shared) { 5, 10, 11 } } )
+        Name ( BUFB, Buffer() { 0x23, 0x00, 0x00, 0x18, 0x79, 0 } )
+        CreateWordField ( BUFB, 0x01, IRQV )
+EndOfASL
+
+links="ABCD"
+
+for i in $(seq 0 3)
+do
+    link=${links:$i:1}

This is not portable.

Use following instead:

links="A B C D"

set $links
for link in $@
do
...
done

See http://pubs.opengroup.org/onlinepubs/009696799/utilities/set.html

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw

Wei Liu writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 9 lines · Boris Ostrovsky

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 44

Quoted 5 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +5 -0
+links="ABCD"
+
+for i in $(seq 0 3)
+do
+    link=${links:$i:1}

This is not portable.

Quoted 6 lines

Use following instead:

links="A B C D"

set $links
for link in $@

What's wrong with

links="A B C D"

for link in $links; do

    ....

?

(To my surprise I discover that there are only marginal dependencies on bash already in xen.git, so we should probably avoid adding a new dependency on bash.)

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
Quoted 17 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 9 lines · Boris Ostrovsky

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 44

Quoted 5 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +5 -0
+links="ABCD"
+
+for i in $(seq 0 3)
+do
+    link=${links:$i:1}

This is not portable.

Quoted 6 lines

Use following instead:

links="A B C D"

set $links
for link in $@

Quoted 8 lines

What's wrong with

links="A B C D"

for link in $links; do

    ....

?

Yes, I think this works, too.

I mistakenly thought that was bash-ism.

Quoted 5 lines

(To my surprise I discover that there are only marginal dependencies on bash already in xen.git, so we should probably avoid adding a new dependency on bash.)

Agreed.

Wei.

Quoted 1 line

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#9 lore raw
Quoted 16 lines · Wei Liu
Quoted 15 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 14 lines · Boris Ostrovsky

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 44

Quoted 5 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +5 -0
+links="ABCD"
+
+for i in $(seq 0 3)
+do
+    link=${links:$i:1}

This is not portable.

Use following instead:

links="A B C D"

set $links
for link in $@

Quoted 8 lines
Quoted 8 lines

What's wrong with

links="A B C D"

for link in $links; do

    ....

?

There are two interdependent variables that I need to print. The C equivalent is

    for ( i = 0; i < 4; i++ )
        printf("%d %c\n", i, 'A'+i);

The character value is derived from 'i', which in this example is an index into 'links' array.

I suggested in response to Jan

    link=`echo "A B C D" | cut -d" " -f $i`

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#10 lore raw
Quoted 32 lines · Boris Ostrovsky
Quoted 16 lines · Wei Liu
Quoted 15 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 14 lines · Boris Ostrovsky

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh line 44

Quoted 5 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +5 -0
+links="ABCD"
+
+for i in $(seq 0 3)
+do
+    link=${links:$i:1}

This is not portable.

Use following instead:

links="A B C D"

set $links
for link in $@

Quoted 8 lines
Quoted 8 lines

What's wrong with

links="A B C D"

for link in $links; do

    ....

?

There are two interdependent variables that I need to print. The C equivalent is

    for ( i = 0; i < 4; i++ )
        printf("%d %c\n", i, 'A'+i);
Quoted 7 lines

The character value is derived from 'i', which in this example is an index into 'links' array.

I suggested in response to Jan

    link=`echo "A B C D" | cut -d" " -f $i`

Oh, two variables. Then you could also do:

link=echo $i | tr "1234" "ABCD"

(cut and tr are both from coreutils, so I think we're fine with using either of them)

Anyway, enough of discussion about shell script. Pick the method you like. :-)

Wei.

Quoted 4 lines

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw
In reply to Boris Ostrovsky

Boris Ostrovsky writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 6 lines

There are two interdependent variables that I need to print. The C equivalent is

    for ( i = 0; i < 4; i++ )
        printf("%d %c\n", i, 'A'+i);
Quoted 6 lines

The character value is derived from 'i', which in this example is an index into 'links' array.

I suggested in response to Jan

    link=`echo "A B C D" | cut -d" " -f $i`

If the indices are necessarily successive integers:

  links="A B C D"
  index=0
  for link in $links; do
    index=$(( $index + 1 ))
    something with $link and $index

If the indices are arbitrary:

  links="1:A 4:B 7:C 10:D"
  for linkinfo in $links; do
    link=${linkinfo#*:}
    index=${linkinfo%%:*}
    something with $link and $index

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw
Quoted 21 lines · Ian Jackson

Boris Ostrovsky writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 6 lines

There are two interdependent variables that I need to print. The C equivalent is

    for ( i = 0; i < 4; i++ )
        printf("%d %c\n", i, 'A'+i);
Quoted 6 lines

The character value is derived from 'i', which in this example is an index into 'links' array.

I suggested in response to Jan

    link=`echo "A B C D" | cut -d" " -f $i`

If the indices are necessarily successive integers:

  links="A B C D"
  index=0
  for link in $links; do
    index=$(( $index + 1 ))
    something with $link and $index
Quoted 7 lines

If the indices are arbitrary:

  links="1:A 4:B 7:C 10:D"
  for linkinfo in $links; do
    link=${linkinfo#*:}
    index=${linkinfo%%:*}
    something with $link and $index

The indices are not successive, in one case they are a function of two enclosing loop indices, such as
for dev in $(seq 1 31)
do

    for intx in $(seq 0 3)
    do
    link_idx=$(((dev + intx) & 3))
    printf "            Package(){0x%04xffff, %u, \\\\_SB.PCI0.LNK%c,
0},\n" \
        $dev $intx ${links:$link_idx:1}
    done

done

(And then there might also be a question of portability with the second approach?)

So if you don't object to

    link=`echo "A B C D" | cut -d" " -f $i`

I'd rather go with that.

(I'll add '#!/bin/sh' as you requested in another email)

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw

Boris Ostrovsky writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 18 lines · Ian Jackson
Quoted 8 lines

If the indices are necessarily successive integers:

  links="A B C D"
  index=0
  for link in $links; do
    index=$(( $index + 1 ))
    something with $link and $index
Quoted 7 lines

If the indices are arbitrary:

  links="1:A 4:B 7:C 10:D"
  for linkinfo in $links; do
    link=${linkinfo#*:}
    index=${linkinfo%%:*}
    something with $link and $index
Quoted 2 lines

The indices are not successive, in one case they are a function of two enclosing loop indices, such as

By indices' I meant the things which in your code are 1 2 3 4. Apparently there is a different thing called an idx'.

Your code below suggests that the numbers you need for each A B C D are indeed successive integers.

Quoted 11 lines

for dev in $(seq 1 31)
do

    for intx in $(seq 0 3)
    do
    link_idx=$(((dev + intx) & 3))
    printf "            Package(){0x%04xffff, %u, \\\\_SB.PCI0.LNK%c,
0},\n" \
        $dev $intx ${links:$link_idx:1}
    done

done

Quoted 8 lines

(And then there might also be a question of portability with the second approach?)

So if you don't object to

    link=`echo "A B C D" | cut -d" " -f $i`

I'd rather go with that.

I would still prefer

   links="A B C D"
   linkcounter=0
   for link in $links
   do
       linkcounter=$(( $linkcounter + 1))
       link_idx=$(( ($dev + $linkcounter) & 3 ))

I think this is a lot easier to read than messing about with seq and string slicing.

NB that the spaces inside the $(( )) are IMO essential for readability.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#14 lore raw
Quoted 45 lines · Ian Jackson

Boris Ostrovsky writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 11 lines · Ian Jackson
Quoted 10 lines

If the indices are necessarily successive integers:

  links="A B C D"
  index=0
  for link in $links; do
    index=$(( $index + 1 ))
    something with $link and $index

If the indices are arbitrary:

Quoted 8 lines
Quoted 5 lines
  links="1:A 4:B 7:C 10:D"
  for linkinfo in $links; do
    link=${linkinfo#*:}
    index=${linkinfo%%:*}
    something with $link and $index

The indices are not successive, in one case they are a function of two enclosing loop indices, such as

By indices' I meant the things which in your code are 1 2 3 4. Apparently there is a different thing called an idx'.

Your code below suggests that the numbers you need for each A B C D are indeed successive integers.

Quoted 11 lines

for dev in $(seq 1 31)
do

    for intx in $(seq 0 3)
    do
    link_idx=$(((dev + intx) & 3))
    printf "            Package(){0x%04xffff, %u, \\\\_SB.PCI0.LNK%c,
0},\n" \
        $dev $intx ${links:$link_idx:1}
    done

done

Quoted 8 lines

(And then there might also be a question of portability with the second approach?)

So if you don't object to

    link=`echo "A B C D" | cut -d" " -f $i`

I'd rather go with that.

Quoted 9 lines

I would still prefer

   links="A B C D"
   linkcounter=0
   for link in $links
   do
       linkcounter=$(( $linkcounter + 1))
       link_idx=$(( ($dev + $linkcounter) & 3 ))

This will not produce what I am trying to print tough. I want this sequence:

B C D A C D A B D A B C A

I can reverse loop order (I believe that even though resulting ASL will be different, the AML binary that iasl produces will stay the same) but then I think I will also need to reverse the dev loop direction.

Or I am just not understanding what you are suggesting.

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw

Boris Ostrovsky writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 2 lines

This will not produce what I am trying to print tough. I want this sequence:
B C D A C D A B D A B C A

I went back to your patch and AFAICT it doesn't generate that sequence. But:

I think this conversation has turned into a ridiculous bikeshed argument, for which I apologise. The code in your patch is acceptable from a portability and style pov and I don't think we should spend any more time trying to make it prettier.

Regards,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#16 lore raw
In reply to Wei Liu
Quoted 8 lines · Wei Liu

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh

Quoted 6 lines · Boris Ostrovsky
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +0 -0
new file mode 100755
index 0000000..28a0dd7
@@ -0,0 +1,116 @@

#!/bin/sh ?

(Just noticed this comment)

I don't think this is needed since it's invoked by the Makefile as

    $(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#17 lore raw
Quoted 10 lines · Boris Ostrovsky
Quoted 8 lines · Wei Liu

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh

Quoted 6 lines · Boris Ostrovsky
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +0 -0
new file mode 100755
index 0000000..28a0dd7
@@ -0,0 +1,116 @@

#!/bin/sh ?

Quoted 6 lines

(Just noticed this comment)

I don't think this is needed since it's invoked by the Makefile as

    $(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)

Fair enough.

I don't think this is large enough an issue to block this patch. Please resend this patch and provide a branch on top of staging.

Wei.

Quoted 4 lines

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#18 lore raw
In reply to Boris Ostrovsky

Boris Ostrovsky writes ("Re: [PATCH v6] acpi: Prevent GPL-only code from seeping into non-GPL binaries"):

Quoted 10 lines · Wei Liu
Quoted 8 lines · Boris Ostrovsky

tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh

Quoted 6 lines
tools/firmware/hvmloader/acpi/gpl/mk_dsdt_gpl.sh new file +0 -0
new file mode 100755
index 0000000..28a0dd7
@@ -0,0 +1,116 @@

#!/bin/sh ?

Quoted 5 lines

(Just noticed this comment)

I don't think this is needed since it's invoked by the Makefile as

    $(SHELL) gpl/mk_dsdt_gpl.sh >> $@.$(TMP_SUFFIX)

The script should be runnable from the command line without saying "sh" or soemthing. So it should have a #! line and be executable.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel