From: Herbert Xu <herbert@gondor.apana.org.au>
To: Taehee Yoo <ap420073@gmail.com>
Cc: linux-crypto@vger.kernel.org, davem@davemloft.net,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
ardb@kernel.org, ebiggers@google.com
Subject: Re: [PATCH] crypto: x86: Do not acquire fpu context for too long
Date: Tue, 4 Oct 2022 12:52:57 +0800 [thread overview]
Message-ID: <Yzu8Kd2botr3eegj@gondor.apana.org.au> (raw)
In-Reply-To: <20221004044912.24770-1-ap420073@gmail.com>
On Tue, Oct 04, 2022 at 04:49:12AM +0000, Taehee Yoo wrote:
>
> #define ECB_WALK_START(req, bsize, fpu_blocks) do { \
> void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req)); \
> + unsigned int walked_bytes = 0; \
> const int __bsize = (bsize); \
> struct skcipher_walk walk; \
> - int err = skcipher_walk_virt(&walk, (req), false); \
> + int err; \
> + \
> + err = skcipher_walk_virt(&walk, (req), false); \
> while (walk.nbytes > 0) { \
> - unsigned int nbytes = walk.nbytes; \
> - bool do_fpu = (fpu_blocks) != -1 && \
> - nbytes >= (fpu_blocks) * __bsize; \
> const u8 *src = walk.src.virt.addr; \
> - u8 *dst = walk.dst.virt.addr; \
> u8 __maybe_unused buf[(bsize)]; \
> - if (do_fpu) kernel_fpu_begin()
> + u8 *dst = walk.dst.virt.addr; \
> + unsigned int nbytes; \
> + bool do_fpu; \
> + \
> + if (walk.nbytes - walked_bytes > ECB_CBC_WALK_MAX) { \
> + nbytes = ECB_CBC_WALK_MAX; \
> + walked_bytes += ECB_CBC_WALK_MAX; \
> + } else { \
> + nbytes = walk.nbytes - walked_bytes; \
> + walked_bytes = walk.nbytes; \
> + } \
> + \
> + do_fpu = (fpu_blocks) != -1 && \
> + nbytes >= (fpu_blocks) * __bsize; \
> + if (do_fpu) \
> + kernel_fpu_begin()
>
> #define CBC_WALK_START(req, bsize, fpu_blocks) \
> ECB_WALK_START(req, bsize, fpu_blocks)
> @@ -65,8 +81,12 @@
> } while (0)
>
> #define ECB_WALK_END() \
> - if (do_fpu) kernel_fpu_end(); \
> + if (do_fpu) \
> + kernel_fpu_end(); \
> + if (walked_bytes < walk.nbytes) \
> + continue; \
> err = skcipher_walk_done(&walk, nbytes); \
> + walked_bytes = 0; \
> } \
> return err; \
> } while (0)
skcipher_walk_* is supposed to return at most a page. Why is this
necessary?
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2022-10-04 4:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 4:49 [PATCH] crypto: x86: Do not acquire fpu context for too long Taehee Yoo
2022-10-04 4:52 ` Herbert Xu [this message]
2022-10-04 6:01 ` Taehee Yoo
2022-10-04 15:16 ` Elliott, Robert (Servers)
2022-10-07 21:54 ` Ard Biesheuvel
2022-10-08 19:48 ` Elliott, Robert (Servers)
2022-10-09 6:19 ` Herbert Xu
2022-10-09 19:58 ` Elliott, Robert (Servers)
2022-10-11 15:16 ` Elliott, Robert (Servers)
2022-10-12 6:08 ` Taehee Yoo
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=Yzu8Kd2botr3eegj@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=ap420073@gmail.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=ebiggers@google.com \
--cc=hpa@zytor.com \
--cc=linux-crypto@vger.kernel.org \
--cc=mingo@redhat.com \
--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