mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/1] x86/platform/quark: Print boundaries correctly
@ 2016-01-20 19:19 Andy Shevchenko
  2016-01-20 20:12 ` kbuild test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2016-01-20 19:19 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, linux-kernel, Ong,
	Boon Leong
  Cc: Andy Shevchenko

When we print values, such as @size, we have to understand that it's derived
from [begin .. end] as:

	size = end - begin + 1

On the opposite the @end is derived from the rest as:

	end = begin + size - 1

Correct the IMR code to print values correctly.

Note that @__end_rodata actually points to the next address after the aligned
.rodata section.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/platform/intel-quark/imr.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/platform/intel-quark/imr.c b/arch/x86/platform/intel-quark/imr.c
index 0ee619f..47fd18f 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)
 		if (imr_is_enabled(&imr)) {
 			base = imr_to_phys(imr.addr_lo);
 			end = imr_to_phys(imr.addr_hi) + IMR_MASK;
+			size = end - base + 1;
 		} else {
 			base = 0;
 			end = 0;
+			size = 0;
 		}
-		size = end - base;
 		seq_printf(s, "imr%02i: base=%pa, end=%pa, size=0x%08zx "
 			   "rmask=0x%08x, wmask=0x%08x, %s, %s\n", i,
 			   &base, &end, size, imr.rmask, imr.wmask,
@@ -598,14 +599,17 @@ static void __init imr_fixup_memmap(struct imr_device *idev)
 	 * Setup a locked IMR around the physical extent of the kernel
 	 * from the beginning of the .text secton to the end of the
 	 * .rodata section as one physically contiguous block.
+	 *
+	 * We don't round up @size since it is already PAGE_SIZE aligned.
+	 * See vmlinux.lds.S for details.
 	 */
 	ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true);
 	if (ret < 0) {
 		pr_err("unable to setup IMR for kernel: (%p - %p)\n",
-			&_text, &__end_rodata);
+			&_text, &__end_rodata - 1);
 	} else {
 		pr_info("protecting kernel .text - .rodata: %zu KiB (%p - %p)\n",
-			size / 1024, &_text, &__end_rodata);
+			size / 1024, &_text, &__end_rodata - 1);
 	}
 
 }
-- 
2.7.0.rc3

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 1/1] x86/platform/quark: Print boundaries correctly
  2016-01-20 19:19 [PATCH v1 1/1] x86/platform/quark: Print boundaries correctly Andy Shevchenko
@ 2016-01-20 20:12 ` kbuild test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2016-01-20 20:12 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: kbuild-all, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	linux-kernel, Ong, Boon Leong, Andy Shevchenko

[-- Attachment #1: Type: text/plain, Size: 2182 bytes --]

Hi Andy,

[auto build test ERROR on tip/auto-latest]
[also build test ERROR on v4.4 next-20160120]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/x86-platform-quark-Print-boundaries-correctly/20160121-032714
config: i386-allmodconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   arch/x86/platform/intel-quark/imr.c: In function 'imr_fixup_memmap':
>> arch/x86/platform/intel-quark/imr.c:600:3: error: invalid use of array with unspecified bounds
      pr_err("unable to setup IMR for kernel: (%p - %p)\n",
      ^
   arch/x86/platform/intel-quark/imr.c:603:3: error: invalid use of array with unspecified bounds
      pr_info("protecting kernel .text - .rodata: %zu KiB (%p - %p)\n",
      ^

vim +600 arch/x86/platform/intel-quark/imr.c

4fc6cc68 Andy Shevchenko  2016-01-20  594  	 *
4fc6cc68 Andy Shevchenko  2016-01-20  595  	 * We don't round up @size since it is already PAGE_SIZE aligned.
4fc6cc68 Andy Shevchenko  2016-01-20  596  	 * See vmlinux.lds.S for details.
28a375df Bryan O'Donoghue 2015-01-30  597  	 */
28a375df Bryan O'Donoghue 2015-01-30  598  	ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true);
28a375df Bryan O'Donoghue 2015-01-30  599  	if (ret < 0) {
28a375df Bryan O'Donoghue 2015-01-30 @600  		pr_err("unable to setup IMR for kernel: (%p - %p)\n",
4fc6cc68 Andy Shevchenko  2016-01-20  601  			&_text, &__end_rodata - 1);
28a375df Bryan O'Donoghue 2015-01-30  602  	} else {
28a375df Bryan O'Donoghue 2015-01-30  603  		pr_info("protecting kernel .text - .rodata: %zu KiB (%p - %p)\n",

:::::: The code at line 600 was first introduced by commit
:::::: 28a375df16c2b6d01227541f3956568995aa5fda x86/intel/quark: Add Isolated Memory Regions for Quark X1000

:::::: TO: Bryan O'Donoghue <pure.logic@nexus-software.ie>
:::::: CC: Ingo Molnar <mingo@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 53093 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-20 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 19:19 [PATCH v1 1/1] x86/platform/quark: Print boundaries correctly Andy Shevchenko
2016-01-20 20:12 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome