From: Avi Kivity <avi@redhat.com>
To: Christoffer Dall <cdall@cs.columbia.edu>
Cc: kvm@vger.kernel.org, catalin.marinas@arm.com,
tech@virtualopensystems.com, android-virt@lists.cs.columbia.edu
Subject: Re: [PATCH v4 06/10] ARM: KVM: World-switch implementation
Date: Tue, 09 Aug 2011 14:09:16 +0300 [thread overview]
Message-ID: <4E41155C.1070909@redhat.com> (raw)
In-Reply-To: <20110806103941.27198.33157.stgit@localhost6.localdomain6>
On 08/06/2011 01:39 PM, Christoffer Dall wrote:
> Provides complete world-switch implementation to switch to other guests
> runinng in non-secure modes. Includes Hyp exception handlers that
> captures necessary exception information and stores the information on
> the VCPU and KVM structures.
>
> Switching to Hyp mode is done through a simple HVC instructions. The
> exception vector code will check that the HVC comes from VMID==0 and if
> so will store the necessary state on the Hyp stack, which will look like
> this (see hyp_hvc):
> ...
> Hyp_Sp + 4: lr_usr
> Hyp_Sp : spsr (Host-SVC cpsr)
>
> When returning from Hyp mode to SVC mode, another HVC instruction is
> executed from Hyp mode, which is taken in the Hyp_Svc handler. The Hyp
> stack pointer should be where it was left from the above initial call,
> since the values on the stack will be used to restore state (see
> hyp_svc).
>
> Otherwise, the world-switch is pretty straight-forward. All state that
> can be modified by the guest is first backed up on the Hyp stack and the
> VCPU values is loaded onto the hardware. State, which is not loaded, but
> theoretically modifiable by the guest is protected through the
> virtualiation features to generate a trap and cause software emulation.
> Upon guest returns, all state is restored from hardware onto the VCPU
> struct and the original state is restored from the Hyp-stack onto the
> hardware.
>
> One controversy may be the back-door call to __irq_svc (the host
> kernel's own physical IRQ handler) which is called when a physical IRQ
> exception is taken in Hyp mode while running in the guest.
>
>
> void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
> {
> + unsigned long start, end;
> +
> latest_vcpu = NULL;
> - KVMARM_NOT_IMPLEMENTED();
> +
> + start = (unsigned long)vcpu,
> + end = start + sizeof(struct kvm_vcpu);
> + remove_hyp_mappings(kvm_hyp_pgd, start, end);
What if vcpu shares a page with another mapped structure?
> +
> + kmem_cache_free(kvm_vcpu_cache, vcpu);
> }
> return 0;
> }
>
> +/**
> + * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code
> + * @vcpu: The VCPU pointer
> + * @run: The kvm_run structure pointer used for userspace state exchange
> + *
> + * This function is called through the VCPU_RUN ioctl called from user space. It
> + * will execute VM code in a loop until the time slice for the process is used
> + * or some emulation is needed from user space in which case the function will
> + * return with return value 0 and with the kvm_run structure filled in with the
> + * required data for the requested emulation.
> + */
> int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
> {
> - KVMARM_NOT_IMPLEMENTED();
> - return -EINVAL;
> + unsigned long flags;
> + int ret;
> +
> + for (;;) {
> + trace_kvm_entry(vcpu->arch.regs.pc);
> + debug_ws_enter(vcpu->arch.regs.pc);
why both trace_kvm and debug_ws?
> + kvm_guest_enter();
> +
> + local_irq_save(flags);
local_irq_disable() is likely sufficient - the call path never changes.
> + ret = __kvm_vcpu_run(vcpu);
> + local_irq_restore(flags);
> +
> + kvm_guest_exit();
> + debug_ws_exit(vcpu->arch.regs.pc);
> + trace_kvm_exit(vcpu->arch.regs.pc);
> + }
> +
> + return ret;
> }
>
>
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-08-09 11:09 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-06 10:38 [PATCH v4 00/10] KVM/ARM Implementation Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 01/10] ARM: KVM: Initial skeleton to compile KVM support Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 02/10] ARM: KVM: Hypervisor identity mapping Christoffer Dall
2011-08-09 9:20 ` Avi Kivity
2011-08-09 9:29 ` Catalin Marinas
2011-08-09 9:29 ` Christoffer Dall
2011-08-09 10:23 ` [Android-virt] " Alexey Smirnov
2011-08-09 11:23 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 03/10] ARM: KVM: Add hypervisor inititalization Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 04/10] ARM: KVM: Memory virtualization setup Christoffer Dall
2011-08-09 9:57 ` Avi Kivity
2011-08-09 11:24 ` [Android-virt] " Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 05/10] ARM: KVM: Inject IRQs and FIQs from userspace Christoffer Dall
2011-08-09 10:07 ` Avi Kivity
2011-08-09 11:27 ` [Android-virt] " Christoffer Dall
2011-08-09 11:37 ` Avi Kivity
2011-08-09 11:40 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 06/10] ARM: KVM: World-switch implementation Christoffer Dall
2011-08-09 11:09 ` Avi Kivity [this message]
2011-08-09 11:29 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 07/10] ARM: KVM: Emulation framework and CP15 emulation Christoffer Dall
2011-08-09 11:17 ` Avi Kivity
2011-08-09 11:34 ` Christoffer Dall
2011-08-09 11:39 ` Avi Kivity
2011-08-09 11:40 ` Christoffer Dall
2011-08-06 10:39 ` [PATCH v4 08/10] ARM: KVM: Handle guest faults in KVM Christoffer Dall
2011-08-09 11:24 ` Avi Kivity
2011-08-09 11:35 ` Christoffer Dall
2011-08-06 10:40 ` [PATCH v4 09/10] ARM: KVM: Handle I/O aborts Christoffer Dall
2011-08-09 11:34 ` Avi Kivity
2011-08-09 11:39 ` Christoffer Dall
2011-08-09 11:46 ` Avi Kivity
2011-08-06 10:40 ` [PATCH v4 10/10] ARM: KVM: Guest wait-for-interrupts (WFI) support Christoffer Dall
2011-08-09 11:43 ` [PATCH v4 00/10] KVM/ARM Implementation Avi Kivity
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=4E41155C.1070909@redhat.com \
--to=avi@redhat.com \
--cc=android-virt@lists.cs.columbia.edu \
--cc=catalin.marinas@arm.com \
--cc=cdall@cs.columbia.edu \
--cc=kvm@vger.kernel.org \
--cc=tech@virtualopensystems.com \
/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.