Skip to contentSkip to conversation

x86: Add missing forward declaration and include to hvm/svm/vmcb.h

PATCH In review Alejandro Vallejo 2 participants 5 messages Oct 6, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Add missing forward declaration and include to hvm/svm/vmcb.h

"struct segment_register" requires a prior inclusion of x86_emulate.h, and it's missing a forward declaration of "struct vcpu" too.

Sort these out so the header can be included by itself.

Not a functional change.

---
This dependency already exists today. I'm just making it explicit.

"segment_register" is weird. It naturally belongs in vmcb.h, but the emulator makes use of it and must be compilable outside of Xen.

I don't like having vmcb.h depending on the emulator header, but I see no way of breaking that dependency without breaking the emulator unit tests.

---
 xen/arch/x86/include/asm/hvm/svm/vmcb.h | 4 ++++
 1 file changed, 4 insertions(+)
xen/arch/x86/include/asm/hvm/svm/vmcb.h +4 -0
index 28f715e376..7c599a1c39 100644
@@ -10,6 +10,10 @@
 
 #include <xen/types.h>
 
+#include <asm/x86_emulate.h> /* for "struct segment_register" */
+
+struct vcpu;
+
 /* general 1 intercepts */
 enum GenericIntercept1bits
 {

base-commit: b6fc307b0b00314d4e4460fcf8be2cd9e4ff8652

Signature · 1 line
2.43.0
#1 lore raw
Quoted 8 lines · Alejandro Vallejo

"struct segment_register" requires a prior inclusion of x86_emulate.h, and it's missing a forward declaration of "struct vcpu" too.

Sort these out so the header can be included by itself.

Not a functional change.

I have a pending series for 4.22 which does substantially more rearranging of this file and others.  See
https://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen.git;a=shortlog;h=refs/heads/xen-svm-hdrs

I'd found the need for struct vcpu, but not for segment_register.  How did you find it?

Quoted 9 lines

---
This dependency already exists today. I'm just making it explicit.

"segment_register" is weird. It naturally belongs in vmcb.h, but the emulator makes use of it and must be compilable outside of Xen.

I don't like having vmcb.h depending on the emulator header, but I see no way of breaking that dependency without breaking the emulator unit tests.

Pulling it into a new header is fine.  The emulator can include anything (free-enough standing) in arch/x86/include/asm/

~Andrew

#2 lore raw
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Alejandro Vallejo

"struct segment_register" requires a prior inclusion of x86_emulate.h, and it's missing a forward declaration of "struct vcpu" too.

Sort these out so the header can be included by itself.

Not a functional change.

Quoted 8 lines
Quoted 1 line

I have a pending series for 4.22 which does substantially more rearranging of this file and others.  See
https://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen.git;a=shortlog;h=refs/heads/xen-svm-hdrs

I'd found the need for struct vcpu, but not for segment_register.  How did you find it?

By chance. I happened to include it in a file at a position where the x86_emulate.h header hadn't been included.

Quoted 7 lines
Quoted 7 lines

---
This dependency already exists today. I'm just making it explicit.

"segment_register" is weird. It naturally belongs in vmcb.h, but the emulator makes use of it and must be compilable outside of Xen.

Quoted 6 lines
Quoted 3 lines

I don't like having vmcb.h depending on the emulator header, but I see no way of breaking that dependency without breaking the emulator unit tests.

Pulling it into a new header is fine.  The emulator can include anything (free-enough standing) in arch/x86/include/asm/

I thought it didn't, if so I'm at a loss at to why segment_register is where it is.

Be that as it may, your series conflicts with this patch and it makes no sense to keep both around (when none of them are going in for until 4.22).

Will you be including a fix for the segment register in your series also? If so, I'll just drop this one.

Cheers,
Alejandro

#3 lore raw
Quoted 8 lines · Alejandro Vallejo
Quoted 7 lines · Andrew Cooper
Quoted 6 lines · Alejandro Vallejo

---
This dependency already exists today. I'm just making it explicit.

"segment_register" is weird. It naturally belongs in vmcb.h, but the emulator makes use of it and must be compilable outside of Xen.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I don't like having vmcb.h depending on the emulator header, but I see no way of breaking that dependency without breaking the emulator unit tests.

Pulling it into a new header is fine.  The emulator can include anything (free-enough standing) in arch/x86/include/asm/

I thought it didn't, if so I'm at a loss at to why segment_register is where it is.

Well - it's needed by the emulator as well as SVM.

Quoted 6 lines

Be that as it may, your series conflicts with this patch and it makes no sense to keep both around (when none of them are going in for until 4.22).

Will you be including a fix for the segment register in your series also? If so, I'll just drop this one.

I've folded the extra include into my first patch.

~Andrew

#4 lore raw
Quoted 12 lines · Andrew Cooper
Quoted 11 lines · Alejandro Vallejo
Quoted 10 lines · Andrew Cooper
Quoted 9 lines · Alejandro Vallejo

---
This dependency already exists today. I'm just making it explicit.

"segment_register" is weird. It naturally belongs in vmcb.h, but the emulator makes use of it and must be compilable outside of Xen.

I don't like having vmcb.h depending on the emulator header, but I see no way of breaking that dependency without breaking the emulator unit tests.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Pulling it into a new header is fine.  The emulator can include anything (free-enough standing) in arch/x86/include/asm/

I thought it didn't, if so I'm at a loss at to why segment_register is where it is.

Well - it's needed by the emulator as well as SVM.

I meant that it's an SVM-specific description of segments, which is then conveniently reused on the emulator. It's a bit shocking for an SVM struct to be described by the emulator.

I'd have expected the dependency to go the other way around, if it were possible to have it that way.

Quoted 9 lines
Quoted 7 lines

Be that as it may, your series conflicts with this patch and it makes no sense to keep both around (when none of them are going in for until 4.22).

Will you be including a fix for the segment register in your series also? If so, I'll just drop this one.

I've folded the extra include into my first patch.

Ta.

Cheers,
Alejandro