Skip to contentSkip to conversation

x86/vmx: Update DR7 type

PATCH Superseded [email protected] 3 participants 4 messages Apr 26, 2025 – Apr 28, 2025

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 2/3 x86/vmx: Update DR7 type

From: Denis Mukhin <[email protected]>

Convert the DR7 type to unsigned int and fix the accesses where necessary.

[1] https://lore.kernel.org/xen-devel/[email protected]/

---
 xen/arch/x86/hvm/vmx/vmx.c        | 2 +-
 xen/arch/x86/include/asm/domain.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +1 -1
index 4883bd823d..75c6992172 100644
@@ -926,7 +926,7 @@ static void vmx_save_dr(struct vcpu *v)
     v->arch.dr[3] = read_debugreg(3);
     v->arch.dr6   = read_debugreg(6);
     /* DR7 must be saved as it is used by vmx_restore_dr(). */
-    __vmread(GUEST_DR7, &v->arch.dr7);
+    v->arch.dr7 = vmread(GUEST_DR7);
 }
 
 static void __restore_debug_registers(struct vcpu *v)
xen/arch/x86/include/asm/domain.h +1 -1
index 5fc1d1e5d0..a54ef3a8c1 100644
@@ -595,7 +595,7 @@ struct arch_vcpu
 
     /* Debug registers. */
     unsigned long dr[4];
-    unsigned long dr7; /* Ideally int, but __vmread() needs long. */
+    unsigned int dr7;
     unsigned int dr6;
 
     /* other state */
Signature · 1 line
2.34.1
#2 lore raw
In reply to [email protected]
Quoted 17 lines · On 26/04/2025 8:27 am, [email protected] wrote:

From: Denis Mukhin <[email protected]>

Convert the DR7 type to unsigned int and fix the accesses where necessary.

[1] https://lore.kernel.org/xen-devel/[email protected]/

---
 xen/arch/x86/hvm/vmx/vmx.c        | 2 +-
 xen/arch/x86/include/asm/domain.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +0 -0
index 4883bd823d..75c6992172 100644

xen/arch/x86/hvm/vmx/vmx.c static void vmx_save_dr(struct vcpu *v) · line 929

Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -926,7 +926,7 @@ static void vmx_save_dr(struct vcpu *v)
     v->arch.dr[3] = read_debugreg(3);
     v->arch.dr6   = read_debugreg(6);
     /* DR7 must be saved as it is used by vmx_restore_dr(). */
-    __vmread(GUEST_DR7, &v->arch.dr7);
+    v->arch.dr7 = vmread(GUEST_DR7);

Two minor points.  The = wants lining up for vertical tabulation, and ...

Quoted 8 lines
xen/arch/x86/hvm/vmx/vmx.c +0 -0
 }
 
 static void __restore_debug_registers(struct vcpu *v)
xen/arch/x86/include/asm/domain.h +0 -0
index 5fc1d1e5d0..a54ef3a8c1 100644

xen/arch/x86/include/asm/domain.h struct arch_vcpu · line 599

Quoted 6 lines
xen/arch/x86/include/asm/domain.h +1 -1
@@ -595,7 +595,7 @@ struct arch_vcpu
 
     /* Debug registers. */
     unsigned long dr[4];
-    unsigned long dr7; /* Ideally int, but __vmread() needs long. */
+    unsigned int dr7;
     unsigned int dr6;

... these fields want switching back around now that dr7 is unsigned int.

We always access in numeric order, and they're only out-of-order for packing reasons.

Can fix on commit.

~Andrew

#3 lore raw
Quoted 43 lines · Andrew Cooper
Quoted 17 lines · On 26/04/2025 8:27 am, [email protected] wrote:

From: Denis Mukhin <[email protected]>

Convert the DR7 type to unsigned int and fix the accesses where necessary.

[1] https://lore.kernel.org/xen-devel/[email protected]/

---
 xen/arch/x86/hvm/vmx/vmx.c        | 2 +-
 xen/arch/x86/include/asm/domain.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/vmx/vmx.c +0 -0
index 4883bd823d..75c6992172 100644

xen/arch/x86/hvm/vmx/vmx.c static void vmx_save_dr(struct vcpu *v) · line 929

Quoted 5 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -926,7 +926,7 @@ static void vmx_save_dr(struct vcpu *v)
     v->arch.dr[3] = read_debugreg(3);
     v->arch.dr6   = read_debugreg(6);
     /* DR7 must be saved as it is used by vmx_restore_dr(). */
-    __vmread(GUEST_DR7, &v->arch.dr7);
+    v->arch.dr7 = vmread(GUEST_DR7);

Two minor points.  The = wants lining up for vertical tabulation, and ...

Quoted 8 lines
xen/arch/x86/hvm/vmx/vmx.c +0 -0
 }
 
 static void __restore_debug_registers(struct vcpu *v)
xen/arch/x86/include/asm/domain.h +0 -0
index 5fc1d1e5d0..a54ef3a8c1 100644

xen/arch/x86/include/asm/domain.h struct arch_vcpu · line 599

Quoted 6 lines
xen/arch/x86/include/asm/domain.h +1 -1
@@ -595,7 +595,7 @@ struct arch_vcpu
 
     /* Debug registers. */
     unsigned long dr[4];
-    unsigned long dr7; /* Ideally int, but __vmread() needs long. */
+    unsigned int dr7;
     unsigned int dr6;

... these fields want switching back around now that dr7 is unsigned int.

Quoted 4 lines

We always access in numeric order, and they're only out-of-order for packing reasons.

Can fix on commit.

Thanks!

Quoted 2 lines

~Andrew