From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/3] KVM: VMX: Fix for kexec VMCLEAR and VMXON cleanup
Date: Sat, 21 Mar 2020 12:37:48 -0700 [thread overview]
Message-ID: <20200321193751.24985-1-sean.j.christopherson@intel.com> (raw)
Patch 1 fixes a a theoretical bug where a crashdump NMI that arrives
while KVM is messing with the percpu VMCS list would result in one or more
VMCSes not being cleared, potentially causing memory corruption in the new
kexec'd kernel.
Patch 2 is cleanup that's made possible by patch 1.
Patch 3 isn't directly related, but it conflicts with the crash cleanup
changes, both from a code and a semantics perspective. Without the crash
cleanup, IMO hardware_enable() should do crash_disable_local_vmclear()
if VMXON fails, i.e. clean up after itself. But hardware_disable()
doesn't even do crash_disable_local_vmclear() (which is what got me
looking at that code in the first place). Basing the VMXON change on top
of the crash cleanup avoids the debate entirely.
v2:
- Inverted the code flow, i.e. move code from loaded_vmcs_init() to
__loaded_vmcs_clear(). Trying to share loaded_vmcs_init() with
alloc_loaded_vmcs() was taking more code than it saved. [Paolo]
Gory details on the crashdump bug:
I verified my analysis of the NMI bug by simulating what would happen if
an NMI arrived in the middle of list_add() and list_del(). The below
output matches expectations, e.g. nothing hangs, the entry being added
doesn't show up, and the entry being deleted _does_ show up.
[ 8.205898] KVM: testing NMI in list_add()
[ 8.205898] KVM: testing NMI in list_del()
[ 8.205899] KVM: found e3
[ 8.205899] KVM: found e2
[ 8.205899] KVM: found e1
[ 8.205900] KVM: found e3
[ 8.205900] KVM: found e1
static void vmx_test_list(struct list_head *list, struct list_head *e1,
struct list_head *e2, struct list_head *e3)
{
struct list_head *tmp;
list_for_each(tmp, list) {
if (tmp == e1)
pr_warn("KVM: found e1\n");
else if (tmp == e2)
pr_warn("KVM: found e2\n");
else if (tmp == e3)
pr_warn("KVM: found e3\n");
else
pr_warn("KVM: kaboom\n");
}
}
static int __init vmx_init(void)
{
LIST_HEAD(list);
LIST_HEAD(e1);
LIST_HEAD(e2);
LIST_HEAD(e3);
pr_warn("KVM: testing NMI in list_add()\n");
list.next->prev = &e1;
vmx_test_list(&list, &e1, &e2, &e3);
e1.next = list.next;
vmx_test_list(&list, &e1, &e2, &e3);
e1.prev = &list;
vmx_test_list(&list, &e1, &e2, &e3);
INIT_LIST_HEAD(&list);
INIT_LIST_HEAD(&e1);
list_add(&e1, &list);
list_add(&e2, &list);
list_add(&e3, &list);
pr_warn("KVM: testing NMI in list_del()\n");
e3.prev = &e1;
vmx_test_list(&list, &e1, &e2, &e3);
list_del(&e2);
list.prev = &e1;
vmx_test_list(&list, &e1, &e2, &e3);
}
Sean Christopherson (3):
KVM: VMX: Always VMCLEAR in-use VMCSes during crash with kexec support
KVM: VMX: Fold loaded_vmcs_init() into alloc_loaded_vmcs()
KVM: VMX: Gracefully handle faults on VMXON
arch/x86/kvm/vmx/vmx.c | 103 ++++++++++++++++-------------------------
arch/x86/kvm/vmx/vmx.h | 1 -
2 files changed, 40 insertions(+), 64 deletions(-)
--
2.24.1
next reply other threads:[~2020-03-21 19:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-21 19:37 Sean Christopherson [this message]
2020-03-21 19:37 ` [PATCH v2 1/3] KVM: VMX: Always VMCLEAR in-use VMCSes during crash with kexec support Sean Christopherson
2020-03-21 19:37 ` [PATCH v2 2/3] KVM: VMX: Fold loaded_vmcs_init() into alloc_loaded_vmcs() Sean Christopherson
2020-03-22 13:08 ` Vitaly Kuznetsov
2020-03-21 19:37 ` [PATCH v2 3/3] KVM: VMX: Gracefully handle faults on VMXON Sean Christopherson
2020-03-22 13:37 ` Vitaly Kuznetsov
2020-04-07 11:01 ` [PATCH v2 0/3] KVM: VMX: Fix for kexec VMCLEAR and VMXON cleanup Baoquan He
2020-04-07 12:04 ` Vitaly Kuznetsov
2020-04-08 15:18 ` Baoquan He
2020-04-08 19:44 ` Vitaly Kuznetsov
2020-04-09 1:20 ` Baoquan He
2020-04-09 11:14 ` Vitaly Kuznetsov
2020-04-09 12:57 ` Baoquan He
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=20200321193751.24985-1-sean.j.christopherson@intel.com \
--to=sean.j.christopherson@intel.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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
all inboxes | Powered by JetHome®