public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Gregory Haskins <ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 3/5] KVM: Adds ability to preepmt an	executing VCPU
Date: Tue, 24 Apr 2007 12:17:50 +0300	[thread overview]
Message-ID: <462DCB3E.6070802@qumranet.com> (raw)
In-Reply-To: <462C9B94.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>

Gregory Haskins wrote:
>>>> On Sun, Apr 22, 2007 at  4:50 AM, in message <462B21C7.2060007-atKUWr5tajBWk0Htik3J/w@public.gmane.org>,
>>>>         
> Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote: 
>   
>> Gregory Haskins wrote:
>>     
>>>  	/*
>>> +	 * Signal that we have transitioned back to host mode 
>>> +	 */
>>> +	spin_lock_irqsave(&vcpu- >irq.lock, irq_flags);
>>> +	vcpu- >irq.guest_mode = 0;
>>> +	spin_unlock_irqrestore(&vcpu- >irq.lock, irq_flags);
>>> +
>>>   
>>>       
>> You need to check for an interrupt here. Otherwise you might go back to 
>> user mode and sleep there, no?
>>     
>
>
> It's subtle, but I'm not sure if you need to or not.  I'm glad you brought it up because its something I wanted to talk about.  The case where interrupts are raised outside the guest_mode brackets is obviously handled since we inject a signal, so the area in question is while guest_mode  = 1.
>
> In the simple case, an async-interrupt comes in and sends an IPI to cause a VMEXIT.  The guest exits with an EXTERNAL_INTERRUPT exception (IIUC), and the current handler causes the system to loop back into the VMENTER code (and thus injecting the interrupt).
>   

Okay.

> If the guest exits because of HLT, this is also handled since the current handle_halt() code checks if there are pending interrupts first before allowing the halt.   If there are interrupts, its loops back into VMENTER.
>   

Okay.

> For other cases, (e.g. the guest is VMEXITing for a reason other than the IPI)  the guest may need some userspace assistance:  e.g. MMIO servicing, exception handling, etc..  In this case, looping back to VMENTER would be incorrect.  The current code already handles this correctly too.  However, the potential problem (as you pointed out) is if the userspace wants to sleep after servicing those types of requests, but doesn't realize that it cannot due to a pending interrupt.  I currently am not sure if this is a problem or not since halt is handled.  
>   

I'm not sure either.  It seems natural to assume that qemu will re-enter
the guest without sleeping except for hlt.

> Are there any other userspace sleeps that we need to handle (e.g. maybe AIO)?  If so, one way to handle this is to mark the exportable state of the VCPU such that userspace can tell if interrupts are pending.  However, I'm not really sure if this is the best way to do it or if it can be easily done in a way that doesn't break ABI compatiblity.  Please advise. 
>   

The ABI can be extended by adding fields to struct kvm_vcpu_run and an
extension check to indicate their availability.

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

  parent reply	other threads:[~2007-04-24  9:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-20  3:09 KVM: Patch series for in-kernel APIC support Gregory Haskins
     [not found] ` <20070420030905.12408.40403.stgit-5CR4LY5GPkvLDviKLk5550HKjMygAv58XqFh9Ls21Oc@public.gmane.org>
2007-04-20  3:09   ` [PATCH 1/5] Adds support for in-kernel mmio handlers Gregory Haskins
2007-04-20  3:09   ` [PATCH 2/5] KVM: Add irqdevice object Gregory Haskins
     [not found]     ` <20070420030916.12408.80159.stgit-5CR4LY5GPkvLDviKLk5550HKjMygAv58XqFh9Ls21Oc@public.gmane.org>
2007-04-22  8:42       ` Avi Kivity
     [not found]         ` <462B1FD8.4080004-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-23 13:58           ` Gregory Haskins
     [not found]             ` <462C8333.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-24  9:09               ` Avi Kivity
     [not found]                 ` <462DC954.1020400-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-26 14:37                   ` Gregory Haskins
     [not found]                     ` <463080C8.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-26 16:26                       ` Avi Kivity
2007-04-20  3:09   ` [PATCH 3/5] KVM: Adds ability to preepmt an executing VCPU Gregory Haskins
     [not found]     ` <20070420030921.12408.97321.stgit-5CR4LY5GPkvLDviKLk5550HKjMygAv58XqFh9Ls21Oc@public.gmane.org>
2007-04-22  8:50       ` Avi Kivity
     [not found]         ` <462B21C7.2060007-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-23 15:42           ` Gregory Haskins
     [not found]             ` <462C9B94.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-24  9:17               ` Avi Kivity [this message]
     [not found]                 ` <462DCB3E.6070802-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-26 14:40                   ` Gregory Haskins
2007-04-20  3:09   ` [PATCH 4/5] KVM: Local-APIC interface cleanup Gregory Haskins
     [not found]     ` <20070420030926.12408.27637.stgit-5CR4LY5GPkvLDviKLk5550HKjMygAv58XqFh9Ls21Oc@public.gmane.org>
2007-04-22  8:54       ` Avi Kivity
     [not found]         ` <462B22AE.4090108-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-23 15:55           ` Gregory Haskins
     [not found]             ` <462C9EAE.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-04-24  9:26               ` Avi Kivity
     [not found]                 ` <462DCD31.4030108-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-26 14:43                   ` Gregory Haskins
2007-04-20  3:09   ` [PATCH 5/5] KVM: Add support for in-kernel LAPIC model Gregory Haskins
     [not found]     ` <20070420030931.12408.88158.stgit-5CR4LY5GPkvLDviKLk5550HKjMygAv58XqFh9Ls21Oc@public.gmane.org>
2007-04-22  9:04       ` Avi Kivity
     [not found]         ` <462B250E.6050603-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-23 15:57           ` Gregory Haskins
2007-04-22  9:06   ` KVM: Patch series for in-kernel APIC support 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=462DCB3E.6070802@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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