Skip to contentSkip to conversation

selftests: kvm: remove reassignment of non-absolute variables

PATCH Superseded Bill Wendling 4 participants 10 messages Dec 10, 2020 – May 4, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: kvm: remove reassignment of non-absolute variables

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
index aaf7bc7d2ce1..3f9181e9a0a7 100644
@@ -54,9 +54,9 @@ idt_handlers:
 	.align 8
 
 	/* Fetch current address and append it to idt_handlers. */
-	current_handler = .
+0 :
 .pushsection .rodata
-.quad current_handler
+	.quad 0b
 .popsection
 
 	.if ! \has_error
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
#1 lore raw
Quoted 16 lines · Bill Wendling

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -0
index aaf7bc7d2ce1..3f9181e9a0a7 100644

tools/testing/selftests/kvm/lib/x86_64/handlers.S idt_handlers: · line 59

Quoted 8 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
@@ -54,9 +54,9 @@ idt_handlers:
 	.align 8
 
 	/* Fetch current address and append it to idt_handlers. */
-	current_handler = .
+0 :
 .pushsection .rodata
-.quad current_handler
+	.quad 0b

Bit of a silly nit: can we use a named label, or at least a non-zero shorthand? It's really easy to misread "0b" as zeroing out the value, at least for me.

Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -0
 .popsection
 
 	.if ! \has_error
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
#2 lore raw
Quoted 20 lines · Sean Christopherson
Quoted 18 lines · Bill Wendling

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -0
index aaf7bc7d2ce1..3f9181e9a0a7 100644
@@ -54,9 +54,9 @@ idt_handlers:
      .align 8
 
Quoted 10 lines

tools/testing/selftests/kvm/lib/x86_64/handlers.S idt_handlers: · line 59

Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
      /* Fetch current address and append it to idt_handlers. */
-     current_handler = .
+0 :
 .pushsection .rodata
-.quad current_handler
+     .quad 0b

Bit of a silly nit: can we use a named label, or at least a non-zero shorthand? It's really easy to misread "0b" as zeroing out the value, at least for me.

I don't believe that will work. If I rename "0 :" to something more concrete, like ".Lcurrent :", then the label's redefined because of the ".rept". If I assign the "0b" to something, we're back with the unmodified code, which clang issues an error for:

<instantiation>:3500:6: error: invalid reassignment of non-absolute variable 'x'
x = 0b

     ^

<instantiation>:2:2: note: while in macro instantiation
.rept 255 - 18 + 1
^

Quoted 6 lines
Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -1
 .popsection
 
      .if ! \has_error
--

2.29.2.576.ga3fc446d84-goog

#3 lore raw
Quoted 36 lines · Bill Wendling
Quoted 20 lines · Sean Christopherson
Quoted 18 lines · Bill Wendling

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -0
index aaf7bc7d2ce1..3f9181e9a0a7 100644
@@ -54,9 +54,9 @@ idt_handlers:
      .align 8
 
Quoted 10 lines

tools/testing/selftests/kvm/lib/x86_64/handlers.S idt_handlers: · line 59

Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
      /* Fetch current address and append it to idt_handlers. */
-     current_handler = .
+0 :
 .pushsection .rodata
-.quad current_handler
+     .quad 0b

Bit of a silly nit: can we use a named label, or at least a non-zero shorthand? It's really easy to misread "0b" as zeroing out the value, at least for me.

I don't believe that will work. If I rename "0 :" to something more concrete, like ".Lcurrent :", then the label's redefined because of the ".rept". If I assign the "0b" to something, we're back with the unmodified code, which clang issues an error for:

Quoted 5 lines

<instantiation>:3500:6: error: invalid reassignment of non-absolute variable 'x'
x = 0b

     ^

<instantiation>:2:2: note: while in macro instantiation
.rept 255 - 18 + 1

Boo. I assume 1: and 1b work? Or my KVM favorite "666:" :-) That's enough to at least make me pause and actually read the code.

Quoted 8 lines

^

Quoted 6 lines
Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -1
 .popsection
 
      .if ! \has_error
--

2.29.2.576.ga3fc446d84-goog

#4 lore raw
Quoted 36 lines · Sean Christopherson
Quoted 35 lines · Bill Wendling
Quoted 19 lines · Sean Christopherson
Quoted 18 lines · Bill Wendling

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -0
index aaf7bc7d2ce1..3f9181e9a0a7 100644
@@ -54,9 +54,9 @@ idt_handlers:
      .align 8
 
Quoted 10 lines

tools/testing/selftests/kvm/lib/x86_64/handlers.S idt_handlers: · line 59

Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
      /* Fetch current address and append it to idt_handlers. */
-     current_handler = .
+0 :
 .pushsection .rodata
-.quad current_handler
+     .quad 0b

Bit of a silly nit: can we use a named label, or at least a non-zero shorthand? It's really easy to misread "0b" as zeroing out the value, at least for me.

