msm8953-mainline / linux

Linux mainline kernel with WIP patches for msm8953 devices
Other
111 stars 59 forks source link

sdhc_1 eMMC ICE support #81

Closed z3ntu closed 1 year ago

z3ntu commented 1 year ago

I'm quite sure our sdhc_1 supports some crypto stuff (ICE). Need to check at runtime if that's actually the case and if that works correctly.

diff --git a/arch/arm64/boot/dts/qcom/msm8953.dtsi b/arch/arm64/boot/dts/qcom/msm8953.dtsi
index 32349174c4bd..025684357f9a 100644
--- a/arch/arm64/boot/dts/qcom/msm8953.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8953.dtsi
@@ -1042,8 +1042,11 @@ usb3_dwc3: usb@7000000 {
        sdhc_1: mmc@7824900 {
            compatible = "qcom,msm8953-sdhci", "qcom,sdhci-msm-v4";

-           reg = <0x7824900 0x500>, <0x7824000 0x800>;
-           reg-names = "hc", "core";
+           reg = <0x7824900 0x500>,
+                 <0x7824000 0x800>,
+                 <0x7824e00 0x200>,
+                 <0x7803000 0x8000>;
+           reg-names = "hc", "core", "cqhci", "ice";

            interrupts = <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
                     <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>;
@@ -1051,8 +1054,9 @@ sdhc_1: mmc@7824900 {

            clocks = <&gcc GCC_SDCC1_AHB_CLK>,
                 <&gcc GCC_SDCC1_APPS_CLK>,
-                <&xo_board>;
-           clock-names = "iface", "core", "xo";
+                <&xo_board>,
+                <&gcc GCC_SDCC1_ICE_CORE_CLK>;
+           clock-names = "iface", "core", "xo", "ice";

            power-domains = <&rpmpd MSM8953_VDDCX>;
            operating-points-v2 = <&sdhc1_opp_table>;
@@ -1066,6 +1070,7 @@ sdhc_1: mmc@7824900 {
            mmc-ddr-1_8v;
            bus-width = <8>;
            non-removable;
+           supports-cqe;

            status = "disabled";

Some message like [ 0.391950] sdhci_msm 4744000.mmc: mmc0: CQE init: success for the supports-cqe property should pop up. Not sure how to validate ICE really.

edit: test commands from Konrad:

mkfs.ext4 -O encrypt part
mount -o inlinecrypt ...
fscrypt setup
mkdir secret/
fscrypt encrypt secret/
~ add some files to secret/ ~
~ you should/could get some spam in dmesg ~
umount 
mount without inlinecrypt
you should have garbage (encrypted) data
fscrypt status private/ # Unlocked: No
fscrypt unlock private/
fscrypt status private/ # Unlocked: Yes
check that the files are still in there
fscrypt lock private/
fscrypt status private/ # Unlocked: No
Check that you have the same sort of garbage (encrypted) files as before

extra edit: more something like this


# CONFIG_FS_ENCRYPTION_INLINE_CRYPT=y
fallocate -l 1G part
mkfs.ext4 -O encrypt part
mkdir mount/
sudo mount -o inlinecrypt part mount/
sudo fscrypt setup # do this once
sudo fscrypt setup mount/
sudo mkdir mount/secret/
sudo fscrypt encrypt mount/secret/
# ~ add some files to secret/ ~
    echo "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." | sudo tee mount/secret/lorem.txt
    sudo f3write -e 1 mount/secret/
# ~ you should/could get some spam in dmesg ~
sudo umount mount/
sudo mount part mount/ # mount without inlinecrypt
# you should have garbage (encrypted) data
sudo fscrypt status mount/ # Unlocked: No
sudo fscrypt unlock mount/secret/
sudo fscrypt status mount/ # Unlocked: Yes
# check that the files are still in there
sudo fscrypt lock mount/secret/
sudo fscrypt status mount/ # Unlocked: No
Check that you have the same sort of garbage (encrypted) files as before
z3ntu commented 1 year ago

Spent a bit messing around with this now, but various bits don't really align with what we have on msm8953..

And seems from downstream dmesg we also have ICE v2.x while the upstream sdhci-msm driver only supports ICE 3.x but it actually doesn't even get to that and crashes earlier.

(from downstream)

[    3.933315] qcom_ice 7803000.sdcc1ice: QC ICE 2.1.44 device found @0xffffff8008be0000

So unless the driver starts getting support for ICE 2.x (upstream supports 3.x, and seemingly in some version also 4.x) I don't think we can add this. Closing.