Skip to contentSkip to conversation

Definition of mfn_t in x86's hvm/grant_table.h

DISCUSSION Nicola Vetrini 2 participants 3 messages Sep 29, 2023 – Oct 16, 2023

lore
Share & tools
lore
#0 lore raw

Hi,

while fixing a violation of R8.4 related to a missing include in x86/hvm/grant_table.c I included <asm/hvm/grant_table.h>, since that file contains just the declarations needed by the .c file. However, since the declaration uses the type mfn_t, which is defined in an header not included from hvm/grant_table.h I'm wondering what is preferred:
1. include #include <asm/paging.h> in asm/hvm/grant_table.h, so that mfn_t can be used without relying on other headers using this one to provide it.
2. include <asm/grant_table.h> in x86/hvm/grant_table.c, which includes more declarations than needed, but has all type definitions.

I prefer (1), but (2) does not have major downsides either.

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)
#1 lore raw
Quoted 15 lines · Nicola Vetrini

while fixing a violation of R8.4 related to a missing include in x86/hvm/grant_table.c
I included <asm/hvm/grant_table.h>, since that file contains just the declarations needed
by the .c file. However, since the declaration uses the type mfn_t, which is defined in an
header not included from hvm/grant_table.h I'm wondering what is preferred:
1. include #include <asm/paging.h> in asm/hvm/grant_table.h, so that mfn_t can be used
without relying on other headers using this one to provide it.
2. include <asm/grant_table.h> in x86/hvm/grant_table.c, which includes more declarations
than needed, but has all type definitions.

Quoted 1 line

I prefer (1), but (2) does not have major downsides either.

Why asm/paging.h? xen/mm-frame.h is what you need for mfn_t. I'd be fine with (1) in that case, but if it was asm/paging.h that's needed (for another reason) I guess I'd prefer (2).

Jan

#2 lore raw
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Nicola Vetrini

while fixing a violation of R8.4 related to a missing include in x86/hvm/grant_table.c
I included <asm/hvm/grant_table.h>, since that file contains just the declarations needed
by the .c file. However, since the declaration uses the type mfn_t, which is defined in an
header not included from hvm/grant_table.h I'm wondering what is preferred:
1. include #include <asm/paging.h> in asm/hvm/grant_table.h, so that mfn_t can be used
without relying on other headers using this one to provide it.
2. include <asm/grant_table.h> in x86/hvm/grant_table.c, which includes more declarations
than needed, but has all type definitions.

Quoted 7 lines
Quoted 1 line

I prefer (1), but (2) does not have major downsides either.

Why asm/paging.h? xen/mm-frame.h is what you need for mfn_t. I'd be fine with (1) in that case, but if it was asm/paging.h that's needed (for another reason) I guess I'd prefer (2).

Jan

This is part of a patch series now [1].
I put asm/paging because asm/grant_table uses it and I wasn't entirely sure whether including mm-frame directly was the right thing to do. I don't remember whether I actually tested that solution, but changing the included header should not be problematic.

[1] https://lore.kernel.org/xen-devel/d49c648e940a651790fa6075a3fde40009501262.1696833629.git.nicola.vetrini@bugseng.com/

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)