I don't believe that will work. If I rename "0 :" to something more concrete, like ".Lcurrent :", then the label's redefined because of the ".rept". If I assign the "0b" to something, we're back with the unmodified code, which clang issues an error for:

Quoted 9 lines
Quoted 5 lines

<instantiation>:3500:6: error: invalid reassignment of non-absolute variable 'x'
x = 0b

     ^

<instantiation>:2:2: note: while in macro instantiation
.rept 255 - 18 + 1

Boo. I assume 1: and 1b work? Or my KVM favorite "666:" :-) That's enough to at least make me pause and actually read the code.

Ah! I missed the second part of your message (about the non-zero shorthand). That should work. Sorry about that. :-) Should I submit a new version of this patch?

-bw

#5 lore raw
Quoted 43 lines · Bill Wendling
Quoted 42 lines · Sean Christopherson
Quoted 40 lines · Bill Wendling
Quoted 19 lines · Sean Christopherson
Quoted 18 lines · Bill Wendling

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -0
index aaf7bc7d2ce1..3f9181e9a0a7 100644
@@ -54,9 +54,9 @@ idt_handlers:
      .align 8
 
Quoted 10 lines

tools/testing/selftests/kvm/lib/x86_64/handlers.S idt_handlers: · line 59

Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
      /* Fetch current address and append it to idt_handlers. */
-     current_handler = .
+0 :
 .pushsection .rodata
-.quad current_handler
+     .quad 0b

Bit of a silly nit: can we use a named label, or at least a non-zero shorthand? It's really easy to misread "0b" as zeroing out the value, at least for me.

I don't believe that will work. If I rename "0 :" to something more concrete, like ".Lcurrent :", then the label's redefined because of the ".rept". If I assign the "0b" to something, we're back with the unmodified code, which clang issues an error for:

<instantiation>:3500:6: error: invalid reassignment of non-absolute variable 'x'
x = 0b

     ^

<instantiation>:2:2: note: while in macro instantiation
.rept 255 - 18 + 1

Quoted 6 lines
Quoted 3 lines

Boo. I assume 1: and 1b work? Or my KVM favorite "666:" :-) That's enough to at least make me pause and actually read the code.

Ah! I missed the second part of your message (about the non-zero shorthand). That should work. Sorry about that. :-) Should I submit a new version of this patch?

That'd probably be easiest. This is trivial enought to fixup when applying, but we might as well save a few of Paolo's cycles for other things.

Thanks!

#6 lore raw

PATCH v2 1/1 selftests: kvm: remove reassignment of non-absolute variables

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
index aaf7bc7d2ce1..7629819734af 100644
@@ -54,9 +54,9 @@ idt_handlers:
 	.align 8
 
 	/* Fetch current address and append it to idt_handlers. */
-	current_handler = .
+666 :
 .pushsection .rodata
-.quad current_handler
+	.quad 666b
 .popsection
 
 	.if ! \has_error
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
maintainer Applied
#8 lore raw
Quoted 11 lines · Jim Mattson
Quoted 8 lines · Bill Wendling

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

Queued, thanks.

Paolo

#9 lore raw
In reply to Bill Wendling

By non-zero, I think Sean means something like:

666:
.pushsection .rodata
.quad 666b

Quoted 50 lines · Bill Wendling
Quoted 20 lines · Sean Christopherson
Quoted 18 lines · Bill Wendling

Clang's integrated assembler does not allow symbols with non-absolute values to be reassigned. Modify the interrupt entry loop macro to be compatible with IAS by using a label and an offset.

References: https://lore.kernel.org/lkml/[email protected]/

---
 tools/testing/selftests/kvm/lib/x86_64/handlers.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -0
index aaf7bc7d2ce1..3f9181e9a0a7 100644
@@ -54,9 +54,9 @@ idt_handlers:
      .align 8
 
Quoted 10 lines

tools/testing/selftests/kvm/lib/x86_64/handlers.S idt_handlers: · line 59

Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +2 -2
      /* Fetch current address and append it to idt_handlers. */
-     current_handler = .
+0 :
 .pushsection .rodata
-.quad current_handler
+     .quad 0b

Bit of a silly nit: can we use a named label, or at least a non-zero shorthand? It's really easy to misread "0b" as zeroing out the value, at least for me.

I don't believe that will work. If I rename "0 :" to something more concrete, like ".Lcurrent :", then the label's redefined because of the ".rept". If I assign the "0b" to something, we're back with the unmodified code, which clang issues an error for:

<instantiation>:3500:6: error: invalid reassignment of non-absolute variable 'x'
x = 0b

     ^

<instantiation>:2:2: note: while in macro instantiation
.rept 255 - 18 + 1
^

Quoted 6 lines
Quoted 6 lines
tools/testing/selftests/kvm/lib/x86_64/handlers.S +0 -1
 .popsection
 
      .if ! \has_error
--

2.29.2.576.ga3fc446d84-goog