From: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
To: Darren Hart <dvhart@infradead.org>
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
Boon Leong Ong <boon.leong.ong@intel.com>
Subject: Re: [PATCH 1/2] x86: Add Isolated Memory Regions for Quark X1000
Date: Tue, 06 Jan 2015 13:43:23 +0000 [thread overview]
Message-ID: <54ABE67B.1070706@nexus-software.ie> (raw)
In-Reply-To: <20150106073634.GB59754@vmdeb7>
On 06/01/15 07:36, Darren Hart wrote:
>> Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
>
> Since you have Intel (C) below and then your own, are you the sole author?
Yes, for the platform code.
Platform code tears-down IMRs and sets-up up a new one around the
kernel. Quark BSP does a similar thing in a different place.
To be safe I'm happy to add a Intel (C) to this file anyway.
>> +config IMR
>> + tristate "Isolated Memory Region support"
>> + default m
>> + depends on IOSF_MBI
>> + ---help---
>> + This option enables support for Isolated Memory Regions.
>
> It supports manipulating them specifically, correct? No support is needed to
> trigger an IMR violation and reboot the system, that happens in
> hardware/firmware without any OS involvement.
Exactly.
> So we're specifically providing the means to manipulate the IMRs.
True - I'll add that statement to the description.
>> +/*
>> + * Right now IMRs are not reported via CPUID though it'd be really great if
>> + * future silicon did report via CPUID for this feature bringing it in-line with
>> + * other similar features - like MTRRs, MSRs etc.
>
> I think we can drop the editorializing :-)
:)
>
> /*
> * Unfortunately, IMRs are not reported via CPUID, unlike MTRRs, MSRs, etc.
> * Define a macro analogous to cpu_has_x type features.
> */
Done.
>> +/* Definition of read/write masks from published BSP code */
>> +#define IMR_READ_ACCESS_ALL 0xBFFFFFFF
>> +#define IMR_WRITE_ACCESS_ALL 0xFFFFFFFF
>> +
>> +/* Number of IMRs provided by Quark X1000 SoC */
>> +#define QUARK_X1000_IMR_NUM 0x07
>
> Hrm, I thought there were 8?
There are. All of the loops look like this
for (i = 0; i <= imr_dev.num; i++)
aka
for (i = 0; i <= QUARK_X1000_IMR_NUM; i++)
Worth changing IMR_NUM to 8 and changing the loops to < IMR_NUM to
remove confusion.
> Also in the datasheet here:
>
> https://communities.intel.com/servlet/JiveServlet/previewBody/21828-102-2-25120/329676_QuarkDatasheet.pdf
>
>> + *
>> + * addr_lo
>> + * 31 Lock bit
>> + * 30 Enable bit - not implemented on Quark X1000
>
> With the exception of bit 30, also marked as reserved per the above datasheet.
Fair point. I'll refer to the spec directly for all of the bits.
>> +struct imr {
>> + u32 addr_lo;
>> + u32 addr_hi;
>> + u32 rmask;
>> + u32 wmask;
>> +};
>> +
>> +#define IMR_NUM_REGS (sizeof(struct imr)/sizeof(u32))
>
> Perhaps call the imr imr_regs so nobody breaks this in the future by adding
> something other than a u32 to it? Alternatively, use a datatype that enforces
> this... like the union Andy suggested...
I'll take a look and see which suggestion fits better
>> +#define IMR_SHIFT 8
>> +#define imr_to_phys(x) (x << IMR_SHIFT)
>> +#define phys_to_imr(x) (x >> IMR_SHIFT)
>> +
>> +/**
>> + * imr_enabled
>> + * Determines if an IMR is enabled based on address range
>> + *
>> + * @imr: Pointer to IMR descriptor
>> + * @return true if IMR enabled false if disabled
>> + */
>> +static int imr_enabled(struct imr *imr)
>> +{
>> + return (imr_to_phys(imr->addr_lo) && imr_to_phys(imr->addr_hi));
>
> What are testing here? You have bit 30 marked as "Enabled" above (but it isn't
> in the datasheet). With Reserved bits in each register, this test for non-zero
> doesn't seem robust.
Good question.
Bit 30 is not present in X1000 silicon, though is present in the BSP
code. Lets forget about all non-X1000 cases for now since X1000 is the
only processor currently available.
On X1000 the only means of determining if an IMR is enabled is if it's
address bits are set to some address everybody agrees means 'off', since
the enable bit doesn't exist. Everybody in this case is ROM, BIOS, 2nd
stage bootloader and kernel.
In the BSP code, that address is zero. So in lieu of bit 30 'enable' we
have address 0x00000000.
The kernel could define an alternative address to 0x00000000 but, then
this would break with the convention in BIOS etc.
Since BIOS and grub code both use 0x00000000 as the 'off' address I
think it makes sense for the kernel to continue to use that address.
>> + /* Error out if we have an overlap or no free IMR entries */
>
> According to the datasheet, overlapping ranges are valid, and access must be
> granted by all IMRs associated with a given address. Why declare an overlap as
> invalid here?
Simplicity.
It's more straight forward to define your IMR memory map if you don't
allow the address ranges to stomp all over each other.
None of the BSP reference code does overlap.
If there's an argument for an overlap use-case it can be supported
pretty simply by simply removing the overlap checks.
My own view is that it's not really desirable and easier to debug IMRs
generally on a platform if overlaps aren't allowed.
Best,
BOD
next prev parent reply other threads:[~2015-01-06 13:43 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-29 17:23 [PATCH 0/2] x86: Add IMR support to Quark/Galileo Bryan O'Donoghue
2014-12-29 17:23 ` [PATCH 1/2] x86: Add Isolated Memory Regions for Quark X1000 Bryan O'Donoghue
2014-12-31 15:05 ` Andy Shevchenko
2015-01-01 20:11 ` Bryan O'Donoghue
2015-01-06 7:36 ` Darren Hart
2015-01-06 13:43 ` Bryan O'Donoghue [this message]
2015-01-06 16:54 ` Darren Hart
2015-01-07 23:45 ` Ong, Boon Leong
2015-01-08 12:10 ` Bryan O'Donoghue
2015-01-08 14:52 ` Ong, Boon Leong
2015-01-08 0:04 ` Ong, Boon Leong
2015-01-08 13:08 ` Bryan O'Donoghue
2015-01-08 14:45 ` Ong, Boon Leong
2015-01-08 15:11 ` Bryan O'Donoghue
2015-01-09 3:44 ` Darren Hart
2014-12-29 17:23 ` [PATCH 2/2] platform/x86: Add Intel Galileo platform specific setup Bryan O'Donoghue
2014-12-31 15:25 ` Andy Shevchenko
2015-01-09 1:00 ` Ong, Boon Leong
2015-01-09 2:11 ` Bryan O'Donoghue
2015-01-09 4:46 ` Darren Hart
2015-01-09 11:17 ` Bryan O'Donoghue
2015-01-09 11:29 ` Bryan O'Donoghue
2015-01-09 14:11 ` Ong, Boon Leong
2015-01-10 6:54 ` Darren Hart
2015-01-11 1:53 ` Bryan O'Donoghue
2014-12-31 10:12 ` [PATCH 0/2] x86: Add IMR support to Quark/Galileo Andy Shevchenko
2014-12-31 11:59 ` Bryan O'Donoghue
2015-01-02 2:02 ` Darren Hart
2015-01-02 4:24 ` Darren Hart
2015-01-06 6:00 ` Darren Hart
2015-01-06 13:56 ` Bryan O'Donoghue
2015-01-06 16:48 ` Darren Hart
2015-01-06 17:23 ` Bryan O'Donoghue
-- strict thread matches above, loose matches on Subject: below --
2015-01-28 18:36 [PATCH v6 " Bryan O'Donoghue
2015-01-28 18:36 ` [PATCH 1/2] x86: Add Isolated Memory Regions for Quark X1000 Bryan O'Donoghue
2015-01-29 5:38 ` Darren Hart
2015-01-29 7:44 ` Ingo Molnar
2015-01-29 10:08 ` Andy Shevchenko
2015-01-29 10:12 ` Bryan O'Donoghue
2015-01-29 13:47 ` Ong, Boon Leong
2015-01-29 15:22 ` Bryan O'Donoghue
2015-01-29 15:32 ` Ong, Boon Leong
2015-01-29 15:40 ` Bryan O'Donoghue
2015-01-29 16:12 ` Bryan O'Donoghue
2015-01-29 16:26 ` Ong, Boon Leong
2015-01-29 15:15 ` Ong, Boon Leong
2015-01-29 13:27 ` Bryan O'Donoghue
2015-01-29 9:59 ` Ong, Boon Leong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54ABE67B.1070706@nexus-software.ie \
--to=pure.logic@nexus-software.ie \
--cc=boon.leong.ong@intel.com \
--cc=dvhart@infradead.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).