On 26.09.2025 17:33, Oleksii Kurochko wrote:
> On 9/20/25 1:57 AM, Jan Beulich wrote:
>> On 17.09.2025 23:55, Oleksii Kurochko wrote:
>>> +/* Put any references on the page referenced by pte. */
>>> +static void p2m_put_page(const pte_t pte, unsigned int level, p2m_type_t
>>> p2mt)
>>> +{
>>> + mfn_t mfn = pte_get_mfn(pte);
>>> +
>>> + ASSERT(pte_is_valid(pte));
>>> +
>>> + /*
>>> + * TODO: Currently we don't handle level 2 super-page, Xen is not
>>> + * preemptible and therefore some work is needed to handle such
>>> + * superpages, for which at some point Xen might end up freeing memory
>>> + * and therefore for such a big mapping it could end up in a very long
>>> + * operation.
>>> + */
>>> + switch ( level )
>>> + {
>>> + case 1:
>>> + return p2m_put_2m_superpage(mfn, p2mt);
>>> +
>>> + case 0:
>>> + return p2m_put_4k_page(mfn, p2mt);
>>> +
>>> + default:
>>> + assert_failed("Unsupported level");
>> I don't think assert_failed() is supposed to be used directly. What's
>> wrong with using ASSERT_UNREACHABLE() here?
>
> Nothing, I just wanted to have some custom massage. I am okay with
> ASSERT_UNREACHABLE(), anyway it will print where ASSERT occurred.
Just fyi, the (kind of) "canonical" way of having a custom message emitted
from an assertion is ASSERT(!"<message text>").
Jan