Skip to contentSkip to conversation

target/ppc: Fix TCG temporary leaks in gen_slbia()

PATCH-for-5.0? Applied Philippe Mathieu-Daudé 6 participants 12 messages Apr 17, 2020 – Apr 21, 2020

lore
Share & tools
lore
#0 lore raw

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")
---
 target/ppc/translate.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/translate.c +1 -0
index b207fb5386..0136c7e3ff 100644
@@ -5003,6 +5003,7 @@ static void gen_slbia(DisasContext *ctx)
     CHK_SV;
 
     gen_helper_slbia(cpu_env, t0);
+    tcg_temp_free_i32(t0);
 #endif /* defined(CONFIG_USER_ONLY) */
 }
 
Signature · 1 line
2.21.1
#1 lore raw

Excerpts from Philippe Mathieu-Daudé's message of April 17, 2020 7:07 pm:

Quoted 12 lines

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
Quoted 5 lines

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")

Thank you, brown bag required. Looks like I should be testing this stuff with --enable-debug, sorry I didn't realise it.

Thanks,
Nick

author Reviewed-by Nicholas Piggin
#2 lore raw
Quoted 13 lines · Nicholas Piggin

Excerpts from Philippe Mathieu-Daudé's message of April 17, 2020 7:07 pm:

Quoted 12 lines

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
Quoted 8 lines
Quoted 5 lines

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")

Thank you, brown bag required. Looks like I should be testing this stuff with --enable-debug, sorry I didn't realise it.

Is that an implicit:

?

Reviewed-by
#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 12 lines · Philippe Mathieu-Daudé

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
Quoted 5 lines

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")

Thanks,

C.

Quoted 17 lines
---
 target/ppc/translate.c | 1 +
 1 file changed, 1 insertion(+)
target/ppc/translate.c +1 -0
index b207fb5386..0136c7e3ff 100644
@@ -5003,6 +5003,7 @@ static void gen_slbia(DisasContext *ctx)
     CHK_SV;
 
     gen_helper_slbia(cpu_env, t0);
+    tcg_temp_free_i32(t0);
 #endif /* defined(CONFIG_USER_ONLY) */
 }
 
Reviewed-by
#3 lore raw
In reply to Philippe Mathieu-Daudé

Excerpts from Philippe Mathieu-Daudé's message of April 17, 2020 9:00 pm:

Quoted 20 lines · Nicholas Piggin
Quoted 19 lines

Excerpts from Philippe Mathieu-Daudé's message of April 17, 2020 7:07 pm:

Quoted 17 lines

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")
Quoted 6 lines
Quoted 2 lines

Thank you, brown bag required. Looks like I should be testing this stuff with --enable-debug, sorry I didn't realise it.

Is that an implicit:

Yes sure :) If not already merged,

#5 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 13 lines · Philippe Mathieu-Daudé

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
Quoted 5 lines

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")

I propose to apply this patch for 5.0 rc4 (as well as the ppc pullreq already sent), since the iscsi bugfix means we need an rc4 anyway. Any objections?

thanks
-- PMM

#6 lore raw
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Quoted 7 lines
Quoted 3 lines
Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")

I propose to apply this patch for 5.0 rc4 (as well as the ppc pullreq already sent), since the iscsi bugfix means we need an rc4 anyway. Any objections?

Works for me.

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
#8 lore raw
In reply to Peter Maydell
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé

This fixes:

   $ qemu-system-ppc64 \
   -machine pseries-4.1 -cpu power9 \
   -smp 4 -m 12G -accel tcg ...
   ...
   Quiescing Open Firmware ...
   Booting Linux via __start() @ 0x0000000002000000 ...
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Quoted 8 lines
Quoted 3 lines
Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")

I propose to apply this patch for 5.0 rc4 (as well as the ppc pullreq already sent), since the iscsi bugfix means we need an rc4 anyway. Any objections?

I have been running rc3 with this patch fine for some days now. Both with and without a debug enabled build wherein the performance difference between the two is obvious.

However, I do see warnings from 5.0.0-rc3 that worry me :

$ /usr/local/bin/qemu-system-ppc64 \

Review

