Copy SME detection sysctl code from ZA test. Also fix a logic issue in the original code while being reviewed.