Skip to contentSkip to conversation

hvm/hpet: Alter hpet_init() to take a domain rather than vcpu

PATCH In review Andrew Cooper 2 participants 3 messages Jul 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hvm/hpet: Alter hpet_init() to take a domain rather than vcpu

There is nothing vcpu-specific about hpet_init(); all it does is follow the vcpu's domain pointer to get at the domain vhpet state.

---

Despite the comment in scope in hvm_vcpu_initialise(), the call can't currently be moved to hvm_domain_initialise() as the extra hpet_deinit() (in an error path) needs an allocated vcpu which wouldn't be present at that point. I need more tuits to disentangle that mess.

---
 xen/arch/x86/hvm/hpet.c       |    6 +++---
 xen/arch/x86/hvm/hvm.c        |    2 +-
 xen/include/asm-x86/hvm/vpt.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
xen/arch/x86/hvm/hpet.c +3 -3
index 167994e..81ad0d6 100644
@@ -611,9 +611,9 @@ static int hpet_load(struct domain *d, hvm_domain_context_t *h)
 
 HVM_REGISTER_SAVE_RESTORE(HPET, hpet_save, hpet_load, 1, HVMSR_PER_DOM);
 
-void hpet_init(struct vcpu *v)
+void hpet_init(struct domain *d)
 {
-    HPETState *h = vcpu_vhpet(v);
+    HPETState *h = domain_vhpet(d);
     int i;
 
     memset(h, 0, sizeof(HPETState));
@@ -665,7 +665,7 @@ void hpet_deinit(struct domain *d)
 void hpet_reset(struct domain *d)
 {
     hpet_deinit(d);
-    hpet_init(d->vcpu[0]);
+    hpet_init(d);
 }
 
 /*
xen/arch/x86/hvm/hvm.c +1 -1
index 51011ea..14db6dc 100644
@@ -2282,7 +2282,7 @@ int hvm_vcpu_initialise(struct vcpu *v)
     {
         /* NB. All these really belong in hvm_domain_initialise(). */
         pmtimer_init(v);
-        hpet_init(v);
+        hpet_init(d);
  
         /* Init guest TSC to start from zero. */
         hvm_set_guest_tsc(v, 0);
xen/include/asm-x86/hvm/vpt.h +1 -1
index 41159d8..105fbdb 100644
@@ -190,7 +190,7 @@ void pmtimer_deinit(struct domain *d);
 void pmtimer_reset(struct domain *d);
 int pmtimer_change_ioport(struct domain *d, unsigned int version);
 
-void hpet_init(struct vcpu *v);
+void hpet_init(struct domain *d);
 void hpet_deinit(struct domain *d);
 void hpet_reset(struct domain *d);
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 15:19, <[email protected]> wrote:

There is nothing vcpu-specific about hpet_init(); all it does is follow the vcpu's domain pointer to get at the domain vhpet state.

Quoted 6 lines

---

Despite the comment in scope in hvm_vcpu_initialise(), the call can't currently be moved to hvm_domain_initialise() as the extra hpet_deinit() (in an error path) needs an allocated vcpu which wouldn't be present at that point. I need more tuits to disentangle that mess.

And indeed I was about to ask that very question. Thanks for the patch in any case!

Jan

#2 lore raw
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 25.07.14 at 15:19, <[email protected]> wrote:

There is nothing vcpu-specific about hpet_init(); all it does is follow the vcpu's domain pointer to get at the domain vhpet state.

---

Quoted 9 lines
Quoted 4 lines

Despite the comment in scope in hvm_vcpu_initialise(), the call can't currently be moved to hvm_domain_initialise() as the extra hpet_deinit() (in an error path) needs an allocated vcpu which wouldn't be present at that point. I need more tuits to disentangle that mess.

And indeed I was about to ask that very question. Thanks for the patch in any case!

Jan

I was wondering whether to extend the comment in the code, as it is not very obvious that hpet_deinit(d) has an implicit requirement on d->vcpu[0], but opted for the lazy route.

All of this is wrapped up in the pl_time which combines the vrtc, vhpet and vpmt, where the vpmt has a hook onto vcpu[0], which all time pieces share.

In an ideal world, I would expect there to be a vpmt per vcpu, and vrtc/vhpet to hook onto the vioapic or vi8259 for the purpose of delivering interrupts. Part of the problem is that vcpu[0]'s guest time is uses as a substitute for a domain wide time.

~Andrew