x86: fix stack overflow for large values of MAX_APICS