Skip to contentSkip to conversation

spapr: add missing break in h_get_cpu_characteristics()

PATCH Applied Greg Kurz 4 participants 6 messages Feb 1, 2018 – Feb 8, 2018

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 spapr: add missing break in h_get_cpu_characteristics()

Detected by Coverity (CID 1385702). This fixes the recently added hypercall to let guests properly apply Spectre and Meltdown workarounds.

Fixes c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"
---
 hw/ppc/spapr_hcall.c |    1 +
 1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 4d0e6eb0cf1d..596f58378a40 100644
@@ -1697,6 +1697,7 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
     switch (safe_indirect_branch) {
     case SPAPR_CAP_FIXED:
         characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+        break;
     default: /* broken */
         assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
         break;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Greg Kurz

Detected by Coverity (CID 1385702). This fixes the recently added hypercall
to let guests properly apply Spectre and Meltdown workarounds.

Fixes c59704b25473 "target/ppc/spapr: Add H-Call

H_GET_CPU_CHARACTERISTICS"

Quoted 18 lines
---
 hw/ppc/spapr_hcall.c |    1 +
 1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 4d0e6eb0cf1d..596f58378a40 100644
@@ -1697,6 +1697,7 @@ static target_ulong
 h_get_cpu_characteristics(PowerPCCPU *cpu,
     switch (safe_indirect_branch) {
     case SPAPR_CAP_FIXED:
         characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+        break;
     default: /* broken */
         assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
         break;
#2 lore raw
In reply to Greg Kurz
Quoted 2 lines · Greg Kurz

Detected by Coverity (CID 1385702). This fixes the recently added hypercall to let guests properly apply Spectre and Meltdown workarounds.

Paolo Bonzini reported this error in a reply to the pull request that added the patch:

"Re: [Qemu-ppc] [Qemu-devel] [PULL 12/12] target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS

Review

Quoted 3 lines · David Gibson
(quoted diff) +3 -0
+    switch (safe_indirect_branch) {
+    case SPAPR_CAP_FIXED:
+        characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;

Missing "break;" here.

Paolo

"

I think it is nice to mention in the commit msg that Paolo also detected this same error, specially given that his email was sent before this patch.

Thanks,

Daniel

Quoted 21 lines
Fixes c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"
---
  hw/ppc/spapr_hcall.c |    1 +
  1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 4d0e6eb0cf1d..596f58378a40 100644
@@ -1697,6 +1697,7 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
      switch (safe_indirect_branch) {
      case SPAPR_CAP_FIXED:
          characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+        break;
      default: /* broken */
          assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
          break;
author
#3 lore raw
Quoted 18 lines · On Fri, 2 Feb 2018 07:11:08 -0200 Daniel Henrique Barboza…
Quoted 2 lines · Greg Kurz

Detected by Coverity (CID 1385702). This fixes the recently added hypercall to let guests properly apply Spectre and Meltdown workarounds.

Paolo Bonzini reported this error in a reply to the pull request that added the patch:

"Re: [Qemu-ppc] [Qemu-devel] [PULL 12/12] target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS

Review

Quoted 3 lines · David Gibson
(quoted diff) +3 -0
+    switch (safe_indirect_branch) {
+    case SPAPR_CAP_FIXED:
+        characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;  

Missing "break;" here.

Quoted 8 lines

Paolo

"

I think it is nice to mention in the commit msg that Paolo also detected this same error,
specially given that his email was sent before this patch.

Heh, Paolo's mail landed in the pull req thread in my mail client and I saw it after sending the patch :P ... also I'm pretty sure Paolo was made aware of this issue by Coverity, just as I was :)

From: [email protected]
To: [email protected]
Subject: New Defects reported by Coverity Scan for QEMU
Date: Thu, 01 Feb 2018 18:11:33 +0000 (UTC)

Hi,

Please find the latest report on new defect(s) introduced to QEMU found with Coverity Scan.

...

*** CID 1385702: Control flow issues (MISSING_BREAK) /hw/ppc/spapr_hcall.c: 1700 in h_get_cpu_characteristics()
1694 break;
1695 }
1696
1697 switch (safe_indirect_branch) {
1698 case SPAPR_CAP_FIXED:
1699 characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1385702: Control flow issues (MISSING_BREAK) The above case falls through to this one.

1700 default: /* broken */
1701 assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
1702 break;
1703 }
1704
1705 args[0] = characteristics;

No big deal I guess :)

Quoted 29 lines

Thanks,

Daniel

Quoted 21 lines
Fixes c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"
---
  hw/ppc/spapr_hcall.c |    1 +
  1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 4d0e6eb0cf1d..596f58378a40 100644
@@ -1697,6 +1697,7 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
      switch (safe_indirect_branch) {
      case SPAPR_CAP_FIXED:
          characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+        break;
      default: /* broken */
          assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
          break;
#4 lore raw
Quoted 61 lines · Greg Kurz
Quoted 16 lines · On Fri, 2 Feb 2018 07:11:08 -0200 Daniel Henrique Barboza…
Quoted 2 lines · Greg Kurz

Detected by Coverity (CID 1385702). This fixes the recently added hypercall to let guests properly apply Spectre and Meltdown workarounds.

Paolo Bonzini reported this error in a reply to the pull request that added the patch:

"Re: [Qemu-ppc] [Qemu-devel] [PULL 12/12] target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS

Review

Quoted 3 lines · David Gibson
(quoted diff) +3 -0
+    switch (safe_indirect_branch) {
+    case SPAPR_CAP_FIXED:
+        characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;

Missing "break;" here.

Quoted 8 lines

Paolo

"

I think it is nice to mention in the commit msg that Paolo also detected this same error,
specially given that his email was sent before this patch.

Heh, Paolo's mail landed in the pull req thread in my mail client and I saw it after sending the patch :P ... also I'm pretty sure Paolo was made aware of this issue by Coverity, just as I was :)

From: [email protected]
To: [email protected]
Subject: New Defects reported by Coverity Scan for QEMU
Date: Thu, 01 Feb 2018 18:11:33 +0000 (UTC)

Hi,

Please find the latest report on new defect(s) introduced to QEMU found with Coverity Scan.

...

*** CID 1385702: Control flow issues (MISSING_BREAK) /hw/ppc/spapr_hcall.c: 1700 in h_get_cpu_characteristics()
1694 break;
1695 }
1696
1697 switch (safe_indirect_branch) {
1698 case SPAPR_CAP_FIXED:
1699 characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1385702: Control flow issues (MISSING_BREAK) The above case falls through to this one.

1700 default: /* broken */
1701 assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
1702 break;
1703 }
1704
1705 args[0] = characteristics;

Quoted 1 line

No big deal I guess :)

Roger that!

Quoted 27 lines
Quoted 27 lines

Thanks,

Daniel

Quoted 20 lines
Fixes c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"
---
   hw/ppc/spapr_hcall.c |    1 +
   1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 4d0e6eb0cf1d..596f58378a40 100644
@@ -1697,6 +1697,7 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
       switch (safe_indirect_branch) {
       case SPAPR_CAP_FIXED:
           characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+        break;
       default: /* broken */
           assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
           break;
Applied
#5 lore raw
In reply to Greg Kurz
Quoted 5 lines · Greg Kurz

Detected by Coverity (CID 1385702). This fixes the recently added hypercall to let guests properly apply Spectre and Meltdown workarounds.

Fixes c59704b25473 "target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS"

Applied to ppc-for-2.12, thanks.

Quoted 17 lines
---
 hw/ppc/spapr_hcall.c |    1 +
 1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 4d0e6eb0cf1d..596f58378a40 100644
@@ -1697,6 +1697,7 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu,
     switch (safe_indirect_branch) {
     case SPAPR_CAP_FIXED:
         characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED;
+        break;
     default: /* broken */
         assert(safe_indirect_branch == SPAPR_CAP_BROKEN);
         break;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson