[PATCH] [AArch64] Fix removal of non-address bits for PAuth

Lancelot SIX lsix@lancelotsix.com
Wed Jul 6 11:38:57 GMT 2022


> +
> +/* See arch/aarch64.h.  */
> +
> +CORE_ADDR
> +aarch64_remove_top_bytes (CORE_ADDR pointer, CORE_ADDR mask)

Hi,

Shouldn't this function be called aarch64_remove_top_bits (note the
s/bytes/bits)?  This function does not work at the byte grain.


> +{
> +  /* The VA range select bit is 55.  This bit tells us if we have a
> +     kernel-space address or a user-space address.  */
> +  bool kernel_address = (pointer & VA_RANGE_SELECT_BIT_MASK)? true : false;

You could drop the ternary operator by using

  bool kernel_address = (pointer & VA_RANGE_SELECT_BIT_MASK) != 0;

which I find a "more canonical" way to write it, but I guess it is
mostly a matter of taste.

Best,
Lancelot.

> +/* Given a pointer value POINTER and a MASK of non-address bits, remove the
> +   non-address bits from the pointer and sign-extend the result if required.
> +   The sign-extension is required so we can handle kernel addresses
> +   correctly.  */
> +CORE_ADDR aarch64_remove_top_bytes (CORE_ADDR pointer, CORE_ADDR mask);


More information about the Gdb-patches mailing list