.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Re-map IO memory to kernel address space so that we can access it. |
---|
3 | 4 | * This is needed for high PCI addresses that aren't mapped in the |
---|
.. | .. |
---|
6 | 7 | * (C) Copyright 1995 1996 Linus Torvalds |
---|
7 | 8 | */ |
---|
8 | 9 | |
---|
9 | | -#include <linux/bootmem.h> |
---|
| 10 | +#include <linux/memblock.h> |
---|
10 | 11 | #include <linux/init.h> |
---|
11 | 12 | #include <linux/io.h> |
---|
12 | 13 | #include <linux/ioport.h> |
---|
.. | .. |
---|
15 | 16 | #include <linux/mmiotrace.h> |
---|
16 | 17 | #include <linux/mem_encrypt.h> |
---|
17 | 18 | #include <linux/efi.h> |
---|
| 19 | +#include <linux/pgtable.h> |
---|
18 | 20 | |
---|
19 | 21 | #include <asm/set_memory.h> |
---|
20 | 22 | #include <asm/e820/api.h> |
---|
| 23 | +#include <asm/efi.h> |
---|
21 | 24 | #include <asm/fixmap.h> |
---|
22 | | -#include <asm/pgtable.h> |
---|
23 | 25 | #include <asm/tlbflush.h> |
---|
24 | 26 | #include <asm/pgalloc.h> |
---|
25 | | -#include <asm/pat.h> |
---|
| 27 | +#include <asm/memtype.h> |
---|
26 | 28 | #include <asm/setup.h> |
---|
27 | 29 | |
---|
28 | 30 | #include "physaddr.h" |
---|
29 | 31 | |
---|
30 | | -struct ioremap_mem_flags { |
---|
31 | | - bool system_ram; |
---|
32 | | - bool desc_other; |
---|
| 32 | +/* |
---|
| 33 | + * Descriptor controlling ioremap() behavior. |
---|
| 34 | + */ |
---|
| 35 | +struct ioremap_desc { |
---|
| 36 | + unsigned int flags; |
---|
33 | 37 | }; |
---|
34 | 38 | |
---|
35 | 39 | /* |
---|
.. | .. |
---|
61 | 65 | return err; |
---|
62 | 66 | } |
---|
63 | 67 | |
---|
64 | | -static bool __ioremap_check_ram(struct resource *res) |
---|
| 68 | +/* Does the range (or a subset of) contain normal RAM? */ |
---|
| 69 | +static unsigned int __ioremap_check_ram(struct resource *res) |
---|
65 | 70 | { |
---|
66 | 71 | unsigned long start_pfn, stop_pfn; |
---|
67 | 72 | unsigned long i; |
---|
68 | 73 | |
---|
69 | 74 | if ((res->flags & IORESOURCE_SYSTEM_RAM) != IORESOURCE_SYSTEM_RAM) |
---|
70 | | - return false; |
---|
| 75 | + return 0; |
---|
71 | 76 | |
---|
72 | 77 | start_pfn = (res->start + PAGE_SIZE - 1) >> PAGE_SHIFT; |
---|
73 | 78 | stop_pfn = (res->end + 1) >> PAGE_SHIFT; |
---|
.. | .. |
---|
75 | 80 | for (i = 0; i < (stop_pfn - start_pfn); ++i) |
---|
76 | 81 | if (pfn_valid(start_pfn + i) && |
---|
77 | 82 | !PageReserved(pfn_to_page(start_pfn + i))) |
---|
78 | | - return true; |
---|
| 83 | + return IORES_MAP_SYSTEM_RAM; |
---|
79 | 84 | } |
---|
80 | 85 | |
---|
81 | | - return false; |
---|
| 86 | + return 0; |
---|
82 | 87 | } |
---|
83 | 88 | |
---|
84 | | -static int __ioremap_check_desc_other(struct resource *res) |
---|
| 89 | +/* |
---|
| 90 | + * In a SEV guest, NONE and RESERVED should not be mapped encrypted because |
---|
| 91 | + * there the whole memory is already encrypted. |
---|
| 92 | + */ |
---|
| 93 | +static unsigned int __ioremap_check_encrypted(struct resource *res) |
---|
85 | 94 | { |
---|
86 | | - return (res->desc != IORES_DESC_NONE); |
---|
| 95 | + if (!sev_active()) |
---|
| 96 | + return 0; |
---|
| 97 | + |
---|
| 98 | + switch (res->desc) { |
---|
| 99 | + case IORES_DESC_NONE: |
---|
| 100 | + case IORES_DESC_RESERVED: |
---|
| 101 | + break; |
---|
| 102 | + default: |
---|
| 103 | + return IORES_MAP_ENCRYPTED; |
---|
| 104 | + } |
---|
| 105 | + |
---|
| 106 | + return 0; |
---|
87 | 107 | } |
---|
88 | 108 | |
---|
89 | | -static int __ioremap_res_check(struct resource *res, void *arg) |
---|
| 109 | +/* |
---|
| 110 | + * The EFI runtime services data area is not covered by walk_mem_res(), but must |
---|
| 111 | + * be mapped encrypted when SEV is active. |
---|
| 112 | + */ |
---|
| 113 | +static void __ioremap_check_other(resource_size_t addr, struct ioremap_desc *desc) |
---|
90 | 114 | { |
---|
91 | | - struct ioremap_mem_flags *flags = arg; |
---|
| 115 | + if (!sev_active()) |
---|
| 116 | + return; |
---|
92 | 117 | |
---|
93 | | - if (!flags->system_ram) |
---|
94 | | - flags->system_ram = __ioremap_check_ram(res); |
---|
| 118 | + if (!IS_ENABLED(CONFIG_EFI)) |
---|
| 119 | + return; |
---|
95 | 120 | |
---|
96 | | - if (!flags->desc_other) |
---|
97 | | - flags->desc_other = __ioremap_check_desc_other(res); |
---|
| 121 | + if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA || |
---|
| 122 | + (efi_mem_type(addr) == EFI_BOOT_SERVICES_DATA && |
---|
| 123 | + efi_mem_attributes(addr) & EFI_MEMORY_RUNTIME)) |
---|
| 124 | + desc->flags |= IORES_MAP_ENCRYPTED; |
---|
| 125 | +} |
---|
98 | 126 | |
---|
99 | | - return flags->system_ram && flags->desc_other; |
---|
| 127 | +static int __ioremap_collect_map_flags(struct resource *res, void *arg) |
---|
| 128 | +{ |
---|
| 129 | + struct ioremap_desc *desc = arg; |
---|
| 130 | + |
---|
| 131 | + if (!(desc->flags & IORES_MAP_SYSTEM_RAM)) |
---|
| 132 | + desc->flags |= __ioremap_check_ram(res); |
---|
| 133 | + |
---|
| 134 | + if (!(desc->flags & IORES_MAP_ENCRYPTED)) |
---|
| 135 | + desc->flags |= __ioremap_check_encrypted(res); |
---|
| 136 | + |
---|
| 137 | + return ((desc->flags & (IORES_MAP_SYSTEM_RAM | IORES_MAP_ENCRYPTED)) == |
---|
| 138 | + (IORES_MAP_SYSTEM_RAM | IORES_MAP_ENCRYPTED)); |
---|
100 | 139 | } |
---|
101 | 140 | |
---|
102 | 141 | /* |
---|
103 | 142 | * To avoid multiple resource walks, this function walks resources marked as |
---|
104 | 143 | * IORESOURCE_MEM and IORESOURCE_BUSY and looking for system RAM and/or a |
---|
105 | 144 | * resource described not as IORES_DESC_NONE (e.g. IORES_DESC_ACPI_TABLES). |
---|
| 145 | + * |
---|
| 146 | + * After that, deal with misc other ranges in __ioremap_check_other() which do |
---|
| 147 | + * not fall into the above category. |
---|
106 | 148 | */ |
---|
107 | 149 | static void __ioremap_check_mem(resource_size_t addr, unsigned long size, |
---|
108 | | - struct ioremap_mem_flags *flags) |
---|
| 150 | + struct ioremap_desc *desc) |
---|
109 | 151 | { |
---|
110 | 152 | u64 start, end; |
---|
111 | 153 | |
---|
112 | 154 | start = (u64)addr; |
---|
113 | 155 | end = start + size - 1; |
---|
114 | | - memset(flags, 0, sizeof(*flags)); |
---|
| 156 | + memset(desc, 0, sizeof(struct ioremap_desc)); |
---|
115 | 157 | |
---|
116 | | - walk_mem_res(start, end, flags, __ioremap_res_check); |
---|
| 158 | + walk_mem_res(start, end, desc, __ioremap_collect_map_flags); |
---|
| 159 | + |
---|
| 160 | + __ioremap_check_other(addr, desc); |
---|
117 | 161 | } |
---|
118 | 162 | |
---|
119 | 163 | /* |
---|
.. | .. |
---|
130 | 174 | * have to convert them into an offset in a page-aligned mapping, but the |
---|
131 | 175 | * caller shouldn't need to know that small detail. |
---|
132 | 176 | */ |
---|
133 | | -static void __iomem *__ioremap_caller(resource_size_t phys_addr, |
---|
134 | | - unsigned long size, enum page_cache_mode pcm, void *caller) |
---|
| 177 | +static void __iomem * |
---|
| 178 | +__ioremap_caller(resource_size_t phys_addr, unsigned long size, |
---|
| 179 | + enum page_cache_mode pcm, void *caller, bool encrypted) |
---|
135 | 180 | { |
---|
136 | 181 | unsigned long offset, vaddr; |
---|
137 | 182 | resource_size_t last_addr; |
---|
138 | 183 | const resource_size_t unaligned_phys_addr = phys_addr; |
---|
139 | 184 | const unsigned long unaligned_size = size; |
---|
140 | | - struct ioremap_mem_flags mem_flags; |
---|
| 185 | + struct ioremap_desc io_desc; |
---|
141 | 186 | struct vm_struct *area; |
---|
142 | 187 | enum page_cache_mode new_pcm; |
---|
143 | 188 | pgprot_t prot; |
---|
.. | .. |
---|
156 | 201 | return NULL; |
---|
157 | 202 | } |
---|
158 | 203 | |
---|
159 | | - __ioremap_check_mem(phys_addr, size, &mem_flags); |
---|
| 204 | + __ioremap_check_mem(phys_addr, size, &io_desc); |
---|
160 | 205 | |
---|
161 | 206 | /* |
---|
162 | 207 | * Don't allow anybody to remap normal RAM that we're using.. |
---|
163 | 208 | */ |
---|
164 | | - if (mem_flags.system_ram) { |
---|
| 209 | + if (io_desc.flags & IORES_MAP_SYSTEM_RAM) { |
---|
165 | 210 | WARN_ONCE(1, "ioremap on RAM at %pa - %pa\n", |
---|
166 | 211 | &phys_addr, &last_addr); |
---|
167 | 212 | return NULL; |
---|
.. | .. |
---|
171 | 216 | * Mappings have to be page-aligned |
---|
172 | 217 | */ |
---|
173 | 218 | offset = phys_addr & ~PAGE_MASK; |
---|
174 | | - phys_addr &= PHYSICAL_PAGE_MASK; |
---|
| 219 | + phys_addr &= PAGE_MASK; |
---|
175 | 220 | size = PAGE_ALIGN(last_addr+1) - phys_addr; |
---|
176 | 221 | |
---|
177 | | - retval = reserve_memtype(phys_addr, (u64)phys_addr + size, |
---|
| 222 | + /* |
---|
| 223 | + * Mask out any bits not part of the actual physical |
---|
| 224 | + * address, like memory encryption bits. |
---|
| 225 | + */ |
---|
| 226 | + phys_addr &= PHYSICAL_PAGE_MASK; |
---|
| 227 | + |
---|
| 228 | + retval = memtype_reserve(phys_addr, (u64)phys_addr + size, |
---|
178 | 229 | pcm, &new_pcm); |
---|
179 | 230 | if (retval) { |
---|
180 | | - printk(KERN_ERR "ioremap reserve_memtype failed %d\n", retval); |
---|
| 231 | + printk(KERN_ERR "ioremap memtype_reserve failed %d\n", retval); |
---|
181 | 232 | return NULL; |
---|
182 | 233 | } |
---|
183 | 234 | |
---|
.. | .. |
---|
199 | 250 | * resulting mapping. |
---|
200 | 251 | */ |
---|
201 | 252 | prot = PAGE_KERNEL_IO; |
---|
202 | | - if (sev_active() && mem_flags.desc_other) |
---|
| 253 | + if ((io_desc.flags & IORES_MAP_ENCRYPTED) || encrypted) |
---|
203 | 254 | prot = pgprot_encrypted(prot); |
---|
204 | 255 | |
---|
205 | 256 | switch (pcm) { |
---|
.. | .. |
---|
233 | 284 | area->phys_addr = phys_addr; |
---|
234 | 285 | vaddr = (unsigned long) area->addr; |
---|
235 | 286 | |
---|
236 | | - if (kernel_map_sync_memtype(phys_addr, size, pcm)) |
---|
| 287 | + if (memtype_kernel_map_sync(phys_addr, size, pcm)) |
---|
237 | 288 | goto err_free_area; |
---|
238 | 289 | |
---|
239 | 290 | if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) |
---|
.. | .. |
---|
253 | 304 | err_free_area: |
---|
254 | 305 | free_vm_area(area); |
---|
255 | 306 | err_free_memtype: |
---|
256 | | - free_memtype(phys_addr, phys_addr + size); |
---|
| 307 | + memtype_free(phys_addr, phys_addr + size); |
---|
257 | 308 | return NULL; |
---|
258 | 309 | } |
---|
259 | 310 | |
---|
260 | 311 | /** |
---|
261 | | - * ioremap_nocache - map bus memory into CPU space |
---|
| 312 | + * ioremap - map bus memory into CPU space |
---|
262 | 313 | * @phys_addr: bus address of the memory |
---|
263 | 314 | * @size: size of the resource to map |
---|
264 | 315 | * |
---|
265 | | - * ioremap_nocache performs a platform specific sequence of operations to |
---|
| 316 | + * ioremap performs a platform specific sequence of operations to |
---|
266 | 317 | * make bus memory CPU accessible via the readb/readw/readl/writeb/ |
---|
267 | 318 | * writew/writel functions and the other mmio helpers. The returned |
---|
268 | 319 | * address is not guaranteed to be usable directly as a virtual |
---|
.. | .. |
---|
278 | 329 | * |
---|
279 | 330 | * Must be freed with iounmap. |
---|
280 | 331 | */ |
---|
281 | | -void __iomem *ioremap_nocache(resource_size_t phys_addr, unsigned long size) |
---|
| 332 | +void __iomem *ioremap(resource_size_t phys_addr, unsigned long size) |
---|
282 | 333 | { |
---|
283 | 334 | /* |
---|
284 | 335 | * Ideally, this should be: |
---|
.. | .. |
---|
291 | 342 | enum page_cache_mode pcm = _PAGE_CACHE_MODE_UC_MINUS; |
---|
292 | 343 | |
---|
293 | 344 | return __ioremap_caller(phys_addr, size, pcm, |
---|
294 | | - __builtin_return_address(0)); |
---|
| 345 | + __builtin_return_address(0), false); |
---|
295 | 346 | } |
---|
296 | | -EXPORT_SYMBOL(ioremap_nocache); |
---|
| 347 | +EXPORT_SYMBOL(ioremap); |
---|
297 | 348 | |
---|
298 | 349 | /** |
---|
299 | 350 | * ioremap_uc - map bus memory into CPU space as strongly uncachable |
---|
.. | .. |
---|
324 | 375 | enum page_cache_mode pcm = _PAGE_CACHE_MODE_UC; |
---|
325 | 376 | |
---|
326 | 377 | return __ioremap_caller(phys_addr, size, pcm, |
---|
327 | | - __builtin_return_address(0)); |
---|
| 378 | + __builtin_return_address(0), false); |
---|
328 | 379 | } |
---|
329 | 380 | EXPORT_SYMBOL_GPL(ioremap_uc); |
---|
330 | 381 | |
---|
.. | .. |
---|
341 | 392 | void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size) |
---|
342 | 393 | { |
---|
343 | 394 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WC, |
---|
344 | | - __builtin_return_address(0)); |
---|
| 395 | + __builtin_return_address(0), false); |
---|
345 | 396 | } |
---|
346 | 397 | EXPORT_SYMBOL(ioremap_wc); |
---|
347 | 398 | |
---|
.. | .. |
---|
358 | 409 | void __iomem *ioremap_wt(resource_size_t phys_addr, unsigned long size) |
---|
359 | 410 | { |
---|
360 | 411 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WT, |
---|
361 | | - __builtin_return_address(0)); |
---|
| 412 | + __builtin_return_address(0), false); |
---|
362 | 413 | } |
---|
363 | 414 | EXPORT_SYMBOL(ioremap_wt); |
---|
| 415 | + |
---|
| 416 | +void __iomem *ioremap_encrypted(resource_size_t phys_addr, unsigned long size) |
---|
| 417 | +{ |
---|
| 418 | + return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WB, |
---|
| 419 | + __builtin_return_address(0), true); |
---|
| 420 | +} |
---|
| 421 | +EXPORT_SYMBOL(ioremap_encrypted); |
---|
364 | 422 | |
---|
365 | 423 | void __iomem *ioremap_cache(resource_size_t phys_addr, unsigned long size) |
---|
366 | 424 | { |
---|
367 | 425 | return __ioremap_caller(phys_addr, size, _PAGE_CACHE_MODE_WB, |
---|
368 | | - __builtin_return_address(0)); |
---|
| 426 | + __builtin_return_address(0), false); |
---|
369 | 427 | } |
---|
370 | 428 | EXPORT_SYMBOL(ioremap_cache); |
---|
371 | 429 | |
---|
.. | .. |
---|
374 | 432 | { |
---|
375 | 433 | return __ioremap_caller(phys_addr, size, |
---|
376 | 434 | pgprot2cachemode(__pgprot(prot_val)), |
---|
377 | | - __builtin_return_address(0)); |
---|
| 435 | + __builtin_return_address(0), false); |
---|
378 | 436 | } |
---|
379 | 437 | EXPORT_SYMBOL(ioremap_prot); |
---|
380 | 438 | |
---|
.. | .. |
---|
422 | 480 | return; |
---|
423 | 481 | } |
---|
424 | 482 | |
---|
425 | | - free_memtype(p->phys_addr, p->phys_addr + get_vm_area_size(p)); |
---|
| 483 | + memtype_free(p->phys_addr, p->phys_addr + get_vm_area_size(p)); |
---|
426 | 484 | |
---|
427 | 485 | /* Finally remove it */ |
---|
428 | 486 | o = remove_vm_area((void __force *)addr); |
---|
.. | .. |
---|
430 | 488 | kfree(p); |
---|
431 | 489 | } |
---|
432 | 490 | EXPORT_SYMBOL(iounmap); |
---|
| 491 | + |
---|
| 492 | +int __init arch_ioremap_p4d_supported(void) |
---|
| 493 | +{ |
---|
| 494 | + return 0; |
---|
| 495 | +} |
---|
433 | 496 | |
---|
434 | 497 | int __init arch_ioremap_pud_supported(void) |
---|
435 | 498 | { |
---|
.. | .. |
---|
519 | 582 | /* For SEV, these areas are encrypted */ |
---|
520 | 583 | if (sev_active()) |
---|
521 | 584 | break; |
---|
522 | | - /* Fallthrough */ |
---|
| 585 | + fallthrough; |
---|
523 | 586 | |
---|
524 | 587 | case E820_TYPE_PRAM: |
---|
525 | 588 | return true; |
---|
.. | .. |
---|
576 | 639 | static bool memremap_is_setup_data(resource_size_t phys_addr, |
---|
577 | 640 | unsigned long size) |
---|
578 | 641 | { |
---|
| 642 | + struct setup_indirect *indirect; |
---|
579 | 643 | struct setup_data *data; |
---|
580 | 644 | u64 paddr, paddr_next; |
---|
581 | 645 | |
---|
.. | .. |
---|
588 | 652 | |
---|
589 | 653 | data = memremap(paddr, sizeof(*data), |
---|
590 | 654 | MEMREMAP_WB | MEMREMAP_DEC); |
---|
| 655 | + if (!data) { |
---|
| 656 | + pr_warn("failed to memremap setup_data entry\n"); |
---|
| 657 | + return false; |
---|
| 658 | + } |
---|
591 | 659 | |
---|
592 | 660 | paddr_next = data->next; |
---|
593 | 661 | len = data->len; |
---|
| 662 | + |
---|
| 663 | + if ((phys_addr > paddr) && (phys_addr < (paddr + len))) { |
---|
| 664 | + memunmap(data); |
---|
| 665 | + return true; |
---|
| 666 | + } |
---|
| 667 | + |
---|
| 668 | + if (data->type == SETUP_INDIRECT) { |
---|
| 669 | + memunmap(data); |
---|
| 670 | + data = memremap(paddr, sizeof(*data) + len, |
---|
| 671 | + MEMREMAP_WB | MEMREMAP_DEC); |
---|
| 672 | + if (!data) { |
---|
| 673 | + pr_warn("failed to memremap indirect setup_data\n"); |
---|
| 674 | + return false; |
---|
| 675 | + } |
---|
| 676 | + |
---|
| 677 | + indirect = (struct setup_indirect *)data->data; |
---|
| 678 | + |
---|
| 679 | + if (indirect->type != SETUP_INDIRECT) { |
---|
| 680 | + paddr = indirect->addr; |
---|
| 681 | + len = indirect->len; |
---|
| 682 | + } |
---|
| 683 | + } |
---|
594 | 684 | |
---|
595 | 685 | memunmap(data); |
---|
596 | 686 | |
---|
.. | .. |
---|
610 | 700 | static bool __init early_memremap_is_setup_data(resource_size_t phys_addr, |
---|
611 | 701 | unsigned long size) |
---|
612 | 702 | { |
---|
| 703 | + struct setup_indirect *indirect; |
---|
613 | 704 | struct setup_data *data; |
---|
614 | 705 | u64 paddr, paddr_next; |
---|
615 | 706 | |
---|
616 | 707 | paddr = boot_params.hdr.setup_data; |
---|
617 | 708 | while (paddr) { |
---|
618 | | - unsigned int len; |
---|
| 709 | + unsigned int len, size; |
---|
619 | 710 | |
---|
620 | 711 | if (phys_addr == paddr) |
---|
621 | 712 | return true; |
---|
622 | 713 | |
---|
623 | 714 | data = early_memremap_decrypted(paddr, sizeof(*data)); |
---|
| 715 | + if (!data) { |
---|
| 716 | + pr_warn("failed to early memremap setup_data entry\n"); |
---|
| 717 | + return false; |
---|
| 718 | + } |
---|
| 719 | + |
---|
| 720 | + size = sizeof(*data); |
---|
624 | 721 | |
---|
625 | 722 | paddr_next = data->next; |
---|
626 | 723 | len = data->len; |
---|
627 | 724 | |
---|
628 | | - early_memunmap(data, sizeof(*data)); |
---|
| 725 | + if ((phys_addr > paddr) && (phys_addr < (paddr + len))) { |
---|
| 726 | + early_memunmap(data, sizeof(*data)); |
---|
| 727 | + return true; |
---|
| 728 | + } |
---|
| 729 | + |
---|
| 730 | + if (data->type == SETUP_INDIRECT) { |
---|
| 731 | + size += len; |
---|
| 732 | + early_memunmap(data, sizeof(*data)); |
---|
| 733 | + data = early_memremap_decrypted(paddr, size); |
---|
| 734 | + if (!data) { |
---|
| 735 | + pr_warn("failed to early memremap indirect setup_data\n"); |
---|
| 736 | + return false; |
---|
| 737 | + } |
---|
| 738 | + |
---|
| 739 | + indirect = (struct setup_indirect *)data->data; |
---|
| 740 | + |
---|
| 741 | + if (indirect->type != SETUP_INDIRECT) { |
---|
| 742 | + paddr = indirect->addr; |
---|
| 743 | + len = indirect->len; |
---|
| 744 | + } |
---|
| 745 | + } |
---|
| 746 | + |
---|
| 747 | + early_memunmap(data, size); |
---|
629 | 748 | |
---|
630 | 749 | if ((phys_addr > paddr) && (phys_addr < (paddr + len))) |
---|
631 | 750 | return true; |
---|
.. | .. |
---|
712 | 831 | void __init *early_memremap_encrypted_wp(resource_size_t phys_addr, |
---|
713 | 832 | unsigned long size) |
---|
714 | 833 | { |
---|
715 | | - /* Be sure the write-protect PAT entry is set for write-protect */ |
---|
716 | | - if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) |
---|
| 834 | + if (!x86_has_pat_wp()) |
---|
717 | 835 | return NULL; |
---|
718 | | - |
---|
719 | 836 | return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_ENC_WP); |
---|
720 | 837 | } |
---|
721 | 838 | |
---|
.. | .. |
---|
733 | 850 | void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, |
---|
734 | 851 | unsigned long size) |
---|
735 | 852 | { |
---|
736 | | - /* Be sure the write-protect PAT entry is set for write-protect */ |
---|
737 | | - if (__pte2cachemode_tbl[_PAGE_CACHE_MODE_WP] != _PAGE_CACHE_MODE_WP) |
---|
| 853 | + if (!x86_has_pat_wp()) |
---|
738 | 854 | return NULL; |
---|
739 | | - |
---|
740 | 855 | return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP); |
---|
741 | 856 | } |
---|
742 | 857 | #endif /* CONFIG_AMD_MEM_ENCRYPT */ |
---|
.. | .. |
---|
817 | 932 | pte = early_ioremap_pte(addr); |
---|
818 | 933 | |
---|
819 | 934 | /* Sanitize 'prot' against any unsupported bits: */ |
---|
820 | | - pgprot_val(flags) &= __default_kernel_pte_mask; |
---|
| 935 | + pgprot_val(flags) &= __supported_pte_mask; |
---|
821 | 936 | |
---|
822 | 937 | if (pgprot_val(flags)) |
---|
823 | 938 | set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags)); |
---|
824 | 939 | else |
---|
825 | 940 | pte_clear(&init_mm, addr, pte); |
---|
826 | | - __flush_tlb_one_kernel(addr); |
---|
| 941 | + flush_tlb_one_kernel(addr); |
---|
827 | 942 | } |
---|