Quoted 5 lines
(quoted diff) +0 -5
-machine pseries-4.1 -cpu power9 -smp 4 -m 12G -accel tcg \
-drive file=/home/ppc64/ppc64le.qcow2 \
-device virtio-net-pci,netdev=usernet \
-netdev user,id=usernet,hostfwd=tcp::10000-:22 \
-serial stdio -display none -vga none

qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-cfpc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-sbbc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-ibs=workaround

SLOF ********************************************************************** QEMU Starting
Build Date = Mar 27 2020 13:57:26
FW Version = git-8e012d6fddb62be8
Press "s" to enter Open Firmware.

Populating /vdevice methods
Populating /vdevice/vty@71000000
Populating /vdevice/nvram@71000001
Populating /vdevice/v-scsi@71000002

       SCSI: Looking for devices
          8000000000000000 DISK     : "QEMU     QEMU HARDDISK    2.5+"
          8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+"
Populating /pci@800000020000000
                     00 0000 (D) : 1af4 1000    virtio [ net ]

No NVRAM common partition, re-initializing...
Scanning USB
Using default console: /vdevice/vty@71000000

Welcome to Open Firmware

Copyright (c) 2004, 2017 IBM Corporation All rights reserved. This program and the accompanying materials are made available under the terms of the BSD License available at
http://www.opensource.org/licenses/bsd-license.php

Trying to load: from: /vdevice/v-scsi@71000002/disk@8000000000000000 ... Successfully loaded

etc etc etc

What shall I do with "TCG doesn't support requested feature, cap-cfpc=workaround" ??

Signature · 4 lines
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional
#9 lore raw
Quoted 33 lines · Dennis Clarke
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Philippe Mathieu-Daudé

This fixes:

   $ qemu-system-ppc64 \
   -machine pseries-4.1 -cpu power9 \
   -smp 4 -m 12G -accel tcg ...
   ...
   Quiescing Open Firmware ...
   Booting Linux via __start() @ 0x0000000002000000 ...
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Quoted 8 lines
Quoted 3 lines
Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")

I propose to apply this patch for 5.0 rc4 (as well as the ppc pullreq already sent), since the iscsi bugfix means we need an rc4 anyway. Any objections?

I have been running rc3 with this patch fine for some days now. Both with and without a debug enabled build wherein the performance difference between the two is obvious.

However, I do see warnings from 5.0.0-rc3 that worry me :

$ /usr/local/bin/qemu-system-ppc64 \
Quoted 11 lines

Review

Quoted 5 lines
(quoted diff) +0 -5
-machine pseries-4.1 -cpu power9 -smp 4 -m 12G -accel tcg \
-drive file=/home/ppc64/ppc64le.qcow2 \
-device virtio-net-pci,netdev=usernet \
-netdev user,id=usernet,hostfwd=tcp::10000-:22 \
-serial stdio -display none -vga none

qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-cfpc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-sbbc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-ibs=workaround

These are completely unrelated to the slbia patch.

[snip]

Quoted 4 lines

etc etc etc

What shall I do with "TCG doesn't support requested feature, cap-cfpc=workaround" ??

Ignore them, probably. It means your TCG guest is insecure against Spectre attacks, but it was always going to be one way or another.

You can suppress them with:
-machine cap-cfpc=broken,cap-sbbc=broken,cap-ibs=broken

That doesn't make anything more secure, it just lets qemu know that's what you intended, and in turn it will tell the guest that these mitigations are not available.

These are enabled by default, because they're very important for production KVM guests. However, doing equivalent Spectre mitigation for TCG is essentially infeasible.

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
author Tested-by Dennis Clarke
#10 lore raw
In reply to Dennis Clarke
Quoted 22 lines · Dennis Clarke
Quoted 21 lines · Peter Maydell
Quoted 18 lines · Philippe Mathieu-Daudé

This fixes:

   $ qemu-system-ppc64 \
   -machine pseries-4.1 -cpu power9 \
   -smp 4 -m 12G -accel tcg ...
   ...
   Quiescing Open Firmware ...
   Booting Linux via __start() @ 0x0000000002000000 ...
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
   Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")
Quoted 8 lines
Quoted 4 lines

