Skip to contentSkip to conversation

x86/hvm/viridian: stop open coding updates to APIC registers

PATCH In review Paul Durrant 3 participants 9 messages Dec 7, 2018 – Dec 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hvm/viridian: stop open coding updates to APIC registers

The code in viridian_synic_wrmsr() duplicates logic in vlapic_reg_write() to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>

---
 xen/arch/x86/hvm/viridian/synic.c | 15 +++++----------
 xen/arch/x86/hvm/vlapic.c         |  3 +--
 xen/include/asm-x86/hvm/vlapic.h  |  2 ++
 3 files changed, 8 insertions(+), 12 deletions(-)
xen/arch/x86/hvm/viridian/synic.c +5 -10
index 845029b568..a6ebbbc9f5 100644
@@ -84,18 +84,13 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)
         vlapic_EOI_set(vcpu_vlapic(v));
         break;
 
-    case HV_X64_MSR_ICR: {
-        u32 eax = (u32)val, edx = (u32)(val >> 32);
-        struct vlapic *vlapic = vcpu_vlapic(v);
-        eax &= ~(1 << 12);
-        edx &= 0xff000000;
-        vlapic_set_reg(vlapic, APIC_ICR2, edx);
-        vlapic_ipi(vlapic, eax, edx);
-        vlapic_set_reg(vlapic, APIC_ICR, eax);
+    case HV_X64_MSR_ICR:
+        vlapic_reg_write(v, APIC_ICR2, val >> 32);
+        vlapic_reg_write(v, APIC_ICR, val);
         break;
-    }
+
     case HV_X64_MSR_TPR:
-        vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI, (uint8_t)val);
+        vlapic_reg_write(v, APIC_TASKPRI, val);
         break;
 
     case HV_X64_MSR_VP_ASSIST_PAGE:
xen/arch/x86/hvm/vlapic.c +1 -2
index 4f02499b3b..6f1879d4df 100644
@@ -769,8 +769,7 @@ static void vlapic_update_timer(struct vlapic *vlapic, uint32_t lvtt,
     }
 }
 
-static void vlapic_reg_write(struct vcpu *v,
-                             unsigned int offset, uint32_t val)
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t val)
 {
     struct vlapic *vlapic = vcpu_vlapic(v);
 
xen/include/asm-x86/hvm/vlapic.h +2 -0
index 8dbec90ab0..40434afd7b 100644
@@ -145,4 +145,6 @@ bool_t vlapic_match_dest(
     const struct vlapic *target, const struct vlapic *source,
     int short_hand, uint32_t dest, bool_t dest_mode);
 
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t val);
+
 #endif /* __ASM_X86_HVM_VLAPIC_H__ */
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 31 lines · Paul Durrant

The code in viridian_synic_wrmsr() duplicates logic in vlapic_reg_write() to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>

---
 xen/arch/x86/hvm/viridian/synic.c | 15 +++++----------
 xen/arch/x86/hvm/vlapic.c         |  3 +--
 xen/include/asm-x86/hvm/vlapic.h  |  2 ++
 3 files changed, 8 insertions(+), 12 deletions(-)
xen/arch/x86/hvm/viridian/synic.c +0 -7
index 845029b568..a6ebbbc9f5 100644
@@ -84,18 +84,13 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val)
         vlapic_EOI_set(vcpu_vlapic(v));
         break;
 
-    case HV_X64_MSR_ICR: {
-        u32 eax = (u32)val, edx = (u32)(val >> 32);
-        struct vlapic *vlapic = vcpu_vlapic(v);
-        eax &= ~(1 << 12);
-        edx &= 0xff000000;
-        vlapic_set_reg(vlapic, APIC_ICR2, edx);
-        vlapic_ipi(vlapic, eax, edx);

xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val) · line 93

Quoted 10 lines
xen/arch/x86/hvm/viridian/synic.c +5 -3
-        vlapic_set_reg(vlapic, APIC_ICR, eax);
+    case HV_X64_MSR_ICR:
+        vlapic_reg_write(v, APIC_ICR2, val >> 32);
+        vlapic_reg_write(v, APIC_ICR, val);
         break;
-    }
+
     case HV_X64_MSR_TPR:
-        vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI, (uint8_t)val);
+        vlapic_reg_write(v, APIC_TASKPRI, val);

This uint8_t cast isn't implemented in reg_write.

It is unclear what the behaviour in real hardware is.  The upper bits are reserved even in xAPIC mode, but the Intel manual isn't clear on whether they get dropped from writes, or preserved.  The AMD manual lists them as MBZ, but again is unclear as to whether updates get dropped.

To be on the safe side, I'd recommend implementing the masking internally.

Quoted 22 lines
xen/arch/x86/hvm/viridian/synic.c +0 -0
         break;
 
     case HV_X64_MSR_VP_ASSIST_PAGE:
xen/arch/x86/hvm/vlapic.c +1 -2
index 4f02499b3b..6f1879d4df 100644
@@ -769,8 +769,7 @@ static void vlapic_update_timer(struct vlapic *vlapic, uint32_t lvtt,
     }
 }
 
-static void vlapic_reg_write(struct vcpu *v,
-                             unsigned int offset, uint32_t val)
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t val)
 {
     struct vlapic *vlapic = vcpu_vlapic(v);
 
xen/include/asm-x86/hvm/vlapic.h +0 -0
index 8dbec90ab0..40434afd7b 100644

xen/include/asm-x86/hvm/vlapic.h bool_t vlapic_match_dest( · line 148

Quoted 4 lines
xen/include/asm-x86/hvm/vlapic.h +1 -0
@@ -145,4 +145,6 @@ bool_t vlapic_match_dest(
     const struct vlapic *target, const struct vlapic *source,
     int short_hand, uint32_t dest, bool_t dest_mode);
 
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t val);

This export ought to be next to vlapic_{set,set}_reg(), and we should s/offset/reg/ for consistency with the rest of the code.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 55 lines

-----Original Message-----
From: Andrew Cooper
Sent: 07 December 2018 18:23
To: Paul Durrant <[email protected]>; [email protected]
Cc: Jan Beulich <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: stop open coding updates to APIC registers

Quoted 1 line · Paul Durrant

The code in viridian_synic_wrmsr() duplicates logic in

vlapic_reg_write()

Quoted 9 lines

to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>

Review

Quoted 7 lines
---
 xen/arch/x86/hvm/viridian/synic.c | 15 +++++----------
 xen/arch/x86/hvm/vlapic.c         |  3 +--
 xen/include/asm-x86/hvm/vlapic.h  |  2 ++
 3 files changed, 8 insertions(+), 12 deletions(-)
(quoted diff) +0 -0

b/xen/arch/x86/hvm/viridian/synic.c

xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t

Quoted 4 lines

index 845029b568..a6ebbbc9f5 100644

xen/arch/x86/hvm/viridian/synic.c +0 -0
@@ -84,18 +84,13 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t

idx, uint64_t val)

Quoted 10 lines
xen/arch/x86/hvm/viridian/synic.c +0 -7
         vlapic_EOI_set(vcpu_vlapic(v));
         break;
 
-    case HV_X64_MSR_ICR: {
-        u32 eax = (u32)val, edx = (u32)(val >> 32);
-        struct vlapic *vlapic = vcpu_vlapic(v);
-        eax &= ~(1 << 12);
-        edx &= 0xff000000;
-        vlapic_set_reg(vlapic, APIC_ICR2, edx);
-        vlapic_ipi(vlapic, eax, edx);

xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val) · line 93

Quoted 10 lines
xen/arch/x86/hvm/viridian/synic.c +5 -3
-        vlapic_set_reg(vlapic, APIC_ICR, eax);
+    case HV_X64_MSR_ICR:
+        vlapic_reg_write(v, APIC_ICR2, val >> 32);
+        vlapic_reg_write(v, APIC_ICR, val);
         break;
-    }
+
     case HV_X64_MSR_TPR:
-        vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI, (uint8_t)val);
+        vlapic_reg_write(v, APIC_TASKPRI, val);
Quoted 1 line

This uint8_t cast isn't implemented in reg_write.

No, it's not, but reg_write does do a '& 0xff' which will have the same effect.

Quoted 7 lines

It is unclear what the behaviour in real hardware is.  The upper bits are reserved even in xAPIC mode, but the Intel manual isn't clear on whether they get dropped from writes, or preserved.  The AMD manual lists them as MBZ, but again is unclear as to whether updates get dropped.

To be on the safe side, I'd recommend implementing the masking internally.

As I said, it's already there :-)

Quoted 29 lines

