tcg enhancements on powerpc - linux foundation...

27
TCG enhancements on PowerPC Nikunj A. Dadhania [email protected] Linux Technology Center, India, IBM KVM Forum 25th August 2016

Upload: others

Post on 12-Jan-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

TCG enhancements on PowerPC

Nikunj A. [email protected]

Linux Technology Center, India, IBM

KVM Forum

25th August 2016

Page 2: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

2/27

About me Guest firmware(SLOF) developer

QEMU user/developer

Page 3: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

3/27

QEMU TCG – Quick look

Power ISA 3.0 Support

PowerNV Platform

PowerPC support for Multi-threaded TCG

Other Optimizations

Future work

Agenda

Page 4: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

4/27

How is emulation done ?PowerPC

Machine Code

Translate

LAPTOP(x86)

x86Machine Code

Runs On

POWER ISA

Intel ISA

Credits: Alexander Graf’sQEMU’s Recompilation Engine

addi r9,r9,127

add $0x7f,%rbp

Page 5: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

5/27

More architectures !

PowerPC Binary

X86Instructions

X86Hardware

ARMBinary

X86 Binary

Credits: Alexander Graf’sQEMU’s Recompilation Engine

Page 6: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

6/27

N x N Support: Very complex

PowerPC Binary

X86Instructions

X86Hardware

ARMBinary

X86 Binary

PowerPC Hardware

PowerPCInstructions

ARMHardware

ARMInstructions

Credits: Alexander Graf’sQEMU’s Recompilation Engine

Page 7: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

7/27

QEMU TCG – Tiny Code Generator

PowerPC Binary

TCG

Machine IndependentIntermediate notation

ARMBinary

S390 Binary

x86 Binary

PowerPC Hardware

ARMHardware

S390 Hardware

x86 Hardware

Target

Host

tcg micro ops

Credits: Alexander Graf’sQEMU’s Recompilation Engine

Page 8: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

8/27

QEMU Avatar – linux-user

Input: Target binary and libraries

Provides Linux system call emulation

Emulates target ISA

Can be used to debug user programs

Laptop(x86)

ppc6

4 pr

ogra

m

arm

pro

gram

ppc

prog

ram

TCG Linux Syscall

Page 9: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

9/27

POWER ISA 3.0

Page 10: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

10/27

POWER ISA 3.0 POWER (Performance Optimization With Enhanced RISC) Adds ~180 new instructions Various instructions added in different classes

Atomic memory operations Hashing support operations String operations (character testing, string processing) Arithmetic operations(multiply-add, modulo) ……...

http://ibm.biz/power-isa3 (needs registration)

Page 11: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

11/27

Status - POWER ISA 3.0 24 instructions queued in ppc-for-2.8

Modulo, Special compare Vector absolute, compare, shift

24 instructions posted under review Load/Store vector/scalar Vector insert, extract, count trailing zeros

25 instructions under test

https://github.com/nikunjad/qemu/commits/p9-tcg

Page 12: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

12/27

Challenges: POWER ISA 3.0 Testing and verifying the instructions

Correctness Repeatability Negative test cases

Can use: kvm-unit-test QEMU qtest

Anton Blanchard’s instruction fuzzer Compares physical CPU to QEMU emulation

Page 13: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

13/27

PowerNV Platform

Page 14: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

14/27

Laptop(x86)

VM

1 -

PP

C6

4QEMU Avatar – System Emulation

VM

2 -

x86

VM

n –

AR

M

TCG

Emulated Devices

SoftMMU

NetworkDISK

InputVGA

Invoked as machines (-machine pseries)

Runs isolated in its own memory space

Can be used to debug firmware, kernel, etc.

Gu

est

Fir

mw

are

Page 15: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

15/27

pSeries Machine Emulation

Laptop(x86)

SLOF

Based on sPAPR standard Guest Emulation Hyper-Call based Para-virtualized guest Has been supported since a while

Emulated Devices: VIO

MMUXICSXICS

RTAS

TCG

VM

1 (p

pc64

le)

VM

2 (p

pc64

le)

VM

n (p

pc64

)

pSeries Machine

Page 16: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

16/27

