Re: [PATCH v2 1/1] x86: Add Isolated Memory Regions for Quark X1000

From: Andy Shevchenko
Date: Thu Jan 22 2015 - 03:59:49 EST


On Thu, Jan 22, 2015 at 3:27 AM, Bryan O'Donoghue
<pure.logic@xxxxxxxxxxxxxxxxx> wrote:
> On 21/01/15 20:57, Andy Shevchenko wrote:

[]

>>> + ret = iosf_mbi_write(QRK_MBI_UNIT_MM, QRK_MBI_MM_WRITE,
>>> + reg++, imr->rmask);
>>> + if (ret)
>>> + goto done;
>>> +
>>> + ret = iosf_mbi_write(QRK_MBI_UNIT_MM, QRK_MBI_MM_WRITE,
>>> + reg, imr->wmask);
>>
>>
>> Wouldn't be reg++ here as well? Below you substitute full offset which
>> I think points just to next register.
>
>
> I don't think we want to increment below..
>
>>
>>> + if (ret)
>>> + goto done;
>>> +
>>> + /* Lock bit must be set separately to addr_lo address bits */
>>> + if (lock) {
>>> + imr->addr_lo |= IMR_LOCK;
>>> + ret = iosf_mbi_write(QRK_MBI_UNIT_MM, QRK_MBI_MM_WRITE,
>>> + reg - IMR_LOCK_OFF,
>>> imr->addr_lo);
>>> + }
>
>
> ..because we calculate an offset anyway. An additional increment would just
> be unnecessary cycles.

Offset is a compile-time constant, right? And it should be 4.
Otherwise its meaning somehow looks confusing. I looked again and
would recommend to substitute it by NUM_REGS here and leave register
increment. I don't think it's a really big deal to waste CPU cycles
here since you use slower IOSF communication.

>>> + pr_info("protecting kernel .text - .rodata: %ldk (%p -
>>> %p)\n",
>>> + size / 1024, &_text, &__end_rodata);
>>
>>
>> size >> 10
>
>
> Andy.
>
> It was size >> 10 for V1 and you called it out as a magic number :)
>
> IMO, size / 1024 requires less thought to understand when reading the code.

Oh, my bad. Now a bit modified suggestion, to add KiB inside format
string and leave / 1024. Would it work for you?

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/