diff options
| -rw-r--r-- | arch/x86/platform/intel-quark/imr.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/arch/x86/platform/intel-quark/imr.c b/arch/x86/platform/intel-quark/imr.c index 0ee619f9fcb7..ad5ec6f784e8 100644 --- a/arch/x86/platform/intel-quark/imr.c +++ b/arch/x86/platform/intel-quark/imr.c | |||
| @@ -228,11 +228,12 @@ static int imr_dbgfs_state_show(struct seq_file *s, void *unused) | |||
| 228 | if (imr_is_enabled(&imr)) { | 228 | if (imr_is_enabled(&imr)) { |
| 229 | base = imr_to_phys(imr.addr_lo); | 229 | base = imr_to_phys(imr.addr_lo); |
| 230 | end = imr_to_phys(imr.addr_hi) + IMR_MASK; | 230 | end = imr_to_phys(imr.addr_hi) + IMR_MASK; |
| 231 | size = end - base + 1; | ||
| 231 | } else { | 232 | } else { |
| 232 | base = 0; | 233 | base = 0; |
| 233 | end = 0; | 234 | end = 0; |
| 235 | size = 0; | ||
| 234 | } | 236 | } |
| 235 | size = end - base; | ||
| 236 | seq_printf(s, "imr%02i: base=%pa, end=%pa, size=0x%08zx " | 237 | seq_printf(s, "imr%02i: base=%pa, end=%pa, size=0x%08zx " |
| 237 | "rmask=0x%08x, wmask=0x%08x, %s, %s\n", i, | 238 | "rmask=0x%08x, wmask=0x%08x, %s, %s\n", i, |
| 238 | &base, &end, size, imr.rmask, imr.wmask, | 239 | &base, &end, size, imr.rmask, imr.wmask, |
| @@ -587,6 +588,7 @@ static void __init imr_fixup_memmap(struct imr_device *idev) | |||
| 587 | { | 588 | { |
| 588 | phys_addr_t base = virt_to_phys(&_text); | 589 | phys_addr_t base = virt_to_phys(&_text); |
| 589 | size_t size = virt_to_phys(&__end_rodata) - base; | 590 | size_t size = virt_to_phys(&__end_rodata) - base; |
| 591 | unsigned long start, end; | ||
| 590 | int i; | 592 | int i; |
| 591 | int ret; | 593 | int ret; |
| 592 | 594 | ||
| @@ -594,18 +596,24 @@ static void __init imr_fixup_memmap(struct imr_device *idev) | |||
| 594 | for (i = 0; i < idev->max_imr; i++) | 596 | for (i = 0; i < idev->max_imr; i++) |
| 595 | imr_clear(i); | 597 | imr_clear(i); |
| 596 | 598 | ||
| 599 | start = (unsigned long)_text; | ||
| 600 | end = (unsigned long)__end_rodata - 1; | ||
| 601 | |||
| 597 | /* | 602 | /* |
| 598 | * Setup a locked IMR around the physical extent of the kernel | 603 | * Setup a locked IMR around the physical extent of the kernel |
| 599 | * from the beginning of the .text secton to the end of the | 604 | * from the beginning of the .text secton to the end of the |
| 600 | * .rodata section as one physically contiguous block. | 605 | * .rodata section as one physically contiguous block. |
| 606 | * | ||
| 607 | * We don't round up @size since it is already PAGE_SIZE aligned. | ||
| 608 | * See vmlinux.lds.S for details. | ||
| 601 | */ | 609 | */ |
| 602 | ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true); | 610 | ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true); |
| 603 | if (ret < 0) { | 611 | if (ret < 0) { |
| 604 | pr_err("unable to setup IMR for kernel: (%p - %p)\n", | 612 | pr_err("unable to setup IMR for kernel: %zu KiB (%lx - %lx)\n", |
| 605 | &_text, &__end_rodata); | 613 | size / 1024, start, end); |
| 606 | } else { | 614 | } else { |
| 607 | pr_info("protecting kernel .text - .rodata: %zu KiB (%p - %p)\n", | 615 | pr_info("protecting kernel .text - .rodata: %zu KiB (%lx - %lx)\n", |
| 608 | size / 1024, &_text, &__end_rodata); | 616 | size / 1024, start, end); |
| 609 | } | 617 | } |
| 610 | 618 | ||
| 611 | } | 619 | } |
