From: Jan Kiszka <jan.kiszka@web.de>
To: Gleb Natapov <gleb@qumranet.com>
Cc: kvm-devel <kvm@vger.kernel.org>,
"Yang, Sheng" <sheng.yang@intel.com>,
Avi Kivity <avi@qumranet.com>
Subject: Re: [PATCH 8/9] VMX: work around lacking VNMI support
Date: Mon, 22 Sep 2008 09:48:15 +0200 [thread overview]
Message-ID: <48D74DBF.8060309@web.de> (raw)
In-Reply-To: <20080922073958.GD27089@minantech.com>
[-- Attachment #1: Type: text/plain, Size: 3135 bytes --]
Gleb Natapov wrote:
> On Mon, Sep 22, 2008 at 09:19:27AM +0200, Jan Kiszka wrote:
>> Gleb Natapov wrote:
>>> On Sun, Sep 21, 2008 at 06:57:32PM +0200, Jan Kiszka wrote:
>>>> Gleb Natapov wrote:
>>>>> Hi Jan,
>>>>>
>>>>> On Fri, Sep 19, 2008 at 02:04:37PM +0200, Jan Kiszka wrote:
>>>>>> static void vmx_inject_irq(struct kvm_vcpu *vcpu, int irq)
>>>>>> {
>>>>>> struct vcpu_vmx *vmx = to_vmx(vcpu);
>>>>>> @@ -2356,6 +2384,29 @@ static void vmx_inject_nmi(struct kvm_vc
>>>>>> {
>>>>>> struct vcpu_vmx *vmx = to_vmx(vcpu);
>>>>>>
>>>>>> + if (!cpu_has_virtual_nmis()) {
>>>>>> + int desc_size = is_long_mode(vcpu) ? 16 : 8;
>>>>>> + struct descriptor_table dt;
>>>>>> + gpa_t gpa;
>>>>>> + u64 desc;
>>>>>> +
>>>>>> + /*
>>>>>> + * Deny delivery if the NMI will not be handled by an
>>>>>> + * interrupt gate (workaround depends on IRQ masking).
>>>>>> + */
>>>>>> + vmx_get_idt(vcpu, &dt);
>>>>>> + if (!vcpu->arch.rmode.active && dt.limit
>>>>>> + >= desc_size * (NMI_VECTOR + 1) - 1) {
>>>>>> + gpa = vcpu->arch.mmu.gva_to_gpa(vcpu,
>>>>>> + dt.base + desc_size * NMI_VECTOR);
>>>>>> + if (kvm_read_guest(vcpu->kvm, gpa, &desc, 8) == 0
>>>>>> + && ((desc >> 40) & 0x7) != 0x6)
>>>>>> + return;
>>>>>> + }
>>>>> Windows2003 sets NMI entry in IDT as a task gate (0x5) during hibernation and this check
>>>>> prevents it from shutting down itself. It hangs in "It is save to turn
>>>>> your computer now" screen.
>>>> Grmbl, what a weird guest...
>>> This is a known trick that some OSes use.
>> OK. Out of curiosity: What is that trick precisely?
>>
> As far as I understand it this way it can be guaranties that the handler
> will be executed with a known state. Here is the attempt to make linux
> do the same:
> http://marc.info/?l=linux-kernel&m=121638440618671&w=4
I see, dedicated stacks for intra-privilege level switching on good old
32-bit - makes sense.
>
>>>> Is this a regression of this patch because NMIs were considered broken
>>>> by Windows on that host CPU so far?
>>>>
>>> Nope. This is not a regression. Hibernation hangs in the same place with
>>> the current git on this machine. It works on newer CPUs.
>>>
>>>
>>>>> If I replace this part by:
>>>>> if(vmx->soft_vnmi_blocked)
>>>>> return;
>>>>> It shut itself down properly.
>>>> OK, but that almost always evaluates to false here.
>>> Without this check guest BSODs. CPU 0 send two NMI in a row to CPU 1 and
>>> if second one is accepted something goes wrong.
>> That should have been caught at the caller site of vmx_inject_nmi
>> already, having to catch it here is an indication of a deeper problem.
> I understand that. I am trying to find out why we are getting there with
> vmx->soft_vnmi_blocked == 1 at all.
Much appreciated.
>
>> Are you sure the NMIs are sent by CPU (i.e. kvm_inject_nmi is called
>> twice)?
> I am sure. I have a printk there :)
>
>> Maybe it is a bug I fixed meanwhile, an updated series goes out
>> later this morning.
> Will try it.
/me is preparing the posting now.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next prev parent reply other threads:[~2008-09-22 7:48 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-19 12:06 [PATCH 0/9] Enhance NMI support of KVM - v2 Jan Kiszka
2008-09-19 11:59 ` [PATCH 1/9] VMX: include all IRQ window exits in statistics Jan Kiszka
2008-09-19 12:01 ` [PATCH 2/9] VMX: refactor/fix IRQ and NMI injectability determination Jan Kiszka
2008-09-19 12:01 ` [PATCH 3/9] VMX: refactor IRQ and NMI window enabling Jan Kiszka
2008-09-19 12:02 ` [PATCH 4/9] VMX: fix real-mode NMI support Jan Kiszka
2008-09-19 12:03 ` [PATCH 5/9] kvm-x86: Enable NMI Watchdog via in-kernel PIT source Jan Kiszka
2008-09-19 16:55 ` Jan Kiszka
2008-09-23 6:10 ` Yang, Sheng
2008-09-23 15:04 ` Jan Kiszka
2008-09-24 10:18 ` Yang, Sheng
2008-09-19 12:03 ` [PATCH 6/9] kvm-x86: Support for user space injected NMIs Jan Kiszka
2008-09-19 12:03 ` [PATCH 7/9] VMX: Provide support " Jan Kiszka
2008-09-19 12:04 ` [PATCH 8/9] VMX: work around lacking VNMI support Jan Kiszka
2008-09-21 14:31 ` Gleb Natapov
2008-09-21 16:57 ` Jan Kiszka
2008-09-21 18:08 ` Jan Kiszka
2008-09-22 6:41 ` Gleb Natapov
2008-09-22 7:19 ` Jan Kiszka
2008-09-22 7:39 ` Gleb Natapov
2008-09-22 7:48 ` Jan Kiszka [this message]
2008-09-19 12:05 ` [PATCH 9/9] kvm: Enable NMI support for userspace irqchip Jan Kiszka
2008-09-19 12:10 ` [PATCH 0/9] Enhance NMI support of KVM - v2 Jan Kiszka
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=48D74DBF.8060309@web.de \
--to=jan.kiszka@web.de \
--cc=avi@qumranet.com \
--cc=gleb@qumranet.com \
--cc=kvm@vger.kernel.org \
--cc=sheng.yang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox