Thread (82 messages) 82 messages, 5 authors, 2016-09-16

Re: [RFC PATCH v2 11/20] mm: Access BOOT related data in the clear

From: Andy Lutomirski <luto@amacapital.net>
Date: 2016-09-12 16:55:35
Also in: kvm, linux-arch, linux-iommu, linux-mm, lkml

On Aug 22, 2016 6:53 PM, "Tom Lendacky" [off-list ref] wrote:
BOOT data (such as EFI related data) is not encyrpted when the system is
booted and needs to be accessed as non-encrypted.  Add support to the
early_memremap API to identify the type of data being accessed so that
the proper encryption attribute can be applied.  Currently, two types
of data are defined, KERNEL_DATA and BOOT_DATA.
What happens when you memremap boot services data outside of early
boot?  Matt just added code that does this.

IMO this API is not so great.  It scatters a specialized consideration
all over the place.  Could early_memremap not look up the PA to figure
out what to do?

--Andy

[leaving the rest here for Matt's benefit]
quoted hunk ↗ jump to hunk
                     unsigned long size,
+                                                   enum memremap_owner owner,
+                                                   pgprot_t prot)
+{
+       return prot;
+}
+
 void __init early_ioremap_reset(void)
 {
        early_ioremap_shutdown();
@@ -213,16 +221,23 @@ early_ioremap(resource_size_t phys_addr, unsigned long size)

 /* Remap memory */
 void __init *
-early_memremap(resource_size_t phys_addr, unsigned long size)
+early_memremap(resource_size_t phys_addr, unsigned long size,
+              enum memremap_owner owner)
 {
-       return (__force void *)__early_ioremap(phys_addr, size,
-                                              FIXMAP_PAGE_NORMAL);
+       pgprot_t prot = early_memremap_pgprot_adjust(phys_addr, size, owner,
+                                                    FIXMAP_PAGE_NORMAL);
+
+       return (__force void *)__early_ioremap(phys_addr, size, prot);
 }
 #ifdef FIXMAP_PAGE_RO
 void __init *
-early_memremap_ro(resource_size_t phys_addr, unsigned long size)
+early_memremap_ro(resource_size_t phys_addr, unsigned long size,
+                 enum memremap_owner owner)
 {
-       return (__force void *)__early_ioremap(phys_addr, size, FIXMAP_PAGE_RO);
+       pgprot_t prot = early_memremap_pgprot_adjust(phys_addr, size, owner,
+                                                    FIXMAP_PAGE_RO);
+
+       return (__force void *)__early_ioremap(phys_addr, size, prot);
 }
 #endif
@@ -236,7 +251,8 @@ early_memremap_prot(resource_size_t phys_addr, unsigned long size,

 #define MAX_MAP_CHUNK  (NR_FIX_BTMAPS << PAGE_SHIFT)

-void __init copy_from_early_mem(void *dest, phys_addr_t src, unsigned long size)
+void __init copy_from_early_mem(void *dest, phys_addr_t src, unsigned long size,
+                               enum memremap_owner owner)
 {
        unsigned long slop, clen;
        char *p;
@@ -246,7 +262,7 @@ void __init copy_from_early_mem(void *dest, phys_addr_t src, unsigned long size)
                clen = size;
                if (clen > MAX_MAP_CHUNK - slop)
                        clen = MAX_MAP_CHUNK - slop;
-               p = early_memremap(src & PAGE_MASK, clen + slop);
+               p = early_memremap(src & PAGE_MASK, clen + slop, owner);
                memcpy(dest, p + slop, clen);
                early_memunmap(p, clen + slop);
                dest += clen;
@@ -265,12 +281,14 @@ early_ioremap(resource_size_t phys_addr, unsigned long size)

 /* Remap memory */
 void __init *
-early_memremap(resource_size_t phys_addr, unsigned long size)
+early_memremap(resource_size_t phys_addr, unsigned long size,
+              enum memremap_owner owner)
 {
        return (void *)phys_addr;
 }
 void __init *
-early_memremap_ro(resource_size_t phys_addr, unsigned long size)
+early_memremap_ro(resource_size_t phys_addr, unsigned long size,
+                 enum memremap_owner owner)
 {
        return (void *)phys_addr;
 }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help