From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Jones <drjones@redhat.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
David Vrabel <david.vrabel@citrix.com>,
Jan Beulich <JBeulich@suse.com>
Subject: [PATCH RFCv2 1/1] Introduce VCPUOP_reset_vcpu_info
Date: Thu, 14 Aug 2014 10:28:02 +0200 [thread overview]
Message-ID: <1408004882-7256-2-git-send-email-vkuznets@redhat.com> (raw)
In-Reply-To: <1408004882-7256-1-git-send-email-vkuznets@redhat.com>
When an SMP guest performs kexec/kdump it tries issuing VCPUOP_register_vcpu_info.
This fails due to vcpu_info already being registered. Introduce new vcpu operation
to reset vcpu_info to its default state.
Based on the original patch by Konrad Rzeszutek Wilk.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
Changes from RFCv1:
- Don't use unsuitable unmap_vcpu_info(), rewrite [Jan Beulich]
- Require FIFO ABI being in 2-level mode
- Describe limitations in include/public/vcpu.h [Jan Beulich]
---
xen/arch/x86/hvm/hvm.c | 1 +
xen/common/domain.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
xen/include/public/vcpu.h | 14 +++++++++++
3 files changed, 76 insertions(+)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 216c3f2..7917272 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3332,6 +3332,7 @@ static long hvm_vcpu_op(
case VCPUOP_set_singleshot_timer:
case VCPUOP_stop_singleshot_timer:
case VCPUOP_register_vcpu_info:
+ case VCPUOP_reset_vcpu_info:
case VCPUOP_register_vcpu_time_memory_area:
rc = do_vcpu_op(cmd, vcpuid, arg);
break;
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 44e5cbe..889c313 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1116,6 +1116,67 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
break;
}
+ case VCPUOP_reset_vcpu_info:
+ {
+ vcpu_info_t *old_info;
+ unsigned int i;
+
+ if ( !test_bit(_VPF_down, &v->pause_flags) )
+ {
+ printk(XENLOG_G_WARNING
+ "%pv: VCPU is up, refusing to reset vcpu_info!\n", v);
+ return -EBUSY;
+ }
+
+ if ( v->evtchn_fifo )
+ {
+ printk(XENLOG_G_WARNING "%pv: FIFO evtchn ABI is being used,"
+ "refusing to reset vcpu_info!\n", v);
+ return -EBUSY;
+ }
+
+ if ( v->vcpu_info_mfn == INVALID_MFN )
+ {
+ rc = 0;
+ break;
+ }
+
+ domain_lock(d);
+ old_info = v->vcpu_info;
+
+ if ( vcpuid < XEN_LEGACY_MAX_VCPUS )
+ {
+ memcpy(&shared_info(d, vcpu_info[vcpuid]), v->vcpu_info,
+ sizeof(vcpu_info_t));
+ v->vcpu_info = (vcpu_info_t *)&shared_info(d, vcpu_info[vcpuid]);
+ }
+ else
+ {
+ v->vcpu_info = &dummy_vcpu_info;
+ }
+ unmap_domain_page_global((void *)
+ ((unsigned long)old_info & PAGE_MASK));
+
+ put_page_and_type(mfn_to_page(v->vcpu_info_mfn));
+ v->vcpu_info_mfn = INVALID_MFN;
+
+ /* Make sure vcpu_info was set */
+ smp_wmb();
+
+ if ( vcpuid < XEN_LEGACY_MAX_VCPUS )
+ {
+ /*
+ * Mark everything as being pending to make sure nothing gets lost.
+ */
+ vcpu_info(v, evtchn_upcall_pending) = 1;
+ for ( i = 0; i < BITS_PER_EVTCHN_WORD(d); i++ )
+ set_bit(i, &vcpu_info(v, evtchn_pending_sel));
+ }
+ domain_unlock(d);
+ rc = 0;
+ break;
+ }
+
case VCPUOP_register_runstate_memory_area:
{
struct vcpu_register_runstate_memory_area area;
diff --git a/xen/include/public/vcpu.h b/xen/include/public/vcpu.h
index e888daf..81bc1b9 100644
--- a/xen/include/public/vcpu.h
+++ b/xen/include/public/vcpu.h
@@ -227,6 +227,20 @@ struct vcpu_register_time_memory_area {
typedef struct vcpu_register_time_memory_area vcpu_register_time_memory_area_t;
DEFINE_XEN_GUEST_HANDLE(vcpu_register_time_memory_area_t);
+/*
+ * Reset all of the vcpu_info information from their previous location
+ * to the default one used at bootup. The following prerequisites should be met:
+ * 1. VCPU should be switched off. This means the operation is unsupported for
+ * boot VCPU.
+ * 2. Domain should not be using FIFO-based event channel ABI. In case it is in
+ * use domain is supposed to switch back to 2-level ABI with EVTCHNOP_reset.
+ *
+ * After the call vcpu_info is reset to its default state: first
+ * XEN_LEGACY_MAX_VCPUS VCPUs will get it switched to shared_info and all other
+ * VCPUs will get dummy_vcpu_info.
+ */
+#define VCPUOP_reset_vcpu_info 14
+
#endif /* __XEN_PUBLIC_VCPU_H__ */
/*
--
1.9.3
next prev parent reply other threads:[~2014-08-14 8:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-14 8:28 [PATCH RFCv2 0/1] Introduce VCPUOP_reset_vcpu_info Vitaly Kuznetsov
2014-08-14 8:28 ` Vitaly Kuznetsov [this message]
2014-08-14 23:25 ` [PATCH RFCv2 1/1] " Jan Beulich
2014-08-15 9:55 ` Vitaly Kuznetsov
2014-08-15 15:07 ` Jan Beulich
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=1408004882-7256-2-git-send-email-vkuznets@redhat.com \
--to=vkuznets@redhat.com \
--cc=JBeulich@suse.com \
--cc=david.vrabel@citrix.com \
--cc=drjones@redhat.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).