All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Horia Geantă" <horia.geanta@nxp.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 5/6] crypto/fsl: instantiate the RNG with prediciton resistance
Date: Fri, 19 Jun 2020 19:54:47 +0300	[thread overview]
Message-ID: <1d3c9aa6-d352-ef98-e3db-450562504d6c@nxp.com> (raw)
In-Reply-To: <07b4dce1-3d8b-1a5b-15ce-2df7d6146e75@nxp.com>

On 6/19/2020 7:37 PM, Horia Geanta wrote:
> On 6/17/2020 11:48 PM, Michael Walle wrote:
>> Am 2020-06-17 21:15, schrieb Horia Geant?:
>>> On 6/4/2020 6:48 PM, Michael Walle wrote:
>>>> +
>>>> +	desc = memalign(ARCH_DMA_MINALIGN, desc_size);
>>>> +	if (!desc) {
>>>> +		debug("cannot allocate RNG init descriptor memory\n");
>>>> +		return -ENOMEM;
>>>> +	}
>>>> +
>>>> +	for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) {
>>>> +		/*
>>>> +		 * If the corresponding bit is set, then it means the state
>>>> +		 * handle was initialized by us, and thus it needs to be
>>>> +		 * deinitialized as well
>>>> +		 */
>>>> +
>>>> +		if (state_handle_mask & RDSTA_IF(sh_idx)) {
>>>> +			/*
>>>> +			 * Create the descriptor for deinstantating this state
>>>> +			 * handle.
>>>> +			 */
>>>> +			inline_cnstr_jobdesc_rng_deinstantiation(desc, sh_idx);
>>>> +			flush_dcache_range((unsigned long)desc,
>>>> +					   (unsigned long)desc + desc_size);
>>> Shouldn't this be roundup(desc_size, ARCH_DMA_MINALIGN) instead of 
>>> desc_size?
>>
>> I've seen the same idioms sometimes, but it wasn't clear to me why that 
>> would
>> be needed; the hardware only uses the desc_size, right?
>>
> Yes, HW will use only [desc, desc + desc_size].
> 
> I think this is needed to avoid cacheline sharing issues
> on non-coherent platforms: CPU needs to make sure a larger area
> is written back to memory and corresponding cache lines are invalidated.
> 
> Looking at flush_dcache_range() implementation, it does its own rounding,
> based on CTR_EL0[DminLine] - "smallest data cache line size".
> I guess this value might be smaller than ARCH_DMA_MINALIGN,
> hence the explicit rounding to ARCH_DMA_MINALIGN is needed.
> 
Btw, I think
	desc = memalign(ARCH_DMA_MINALIGN, desc_size);
needs to be replaced with
	desc = malloc_cache_aligned(desc_size);

Horia

  reply	other threads:[~2020-06-19 16:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 15:46 [PATCH v2 0/6] crypto/fsl: add RNG support Michael Walle
2020-06-04 15:46 ` [PATCH v2 1/6] crypto/fsl: make SEC%u status line consistent Michael Walle
2020-06-16 14:02   ` Horia Geantă
2020-06-04 15:46 ` [PATCH v2 2/6] crypto/fsl: export caam_get_era() Michael Walle
2020-06-04 15:46 ` [PATCH v2 3/6] crypto/fsl: support newer SEC modules Michael Walle
2020-06-04 15:46 ` [PATCH v2 4/6] crypto/fsl: don't regenerate secure keys Michael Walle
2020-06-17 18:03   ` Horia Geantă
2020-06-17 20:25     ` Michael Walle
2020-06-04 15:46 ` [PATCH v2 5/6] crypto/fsl: instantiate the RNG with prediciton resistance Michael Walle
2020-06-04 16:16   ` Michael Walle
2020-06-17 19:15   ` Horia Geantă
2020-06-17 20:48     ` Michael Walle
2020-06-19 16:37       ` Horia Geantă
2020-06-19 16:54         ` Horia Geantă [this message]
2020-06-19 19:02           ` Michael Walle
2020-06-22 14:30             ` Horia Geantă
2020-06-04 15:46 ` [PATCH v2 6/6] crypto/fsl: add RNG support Michael Walle
2020-06-17 20:09   ` Horia Geantă
2020-06-17 20:55     ` Michael Walle

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=1d3c9aa6-d352-ef98-e3db-450562504d6c@nxp.com \
    --to=horia.geanta@nxp.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.