KVM: PPC: Book3S HV: Read ibm,secure-memory nodes
authorLaurent Dufour <ldufour@linux.ibm.com>
Thu, 16 Apr 2020 16:27:15 +0000 (18:27 +0200)
committerPaul Mackerras <paulus@ozlabs.org>
Wed, 27 May 2020 01:39:31 +0000 (11:39 +1000)
The newly introduced ibm,secure-memory nodes supersede the
ibm,uv-firmware's property secure-memory-ranges.

Firmware will no more expose the secure-memory-ranges property so first
read the new one and if not found rollback to the older one.

Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_hv_uvmem.c

index 76d05c71fb1ff6476662a81584ec7202cdcda083..e2cb3ce4931ca98bc6592dd2dd0f6e7ac51a8069 100644 (file)
@@ -749,6 +749,20 @@ static u64 kvmppc_get_secmem_size(void)
        const __be32 *prop;
        u64 size = 0;
 
+       /*
+        * First try the new ibm,secure-memory nodes which supersede the
+        * secure-memory-ranges property.
+        * If we found some, no need to read the deprecated ones.
+        */
+       for_each_compatible_node(np, NULL, "ibm,secure-memory") {
+               prop = of_get_property(np, "reg", &len);
+               if (!prop)
+                       continue;
+               size += of_read_number(prop + 2, 2);
+       }
+       if (size)
+               return size;
+
        np = of_find_compatible_node(NULL, NULL, "ibm,uv-firmware");
        if (!np)
                goto out;