From: James Morse <james.morse@arm.com>
To: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: Mark Rutland <Mark.Rutland@arm.com>,
"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Marc Zyngier <Marc.Zyngier@arm.com>,
Catalin Marinas <Catalin.Marinas@arm.com>,
Will Deacon <Will.Deacon@arm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"geoff@infradead.org" <geoff@infradead.org>,
"broonie@kernel.org" <broonie@kernel.org>,
"david.griego@linaro.org" <david.griego@linaro.org>,
"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
"christoffer.dall@linaro.org" <christoffer.dall@linaro.org>,
"freddy77@gmail.com" <freddy77@gmail.com>
Subject: Re: [PATCH v5 1/2] arm64: kvm: allows kvm cpu hotplug
Date: Tue, 13 Oct 2015 11:43:16 +0100 [thread overview]
Message-ID: <561CE044.8080401@arm.com> (raw)
In-Reply-To: <561C98C1.3090900@linaro.org>
Hi,
On 13/10/15 06:38, AKASHI Takahiro wrote:
> On 10/12/2015 10:28 PM, James Morse wrote:
>> On 29/05/15 06:38, AKASHI Takahiro wrote:
>>> The current kvm implementation on arm64 does cpu-specific initialization
>>> at system boot, and has no way to gracefully shutdown a core in terms of
>>> kvm. This prevents, especially, kexec from rebooting the system on a boot
>>> core in EL2.
>>>
>>> This patch adds a cpu tear-down function and also puts an existing cpu-init
>>> code into a separate function, kvm_arch_hardware_disable() and
>>> kvm_arch_hardware_enable() respectively.
>>> We don't need arm64-specific cpu hotplug hook any more.
>>
>> I think we do... on platforms where cpuidle uses psci to temporarily turn
>> off cores that aren't in use, we lose the el2 state. This hotplug hook
>> restores the state, even if there a no vms running.
I've just noticed there are two cpu notifiers - we may be referring to
different ones. (hyp_init_cpu_pm_nb and hyp_init_cpu_nb)
> If I understand you correctly, with or without my patch, kvm doesn't work
> under cpuidle anyway. Right?
It works with, and without, v4.
This patch v5 causes the problem.
> If so, saving/restoring cpu states (or at least, kicking cpu hotplug hooks)
> is cpuidle driver's responsibility, isn't it?
Yes - but with v5, (at least one of) the hotplug hooks isn't having the
same effect as before:
Before v5, cpu_init_hyp_mode() is called via cpu_notify() each time
cpu_suspend() suspends/wakes-up the core.
Logically it should be the 'pm' notifier that does this work:
> if (cmd == CPU_PM_EXIT &&
> __hyp_get_vectors() == hyp_default_vectors) {
> cpu_init_hyp_mode(NULL);
> return NOTIFY_OK;
>
With v5, kvm_arch_hardware_enable() isn't called each time cpu_suspend()
cycles the core.
The problem appears to be this hunk, affecting the above code:
> - if (cmd == CPU_PM_EXIT &&
> - __hyp_get_vectors() == hyp_default_vectors) {
> - cpu_init_hyp_mode(NULL);
> + if (cmd == CPU_PM_EXIT && kvm_arm_get_running_vcpu()) {
> + kvm_arch_hardware_enable();
Changing this to just rename cpu_init_hyp_mode() to
kvm_arch_hardware_enable() solves the problem.
Presumably kvm_arm_get_running_vcpu() evaluates to false before the first
vm is started, meaning no vms can be started if pm events occur before
starting the first vm.
Sorry I blamed the wrong cpu notifier hook - I didn't realise there were two!
Thanks,
James
>> This patch prevents me from running vms on such a platform, qemu gives:
>>> kvm [1500]: Unsupported exception type: 6264688KVM internal error.
>> Suberror: 0
>>
>> kvmtool goes with a more dramatic:
>>> KVM exit reason: 17 ("KVM_EXIT_INTERNAL_ERROR")
>>
>> Disabling CONFIG_ARM_CPUIDLE solves this problem.
>>
>>
>> (Sorry to revive an old thread - I've been using v4 of this patch for the
>> hibernate/suspend-to-disk series).
>>
>>
>>> Since this patch modifies common part of code between arm and arm64, one
>>> stub definition, __cpu_reset_hyp_mode(), is added on arm side to avoid
>>> compiling errors.
>>>
>>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
>>
>>> diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S
>>> index fd085ec..afe6263 100644
>>> --- a/arch/arm64/kvm/hyp.S
>>> +++ b/arch/arm64/kvm/hyp.S
>>> @@ -1136,6 +1136,11 @@ ENTRY(kvm_call_hyp)
>>> ret
>>> ENDPROC(kvm_call_hyp)
>>>
>>> +ENTRY(kvm_call_reset)
>>> + hvc #HVC_RESET
>>> + ret
>>> +ENDPROC(kvm_call_reset)
>>> +
>>> .macro invalid_vector label, target
>>> .align 2
>>> \label:
>>> @@ -1179,10 +1184,27 @@ el1_sync: // Guest trapped
>>> into EL2
>>> cmp x18, #HVC_GET_VECTORS
>>> b.ne 1f
>>> mrs x0, vbar_el2
>>> - b 2f
>>> -
>>> -1: /* Default to HVC_CALL_HYP. */
>>> + b do_eret
>>>
>>> + /* jump into trampoline code */
>>> +1: cmp x18, #HVC_RESET
>>> + b.ne 2f
>>> + /*
>>> + * Entry point is:
>>> + * TRAMPOLINE_VA
>>> + * + (__kvm_hyp_reset - (__hyp_idmap_text_start & PAGE_MASK))
>>> + */
>>> + adrp x2, __kvm_hyp_reset
>>> + add x2, x2, #:lo12:__kvm_hyp_reset
>>> + adrp x3, __hyp_idmap_text_start
>>> + add x3, x3, #:lo12:__hyp_idmap_text_start
>>> + and x3, x3, PAGE_MASK
>>> + sub x2, x2, x3
>>> + ldr x3, =TRAMPOLINE_VA
>>> + add x2, x2, x3
>>> + br x2 // no return
>>> +
>>> +2: /* Default to HVC_CALL_HYP. */
>>
>> What was the reason not to use kvm_call_hyp(__kvm_hyp_reset, ...)?
>> (You mentioned you wanted to at [0] - I can't find the details in the
>> archive)
>>
>>
>> Thanks,
>>
>> James
>>
>>
>> [0] http://lists.infradead.org/pipermail/kexec/2015-April/335533.html
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
WARNING: multiple messages have this Message-ID (diff)
From: james.morse@arm.com (James Morse)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 1/2] arm64: kvm: allows kvm cpu hotplug
Date: Tue, 13 Oct 2015 11:43:16 +0100 [thread overview]
Message-ID: <561CE044.8080401@arm.com> (raw)
In-Reply-To: <561C98C1.3090900@linaro.org>
Hi,
On 13/10/15 06:38, AKASHI Takahiro wrote:
> On 10/12/2015 10:28 PM, James Morse wrote:
>> On 29/05/15 06:38, AKASHI Takahiro wrote:
>>> The current kvm implementation on arm64 does cpu-specific initialization
>>> at system boot, and has no way to gracefully shutdown a core in terms of
>>> kvm. This prevents, especially, kexec from rebooting the system on a boot
>>> core in EL2.
>>>
>>> This patch adds a cpu tear-down function and also puts an existing cpu-init
>>> code into a separate function, kvm_arch_hardware_disable() and
>>> kvm_arch_hardware_enable() respectively.
>>> We don't need arm64-specific cpu hotplug hook any more.
>>
>> I think we do... on platforms where cpuidle uses psci to temporarily turn
>> off cores that aren't in use, we lose the el2 state. This hotplug hook
>> restores the state, even if there a no vms running.
I've just noticed there are two cpu notifiers - we may be referring to
different ones. (hyp_init_cpu_pm_nb and hyp_init_cpu_nb)
> If I understand you correctly, with or without my patch, kvm doesn't work
> under cpuidle anyway. Right?
It works with, and without, v4.
This patch v5 causes the problem.
> If so, saving/restoring cpu states (or at least, kicking cpu hotplug hooks)
> is cpuidle driver's responsibility, isn't it?
Yes - but with v5, (at least one of) the hotplug hooks isn't having the
same effect as before:
Before v5, cpu_init_hyp_mode() is called via cpu_notify() each time
cpu_suspend() suspends/wakes-up the core.
Logically it should be the 'pm' notifier that does this work:
> if (cmd == CPU_PM_EXIT &&
> __hyp_get_vectors() == hyp_default_vectors) {
> cpu_init_hyp_mode(NULL);
> return NOTIFY_OK;
>
With v5, kvm_arch_hardware_enable() isn't called each time cpu_suspend()
cycles the core.
The problem appears to be this hunk, affecting the above code:
> - if (cmd == CPU_PM_EXIT &&
> - __hyp_get_vectors() == hyp_default_vectors) {
> - cpu_init_hyp_mode(NULL);
> + if (cmd == CPU_PM_EXIT && kvm_arm_get_running_vcpu()) {
> + kvm_arch_hardware_enable();
Changing this to just rename cpu_init_hyp_mode() to
kvm_arch_hardware_enable() solves the problem.
Presumably kvm_arm_get_running_vcpu() evaluates to false before the first
vm is started, meaning no vms can be started if pm events occur before
starting the first vm.
Sorry I blamed the wrong cpu notifier hook - I didn't realise there were two!
Thanks,
James
>> This patch prevents me from running vms on such a platform, qemu gives:
>>> kvm [1500]: Unsupported exception type: 6264688KVM internal error.
>> Suberror: 0
>>
>> kvmtool goes with a more dramatic:
>>> KVM exit reason: 17 ("KVM_EXIT_INTERNAL_ERROR")
>>
>> Disabling CONFIG_ARM_CPUIDLE solves this problem.
>>
>>
>> (Sorry to revive an old thread - I've been using v4 of this patch for the
>> hibernate/suspend-to-disk series).
>>
>>
>>> Since this patch modifies common part of code between arm and arm64, one
>>> stub definition, __cpu_reset_hyp_mode(), is added on arm side to avoid
>>> compiling errors.
>>>
>>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
>>
>>> diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S
>>> index fd085ec..afe6263 100644
>>> --- a/arch/arm64/kvm/hyp.S
>>> +++ b/arch/arm64/kvm/hyp.S
>>> @@ -1136,6 +1136,11 @@ ENTRY(kvm_call_hyp)
>>> ret
>>> ENDPROC(kvm_call_hyp)
>>>
>>> +ENTRY(kvm_call_reset)
>>> + hvc #HVC_RESET
>>> + ret
>>> +ENDPROC(kvm_call_reset)
>>> +
>>> .macro invalid_vector label, target
>>> .align 2
>>> \label:
>>> @@ -1179,10 +1184,27 @@ el1_sync: // Guest trapped
>>> into EL2
>>> cmp x18, #HVC_GET_VECTORS
>>> b.ne 1f
>>> mrs x0, vbar_el2
>>> - b 2f
>>> -
>>> -1: /* Default to HVC_CALL_HYP. */
>>> + b do_eret
>>>
>>> + /* jump into trampoline code */
>>> +1: cmp x18, #HVC_RESET
>>> + b.ne 2f
>>> + /*
>>> + * Entry point is:
>>> + * TRAMPOLINE_VA
>>> + * + (__kvm_hyp_reset - (__hyp_idmap_text_start & PAGE_MASK))
>>> + */
>>> + adrp x2, __kvm_hyp_reset
>>> + add x2, x2, #:lo12:__kvm_hyp_reset
>>> + adrp x3, __hyp_idmap_text_start
>>> + add x3, x3, #:lo12:__hyp_idmap_text_start
>>> + and x3, x3, PAGE_MASK
>>> + sub x2, x2, x3
>>> + ldr x3, =TRAMPOLINE_VA
>>> + add x2, x2, x3
>>> + br x2 // no return
>>> +
>>> +2: /* Default to HVC_CALL_HYP. */
>>
>> What was the reason not to use kvm_call_hyp(__kvm_hyp_reset, ...)?
>> (You mentioned you wanted to at [0] - I can't find the details in the
>> archive)
>>
>>
>> Thanks,
>>
>> James
>>
>>
>> [0] http://lists.infradead.org/pipermail/kexec/2015-April/335533.html
WARNING: multiple messages have this Message-ID (diff)
From: James Morse <james.morse@arm.com>
To: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: Catalin Marinas <Catalin.Marinas@arm.com>,
Will Deacon <Will.Deacon@arm.com>,
Marc Zyngier <Marc.Zyngier@arm.com>,
Mark Rutland <Mark.Rutland@arm.com>,
"christoffer.dall@linaro.org" <christoffer.dall@linaro.org>,
"geoff@infradead.org" <geoff@infradead.org>,
"broonie@kernel.org" <broonie@kernel.org>,
"david.griego@linaro.org" <david.griego@linaro.org>,
"freddy77@gmail.com" <freddy77@gmail.com>,
"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 1/2] arm64: kvm: allows kvm cpu hotplug
Date: Tue, 13 Oct 2015 11:43:16 +0100 [thread overview]
Message-ID: <561CE044.8080401@arm.com> (raw)
In-Reply-To: <561C98C1.3090900@linaro.org>
Hi,
On 13/10/15 06:38, AKASHI Takahiro wrote:
> On 10/12/2015 10:28 PM, James Morse wrote:
>> On 29/05/15 06:38, AKASHI Takahiro wrote:
>>> The current kvm implementation on arm64 does cpu-specific initialization
>>> at system boot, and has no way to gracefully shutdown a core in terms of
>>> kvm. This prevents, especially, kexec from rebooting the system on a boot
>>> core in EL2.
>>>
>>> This patch adds a cpu tear-down function and also puts an existing cpu-init
>>> code into a separate function, kvm_arch_hardware_disable() and
>>> kvm_arch_hardware_enable() respectively.
>>> We don't need arm64-specific cpu hotplug hook any more.
>>
>> I think we do... on platforms where cpuidle uses psci to temporarily turn
>> off cores that aren't in use, we lose the el2 state. This hotplug hook
>> restores the state, even if there a no vms running.
I've just noticed there are two cpu notifiers - we may be referring to
different ones. (hyp_init_cpu_pm_nb and hyp_init_cpu_nb)
> If I understand you correctly, with or without my patch, kvm doesn't work
> under cpuidle anyway. Right?
It works with, and without, v4.
This patch v5 causes the problem.
> If so, saving/restoring cpu states (or at least, kicking cpu hotplug hooks)
> is cpuidle driver's responsibility, isn't it?
Yes - but with v5, (at least one of) the hotplug hooks isn't having the
same effect as before:
Before v5, cpu_init_hyp_mode() is called via cpu_notify() each time
cpu_suspend() suspends/wakes-up the core.
Logically it should be the 'pm' notifier that does this work:
> if (cmd == CPU_PM_EXIT &&
> __hyp_get_vectors() == hyp_default_vectors) {
> cpu_init_hyp_mode(NULL);
> return NOTIFY_OK;
>
With v5, kvm_arch_hardware_enable() isn't called each time cpu_suspend()
cycles the core.
The problem appears to be this hunk, affecting the above code:
> - if (cmd == CPU_PM_EXIT &&
> - __hyp_get_vectors() == hyp_default_vectors) {
> - cpu_init_hyp_mode(NULL);
> + if (cmd == CPU_PM_EXIT && kvm_arm_get_running_vcpu()) {
> + kvm_arch_hardware_enable();
Changing this to just rename cpu_init_hyp_mode() to
kvm_arch_hardware_enable() solves the problem.
Presumably kvm_arm_get_running_vcpu() evaluates to false before the first
vm is started, meaning no vms can be started if pm events occur before
starting the first vm.
Sorry I blamed the wrong cpu notifier hook - I didn't realise there were two!
Thanks,
James
>> This patch prevents me from running vms on such a platform, qemu gives:
>>> kvm [1500]: Unsupported exception type: 6264688KVM internal error.
>> Suberror: 0
>>
>> kvmtool goes with a more dramatic:
>>> KVM exit reason: 17 ("KVM_EXIT_INTERNAL_ERROR")
>>
>> Disabling CONFIG_ARM_CPUIDLE solves this problem.
>>
>>
>> (Sorry to revive an old thread - I've been using v4 of this patch for the
>> hibernate/suspend-to-disk series).
>>
>>
>>> Since this patch modifies common part of code between arm and arm64, one
>>> stub definition, __cpu_reset_hyp_mode(), is added on arm side to avoid
>>> compiling errors.
>>>
>>> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
>>
>>> diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S
>>> index fd085ec..afe6263 100644
>>> --- a/arch/arm64/kvm/hyp.S
>>> +++ b/arch/arm64/kvm/hyp.S
>>> @@ -1136,6 +1136,11 @@ ENTRY(kvm_call_hyp)
>>> ret
>>> ENDPROC(kvm_call_hyp)
>>>
>>> +ENTRY(kvm_call_reset)
>>> + hvc #HVC_RESET
>>> + ret
>>> +ENDPROC(kvm_call_reset)
>>> +
>>> .macro invalid_vector label, target
>>> .align 2
>>> \label:
>>> @@ -1179,10 +1184,27 @@ el1_sync: // Guest trapped
>>> into EL2
>>> cmp x18, #HVC_GET_VECTORS
>>> b.ne 1f
>>> mrs x0, vbar_el2
>>> - b 2f
>>> -
>>> -1: /* Default to HVC_CALL_HYP. */
>>> + b do_eret
>>>
>>> + /* jump into trampoline code */
>>> +1: cmp x18, #HVC_RESET
>>> + b.ne 2f
>>> + /*
>>> + * Entry point is:
>>> + * TRAMPOLINE_VA
>>> + * + (__kvm_hyp_reset - (__hyp_idmap_text_start & PAGE_MASK))
>>> + */
>>> + adrp x2, __kvm_hyp_reset
>>> + add x2, x2, #:lo12:__kvm_hyp_reset
>>> + adrp x3, __hyp_idmap_text_start
>>> + add x3, x3, #:lo12:__hyp_idmap_text_start
>>> + and x3, x3, PAGE_MASK
>>> + sub x2, x2, x3
>>> + ldr x3, =TRAMPOLINE_VA
>>> + add x2, x2, x3
>>> + br x2 // no return
>>> +
>>> +2: /* Default to HVC_CALL_HYP. */
>>
>> What was the reason not to use kvm_call_hyp(__kvm_hyp_reset, ...)?
>> (You mentioned you wanted to at [0] - I can't find the details in the
>> archive)
>>
>>
>> Thanks,
>>
>> James
>>
>>
>> [0] http://lists.infradead.org/pipermail/kexec/2015-April/335533.html
next prev parent reply other threads:[~2015-10-13 10:43 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 5:38 [PATCH v5 0/2] arm64: kvm: reset hyp context for kexec AKASHI Takahiro
2015-05-29 5:38 ` AKASHI Takahiro
2015-05-29 5:38 ` AKASHI Takahiro
2015-05-29 5:38 ` [PATCH v5 1/2] arm64: kvm: allows kvm cpu hotplug AKASHI Takahiro
2015-05-29 5:38 ` AKASHI Takahiro
2015-05-29 5:38 ` AKASHI Takahiro
2015-06-09 18:00 ` Marc Zyngier
2015-06-09 18:00 ` Marc Zyngier
2015-06-09 18:00 ` Marc Zyngier
2015-07-06 14:53 ` Marc Zyngier
2015-07-06 14:53 ` Marc Zyngier
2015-07-06 14:53 ` Marc Zyngier
2015-07-06 16:57 ` Geoff Levand
2015-07-06 16:57 ` Geoff Levand
2015-07-06 16:57 ` Geoff Levand
2015-07-07 7:43 ` AKASHI Takahiro
2015-07-07 7:43 ` AKASHI Takahiro
2015-07-07 7:43 ` AKASHI Takahiro
2015-07-07 7:46 ` Marc Zyngier
2015-07-07 7:46 ` Marc Zyngier
2015-07-07 7:46 ` Marc Zyngier
2015-10-12 13:28 ` James Morse
2015-10-12 13:28 ` James Morse
2015-10-12 13:28 ` James Morse
2015-10-13 5:38 ` AKASHI Takahiro
2015-10-13 5:38 ` AKASHI Takahiro
2015-10-13 5:38 ` AKASHI Takahiro
2015-10-13 10:43 ` James Morse [this message]
2015-10-13 10:43 ` James Morse
2015-10-13 10:43 ` James Morse
2015-10-15 10:12 ` AKASHI Takahiro
2015-10-15 10:12 ` AKASHI Takahiro
2015-10-15 10:12 ` AKASHI Takahiro
2015-05-29 5:38 ` [PATCH v5 2/2] arm64: kvm: remove !KEXEC dependency AKASHI Takahiro
2015-05-29 5:38 ` AKASHI Takahiro
2015-05-29 5:38 ` AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=561CE044.8080401@arm.com \
--to=james.morse@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Marc.Zyngier@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=Will.Deacon@arm.com \
--cc=broonie@kernel.org \
--cc=christoffer.dall@linaro.org \
--cc=david.griego@linaro.org \
--cc=freddy77@gmail.com \
--cc=geoff@infradead.org \
--cc=kexec@lists.infradead.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=takahiro.akashi@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.