s4-upgradeprovision: fix inverted logic and wrong flags on sd_flags control