On Fri Aug 25 22:26:34 2023 +0000, Jinoh Kang wrote:
If `ctx_count == 1`, we shall still fully set the native context.
if (ctx_count == 1 || is_pending || !thread->context->regs[CTX_WOW].machine)
But the code complexity is getting out of hand. We're needlessly writing `regs[CTX_NATIVE]` twice even as we got rid of `CTX_PENDING` (which made it necessary in the first place). These two native context writes can be merged by tweaking the `native_flags` computation so that it takes both if condition into account.
Actually `ctx_count == 2` only if `thread->context->regs[CTX_WOW].machine` is set (otherwise the parameter validation fails), so you can replace the `thread->context->regs[CTX_WOW].machine` checks with `ctx_count == 2` entirely.