I propose to apply this patch for 5.0 rc4 (as well as the ppc pullreq already sent), since the iscsi bugfix means we need an rc4 anyway. Any objections?

I have been running rc3 with this patch fine for some days now.  Both with and without a debug enabled build wherein the performance difference between the two is obvious.

Thanks for testing it! Can we use your:

tag?

Quoted 53 lines

However, I do see warnings from 5.0.0-rc3 that worry me :

$ /usr/local/bin/qemu-system-ppc64 \

Review

Quoted 5 lines
(quoted diff) +0 -5
-machine pseries-4.1 -cpu power9 -smp 4 -m 12G -accel tcg \
-drive file=/home/ppc64/ppc64le.qcow2 \
-device virtio-net-pci,netdev=usernet \
-netdev user,id=usernet,hostfwd=tcp::10000-:22 \
-serial stdio -display none -vga none

qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-cfpc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-sbbc=workaround
qemu-system-ppc64: warning: TCG doesn't support requested feature, cap-ibs=workaround

SLOF ********************************************************************** QEMU Starting
 Build Date = Mar 27 2020 13:57:26
 FW Version = git-8e012d6fddb62be8
 Press "s" to enter Open Firmware.

Populating /vdevice methods
Populating /vdevice/vty@71000000
Populating /vdevice/nvram@71000001
Populating /vdevice/v-scsi@71000002
       SCSI: Looking for devices
          8000000000000000 DISK     : "QEMU     QEMU HARDDISK    2.5+" 8200000000000000 CD-ROM   : "QEMU     QEMU CD-ROM      2.5+" Populating /pci@800000020000000
                     00 0000 (D) : 1af4 1000    virtio [ net ] No NVRAM common partition, re-initializing...
Scanning USB
Using default console: /vdevice/vty@71000000

  Welcome to Open Firmware

  Copyright (c) 2004, 2017 IBM Corporation All rights reserved. This program and the accompanying materials are made available under the terms of the BSD License available at
  http://www.opensource.org/licenses/bsd-license.php

Trying to load:  from: /vdevice/v-scsi@71000002/disk@8000000000000000 ...   Successfully loaded

etc etc etc

What shall I do with "TCG doesn't support requested feature, cap-cfpc=workaround" ??

#7 lore raw
In reply to David Gibson
Quoted 22 lines · David Gibson
Quoted 20 lines · Peter Maydell
Quoted 18 lines · Philippe Mathieu-Daudé

This fixes:

  $ qemu-system-ppc64 \
  -machine pseries-4.1 -cpu power9 \
  -smp 4 -m 12G -accel tcg ...
  ...
  Quiescing Open Firmware ...
  Booting Linux via __start() @ 0x0000000002000000 ...
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
  Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")
Quoted 5 lines
Quoted 3 lines

I propose to apply this patch for 5.0 rc4 (as well as the ppc pullreq already sent), since the iscsi bugfix means we need an rc4 anyway. Any objections?

Works for me.

Applied to master, thanks.

-- PMM

#11 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 32 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Dennis Clarke
Quoted 21 lines · Peter Maydell
Quoted 18 lines · Philippe Mathieu-Daudé

This fixes:

    $ qemu-system-ppc64 \
    -machine pseries-4.1 -cpu power9 \
    -smp 4 -m 12G -accel tcg ...
    ...
    Quiescing Open Firmware ...
    Booting Linux via __start() @ 0x0000000002000000 ...
    Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
    Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries
    Opcode 1f 12 0f 00 (7ce003e4) leaked temporaries

[*] https://www.mail-archive.com/[email protected]/msg05400.html

Fixes 0418bf78fe8 ("Fix ISA v3.0 (POWER9) slbia implementation")
Quoted 8 lines
Quoted 4 lines

I propose to apply this patch for 5.0 rc4 (as well as the ppc pullreq already sent), since the iscsi bugfix means we need an rc4 anyway. Any objections?

I have been running rc3 with this patch fine for some days now.  Both with and without a debug enabled build wherein the performance difference between the two is obvious.

Quoted 5 lines

Thanks for testing it! Can we use your:

tag?

Of course. Even "running fine by that old UNIX guy" if you want.

Signature · 4 lines
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional