All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/2] dm-crypt: support relaxed memory alignment
@ 2025-11-24 17:09 Keith Busch
  2025-11-24 17:09 ` [PATCHv2 1/3] block: remove stacking default dma_alignment Keith Busch
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Keith Busch @ 2025-11-24 17:09 UTC (permalink / raw)
  To: dm-devel, linux-block, snitzer, hch, axboe, ebiggers; +Cc: Keith Busch

From: Keith Busch <kbusch@kernel.org>

Direct-io can support any memory alignment the hardware allows. Device
mappers don't need to impose any software constraints on memory
alignment, so this series removes one of those limitations.

Changes from the v1, which was an incomplete RFC:

 * A block layer prep patch to allow stacking drivers to define their
   own lower dma alignment limit.

 * Prevent reporting the relaxed alignment for any of the initialization
   vector types that use the scatterlist for other purposes beyond
   encrypt/decrypt.

 * Keep the error handling for data that unaligned data, but instead
   using the block device's queue limits.

 * Use the same scatterlist setup for both the in and out vectors.

 * Use multipage bvecs.

 * Check the alignment as the scatterlist is being built.

 * A follow up patch provides support for dynamic scatterlist allocation
   when the base bio has a lot fragmented segments. 

Keith Busch (3):
  block: remove stacking default dma_alignment
  dm-crypt: allow unaligned bio_vecs for direct io
  dm-crypt: dynamic scatterlist for many segments

 block/blk-settings.c  |   1 -
 drivers/md/dm-crypt.c | 105 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 86 insertions(+), 20 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: [PATCHv2 3/3] dm-crypt: dynamic scatterlist for many segments
  2025-11-24 17:09 ` [PATCHv2 3/3] dm-crypt: dynamic scatterlist for many segments Keith Busch
@ 2025-11-28  6:15 ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-11-28  3:22 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251124170903.3931792-4-kbusch@meta.com>
References: <20251124170903.3931792-4-kbusch@meta.com>
TO: Keith Busch <kbusch@meta.com>
TO: dm-devel@lists.linux.dev
TO: linux-block@vger.kernel.org
TO: snitzer@kernel.org
TO: hch@lst.de
TO: axboe@kernel.dk
TO: ebiggers@kernel.org
CC: Keith Busch <kbusch@kernel.org>

Hi Keith,

kernel test robot noticed the following build warnings:

[auto build test WARNING on device-mapper-dm/for-next]
[also build test WARNING on axboe/for-next linus/master v6.18-rc7 next-20251127]
[cannot apply to hch-configfs/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Keith-Busch/block-remove-stacking-default-dma_alignment/20251125-051340
base:   https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next
patch link:    https://lore.kernel.org/r/20251124170903.3931792-4-kbusch%40meta.com
patch subject: [PATCHv2 3/3] dm-crypt: dynamic scatterlist for many segments
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: i386-randconfig-141-20251127 (https://download.01.org/0day-ci/archive/20251128/202511281018.FNOzcP4r-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202511281018.FNOzcP4r-lkp@intel.com/

New smatch warnings:
drivers/md/dm-crypt.c:1510 crypt_convert_block_skcipher() warn: was || intended here instead of &&?

Old smatch warnings:
drivers/md/dm-crypt.c:3092 crypt_ctr_cipher_old() warn: missing unwind goto?

vim +1510 drivers/md/dm-crypt.c

c1048b5b3bef81 Keith Busch       2025-11-24  1432  
ef43aa38063a6b Milan Broz        2017-01-04  1433  static int crypt_convert_block_skcipher(struct crypt_config *cc,
ef43aa38063a6b Milan Broz        2017-01-04  1434  					struct convert_context *ctx,
ef43aa38063a6b Milan Broz        2017-01-04  1435  					struct skcipher_request *req,
ef43aa38063a6b Milan Broz        2017-01-04  1436  					unsigned int tag_offset)
ef43aa38063a6b Milan Broz        2017-01-04  1437  {
ef43aa38063a6b Milan Broz        2017-01-04  1438  	struct scatterlist *sg_in, *sg_out;
ef43aa38063a6b Milan Broz        2017-01-04  1439  	struct dm_crypt_request *dmreq;
ef43aa38063a6b Milan Broz        2017-01-04  1440  	u8 *iv, *org_iv, *tag_iv;
c13b5487d9dec7 Christoph Hellwig 2019-04-04  1441  	__le64 *sector;
c1048b5b3bef81 Keith Busch       2025-11-24  1442  	int r;
8f0009a225171c Milan Broz        2017-03-16  1443  
ef43aa38063a6b Milan Broz        2017-01-04  1444  	dmreq = dmreq_of_req(cc, req);
c66029f4d42264 Mikulas Patocka   2012-07-27  1445  	dmreq->iv_sector = ctx->cc_sector;
8f0009a225171c Milan Broz        2017-03-16  1446  	if (test_bit(CRYPT_IV_LARGE_SECTORS, &cc->cipher_flags))
ff3af92b4461be Mikulas Patocka   2017-03-23  1447  		dmreq->iv_sector >>= cc->sector_shift;
b2174eebd1fadb Ying Huang        2009-03-16  1448  	dmreq->ctx = ctx;
45711f1af6eff1 Jens Axboe        2007-10-22  1449  
ef43aa38063a6b Milan Broz        2017-01-04  1450  	*org_tag_of_dmreq(cc, dmreq) = tag_offset;
^1da177e4c3f41 Linus Torvalds    2005-04-16  1451  
ef43aa38063a6b Milan Broz        2017-01-04  1452  	iv = iv_of_dmreq(cc, dmreq);
ef43aa38063a6b Milan Broz        2017-01-04  1453  	org_iv = org_iv_of_dmreq(cc, dmreq);
ef43aa38063a6b Milan Broz        2017-01-04  1454  	tag_iv = iv_tag_from_dmreq(cc, dmreq);
ef43aa38063a6b Milan Broz        2017-01-04  1455  
ef43aa38063a6b Milan Broz        2017-01-04  1456  	sector = org_sector_of_dmreq(cc, dmreq);
ef43aa38063a6b Milan Broz        2017-01-04  1457  	*sector = cpu_to_le64(ctx->cc_sector - cc->iv_offset);
ef43aa38063a6b Milan Broz        2017-01-04  1458  
02664d2ac0d3cf Keith Busch       2025-11-24  1459  	dmreq->__sg_in = NULL;
02664d2ac0d3cf Keith Busch       2025-11-24  1460  	dmreq->__sg_out = NULL;
ef43aa38063a6b Milan Broz        2017-01-04  1461  	sg_in  = &dmreq->sg_in[0];
ef43aa38063a6b Milan Broz        2017-01-04  1462  	sg_out = &dmreq->sg_out[0];
^1da177e4c3f41 Linus Torvalds    2005-04-16  1463  
02664d2ac0d3cf Keith Busch       2025-11-24  1464  	r = crypt_build_sgl(cc, &sg_in, &ctx->iter_in, ctx->bio_in,
c1048b5b3bef81 Keith Busch       2025-11-24  1465  			    ARRAY_SIZE(dmreq->sg_in));
c1048b5b3bef81 Keith Busch       2025-11-24  1466  	if (r < 0)
c1048b5b3bef81 Keith Busch       2025-11-24  1467  		return r;
02664d2ac0d3cf Keith Busch       2025-11-24  1468  	else if (sg_in != dmreq->sg_in)
02664d2ac0d3cf Keith Busch       2025-11-24  1469  		dmreq->__sg_in = sg_in;
ef43aa38063a6b Milan Broz        2017-01-04  1470  
02664d2ac0d3cf Keith Busch       2025-11-24  1471  	r = crypt_build_sgl(cc, &sg_out, &ctx->iter_out, ctx->bio_out,
c1048b5b3bef81 Keith Busch       2025-11-24  1472  			    ARRAY_SIZE(dmreq->sg_out));
02664d2ac0d3cf Keith Busch       2025-11-24  1473  	if (r < 0) {
02664d2ac0d3cf Keith Busch       2025-11-24  1474  		kfree(dmreq->__sg_in);
c1048b5b3bef81 Keith Busch       2025-11-24  1475  		return r;
02664d2ac0d3cf Keith Busch       2025-11-24  1476  	} else if (sg_out != dmreq->sg_out) {
02664d2ac0d3cf Keith Busch       2025-11-24  1477  		dmreq->__sg_in = sg_out;
02664d2ac0d3cf Keith Busch       2025-11-24  1478  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  1479  
3a7f6c990ad04e Milan Broz        2008-02-08  1480  	if (cc->iv_gen_ops) {
ef43aa38063a6b Milan Broz        2017-01-04  1481  		/* For READs use IV stored in integrity metadata */
ef43aa38063a6b Milan Broz        2017-01-04  1482  		if (cc->integrity_iv_size && bio_data_dir(ctx->bio_in) != WRITE) {
ef43aa38063a6b Milan Broz        2017-01-04  1483  			memcpy(org_iv, tag_iv, cc->integrity_iv_size);
ef43aa38063a6b Milan Broz        2017-01-04  1484  		} else {
ef43aa38063a6b Milan Broz        2017-01-04  1485  			r = cc->iv_gen_ops->generator(cc, org_iv, dmreq);
3a7f6c990ad04e Milan Broz        2008-02-08  1486  			if (r < 0)
02664d2ac0d3cf Keith Busch       2025-11-24  1487  				goto out;
bbb1658461ac85 Milan Broz        2020-01-03  1488  			/* Data can be already preprocessed in generator */
bbb1658461ac85 Milan Broz        2020-01-03  1489  			if (test_bit(CRYPT_ENCRYPT_PREPROCESS, &cc->cipher_flags))
bbb1658461ac85 Milan Broz        2020-01-03  1490  				sg_in = sg_out;
ef43aa38063a6b Milan Broz        2017-01-04  1491  			/* Store generated IV in integrity metadata */
ef43aa38063a6b Milan Broz        2017-01-04  1492  			if (cc->integrity_iv_size)
ef43aa38063a6b Milan Broz        2017-01-04  1493  				memcpy(tag_iv, org_iv, cc->integrity_iv_size);
ef43aa38063a6b Milan Broz        2017-01-04  1494  		}
ef43aa38063a6b Milan Broz        2017-01-04  1495  		/* Working copy of IV, to be modified in crypto API */
ef43aa38063a6b Milan Broz        2017-01-04  1496  		memcpy(iv, org_iv, cc->iv_size);
3a7f6c990ad04e Milan Broz        2008-02-08  1497  	}
3a7f6c990ad04e Milan Broz        2008-02-08  1498  
8f0009a225171c Milan Broz        2017-03-16  1499  	skcipher_request_set_crypt(req, sg_in, sg_out, cc->sector_size, iv);
3a7f6c990ad04e Milan Broz        2008-02-08  1500  
3a7f6c990ad04e Milan Broz        2008-02-08  1501  	if (bio_data_dir(ctx->bio_in) == WRITE)
bbdb23b5d69521 Herbert Xu        2016-01-24  1502  		r = crypto_skcipher_encrypt(req);
3a7f6c990ad04e Milan Broz        2008-02-08  1503  	else
bbdb23b5d69521 Herbert Xu        2016-01-24  1504  		r = crypto_skcipher_decrypt(req);
3a7f6c990ad04e Milan Broz        2008-02-08  1505  
2dc5327d3acb33 Milan Broz        2011-01-13  1506  	if (!r && cc->iv_gen_ops && cc->iv_gen_ops->post)
ef43aa38063a6b Milan Broz        2017-01-04  1507  		r = cc->iv_gen_ops->post(cc, org_iv, dmreq);
ef43aa38063a6b Milan Broz        2017-01-04  1508  
02664d2ac0d3cf Keith Busch       2025-11-24  1509  out:
02664d2ac0d3cf Keith Busch       2025-11-24 @1510  	if (r == -EINPROGRESS && r == -EBUSY) {
02664d2ac0d3cf Keith Busch       2025-11-24  1511  		kfree(dmreq->__sg_in);
02664d2ac0d3cf Keith Busch       2025-11-24  1512  		kfree(dmreq->__sg_out);
02664d2ac0d3cf Keith Busch       2025-11-24  1513  		dmreq->__sg_in = NULL;
02664d2ac0d3cf Keith Busch       2025-11-24  1514  		dmreq->__sg_out = NULL;
02664d2ac0d3cf Keith Busch       2025-11-24  1515  	}
3a7f6c990ad04e Milan Broz        2008-02-08  1516  	return r;
01482b7671d014 Milan Broz        2008-02-08  1517  }
01482b7671d014 Milan Broz        2008-02-08  1518  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCHv2 0/2] dm-crypt: support relaxed memory alignment
@ 2026-01-14 15:41 Keith Busch
  2026-01-14 15:41 ` [PATCHv2 1/3] block: remove stacking default dma_alignment Keith Busch
  0 siblings, 1 reply; 10+ messages in thread
From: Keith Busch @ 2026-01-14 15:41 UTC (permalink / raw)
  To: dm-devel, linux-block, snitzer, hch, axboe, ebiggers; +Cc: Keith Busch

From: Keith Busch <kbusch@kernel.org>

Direct-io can support any memory alignment the hardware allows. Device
mappers don't need to impose any software constraints on memory
alignment, so this series removes one of those limitations.

Changes from the v1, which was an incomplete RFC:

 * A block layer prep patch to allow stacking drivers to define their
   own lower dma alignment limit.

 * Prevent reporting the relaxed alignment for any of the initialization
   vector types that use the scatterlist for other purposes beyond
   encrypt/decrypt.

 * Keep the error handling for data that unaligned data, but instead
   using the block device's queue limits.

 * Use the same scatterlist setup for both the in and out vectors.

 * Use multipage bvecs.

 * Check the alignment as the scatterlist is being built.

 * A follow up patch provides support for dynamic scatterlist allocation
   when the base bio has a lot fragmented segments. 

Keith Busch (3):
  block: remove stacking default dma_alignment
  dm-crypt: allow unaligned bio_vecs for direct io
  dm-crypt: dynamic scatterlist for many segments

 block/blk-settings.c  |   1 -
 drivers/md/dm-crypt.c | 105 ++++++++++++++++++++++++++++++++++--------
 2 files changed, 86 insertions(+), 20 deletions(-)

-- 
2.47.3


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

end of thread, other threads:[~2026-01-14 15:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-24 17:09 [PATCHv2 0/2] dm-crypt: support relaxed memory alignment Keith Busch
2025-11-24 17:09 ` [PATCHv2 1/3] block: remove stacking default dma_alignment Keith Busch
2025-11-24 17:12   ` Christoph Hellwig
2025-11-25  2:49     ` Keith Busch
2025-11-25  6:35       ` Christoph Hellwig
2025-11-24 17:09 ` [PATCHv2 2/3] dm-crypt: allow unaligned bio_vecs for direct io Keith Busch
2025-11-24 17:09 ` [PATCHv2 3/3] dm-crypt: dynamic scatterlist for many segments Keith Busch
  -- strict thread matches above, loose matches on Subject: below --
2025-11-28  3:22 kernel test robot
2025-11-28  6:15 ` Dan Carpenter
2026-01-14 15:41 [PATCHv2 0/2] dm-crypt: support relaxed memory alignment Keith Busch
2026-01-14 15:41 ` [PATCHv2 1/3] block: remove stacking default dma_alignment Keith Busch

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.