Skip to contentSkip to conversation

is the "tcg translation" necessary when the "kvm acceleration" emulation mode enabled?

Qemu-devel tugouxp 2 participants 3 messages Dec 21, 2018

lore
Share & tools
lore

tugouxp

author
#0 lore raw

hi folks:
i am very puzzled about the relationship between "target cpu instruction" translated to host instructions through TCG module and the "kvm" acceleration" mode.

think about three scenario of emulation:
scenario 1, 2 and 3 as follows:

1. target cpu: x86_64,

host cpu: x84_64,

emulation OS: ubuntu_desktop_amd64.iso
kvm: enabled.

2. target cpu: x86_64,

host cpu: x84_64,

emulation OS: ubuntu_desktop_amd64.iso
kvm: disabled.

3. target cpu x86_64,
host cpu: armv8
emulationOS: ubuntu_desktop_amd64.iso
kvm: enabled

my question is:

scenario 1:  did the tcg translation need to be done in this case now that the host and target arch is the same?  or  let the kvm emulation the system wit the original instructions with out the TCG   translation?
scenario 2:   the pre condition is same with scenario 1 except the kvm is disable? so ,in this scenario, the TCG must be used in order to the pure software emulation without acceleration?
scenario 3:  in this scenario, the host and target arch is not the same, so how to use the "kvm mechainsim" in this case?  so the instructions feed to the kvm module to run must be translated By TCG module? right?

thanks for your kindly support for my puzzle.

#1 lore raw
Quoted 4 lines

scenario 1: did the tcg translation need to be done in this case now that the host and target arch is the same? or let the kvm emulation the system wit the original instructions with out the TCG translation

TCG is turned off when KVM is enabled. The code for TCG does not run at all.

Quoted 3 lines

scenario 2: the pre condition is same with scenario 1 except the kvm
is disable? so ,in this scenario, the TCG must be used in order to the pure software emulation without acceleration?

Correct. In this case KVM is turned off. The capabilities of the emulated CPU will _not_ be what you have in your host processor, but rather what QEMU implements. For example, you will get no AVX.

Quoted 4 lines

scenario 3: in this scenario, the host and target arch is not the same, so how to use the "kvm mechainsim" in this case? so the instructions feed to the kvm module to run must be translated By TCG module? right?

KVM cannot be used in this case; KVM is only enabled when the host and the target are the same.

Paolo

Quoted 25 lines · tugouxp

hi folks:
i am very puzzled about the relationship between "target cpu instruction" translated to host instructions through TCG module and the "kvm" acceleration" mode.

think about three scenario of emulation:
scenario 1, 2 and 3 as follows:

1. target cpu: x86_64,
host cpu: x84_64,
emulation OS: ubuntu_desktop_amd64.iso
kvm: enabled.

2. target cpu: x86_64,

host cpu: x84_64,

emulation OS: ubuntu_desktop_amd64.iso
kvm: disabled.

3. target cpu x86_64,
host cpu: armv8
emulationOS: ubuntu_desktop_amd64.iso
kvm: enabled

author
#2 lore raw

much appreciate!

:)

Quoted 52 lines · Paolo Bonzini
Quoted 4 lines

scenario 1: did the tcg translation need to be done in this case now that the host and target arch is the same? or let the kvm emulation the system wit the original instructions with out the TCG translation

TCG is turned off when KVM is enabled. The code for TCG does not run at all.

Quoted 3 lines

scenario 2: the pre condition is same with scenario 1 except the kvm
is disable? so ,in this scenario, the TCG must be used in order to the pure software emulation without acceleration?

Correct. In this case KVM is turned off. The capabilities of the emulated CPU will _not_ be what you have in your host processor, but rather what QEMU implements. For example, you will get no AVX.

Quoted 4 lines

scenario 3: in this scenario, the host and target arch is not the same, so how to use the "kvm mechainsim" in this case? so the instructions feed to the kvm module to run must be translated By TCG module? right?

KVM cannot be used in this case; KVM is only enabled when the host and the target are the same.

Paolo

Quoted 25 lines · tugouxp

hi folks:
i am very puzzled about the relationship between "target cpu instruction" translated to host instructions through TCG module and the "kvm" acceleration" mode.

think about three scenario of emulation:
scenario 1, 2 and 3 as follows:

1. target cpu: x86_64,
host cpu: x84_64,
emulation OS: ubuntu_desktop_amd64.iso
kvm: enabled.

2. target cpu: x86_64,

host cpu: x84_64,

emulation OS: ubuntu_desktop_amd64.iso
kvm: disabled.

3. target cpu x86_64,
host cpu: armv8
emulationOS: ubuntu_desktop_amd64.iso
kvm: enabled