From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [kvmarm] [PATCH v6 14/15] KVM: ARM: Power State Coordination Interface implementation
Date: Mon, 21 Jan 2013 11:04:08 +0100 [thread overview]
Message-ID: <75f43582106716efe7c8f1360e58732e@localhost> (raw)
In-Reply-To: <CANM98q+z2tj72qFtjDF1ZpKMGs876=hRLpKTEwYKnpCMzdpErg@mail.gmail.com>
On Sun, 20 Jan 2013 18:35:51 -0500, Christoffer Dall
<c.dall@virtualopensystems.com> wrote:
> On Thu, Jan 17, 2013 at 10:55 AM, Marc Zyngier <marc.zyngier@arm.com>
> wrote:
>> On 16/01/13 17:59, Christoffer Dall wrote:
>>> From: Marc Zyngier <marc.zyngier@arm.com>
>>>
>>> Implement the PSCI specification (ARM DEN 0022A) to control
>>> virtual CPUs being "powered" on or off.
>>>
>>> PSCI/KVM is detected using the KVM_CAP_ARM_PSCI capability.
>>>
>>> A virtual CPU can now be initialized in a "powered off" state,
>>> using the KVM_ARM_VCPU_POWER_OFF feature flag.
>>>
>>> The guest can use either SMC or HVC to execute a PSCI function.
>>>
>>> Reviewed-by: Will Deacon <will.deacon@arm.com>
>>> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
>>> Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
>>
>> A few bits went wrong when you reworked this patch. See below.
[...]
>>> @@ -443,13 +445,17 @@ static int handle_hvc(struct kvm_vcpu *vcpu,
>>> struct kvm_run *run)
>>> trace_kvm_hvc(*vcpu_pc(vcpu), *vcpu_reg(vcpu, 0),
>>> vcpu->arch.hsr & HSR_HVC_IMM_MASK);
>>>
>>> + if (kvm_psci_call(vcpu))
>>> + return 1;
>>> +
>>> return 1;
>>
>> No undef injection if there is no PSCI match?
You haven't addressed this issue in you patch.
[...]
> Thanks, see this patch:
>
> diff --git a/arch/arm/include/asm/kvm_host.h
> b/arch/arm/include/asm/kvm_host.h
> index 751aa86..d1736a5 100644
> --- a/arch/arm/include/asm/kvm_host.h
> +++ b/arch/arm/include/asm/kvm_host.h
> @@ -113,7 +113,7 @@ struct kvm_vcpu_arch {
> int last_pcpu;
> cpumask_t require_dcache_flush;
>
> - /* Don't run the guest: see copy_current_insn() */
> + /* Don't run the guest on this vcpu */
> bool pause;
>
> /* IO related fields */
> diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
> index a67392a..2819575 100644
> --- a/arch/arm/kvm/arm.c
> +++ b/arch/arm/kvm/arm.c
> @@ -502,7 +502,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu,
> struct kvm_run *run)
>
> static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run)
> {
> - if (!kvm_psci_call(vcpu))
> + if (kvm_psci_call(vcpu))
> return 1;
>
> kvm_inject_undefined(vcpu);
> @@ -667,6 +667,13 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu
> *vcpu)
> return 0;
> }
>
> +static void vcpu_pause(struct kvm_vcpu *vcpu)
> +{
> + wait_queue_head_t *wq = kvm_arch_vcpu_wq(vcpu);
> +
> + wait_event_interruptible(*wq, !vcpu->arch.pause);
> +}
> +
> /**
> * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute
guest
> code
> * @vcpu: The VCPU pointer
> @@ -710,6 +717,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu,
> struct kvm_run *run)
>
> update_vttbr(vcpu->kvm);
>
> + if (vcpu->arch.pause)
> + vcpu_pause(vcpu);
> +
> kvm_vgic_flush_hwstate(vcpu);
> kvm_timer_flush_hwstate(vcpu);
>
> @@ -737,13 +747,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu
> *vcpu, struct kvm_run *run)
> kvm_guest_enter();
> vcpu->mode = IN_GUEST_MODE;
>
> - smp_mb(); /* set mode before reading vcpu->arch.pause */
> - if (unlikely(vcpu->arch.pause)) {
> - /* This means ignore, try again. */
> - ret = ARM_EXCEPTION_IRQ;
> - } else {
> - ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);
> - }
> + ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);
>
> vcpu->mode = OUTSIDE_GUEST_MODE;
> vcpu->arch.last_pcpu = smp_processor_id();
> diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c
> index 6be3687..d833604 100644
> --- a/arch/arm/kvm/psci.c
> +++ b/arch/arm/kvm/psci.c
> @@ -28,11 +28,7 @@
>
> static void kvm_psci_vcpu_off(struct kvm_vcpu *vcpu)
> {
> - wait_queue_head_t *wq = kvm_arch_vcpu_wq(vcpu);
> -
> vcpu->arch.pause = true;
> -
> - wait_event_interruptible(*wq, !vcpu->arch.pause);
> }
>
> static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
Assuming you fix the above, it looks OK to me.
M.
--
Fast, cheap, reliable. Pick two.
next prev parent reply other threads:[~2013-01-21 10:04 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 17:57 [PATCH v6 00/15] KVM/ARM Implementation Christoffer Dall
2013-01-16 17:57 ` [PATCH v6 01/15] ARM: Add page table and page defines needed by KVM Christoffer Dall
2013-01-24 11:39 ` Catalin Marinas
2013-01-24 16:05 ` Christoffer Dall
2013-01-24 17:02 ` Catalin Marinas
2013-01-24 17:04 ` Christoffer Dall
2013-01-24 17:13 ` Catalin Marinas
2013-01-24 17:25 ` Christoffer Dall
2013-01-16 17:57 ` [PATCH v6 02/15] ARM: Section based HYP idmap Christoffer Dall
2013-01-24 14:32 ` Catalin Marinas
2013-01-24 16:36 ` Christoffer Dall
2013-01-24 17:05 ` Catalin Marinas
2013-01-24 17:10 ` Christoffer Dall
2013-01-16 17:57 ` [PATCH v6 03/15] KVM: ARM: Initial skeleton to compile KVM support Christoffer Dall
2013-01-16 17:57 ` [PATCH v6 04/15] KVM: ARM: Hypervisor initialization Christoffer Dall
2013-01-24 15:45 ` Catalin Marinas
2013-01-24 16:52 ` Christoffer Dall
2013-01-16 17:57 ` [PATCH v6 05/15] KVM: ARM: Memory virtualization setup Christoffer Dall
2013-01-16 17:58 ` [PATCH v6 06/15] KVM: ARM: Inject IRQs and FIQs from userspace Christoffer Dall
2013-01-16 17:58 ` [PATCH v6 07/15] KVM: ARM: World-switch implementation Christoffer Dall
2013-01-16 17:58 ` [PATCH v6 08/15] KVM: ARM: Emulation framework and CP15 emulation Christoffer Dall
2013-01-16 17:58 ` [PATCH v6 09/15] trom: Christoffer Dall <c.dall@virtualopensystems.com> Christoffer Dall
2013-01-16 18:14 ` [RESEND PATCH v6 09/15] KVM: ARM: User space API for getting/setting co-proc registers Christoffer Dall
2013-01-16 17:58 ` [PATCH v6 10/15] KVM: ARM: Demux CCSIDR in the userspace API Christoffer Dall
2013-01-16 17:58 ` [PATCH v6 11/15] KVM: ARM: VFP userspace interface Christoffer Dall
2013-01-16 17:59 ` [PATCH v6 12/15] KVM: ARM: Handle guest faults in KVM Christoffer Dall
2013-01-16 17:59 ` [PATCH v6 13/15] KVM: ARM: Handle I/O aborts Christoffer Dall
2013-01-17 16:37 ` Marc Zyngier
2013-01-17 17:07 ` Christoffer Dall
2013-01-16 17:59 ` [PATCH v6 14/15] KVM: ARM: Power State Coordination Interface implementation Christoffer Dall
2013-01-17 15:55 ` Marc Zyngier
2013-01-20 23:35 ` Christoffer Dall
2013-01-21 10:04 ` Marc Zyngier [this message]
2013-01-21 14:50 ` [kvmarm] " Christoffer Dall
2013-01-21 17:43 ` Marc Zyngier
2013-01-21 17:54 ` Christoffer Dall
2013-01-21 18:08 ` Marc Zyngier
2013-01-21 18:17 ` Peter Maydell
2013-01-21 18:20 ` Christoffer Dall
2013-01-21 13:52 ` Gleb Natapov
2013-01-16 17:59 ` [PATCH v6 15/15] KVM: ARM: Add maintainer entry for KVM/ARM Christoffer Dall
2013-01-17 16:26 ` Will Deacon
2013-01-20 22:57 ` Christoffer Dall
2013-01-24 16:26 ` [PATCH v6 00/15] KVM/ARM Implementation Catalin Marinas
2013-01-24 16:36 ` Christoffer Dall
2013-01-24 17:14 ` Gleb Natapov
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=75f43582106716efe7c8f1360e58732e@localhost \
--to=marc.zyngier@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).