xen/arch/x86/hvm/vlapic.c static void vlapic_update_timer(struct vlapic

Quoted 9 lines
xen/arch/x86/hvm/viridian/synic.c +0 -0
         break;
 
     case HV_X64_MSR_VP_ASSIST_PAGE:
xen/arch/x86/hvm/vlapic.c +0 -0
index 4f02499b3b..6f1879d4df 100644
@@ -769,8 +769,7 @@ static void vlapic_update_timer(struct vlapic

*vlapic, uint32_t lvtt,

xen/arch/x86/hvm/vlapic.c static void vlapic_update_timer(struct vlapic *vlapic, uint32_t lvtt,

Quoted 6 lines
xen/arch/x86/hvm/vlapic.c +1 -2
     }
 }
 
-static void vlapic_reg_write(struct vcpu *v,
-                             unsigned int offset, uint32_t val)
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t

val)

xen/include/asm-

Quoted 4 lines
xen/arch/x86/hvm/vlapic.c +0 -0
 {
     struct vlapic *vlapic = vcpu_vlapic(v);
 
xen/include/asm- renamed from xen/include/asm-x86/hvm/vlapic.h +0 -0

x86/hvm/vlapic.h

Quoted 7 lines

index 8dbec90ab0..40434afd7b 100644

xen/include/asm-x86/hvm/vlapic.h +0 -0
@@ -145,4 +145,6 @@ bool_t vlapic_match_dest(
     const struct vlapic *target, const struct vlapic *source,
     int short_hand, uint32_t dest, bool_t dest_mode);
 
Quoted 5 lines

xen/include/asm-x86/hvm/vlapic.h bool_t vlapic_match_dest( · line 148

Quoted 1 line
xen/include/asm-x86/hvm/vlapic.h +1 -0
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t

val);

This export ought to be next to vlapic_{set,set}_reg(), and we should s/offset/reg/ for consistency with the rest of the code.

Ok, I guess the cosmetic change of s/offset/reg is probably small enough to fold in.

Paul

Quoted 2 lines

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 54 lines · Paul Durrant
Quoted 54 lines

-----Original Message-----
From: Andrew Cooper
Sent: 07 December 2018 18:23
To: Paul Durrant <[email protected]>; [email protected]
Cc: Jan Beulich <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: stop open coding updates to APIC registers

Quoted 1 line · Paul Durrant

The code in viridian_synic_wrmsr() duplicates logic in

vlapic_reg_write()

Quoted 9 lines

to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>

Review

Quoted 7 lines
---
 xen/arch/x86/hvm/viridian/synic.c | 15 +++++----------
 xen/arch/x86/hvm/vlapic.c         |  3 +--
 xen/include/asm-x86/hvm/vlapic.h  |  2 ++
 3 files changed, 8 insertions(+), 12 deletions(-)
(quoted diff) +0 -0

b/xen/arch/x86/hvm/viridian/synic.c

xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t

Quoted 4 lines

index 845029b568..a6ebbbc9f5 100644

xen/arch/x86/hvm/viridian/synic.c +0 -0
@@ -84,18 +84,13 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t

idx, uint64_t val)

Quoted 20 lines
xen/arch/x86/hvm/viridian/synic.c +5 -10
         vlapic_EOI_set(vcpu_vlapic(v));
         break;
 
-    case HV_X64_MSR_ICR: {
-        u32 eax = (u32)val, edx = (u32)(val >> 32);
-        struct vlapic *vlapic = vcpu_vlapic(v);
-        eax &= ~(1 << 12);
-        edx &= 0xff000000;
-        vlapic_set_reg(vlapic, APIC_ICR2, edx);
-        vlapic_ipi(vlapic, eax, edx);
-        vlapic_set_reg(vlapic, APIC_ICR, eax);
+    case HV_X64_MSR_ICR:
+        vlapic_reg_write(v, APIC_ICR2, val >> 32);
+        vlapic_reg_write(v, APIC_ICR, val);
         break;
-    }
+
     case HV_X64_MSR_TPR:
-        vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI, (uint8_t)val);
+        vlapic_reg_write(v, APIC_TASKPRI, val);
Quoted 2 lines
Quoted 1 line

This uint8_t cast isn't implemented in reg_write.

No, it's not, but reg_write does do a '& 0xff' which will have the same effect.

Bah - so it is.  (I've lost count of the number of times I've mixed up TPR and TASKPRI when grepping)

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 8dbec90ab0..40434afd7b 100644

xen/include/asm-x86/hvm/vlapic.h +0 -0
@@ -145,4 +145,6 @@ bool_t vlapic_match_dest(
     const struct vlapic *target, const struct vlapic *source,
     int short_hand, uint32_t dest, bool_t dest_mode);
 
