Skip to content

Commit 2592dbb

Browse files
jgross1David Vrabel
authored andcommitted
mm: provide early_memremap_ro to establish read-only mapping
During early boot as Xen pv domain the kernel needs to map some page tables supplied by the hypervisor read only. This is needed to be able to relocate some data structures conflicting with the physical memory map especially on systems with huge RAM (above 512GB). Provide the function early_memremap_ro() to provide this read only mapping. Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Konrad Rzeszutek Wilk <Konrad.wilk@oracle.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
1 parent 4b9c153 commit 2592dbb

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎include/asm-generic/early_ioremap.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ extern void __iomem *early_ioremap(resource_size_t phys_addr,
1111
unsigned long size);
1212
extern void *early_memremap(resource_size_t phys_addr,
1313
unsigned long size);
14+
extern void *early_memremap_ro(resource_size_t phys_addr,
15+
unsigned long size);
1416
extern void early_iounmap(void __iomem *addr, unsigned long size);
1517
extern void early_memunmap(void *addr, unsigned long size);
1618

‎include/asm-generic/fixmap.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
4646
#ifndef FIXMAP_PAGE_NORMAL
4747
#define FIXMAP_PAGE_NORMAL PAGE_KERNEL
4848
#endif
49+
#if !defined(FIXMAP_PAGE_RO) && defined(PAGE_KERNEL_RO)
50+
#define FIXMAP_PAGE_RO PAGE_KERNEL_RO
51+
#endif
4952
#ifndef FIXMAP_PAGE_NOCACHE
5053
#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
5154
#endif

‎mm/early_ioremap.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ early_memremap(resource_size_t phys_addr, unsigned long size)
217217
return (__force void *)__early_ioremap(phys_addr, size,
218218
FIXMAP_PAGE_NORMAL);
219219
}
220+
#ifdef FIXMAP_PAGE_RO
221+
void __init *
222+
early_memremap_ro(resource_size_t phys_addr, unsigned long size)
223+
{
224+
return (__force void *)__early_ioremap(phys_addr, size, FIXMAP_PAGE_RO);
225+
}
226+
#endif
220227
#else /* CONFIG_MMU */
221228

222229
void __init __iomem *
@@ -231,6 +238,11 @@ early_memremap(resource_size_t phys_addr, unsigned long size)
231238
{
232239
return (void *)phys_addr;
233240
}
241+
void __init *
242+
early_memremap_ro(resource_size_t phys_addr, unsigned long size)
243+
{
244+
return (void *)phys_addr;
245+
}
234246

235247
void __init early_iounmap(void __iomem *addr, unsigned long size)
236248
{

0 commit comments

Comments
 (0)