This is what i did:
XZ1 stock untouched until android 9 update.
After a bad pie xperiance:
-Bootloader unlocked (lost DRM keys)
-Flashed latest sony oreo firmware (47.1.A.16.20) with newflasher
https://forum.xda-developers.com/cr...gress-newflasher-xperia-command-line-t3619426 thanks @munjeni
-Flashed TWRP
https://forum.xda-developers.com/xperia-xz1/development/recovery-twrp-3-2-1-t3727602 thanks @modpunk
-Downloaded patch according with firmware version from post 566
https://forum.xda-developers.com/showpost.php?p=77626633&postcount=566 thanks @janjan
The patch works on sony stock kernel too, so flashing kernel/boot.img is optional and not needed to fix lost functionalities. I didn't.
In 2-Patching.zip there is a system dir with su.d inside it. There is no need for it. I think it could break Magisk systemless-ly job, so I deleted system from 2-Patching.zip.
-Flashed modified 2-Patching.zip with TWRP
-Downloaded Magisk v18.1 and Magisk Manager v7.0.0
https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445 thanks @topjohnwu
-Flashed Magisk-v18.1.zip with TWRP
-Magisk Manager didn't get installed so I had to manually install MagiskManager-v7.0.0.apk
-The patch only works if selinux is set permissive at boot time. After boot it can be restored to enforced.
For this reason is needed 4-kernel_permissive.zip; this file is the same as magisk-permissive-script_v1.2.zip from
https://forum.xda-developers.com/apps/magisk/module-magisk-selinux-permissive-script-t3577549 thanks @Jman420
-Flashed permissive.zip with TWRP and check it is in Magisk Manager modules tab.
-Done. DRM fixed and rooted.
-Now the phone must always boot in permissive mode to let the patch work as expected. But once the phone has booted selinux can be set again to enforced. Decide by yourself after reading this
https://forum.xda-developers.com/general/general/discussion-root-selinux-risks-t3607295 thanks again @Jman420
-To set selinux to enforced mode after boot:
in a terminal app or adb shell
-To check selinux status
-Alright. CKB OK, WIDEVINE OK, camera working, x-reality working.
(Magisk v19 and onwards will no longer support old format modules)