From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWN1K-0005Y0-VD for qemu-devel@nongnu.org; Fri, 13 Mar 2015 06:40:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWN1H-0000ak-Aa for qemu-devel@nongnu.org; Fri, 13 Mar 2015 06:40:46 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:42859 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWN1H-0000aL-4f for qemu-devel@nongnu.org; Fri, 13 Mar 2015 06:40:43 -0400 References: <1425479753-18349-1-git-send-email-alex.bennee@linaro.org> <1425479753-18349-2-git-send-email-alex.bennee@linaro.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: Date: Fri, 13 Mar 2015 10:40:51 +0000 Message-ID: <87h9tpb2oc.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2 1/6] target-arm: kvm: save/restore mp state List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: kvm-devel , Marc Zyngier , QEMU Developers , Christoffer Dall , "kvmarm@lists.cs.columbia.edu" , arm-mail-list Peter Maydell writes: > On 4 March 2015 at 14:35, Alex Bennée wrote: >> This adds the saving and restore of the current Multi-Processing state >> of the machine. While the KVM_GET/SET_MP_STATE API exposes a number of >> potential states for x86 we only use two for ARM. Either the process is >> running or not. We then save this state into the cpu_powered TCG state >> to avoid changing the serialisation format. >> >> Signed-off-by: Alex Bennée >> >> --- >> v2 >> - make mpstate field runtime dependant (kvm_enabled()) >> - drop initial KVM_CAP_MP_STATE requirement >> - re-use cpu_powered instead of new field >> >> diff --git a/target-arm/machine.c b/target-arm/machine.c >> index 9446e5a..185f9a2 100644 >> --- a/target-arm/machine.c >> +++ b/target-arm/machine.c >> @@ -161,6 +161,7 @@ static const VMStateInfo vmstate_cpsr = { >> .put = put_cpsr, >> }; >> >> + >> static void cpu_pre_save(void *opaque) >> { >> ARMCPU *cpu = opaque; >> @@ -170,6 +171,20 @@ static void cpu_pre_save(void *opaque) >> /* This should never fail */ >> abort(); >> } >> +#if defined CONFIG_KVM >> + if (kvm_check_extension(CPU(cpu)->kvm_state, KVM_CAP_MP_STATE)) { >> + struct kvm_mp_state mp_state; >> + int ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MP_STATE, &mp_state); >> + if (ret) { >> + fprintf(stderr, "%s: failed to get MP_STATE %d/%s\n", >> + __func__, ret, strerror(ret)); >> + abort(); >> + } >> + cpu->powered_off = >> + (mp_state.mp_state == KVM_MP_STATE_RUNNABLE) >> + ? false : true; > > Ternary operator to produce a true-or-false result is a bit > redundant... > >> + } >> +#endif > > Why is this in pre-save/post-load rather than in the > kvm_arch_get/put_registers functions like all the other > syncing code? Yeah the #ifdefs should have waved the red flag - I'll move it ;-) > > -- PMM -- Alex Bennée