[Sony Xperia XZ1 Compact ROMs, Kernels, Recoveries,] j4nn:
[MENTION=9652322]Pixel Shader™[/MENTION], I totally understand the motivation - I was similarly desperate just before I bricked mine:

it was like that I did my first unlock, was so eager to test previously not possible to test things and forgot to backup TA-unlocked before restoring TA-locked.

Normally that would not be a problem for most of you, but it closed me the option to test behaviour of software when device master key is not present - having both TA-locked and TA-unlocked backups allow you to switch between "drm keys restored" and "drm keys lost" states of the unlocked phone.

I could not believe I had screw up my unlocking that big, working so hard for so long and screwing it that way at the end.

So I got an idea to modify just one byte of the device master key TA unit in order to make the key invalid to simulate TA not restored state.

Surely I was nearly certain that would be a dangerous test, so I tested it first on runtime, mounting a modified TA image instead of the TA block device and restarting all processes that used TA partition.

It did not result with any error giving me some hope, so I flashed the patched TA.

It never booted again, got a brick as mentioned above. It was not completely dead as yours, it went to flash mode after connected to usb.

But all ids failed as listed newflasher log above, flashing sin files worked though.

Saying that, I understand you could be similarly frustrated that it did not work as expected in the newest pie.

Still if I would be in your place, not knowing the purpose of misc partition, I would rather ask, why something does not work instead of blindly trying to restore some odd partition inventing a new way to hopefully fix it.

If you asked, you would most likely get an answer either from me or somebody else.

Mine answer would be:

if your camera worked with unlocked bootloader in oreo, your TA-locked was restored correctly.

There is only one key erased with unlock and that is the device master key, which we are restoring with TA restore. This key is not "displayed" in service security test screen.

So the "keys" you think are lost in the security screen are not lost at all. They are just not enabled if the firmware detects the phone has been unlocked.

Having device master key restored, if the firmware is made to think the phone is still locked, all the keys in security screen get shown as OK/provisioned, maybe except the Android Attest Key, which is not connected to bootloader unlock state.

Now one more thing. You upgraded to pie, I guess the DE customization, so that would be the 47.2.A.4.45 firmware version.

You said your camera worked in it. Please see this quote (found it randomly today):

https://xdaforums.com/showpost.php?p=78682507&postcount=11

If that is true, it means your "drm keys" were all right in your pie version making camera to work. If you did not restore TA, you would get a green pic even in that pie version.

The misc backup was only to test a way to skip full erase that results from unlock - there is put a script to wipe data after you unlock to be run with next boot, similarly with factory reset.

In normal runtime state (like the locked one with exploit) the misc partition is empty - the restore of it would just make the wipe script removed.

The persist partition holds your attest key. But it does not get erased with unlock (at least not if unlock was done on oreo, not sure about the newer versions).

Having it's backup might be useful in case you flash later a persist.sin with newflasher by accident for example. I have not tried to erase/restore persist though, so I cannot tell if it would work or not.

But as documented in post#103 and previous posts of Android Attest Key lost thread, having this key provisioned with unlocked bootloader actually allows google to see easily that your bootloader is unlocked (and no magisk voodoo would help you to hide that).

That means having your android attest key with unlocked bootloader does not provide you any benefit at all, it is rather the opposite way.