Quoted 6 lines
Quoted 5 lines

xen/include/asm-x86/hvm/vlapic.h bool_t vlapic_match_dest( · line 148

Quoted 1 line
xen/include/asm-x86/hvm/vlapic.h +1 -0
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t

val);

This export ought to be next to vlapic_{set,set}_reg(), and we should s/offset/reg/ for consistency with the rest of the code.

Ok, I guess the cosmetic change of s/offset/reg is probably small enough to fold in.

I can fold this on commit if you're happy with the change?

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 83 lines

-----Original Message-----
From: Andrew Cooper
Sent: 10 December 2018 11:04
To: Paul Durrant <[email protected]>; [email protected]
Cc: Jan Beulich <[email protected]>; Wei Liu <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: stop open coding updates to APIC registers

Quoted 4 lines · Paul Durrant
Quoted 4 lines

-----Original Message-----
From: Andrew Cooper
Sent: 07 December 2018 18:23
To: Paul Durrant <[email protected]>; xen-

[email protected]

Quoted 1 line
Quoted 1 line
Cc Jan Beulich <[email protected]>; Wei Liu <[email protected]>;

Roger

Quoted 49 lines
Quoted 49 lines

Pau Monne <[email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: stop open coding updates to APIC registers

Quoted 1 line · Paul Durrant

The code in viridian_synic_wrmsr() duplicates logic in

vlapic_reg_write()

Quoted 9 lines

to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: "Roger Pau Monné" <[email protected]>

Review

Quoted 7 lines
---
 xen/arch/x86/hvm/viridian/synic.c | 15 +++++----------
 xen/arch/x86/hvm/vlapic.c         |  3 +--
 xen/include/asm-x86/hvm/vlapic.h  |  2 ++
 3 files changed, 8 insertions(+), 12 deletions(-)
(quoted diff) +0 -0

b/xen/arch/x86/hvm/viridian/synic.c

xen/arch/x86/hvm/viridian/synic.c int viridian_synic_wrmsr(struct vcpu *v, uint32_t

Quoted 4 lines

index 845029b568..a6ebbbc9f5 100644

xen/arch/x86/hvm/viridian/synic.c +0 -0
@@ -84,18 +84,13 @@ int viridian_synic_wrmsr(struct vcpu *v, uint32_t

idx, uint64_t val)

Quoted 20 lines
xen/arch/x86/hvm/viridian/synic.c +5 -10
         vlapic_EOI_set(vcpu_vlapic(v));
         break;
 
-    case HV_X64_MSR_ICR: {
-        u32 eax = (u32)val, edx = (u32)(val >> 32);
-        struct vlapic *vlapic = vcpu_vlapic(v);
-        eax &= ~(1 << 12);
-        edx &= 0xff000000;
-        vlapic_set_reg(vlapic, APIC_ICR2, edx);
-        vlapic_ipi(vlapic, eax, edx);
-        vlapic_set_reg(vlapic, APIC_ICR, eax);
+    case HV_X64_MSR_ICR:
+        vlapic_reg_write(v, APIC_ICR2, val >> 32);
+        vlapic_reg_write(v, APIC_ICR, val);
         break;
-    }
+
     case HV_X64_MSR_TPR:
-        vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI, (uint8_t)val);
+        vlapic_reg_write(v, APIC_TASKPRI, val);
Quoted 2 lines
Quoted 1 line

This uint8_t cast isn't implemented in reg_write.

No, it's not, but reg_write does do a '& 0xff' which will have the same

effect.

Bah - so it is.  (I've lost count of the number of times I've mixed up TPR and TASKPRI when grepping)

Quoted 10 lines
Quoted 10 lines

xen/include/asm-x86/hvm/vlapic.h bool_t vlapic_match_dest( · line 148

Quoted 8 lines

index 8dbec90ab0..40434afd7b 100644

xen/include/asm-x86/hvm/vlapic.h +1 -0
@@ -145,4 +145,6 @@ bool_t vlapic_match_dest(
     const struct vlapic *target, const struct vlapic *source,
     int short_hand, uint32_t dest, bool_t dest_mode);
 
+void vlapic_reg_write(struct vcpu *v, unsigned int offset, uint32_t

val);

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

This export ought to be next to vlapic_{set,set}_reg(), and we should s/offset/reg/ for consistency with the rest of the code.

Ok, I guess the cosmetic change of s/offset/reg is probably small enough

to fold in.

I can fold this on commit if you're happy with the change?

Yes, absolutely. Go ahead. Thanks,

Paul

Quoted 2 lines

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
In reply to Paul Durrant
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.12.18 at 18:50, <[email protected]> wrote:

The code in viridian_synic_wrmsr() duplicates logic in vlapic_reg_write() to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

There's a side effect from this change, which I think should be called out since perhaps it's actually a (minor) bug fix: vlapic_reg_write() clears out vlapic->loaded, which the open coded Viridian code didn't do.

If it wasn't for this, I would have been uncertain whether exposing a function that really was meant to be vlapic.c-internal is a good idea.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
Quoted 12 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 10 December 2018 13:44
To: Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; xen-devel <xen- [email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: stop open coding updates to APIC registers

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 07.12.18 at 18:50, <[email protected]> wrote:

The code in viridian_synic_wrmsr() duplicates logic in

Quoted 9 lines

vlapic_reg_write()

Quoted 2 lines

to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

There's a side effect from this change, which I think should be called out since perhaps it's actually a (minor) bug fix: vlapic_reg_write() clears out vlapic->loaded, which the open coded Viridian code didn't do.

Yes, that was an anomaly and did look wrong.

Quoted 3 lines

If it wasn't for this, I would have been uncertain whether exposing a function that really was meant to be vlapic.c-internal is a good idea.

Unfortunately the way that Microsoft specify the SynIC (as a "superset of the local APIC") means that the code does need to be closely tied. Do you want me to formulate a comment and submit a v2, or are you happy to add a comment on commit?

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 36 lines

-----Original Message-----
From: Paul Durrant
Sent: 10 December 2018 14:57
To: 'Jan Beulich' <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; xen-devel <xen- [email protected]>
Subject: RE: [PATCH] x86/hvm/viridian: stop open coding updates to APIC registers

Quoted 12 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 10 December 2018 13:44
To: Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; xen-devel <xen- [email protected]>
Subject: Re: [PATCH] x86/hvm/viridian: stop open coding updates to APIC registers

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 07.12.18 at 18:50, <[email protected]> wrote:

The code in viridian_synic_wrmsr() duplicates logic in

Quoted 9 lines

vlapic_reg_write()

Quoted 2 lines

to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

There's a side effect from this change, which I think should be called out since perhaps it's actually a (minor) bug fix: vlapic_reg_write() clears out vlapic->loaded, which the open coded Viridian code didn't do.

Yes, that was an anomaly and did look wrong.

Quoted 8 lines
Quoted 3 lines

If it wasn't for this, I would have been uncertain whether exposing a function that really was meant to be vlapic.c-internal is a good idea.

Unfortunately the way that Microsoft specify the SynIC (as a "superset of the local APIC") means that the code does need to be closely tied. Do you want me to formulate a comment and submit a v2, or are you happy to add a comment on commit?

Oh, I see Andrew already committed it.

Paul

Quoted 2 lines

Paul

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
Quoted 25 lines
Quoted 25 lines
Quoted 1 line · On 10.12.18 at 15:57, <[email protected]> wrote:

From: Paul Durrant
Sent: 10 December 2018 14:57

Quoted 5 lines

From: Jan Beulich [mailto:[email protected]]
Sent: 10 December 2018 13:44

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 07.12.18 at 18:50, <[email protected]> wrote:

The code in viridian_synic_wrmsr() duplicates logic in

Quoted 9 lines

vlapic_reg_write()

Quoted 2 lines

to update the ICR, ICR2 and TASKPRI registers. Instead of doing this, make vlapic_reg_write() non-static and call it.

There's a side effect from this change, which I think should be called out since perhaps it's actually a (minor) bug fix: vlapic_reg_write() clears out vlapic->loaded, which the open coded Viridian code didn't do.

Yes, that was an anomaly and did look wrong.

Quoted 3 lines

If it wasn't for this, I would have been uncertain whether exposing a function that really was meant to be vlapic.c-internal is a good idea.

Quoted 6 lines
Quoted 4 lines

Unfortunately the way that Microsoft specify the SynIC (as a "superset of the local APIC") means that the code does need to be closely tied. Do you want me to formulate a comment and submit a v2, or are you happy to add a comment on commit?

Oh, I see Andrew already committed it.

Right, and if anything it would have been an addition to the description, so there's no point submitting any incremental patch.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel