[Sony Xperia X Performance Questions & Answers] sdugoten:
I have done the update to 7.1.1 with Magisk v13beta https://xdaforums.com/apps/magisk/beta-magisk-v13-0-0980cb6-t3618589 . The steps below still more or less works on Android 7.1.1

--------------

After playing with the Xperia XP for 2 days over weekend, I finally managed to root it with PS4 remote play and Safetynet working. (If Safetynet is working, games like Pokemon and app like Android pay should work with rooted phone as well)

Before you do anything, backup the TA partition first. You have to downgrade back to version 6.0.1 to backup the TA partition. Flash your phone back to 6.0.1 first. (If you don't know how to flash a firmware, https://xdaforums.com/xperia-xz/how-to/how-to-flash-firmware-using-flashtool-t3523946)

Download 6.0.1 firmware here. By backing up the TA partition, in case if you want to roll back to stock rom with valid DRM key , you can install the original DRM key back into your phone. You need this if you want your warranty in case you need to fix your phone.

Download and install backupTA_v2

https://xdaforums.com/crossdevice-dev/sony/universal-dirtycow-based-ta-backup-t3514236

Backup TA partition

1) Ensure you have adb access (e.g. drivers installed, install flashtool)

If you encounter issue on installing drivers, follow this to disable driver signature first.

https://www.howtogeek.com/167723/how-to-disable-driver-signature-verification-on-64-bit-windows-8.1-so-that-you-can-install-unsigned-drivers/

2) Run backupTA.sh (linux) or backupTA.cmd (windows) in the root directory.

3) TA will be saved as TA-ModelNumber-Serial-Timestamp.img in

the backupTA.sh directory.

4. Send this image file to your gmail or something so that your email will permanently keep a copy of this backup TA partition image.

DO NOT GO BEYOND THE LINE BELOW IF YOU CAN'T BACKUP YOUR TA PARTITION.

-----------------

Now, you have done all pre-requisite. We can now start the rooting.

1. unlock phone https://developer.sonymobile.com/unlockbootloader/unlock-yourboot-loader/

Get into fastboot mode first by holding down volume up button and plug in USB cable to computer, click BLU

You should type in unlock code which you got it from the above Sony link.

2. flash/upgrade to stock firmware 7.0 if phone is not having stock rom, check all erase on flash. Flash it so that it will have both stock firmware and stock boot image. (don't restart phone after flash).

3. flash the TWRP. fastboot flash recovery f:\path_to_downlaod\TWRP-3.0.2-4-dora.img (Download TWRP here)

Also download XP_AndroPlusKernel_v22.zip . Get the newest version for both app if available.

4. go into twrp install UPDATE-SuperSU-v2.79-20161211114519.zip, reboot (Download https://download.chainfire.eu/696/supersu/ or see attachment)

5. start the phone the first time and get into phone, should find out the phone still not rooted. Check Setting > Display , the Bravia engine should have no effect on your display.

7. go into twrp install Magisk-v12.0.zip, reboot (download https://xdaforums.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445 or see attachment)

8. start magisk, it will open google play to update magisk. reboot

9. go into twrp , install phh’s SuperUser superuser-r310-beta.zip, reboot (download https://superuser.phh.me/ or see attachment)

10. go into phone, open google play, search and install phh’s SuperUser app

11. run SuperUser app, upper right choose setting, choose Superuser access and then choose Apps and ADB

12. run magisk, 2nd checkbox should be check by now. Should show Properly rooted)

13. run magisk, 1st checkbox click and install Magisk v12 , reboot

14. run magisk, upper left menu click, then choose Downloads,install Sony Framework v1, reboot

15. On reboot, the phone should hang during boot up, on boot loop, hold the volume up button , plug the usb cable to computer, until you see the blue light turn on on the top of the phone, and screen stays black

16. flash the XP_AndroPlusKernel_v22.zip boot image. fastboot.exe flash boot f:\path_to_downlaod\boot.img

17. go back into phone once again, run magisk, choose menu upper left, choose modules, find the file Magisk_RemotePlayEnabler_v1.zip, press and hold on that file to select, and install, reboot (download https://xdaforums.com/apps/magisk/module-ps-remote-play-enabler-t3575876 or see attachment)

18. Enable Magisk Hide in Setting of Magisk...can put the remote play in Magisk hide if remote play doesn't work.

18. go back to phone again, run magisk, all 3 checkbox should be all checked and OK. PS4 remote play should work fine as well with root running on phone.

In case if you need to roll back to stock rom with original TA partition, here is the instruction.

1. Backup all the data as your device will reset and formatted after this process.

2. Rename your backed up TA partition and rename it TAbackup.img

3. Boot into TWRP.

4. Plug your device in your pc via USB and check the connection by the command adb devices in command prompt in your fastboot directory.

5. Now run the command adb push TAbackup.img /data/local/tmp/TAbackup.img

6. Then run adb shell dd if=/data/local/tmp/TAbackup.img of=/dev/block/bootdevice/by-name/TA

7. Now flash Stock ROM via FlashTool and your device will have original DRM and stock ROM and Ta partition.