On 17.02.20 16:00, Janosch Frank wrote: > On 2/17/20 3:53 PM, Christian Borntraeger wrote: >> Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxx> >> --- >> arch/s390/kvm/kvm-s390.c | 55 +++++++++++++++++++++++++++++----------- >> 1 file changed, 40 insertions(+), 15 deletions(-) >> >> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c >> index a095d9695f18..10b20e17a7fe 100644 >> --- a/arch/s390/kvm/kvm-s390.c >> +++ b/arch/s390/kvm/kvm-s390.c >> @@ -2171,9 +2171,41 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm, >> return r; >> } >> >> +static int kvm_s390_switch_from_pv(struct kvm *kvm, u16 *rc, u16 *rrc) >> +{ >> + int i, r = 0; >> + >> + struct kvm_vcpu *vcpu; >> + >> + kvm_for_each_vcpu(i, vcpu, kvm) { >> + r = kvm_s390_pv_destroy_cpu(vcpu, rc, rrc); >> + if (r) >> + break; >> + } >> + return r; >> +} >> + >> +static int kvm_s390_switch_to_pv(struct kvm *kvm, u16 *rc, u16 *rrc) >> +{ >> + int i, r = 0; >> + u16 dummy; >> + >> + struct kvm_vcpu *vcpu; >> + >> + kvm_for_each_vcpu(i, vcpu, kvm) { >> + r = kvm_s390_pv_create_cpu(vcpu, rc, rrc); >> + if (r) >> + break; >> + } >> + if (r) >> + kvm_s390_switch_from_pv(kvm,&dummy, &dummy); >> + return r; >> +} > > Why does that only affect the cpus? > If we have a switch function it should do VM and VCPUs, no? It is a helper function for the function below. FWIW, it also needs to take the cpu->mutex for each cpu.