powerpc/rtas: Serialize firmware activation sequences
authorNathan Lynch <nathanl@linux.ibm.com>
Tue, 12 Dec 2023 17:01:54 +0000 (11:01 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 13 Dec 2023 10:38:20 +0000 (21:38 +1100)
Use rtas_ibm_activate_firmware_lock to prevent interleaving call
sequences of the ibm,activate-firmware RTAS function, which typically
requires multiple calls to complete the update. While the spec does
not specifically prohibit interleaved sequences, there's almost
certainly no advantage to allowing them.

Reviewed-by: "Aneesh Kumar K.V (IBM)" <aneesh.kumar@kernel.org>
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231212-papr-sys_rtas-vs-lockdown-v6-7-e9eafd0c8c6c@linux.ibm.com
arch/powerpc/kernel/rtas.c

index 4d28983e8b1d07f0ff846716d3c1769adb410839..72f6b5a402dde72bf1d22c2a7b7d6b39c0890d85 100644 (file)
@@ -1734,10 +1734,14 @@ void rtas_activate_firmware(void)
                return;
        }
 
+       mutex_lock(&rtas_ibm_activate_firmware_lock);
+
        do {
                fwrc = rtas_call(token, 0, 1, NULL);
        } while (rtas_busy_delay(fwrc));
 
+       mutex_unlock(&rtas_ibm_activate_firmware_lock);
+
        if (fwrc)
                pr_err("ibm,activate-firmware failed (%i)\n", fwrc);
 }