public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Avi Kivity <avi@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Joerg Roedel <joerg.roedel@amd.com>,
	Benjamin Serebrin <benjamin.serebrin@amd.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	kvm@vger.kernel.org, Alexander Graf <agraf@suse.de>,
	Arjan van de Ven <arjan@infradead.org>,
	Alexander van Heukelum <heukelum@fastmail.fm>
Subject: Re: kvm vmload/vmsave vs tss.ist
Date: Thu, 25 Dec 2008 19:18:10 +0100	[thread overview]
Message-ID: <20081225181810.GA1548@elte.hu> (raw)
In-Reply-To: <4953CD1A.5090906@redhat.com>


* Avi Kivity <avi@redhat.com> wrote:

> Ingo Molnar wrote:
>>> I think it's enough to switch %rsp before incrementing irqcount, no?
>>>     
>>
>> no - that would introduce a small race: if an exception (say an NMI or  
>> MCE, or a debug trap) happens in that small window then the exception  
>> context thinks that it's on the IRQ stack already, and would use the 
>> task stack.
>>
>>   
>
> I'm suggesting
>
>    check irqcount
>    if (wasnt_in_irq)
>        rsp = irqstack
>    ++irqcount
>
> If the NMI happens before the increment, we'll switch the stack 
> unconditionally, and if the NMI happens after the increment, then we 
> won't switch the stack, but we're guaranteed to be on the irqstack 
> anyway.  The window size is negative :)
>
> Similarly, the exit path should be
>
>    oldstack_reg = oldstack;
>    --irqcount;
>    rsp = oldstack_register;
>
> To guarantee that by the time we decrement irqcount, we don't need the  
> stack anymore.

agreed, something like this would work too. My suggestion, to eliminate 
irqcount altogether and just check RSP against the known-irqstack-range, 
could result in slightly smaller (and thus faster) code, but it's a 
marginal difference at best.

	Ingo

  reply	other threads:[~2008-12-25 18:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-25 14:59 kvm vmload/vmsave vs tss.ist Avi Kivity
2008-12-25 15:17 ` Ingo Molnar
2008-12-25 15:46   ` Avi Kivity
2008-12-25 16:21     ` Ingo Molnar
2008-12-25 16:42       ` Ingo Molnar
2008-12-25 17:40         ` Avi Kivity
2008-12-25 17:58           ` Ingo Molnar
2008-12-25 18:12             ` Avi Kivity
2008-12-25 18:18               ` Ingo Molnar [this message]
2008-12-25 18:19               ` 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=20081225181810.GA1548@elte.hu \
    --to=mingo@elte.hu \
    --cc=agraf@suse.de \
    --cc=arjan@infradead.org \
    --cc=avi@redhat.com \
    --cc=benjamin.serebrin@amd.com \
    --cc=heukelum@fastmail.fm \
    --cc=hpa@zytor.com \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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