Skip to contentSkip to conversation

arm64: KVM: regmap: Mark expected switch fall-through

PATCH In review Anders Roxell 3 participants 4 messages Jul 26, 2019

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

PATCH 1/2 arm64: KVM: regmap: Mark expected switch fall-through

When fall-through warnings was enabled by default, commit d93512ef0f0e ("Makefile: Globally enable fall-through warning"), the following warnings was starting to show up:

In file included from ../arch/arm64/include/asm/kvm_emulate.h:19,

                 from ../arch/arm64/kvm/regmap.c:13:

../arch/arm64/kvm/regmap.c: In function ‘vcpu_write_spsr32’:
../arch/arm64/include/asm/kvm_hyp.h:31:3: warning: this statement may fall
through [-Wimplicit-fallthrough=]
asm volatile(ALTERNATIVE(__msr_s(r##nvh, "%x0"), \
^~~
../arch/arm64/include/asm/kvm_hyp.h:46:31: note: in expansion of macro ‘write_sysreg_elx’

 #define write_sysreg_el1(v,r) write_sysreg_elx(v, r, _EL1, _EL12)
                               ^~~~~~~~~~~~~~~~

../arch/arm64/kvm/regmap.c:180:3: note: in expansion of macro ‘write_sysreg_el1’
write_sysreg_el1(v, SYS_SPSR);
^~~~~~~~~~~~~~~~
../arch/arm64/kvm/regmap.c:181:2: note: here
case KVM_SPSR_ABT:
^~~~
In file included from ../arch/arm64/include/asm/cputype.h:132,

                 from ../arch/arm64/include/asm/cache.h:8,
                 from ../include/linux/cache.h:6,
                 from ../include/linux/printk.h:9,
                 from ../include/linux/kernel.h:15,
                 from ../include/asm-generic/bug.h:18,
                 from ../arch/arm64/include/asm/bug.h:26,
                 from ../include/linux/bug.h:5,
                 from ../include/linux/mmdebug.h:5,
                 from ../include/linux/mm.h:9,
                 from ../arch/arm64/kvm/regmap.c:11:

../arch/arm64/include/asm/sysreg.h:837:2: warning: this statement may fall
through [-Wimplicit-fallthrough=]
asm volatile("msr " __stringify(r) ", %x0" \
^~~
../arch/arm64/kvm/regmap.c:182:3: note: in expansion of macro ‘write_sysreg’
write_sysreg(v, spsr_abt);
^~~~~~~~~~~~
../arch/arm64/kvm/regmap.c:183:2: note: here
case KVM_SPSR_UND:
^~~~

Rework to add a 'break;' in the swich-case since it didn't have that. That also made the compiler happy and didn't warn about fall-through.

Cc [email protected] # v3.16+
Fixes a892819560c4 ("KVM: arm64: Prepare to handle deferred save/restore of 32-bit registers")
---
 arch/arm64/kvm/regmap.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/kvm/regmap.c +5 -0
index 0d60e4f0af66..a900181e3867 100644
@@ -178,13 +178,18 @@ void vcpu_write_spsr32(struct kvm_vcpu *vcpu, unsigned long v)
 	switch (spsr_idx) {
 	case KVM_SPSR_SVC:
 		write_sysreg_el1(v, SYS_SPSR);
+		break;
 	case KVM_SPSR_ABT:
 		write_sysreg(v, spsr_abt);
+		break;
 	case KVM_SPSR_UND:
 		write_sysreg(v, spsr_und);
+		break;
 	case KVM_SPSR_IRQ:
 		write_sysreg(v, spsr_irq);
+		break;
 	case KVM_SPSR_FIQ:
 		write_sysreg(v, spsr_fiq);
+		break;
 	}
 }
Signature · 1 line
2.20.1
#1 lore raw

Hi Anders,

Quoted 39 lines · Anders Roxell

When fall-through warnings was enabled by default, commit d93512ef0f0e ("Makefile: Globally enable fall-through warning"), the following warnings was starting to show up:

In file included from ../arch/arm64/include/asm/kvm_emulate.h:19,

                 from ../arch/arm64/kvm/regmap.c:13:
../arch/arm64/kvm/regmap.c: In function ‘vcpu_write_spsr32’:
../arch/arm64/include/asm/kvm_hyp.h:31:3: warning: this statement may fall
 through [-Wimplicit-fallthrough=]
   asm volatile(ALTERNATIVE(__msr_s(r##nvh, "%x0"), \
   ^~~
../arch/arm64/include/asm/kvm_hyp.h:46:31: note: in expansion of macro ‘write_sysreg_elx’
 #define write_sysreg_el1(v,r) write_sysreg_elx(v, r, _EL1, _EL12)
                               ^~~~~~~~~~~~~~~~
../arch/arm64/kvm/regmap.c:180:3: note: in expansion of macro ‘write_sysreg_el1’
   write_sysreg_el1(v, SYS_SPSR);
   ^~~~~~~~~~~~~~~~

../arch/arm64/kvm/regmap.c:181:2: note: here
case KVM_SPSR_ABT:
^~~~
In file included from ../arch/arm64/include/asm/cputype.h:132,

                 from ../arch/arm64/include/asm/cache.h:8,
                 from ../include/linux/cache.h:6,
                 from ../include/linux/printk.h:9,
                 from ../include/linux/kernel.h:15,
                 from ../include/asm-generic/bug.h:18,
                 from ../arch/arm64/include/asm/bug.h:26,
                 from ../include/linux/bug.h:5,
                 from ../include/linux/mmdebug.h:5,
                 from ../include/linux/mm.h:9,
                 from ../arch/arm64/kvm/regmap.c:11:

../arch/arm64/include/asm/sysreg.h:837:2: warning: this statement may fall
through [-Wimplicit-fallthrough=]
asm volatile("msr " __stringify(r) ", %x0" \
^~~
../arch/arm64/kvm/regmap.c:182:3: note: in expansion of macro ‘write_sysreg’

   write_sysreg(v, spsr_abt);
   ^~~~~~~~~~~~
Quoted 8 lines

../arch/arm64/kvm/regmap.c:183:2: note: here
case KVM_SPSR_UND:
^~~~

Rework to add a 'break;' in the swich-case since it didn't have that. That also made the compiler happy and didn't warn about fall-through.

Cc [email protected] # v3.16+

Erm... Are you sure about that? Here's what I have:

$ git describe --contains  a892819560c4
kvm-arm-for-v4.17~44
$ git describe --contains --match='v*' a892819560c4
v4.17-rc1~72^2~36^2~44
Quoted 19 lines
Fixes a892819560c4 ("KVM: arm64: Prepare to handle deferred save/restore of 32-bit registers")
---
 arch/arm64/kvm/regmap.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/kvm/regmap.c +2 -0
index 0d60e4f0af66..a900181e3867 100644
@@ -178,13 +178,18 @@ void vcpu_write_spsr32(struct kvm_vcpu *vcpu, unsigned long v)
 	switch (spsr_idx) {
 	case KVM_SPSR_SVC:
 		write_sysreg_el1(v, SYS_SPSR);
+		break;
 	case KVM_SPSR_ABT:
 		write_sysreg(v, spsr_abt);
+		break;
 	case KVM_SPSR_UND:

arch/arm64/kvm/regmap.c void vcpu_write_spsr32(struct kvm_vcpu *vcpu, unsigned long v) · line 195

Quoted 10 lines
arch/arm64/kvm/regmap.c +3 -0
 		write_sysreg(v, spsr_und);
+		break;
 	case KVM_SPSR_IRQ:
 		write_sysreg(v, spsr_irq);
+		break;
 	case KVM_SPSR_FIQ:
 		write_sysreg(v, spsr_fiq);
+		break;
 	}
 }

Otherwise looks like the right fix to me. Let me know what you think about the Fixes: tag (no need to resend for that).

Thanks,

	M.
Signature · 1 line
Jazz is not dead, it just smells funny.
#2 lore raw
Quoted 48 lines · Marc Zyngier

Hi Anders,

Quoted 43 lines · Anders Roxell

When fall-through warnings was enabled by default, commit d93512ef0f0e ("Makefile: Globally enable fall-through warning"), the following warnings was starting to show up:

In file included from ../arch/arm64/include/asm/kvm_emulate.h:19,

                 from ../arch/arm64/kvm/regmap.c:13:
../arch/arm64/kvm/regmap.c: In function ‘vcpu_write_spsr32’:
../arch/arm64/include/asm/kvm_hyp.h:31:3: warning: this statement may fall
 through [-Wimplicit-fallthrough=]
   asm volatile(ALTERNATIVE(__msr_s(r##nvh, "%x0"), \
   ^~~
../arch/arm64/include/asm/kvm_hyp.h:46:31: note: in expansion of macro ‘write_sysreg_elx’
 #define write_sysreg_el1(v,r) write_sysreg_elx(v, r, _EL1, _EL12)
                               ^~~~~~~~~~~~~~~~
../arch/arm64/kvm/regmap.c:180:3: note: in expansion of macro ‘write_sysreg_el1’
   write_sysreg_el1(v, SYS_SPSR);
   ^~~~~~~~~~~~~~~~

../arch/arm64/kvm/regmap.c:181:2: note: here
case KVM_SPSR_ABT:
^~~~
In file included from ../arch/arm64/include/asm/cputype.h:132,

                 from ../arch/arm64/include/asm/cache.h:8,
                 from ../include/linux/cache.h:6,
                 from ../include/linux/printk.h:9,
                 from ../include/linux/kernel.h:15,
                 from ../include/asm-generic/bug.h:18,
                 from ../arch/arm64/include/asm/bug.h:26,
                 from ../include/linux/bug.h:5,
                 from ../include/linux/mmdebug.h:5,
                 from ../include/linux/mm.h:9,
                 from ../arch/arm64/kvm/regmap.c:11:

../arch/arm64/include/asm/sysreg.h:837:2: warning: this statement may fall
through [-Wimplicit-fallthrough=]
asm volatile("msr " __stringify(r) ", %x0" \
^~~
../arch/arm64/kvm/regmap.c:182:3: note: in expansion of macro ‘write_sysreg’

   write_sysreg(v, spsr_abt);
   ^~~~~~~~~~~~

../arch/arm64/kvm/regmap.c:183:2: note: here
case KVM_SPSR_UND:
^~~~

Quoted 6 lines
Quoted 4 lines

Rework to add a 'break;' in the swich-case since it didn't have that. That also made the compiler happy and didn't warn about fall-through.

Cc [email protected] # v3.16+

Erm... Are you sure about that?

I made two mistakes.
1. saying 3.x instead of 4.x
2. I said the same kernel that 'git describe' showed and not the later one.

I did not know about '--match='.

Quoted 6 lines

Here's what I have:

$ git describe --contains  a892819560c4
kvm-arm-for-v4.17~44
$ git describe --contains --match='v*' a892819560c4
v4.17-rc1~72^2~36^2~44

That's correct.

Quoted 26 lines
Quoted 26 lines
Fixes a892819560c4 ("KVM: arm64: Prepare to handle deferred save/restore of 32-bit registers")
---
 arch/arm64/kvm/regmap.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/kvm/regmap.c +4 -0
index 0d60e4f0af66..a900181e3867 100644
@@ -178,13 +178,18 @@ void vcpu_write_spsr32(struct kvm_vcpu *vcpu, unsigned long v)
      switch (spsr_idx) {
      case KVM_SPSR_SVC:
              write_sysreg_el1(v, SYS_SPSR);
+             break;
      case KVM_SPSR_ABT:
              write_sysreg(v, spsr_abt);
+             break;
      case KVM_SPSR_UND:
              write_sysreg(v, spsr_und);
+             break;
      case KVM_SPSR_IRQ:
              write_sysreg(v, spsr_irq);
+             break;
Quoted 8 lines

arch/arm64/kvm/regmap.c void vcpu_write_spsr32(struct kvm_vcpu *vcpu, unsigned long v) · line 195

Quoted 5 lines
arch/arm64/kvm/regmap.c +1 -0
      case KVM_SPSR_FIQ:
              write_sysreg(v, spsr_fiq);
+             break;
      }
 }

Otherwise looks like the right fix to me. Let me know what you think about the Fixes: tag (no need to resend for that).

It should be v4.17+.

Cheers,
Anders

maintainer
#3 lore raw
In reply to Anders Roxell

Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: a892819560c4 KVM: arm64: Prepare to handle deferred save/restore of 32-bit registers.

The bot has tested the following trees: v5.2.2, v5.1.19, v4.19.60.

v5.2.2: Failed to apply! Possible dependencies:
fdec2a9ef853 ("KVM: arm64: Migrate _elx sysreg accessors to msr_s/mrs_s")

v5.1.19: Failed to apply! Possible dependencies:
73433762fcae ("KVM: arm64/sve: System register context switch and access support") be604c616ca7 ("arm64: sysreg: Make mrs_s and msr_s macros work with Clang and LTO") fdec2a9ef853 ("KVM: arm64: Migrate _elx sysreg accessors to msr_s/mrs_s")

v4.19.60: Failed to apply! Possible dependencies:
84135d3d18da ("KVM: arm/arm64: consolidate arch timer trap handlers") 8a411b060f82 ("KVM: arm/arm64: Remove arch timer workqueue")
9e01dc76be6a ("KVM: arm/arm64: arch_timer: Assign the phys timer on VHE systems") accb99bcd0ca ("KVM: arm/arm64: Simplify bg_timer programming") bd7d95cafb49 ("arm64: KVM: Consistently advance singlestep when emulating instructions") e604dd5d45c7 ("KVM: arm/arm64: timer: Rework data structures for multiple timers") fdec2a9ef853 ("KVM: arm64: Migrate _elx sysreg accessors to msr_s/mrs_s")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

--
Thanks,
Sasha
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm