On 20.06.2025 13:11, Roger Pau Monne wrote:
> --- /dev/null
> +++ b/xen/arch/x86/include/asm/pdx.h
> @@ -0,0 +1,75 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef X86_PDX_H
> +#define X86_PDX_H
> +
> +#ifndef CONFIG_PDX_NONE
> +
> +#include <asm/alternative.h>
> +
> +/*
> + * Introduce a macro to avoid repeating the same asm goto block in each 
> helper.
> + * Note the macro is strictly tied to the code in the helpers.
> + */
> +#define PDX_ASM_GOTO_SKIP                           \
> +    asm_inline goto (                               \
> +        ALTERNATIVE(                                \
> +            "",                                     \
> +            "jmp %l[skip]",                         \
> +            ALT_NOT(X86_FEATURE_PDX_COMPRESSION))   \
> +        : : : : skip )

Did you consider passing the label name as argument to the macro? That way ...

> +static inline unsigned long pfn_to_pdx(unsigned long pfn)
> +{
> +    PDX_ASM_GOTO_SKIP;
> +
> +    return pfn_to_pdx_xlate(pfn);
> +
> + skip:
> +    return pfn;
> +}

... the labels here and below then wouldn't look unused.

The other slight anomaly with this is that we're wasting 2 or 5 bytes of
code space. Yet I guess that's an acceptable price to pay for keeping the
actual translation code in C (rather than in assembly).

Jan

Reply via email to