Linux's own arch/x86/boot/a20.c tries the BIOS INT 0x15/AX=0x2401 call, then the 8042 keyboard controller, then fast A20 port 0x92 in exactly the fallback order you implement here, because no single method is guaranteed to work across all real chipsets. Forgetting to enable A20 before entering protected mode is a classic bug where memory writes above 1MB silently alias back down, corrupting kernel data in ways that are brutal to debug.