Re: [PATCH v2] generic/altp2m: align and simplify altp2m_vcpu_idx()

Jan Beulich <[email protected]>
Newsgroups org.xenproject.lists.xen-devel
Message-ID <[email protected]>
On 09.07.2026 17:23, Dmytro Prokopchuk1 wrote:
> The return type of altp2m_vcpu_idx() in the generic altp2m.h header is
> currently 'unsigned int', which is inconsistent with its uint16_t
> return type on x86 and the altp2m_idx member of the monitor structures.
> 
> To fix this type inconsistency and simplify the header, this patch
> replaces the static inline implementation of altp2m_vcpu_idx()
> (contained a BUG() stub) with a simple function declaration returning
> uint16_t.

While I appreciate that this may be the easiest route, I disagree. Not
even considering ./CODING_STYLE, uint16_t may be an appropriate choice
on x86, but it pretty certainly isn't a good one in generic code. I
have a vague recollection that it might actually have been me to request
use of unsigned int when the stub was added. If so, it was for said
reason.

> For architectures using the generic altp2m.h header (such as ARM when
> CONFIG_VM_EVENT is enabled), common code calls to altp2m_vcpu_idx() in
> common/monitor.c are guarded by altp2m_active(), which statically
> returns false. The compiler DCE will optimize out these calls, avoiding
> any linker issues for the missing definition.

This part is definitely fine in principle. However, if a declaration
suffices, that would then better also be what x86 uses when !ALTP2M.
I.e. I think you want to #include <asm-generic/altp2m.h> from that
section of x86'es asm/altp2m.h

Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.