Skip to contentSkip to conversation

x86/hvm: assert that we we saved a sane number of MSRs.

PATCH In review Tim Deegan 2 participants 2 messages Feb 27, 2014 – Feb 28, 2014

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

PATCH 1/1 x86/hvm: assert that we we saved a sane number of MSRs.

Just as a backstop measure against later changes that add MSRs to the save function without updating the count in the init function.

---
 xen/arch/x86/hvm/hvm.c | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/hvm/hvm.c +2 -0
index 9e85c13..ae24211 100644
@@ -1148,6 +1148,8 @@ static int hvm_save_cpu_msrs(struct domain *d, hvm_domain_context_t *h)
         if ( hvm_funcs.save_msr )
             hvm_funcs.save_msr(v, ctxt);
 
+        ASSERT(ctxt->count <= msr_count_max);
+
         for ( i = 0; i < ctxt->count; ++i )
             ctxt->msr[i]._rsvd = 0;
 
Signature · 1 line
1.8.5.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Tim Deegan

Just as a backstop measure against later changes that add MSRs to the save function without updating the count in the init function.

Quoted 19 lines
---
 xen/arch/x86/hvm/hvm.c | 2 ++
 1 file changed, 2 insertions(+)
xen/arch/x86/hvm/hvm.c +2 -0
index 9e85c13..ae24211 100644
@@ -1148,6 +1148,8 @@ static int hvm_save_cpu_msrs(struct domain *d, hvm_domain_context_t *h)
         if ( hvm_funcs.save_msr )
             hvm_funcs.save_msr(v, ctxt);
 
+        ASSERT(ctxt->count <= msr_count_max);
+
         for ( i = 0; i < ctxt->count; ++i )
             ctxt->msr[i]._rsvd = 0;
 
Signature · 1 line
1.8.5.2