On 13/02/2025 6:50 pm, Stewart Hildebrand wrote:
> When building with CONFIG_HVM=n and -Og, we encounter:
>
> prelink.o: in function `pit_set_gate':
> xen/xen/arch/x86/emul-i8254.c:195: undefined reference to 
> `destroy_periodic_time'
>
> Add an IS_ENABLED(CONFIG_HVM) check to assist with dead code
> elimination.
>
> Fixes: 14f42af3f52d ("x86/vPIT: account for "counter stopped" time")
> Signed-off-by: Stewart Hildebrand <stewart.hildebr...@amd.com>

While I appreciate the effort to get -Og working (I tried and gave up
due to frustration), this is gnarly.

PIT emulation is used by both PV and HVM guests.  All other uses of
{create,destroy}_periodic_time() are behind something that explicitly
short-circuits in !HVM cases (usually an is_hvm_*() predicate).

The PV path would normally passes 2 for the channel, which would
normally get const-propagated and trigger DCE here.

One option might be to make pit_set_gate() be __always_inline.  It only
has a single caller, and it's only because of -Og that it doesn't get
inlined.  Then again, this is arguably more subtle than the fix
presented here.

A preferable fix (but one that really won't get into 4.20 at this point)
would be to genuinely compile pit->pt0 out in !HVM builds.  That would
save structure space, but would also force the use of full #ifdef-ary
across this file.

Is this the singular failure with -Og, or are there others?  I never got
it working, and there were quite a few failures that failed to get a
resolution.

~Andrew

Reply via email to