PowerNV Machine Emulation

Laptop(x86)

TCG

VM

1 (p

pc64

le)

VM

2 (p

pc64

le)

VM

n (p

pc64

)

PowerNV Machine

Emulate Bare Metal POWER platform Model Board Management controller

(BMC) Supports Hypervisor mode Can run nested guest Assists in early bringup Support IPMI

BMC

OCC

skiboot

INTC

MMU

Page 17: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

17/27

Status: PowerNV Initiated by Benjamin Herrenschmidt Cédric Le Goater developing and pushing patches upstream PowerNV ~50 preparatory patches upstream

POWER8 Hypervisor SPRs Split Instruction and Data caches Batching TLB flushes XICS rework to support new native model

Page 18: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

18/27

PowerPC support for Multi-threaded TCG

Page 19: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

19/27

System emulation - runs vCPUs serially

CPU 1 CPU 2 CPU 3 CPU 4

vCPU1

vCPU2

...

vCPUn

CPU 8….

IO

VNC

Emulates multi-processor VM: but serially.

vCPUs run in round robin mode Can’t emulate concurrent behaviour

PowerPC Emulation on X86

Credits: Alex BennéeTowards Multithreaded TCG

Page 20: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

20/27

QEMU Multi-threaded TCG QEMU for multi-core system bringup Community effort in progress Challenges: Atomics, Memory Barriers, TLB Flush, etc.

CPU 1 CPU 2 CPU 3 CPU 4

vCPU1

CPU 8….

IO

VNC

PowerPC Emulation on X86

vCPU2 vCPU3 vCPU4

Credits: Alex BennéeTowards Multithreaded TCG

Page 21: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

21/27

Status – PPC support for MTTCG Based on MTTCG base patches and atomic cmpxchg Take iothread locks during hcalls Load with reservation(lwarx and family) Store conditional(stwcx. and family) with atomic cmpxchg micro-ops Booted VM with 4 vCPUs Ebizzy performance (ebizzy -S 300 -t 16)

Single-Threaded TCGSingle Core, 4 Threads

1514 records/sreal 300.00 suser 222.74 ssys 976.80 s

Multi-Threaded TCGSingle Core, 4 Threads

5415 records/sreal 300.00 suser 420.01 ssys 778.93 s

3.5x

Page 22: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

22/27

Challenges: PPC support for MTTCG

Still unstable https://github.com/nikunjad/qemu/commits/pseries_mttcg_wip

pSeries uses hcall for page table update/invalidate. Memory barriers Supporting PowerNV platform

Page 23: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

23/27

Misc TCG Improvements Load/Store improvements – Benjamin Herrenschmidt

Exception handling improvements – Benjamin Herrenschmidt

Load/Store consolidation – Nikunj

Page 24: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

24/27

Future

Complete POWER ISA 3.0 support Upstreaming PowerNV in QEMU Future - POWER9 PowerNV support Stabilize MTTCG on POWER 128bit Load/Store support in TCG Testing mechanism for instructions

Page 25: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

25/27

Credits

Benjamin Herrenschmidt Cédric Le Goater Alexander Graf – QEMU’s Recompilation Engine https://dl.dropboxusercontent.com/u/8976842/TCG.pdf

Alex Bennée – Towards Multithreaded TCG http://www.linux-kvm.org/images/c/cf/02x02-Alex_Benee-Towards_Multithreaded_TCG.pdf

Page 26: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

26/27

Legal statement This work represents the views of the author, and does not necessarily

represent the view of IBM IBM and IBM (logo) are trademark of International Business Machines in the

United States and/or other. Linux is a registered trademark of Linus Torvalds Other company, product, logos and service names may be trademarks or

service marks of others This document is provided “AS IS”, with no express or implied warranties. Use

the information in this document at your own risk Results mentioned in the presentation is for reference purposes only, and are

not to be relied on in any manner.

Page 27: TCG enhancements on PowerPC - Linux Foundation Eventsevents17.linuxfoundation.org/sites/events/files/slides/KVMForum_TCG... · service marks of others This document is provided “AS

© 2015 IBM Corporation

27/27

धन्यववाद

Thank you