@@ -56,6 +56,7 @@
#include <asm/debugreg.h>
#include <asm/msr.h>
#include <asm/traps.h>
+#include <asm/vm_event.h>
#include <asm/nmi.h>
#include <asm/mce.h>
#include <asm/amd.h>
@@ -492,8 +493,7 @@ int vcpu_initialise(struct vcpu *v)
void vcpu_destroy(struct vcpu *v)
{
- xfree(v->arch.vm_event);
- v->arch.vm_event = NULL;
+ vm_event_cleanup_vcpu_destroy(v);
if ( is_pv_32bit_vcpu(v) )
{
@@ -67,10 +67,7 @@ void vm_event_cleanup_domain(struct domain *d, struct vm_event_domain *ved)
/* Per-vcpu uninitializations. */
for_each_vcpu ( d, v )
- {
- xfree(v->arch.vm_event);
- v->arch.vm_event = NULL;
- }
+ vm_event_cleanup_vcpu_destroy(v);
d->arch.mem_access_emulate_each_rep = 0;
}
@@ -35,6 +35,16 @@ int vm_event_init_domain(struct domain *d, struct vm_event_domain *ved);
void vm_event_cleanup_domain(struct domain *d, struct vm_event_domain *ved);
+/* Called on vCPU destroy. */
+static inline void vm_event_cleanup_vcpu_destroy(struct vcpu *v)
+{
+ if ( likely(!v->arch.vm_event) )
+ return;
+
+ xfree(v->arch.vm_event);
+ v->arch.vm_event = NULL;
+}
+
void vm_event_toggle_singlestep(struct domain *d, struct vcpu *v);
void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp);
Move vm-event cleanup sequence on vcpu destroyal to vm_event.h along with the other vm-event functions. Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com> --- xen/arch/x86/domain.c | 4 ++-- xen/arch/x86/vm_event.c | 5 +---- xen/include/asm-x86/vm_event.h | 10 ++++++++++ 3 files changed, 13 insertions(+), 6 deletions(-)