From nobody Wed Apr 15 16:24:34 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61F953321D8 for ; Wed, 4 Mar 2026 12:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772626659; cv=none; b=XSj5yug7rYTo+2r4QXYhawlLFJiBsD8yqCunuZQSmsu3WPCF5tDILoAu5AyAlTIrFmird8BQXkDeHxLKsi3iCx1HNQOTTAad0PNTdZenXW7432hJq0MbPxa4NDbwlSO1fzMI3EqZkiof8bPr42AiRn5cSKmPADiXGCqDFZadmNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772626659; c=relaxed/simple; bh=BITlx4Kwj5eBbWFc9rslpJa2+01NebOQNTaEdmYUQ24=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=msDSYwMeMJhY5eCbi6Rfv+NB1appvdMT4tC5FcPOzVU5lfgqGFdfALKfItzr0HktWBDvYXAu4yIppvlITczLbcr+UhE/jLNU+y9XOv+vxuZLoyb33cBW/aeafQb45B3IfUXNlOuD3mD1gyur7e4MwZjExoI1FScqi4zMP9aUXKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=dTUyy5pL; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=A0GddL4C; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="dTUyy5pL"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="A0GddL4C" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 624BuD1x2306170 for ; Wed, 4 Mar 2026 12:17:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=uShH14l/dWy 0o1Tl9pcZPJ74mlezSCjEKQRN2uJbI/U=; b=dTUyy5pL5dK3eS9CPhL4giyELS5 cV7sxqB2c+oBOak+3ANLThm4WjU0Hx8IunPjFNxTIevTOIXAGVpBxzUjCafs3HiI KFyf+seIdc4WYxXRtT8ecqDcV1B777gDj1WuRLVTO27T0PjmFKTwGMh86aQJ/RU5 peafPuQqcgSaBaCqiTzWLDxnO2c7iAd7lL0wWx+AfQ40CLukByJ2OEgzj8GHmUOD VPZ1JliZnuxPTiN/RpCGG+XsGiE0E/SvNwaiHWPyukJ6oOqTSuXjy0agmGy9MEpc CAD4Pb4gHnAiNnTioiY0N3kfMM0IxQibnP8n9HwXkqz1BSiXD7rf7IT+VBQ== Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cpau8t2tv-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 04 Mar 2026 12:17:37 +0000 (GMT) Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-12711ec96fbso107479736c88.0 for ; Wed, 04 Mar 2026 04:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772626657; x=1773231457; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uShH14l/dWy0o1Tl9pcZPJ74mlezSCjEKQRN2uJbI/U=; b=A0GddL4CavOOmpZ9Z1kg8vsHQlVAVk1Ui1oxBOf2ejGAAyKQnDzqkctDkDAseFgkIN 7lbWL/ENohFKl8XPjhqwBbLQ4vmkjusE9TkPOYutqKtSEV7QTI/PbclVWB7zSS9myrKh gmZFJ6AR9yA2dWNudNeRv4lDRdb4a2EwkdqwRYuMJxGLyyaIfldpupq5GC2V2C7B+0ew 1ghaTmWBdTL74teDYRUNsXxhfLQE5g5oN1bYXTaShgrhTS5uX2I85nNSheAlA9aAHVYi 9cf3Bsub27K0e+LCY3TGgb9hxR2Cr5U0YTL3q0BU+rqjOFgO3fdURc7xJwBCcmjck0Tk 79nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772626657; x=1773231457; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uShH14l/dWy0o1Tl9pcZPJ74mlezSCjEKQRN2uJbI/U=; b=rMF9ZP0sFbICNMYALE+j93zcYGh1MqLXlVcOo7aHKbr00iWs5jZQQDoZtDujiKfzZo ms5WbXOSRIFK1tlqBK2TVxVvkxwEgKFOF0IkFcxGZrntTRAt5viVE+9jbIBb+m3JbUiz GECn6rKrFt8XN67Eh8BbCtBC+XerjKhuaVJjZ8/4PSBc46PkcjQMjuGOgSGCkKlCZEjg OMlTEBs2DAanFMu2R8dFgtu7GrroPybvG69sB0hTwMfmhZCelfGeQpKPStyGBt1hKMlJ MZ0szqXqwyJYO9LpPtzwZ2sIX0IAXRfyEWZcA55Hz6a2cu3Kg5LcztXnqct/4iXsqc63 gWsg== X-Gm-Message-State: AOJu0YwAOM+soLmqQev9TxM5ThKWNoDnjc8FZA5D++KmoZyD1tx97u+a /gr0VENEuX6icq0gFdx4Oi18FZCwOjxK7Mzb09LvgZziOR0R2gmjdCdyGsg6AcFoGlUh3HU1XRp QYeqtuN5hjC9RDMMYp8b0hr4Wxi6ueI+bLnFFTPmgf13ASI0+INkI9uoynnX3LjYIsNI= X-Gm-Gg: ATEYQzyz2tUjSB+l3MdThEl51yuggyIfwmj64tkDikuF5nMbahMbUZkYECa3zkb3X+Y mXPyCQ1vJoJNV3nVn4rEN5jpX/7hOqjWJMyJRx3QwulP7xYl3gF2orN6cNfSAq0xBpzR/+bJPzP WxVdsw7OuBa6SR2VXRYt0kU1ogB5I0FouFB6uo+sTb+SFIJToRdRtRciqzhxy7lE8zmRe7Irq6Z gwN+EW5Tkv+YJYfLjLfv/xUN6i3q5vI8ay2/Y/N+GCxvSBf43HZH0SDmVmAs2hXNpyqZ4U0h6Aq arK36CG+QH9OkzN+6Mt6P6qe00PBPtqBjveqCitUZWqvUkKFHIf+jYQ7UKVqC062QNWGeKn46gQ 5o44ViKjV9FubBOi9AEa8K046YVA2DxH6FTXRUjZrOMofYW/dKfndBf7gGPf+P1bFSJOAuoDHi7 CeI0Gi X-Received: by 2002:a05:7022:789:b0:127:3480:7c9f with SMTP id a92af1059eb24-128b70824a3mr855154c88.10.1772626657175; Wed, 04 Mar 2026 04:17:37 -0800 (PST) X-Received: by 2002:a05:7022:789:b0:127:3480:7c9f with SMTP id a92af1059eb24-128b70824a3mr855137c88.10.1772626656661; Wed, 04 Mar 2026 04:17:36 -0800 (PST) Received: from u20-san1p10573.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-127899dfc47sm22171276c88.6.2026.03.04.04.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 04:17:36 -0800 (PST) From: Linlin Zhang To: linux-block@vger.kernel.org, ebiggers@kernel.org Cc: linux-kernel@vger.kernel.org, adrianvovk@gmail.com, dm-devel@lists.linux.dev, quic_mdalam@quicinc.com, gmazyland@gmail.com, israelr@nvidia.com, mpatocka@redhat.com Subject: [PATCH v1 1/3] block: export blk-crypto symbols required by dm-inlinecrypt Date: Wed, 4 Mar 2026 04:17:26 -0800 Message-Id: <20260304121729.1532469-2-linlin.zhang@oss.qualcomm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260304121729.1532469-1-linlin.zhang@oss.qualcomm.com> References: <20260304121729.1532469-1-linlin.zhang@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=AJS1/0o2 c=1 sm=1 tr=0 ts=69a822e1 cx=c_pps a=kVLUcbK0zfr7ocalXnG1qA==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=1XWaLZrsAAAA:8 a=pkKqxYWgxMMasECMkqIA:9 a=vr4QvYf-bLy2KjpDp97w:22 X-Proofpoint-ORIG-GUID: 8vzXBemuhd0BZkuBKyY1du43EBrmdzCU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA0MDA5NyBTYWx0ZWRfX8uXqtYpSp7Qx uYG5QYOQxiKzhqJVj0Uf1/1BvgGon8pHWRTBWYOy9JC9sin7qgRddp3W4ydG50a+G+ujFfFJ9ik R7GwrdDnC3vIf46MM1DWtdeGb2cTvWGVqMUvSCvWRzg7HqSI8NIqJn4E2MqIaP1+P8Jk+LXcDO/ 5/gWyY2dCxbI19cO0fDR4vTwHmATL66NWHy9/G9ZLXtb9Hbg5MsrhqWjgw3HQ0nu8K98E2waIJV acQTs66kHGXFZOvIUy+rqWlnFTJsLFlhpHdG1HSpxkQwZ8tIQ/ih0SQWqtOCg6zgVnDamn9Lxj0 r5fvIHCckVdZaKAV/5K1X2k3K+QBGXfgMMLohtFnxmfl+pdczRgrv2HuwclcH0yW4b/npfvws69 EHQeWMGVEpzX8XL/jXuzOaMDQN2zdWDsbZhkx2gu3HEqG9Cp8ZbcCJZlN09A4N/2sqkFjoXkpto wOO7xg/6X2leTF82Jew== X-Proofpoint-GUID: 8vzXBemuhd0BZkuBKyY1du43EBrmdzCU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-04_05,2026-03-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 priorityscore=1501 clxscore=1011 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603040097 Content-Type: text/plain; charset="utf-8" From: Eric Biggers bio_crypt_set_ctx(), blk_crypto_init_key(), and blk_crypto_start_using_key() are needed to use inline encryption; see Documentation/block/inline-encryption.rst. Export them so that dm-inlinecrypt can use them. The only reason these weren't exported before was that inline encryption was previously used only by fs/crypto/ which is built-in code. Signed-off-by: Eric Biggers Reviewed-by: Jens Axboe --- block/blk-crypto.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-crypto.c b/block/blk-crypto.c index 856d3c5b1fa0..40a99a859748 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -116,6 +116,7 @@ void bio_crypt_set_ctx(struct bio *bio, const struct bl= k_crypto_key *key, =20 bio->bi_crypt_context =3D bc; } +EXPORT_SYMBOL_GPL(bio_crypt_set_ctx); =20 void __bio_crypt_free_ctx(struct bio *bio) { @@ -349,6 +350,7 @@ int blk_crypto_init_key(struct blk_crypto_key *blk_key, =20 return 0; } +EXPORT_SYMBOL_GPL(blk_crypto_init_key); =20 bool blk_crypto_config_supported_natively(struct block_device *bdev, const struct blk_crypto_config *cfg) @@ -399,6 +401,7 @@ int blk_crypto_start_using_key(struct block_device *bde= v, } return blk_crypto_fallback_start_using_mode(key->crypto_cfg.crypto_mode); } +EXPORT_SYMBOL_GPL(blk_crypto_start_using_key); =20 /** * blk_crypto_evict_key() - Evict a blk_crypto_key from a block_device --=20 2.34.1 From nobody Wed Apr 15 16:24:34 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33C923A8728 for ; Wed, 4 Mar 2026 12:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772626662; cv=none; b=eeTlXcIf0j9WyLc5XmBk9S6AZTmNPmNwvXeUejNd/r6u5N7NBg0yYZ469A4uv3jT4ycR06I/cSVf2WxQJBiJh6kNo2p5RduPKtnF7ZDn4qTFWb3MnvqQKNaIxDtqkLpMdceKOC3TcpgOU/gsBufbYpRzAovy1Tjsvgf1Kol36jk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772626662; c=relaxed/simple; bh=njh2bthj7lGQKOViJkMsU6uM3q4SBHiy3HpXfN1BycA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TltSutPwDHmP+cpP0rZ3xqFFlRwDGKr5FEWa3h149b/zwX3DAeU8FocBrydqIwRVxD0X268wGbZbakotj24/xBwj8W84z97/MqcFLOZ4Pb9zyz+UaLvzRl56tvnRUSakc8T4HHOLW3PcdrHDm9vdeGT80P5SjJ4/7W56YSqxM7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=B3D52abH; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=PQ5NosSZ; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="B3D52abH"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="PQ5NosSZ" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 624C0qbB2306277 for ; Wed, 4 Mar 2026 12:17:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=PUsU+4Fm1/B 5TzpCA65Vgoz/dx4A6WK4RfM6wueuLh8=; b=B3D52abHqMNtONXi1OsInS3cW5e ZzlUkRV4YuY9ifnnhkQAOT21OEU6/arAFLgLjU0ghw780jLIFWXMqXOqxoWVq/eF isYT4AsgpSRVz+geRfIp9BIMp9ebvn3j5MAEjO1m5zQmFvnGXij69pvxTjaiwbpi iuR9nM8rtN+0GnOYBCkG0xe3uzWoA+dgxlWPjptdOouSeclglyDwPz+Nnow/zDlp mgYQjuy7YA7CnWG0ZmlKhkATe6aqDLV006hd0HnZQi0cDd9NSaiI3+m/k7XJAEtm TFmwOMh1FXL5q7NkH8V0iyZed+l0TrVo1Up/Oud/u+XjEQI2oGvOS9f/JTg== Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cpau8t2u0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 04 Mar 2026 12:17:39 +0000 (GMT) Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-12734af2ca4so5267296c88.0 for ; Wed, 04 Mar 2026 04:17:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772626659; x=1773231459; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PUsU+4Fm1/B5TzpCA65Vgoz/dx4A6WK4RfM6wueuLh8=; b=PQ5NosSZF3F4V9BYDJua9apL/+V74uNf89Fx/I1bwv/a4aimfEjZixht4RuqdCdDNW HZIdM4NWaJDtDBO3UyeW4/vFBepHZLi447CskuD0uPOvyQxmLaREyRZ5oFO41bqlx02f GRXoD6Cqt6cUxyrm2JV2hUIQCzlguQcESw6BSxX25Bsw49Ej54QLu4Qx6fnf52A6qK3H snksfAAfnnc6sLpJ89SB1pqiWDckm2o84+/vk+NsGlhao/jvhsvzHeEKwzEnwzgWbiM1 E7DA/R5o1Ok3ydnoCVvqoPFM3Bz+DhweTFdicCT5IW0zL9mDe9ApRvIQLy7TSmUFZ8/Q okeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772626659; x=1773231459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PUsU+4Fm1/B5TzpCA65Vgoz/dx4A6WK4RfM6wueuLh8=; b=n/+L9RzJkX75+YqjjgRxWhunEPQvJHvDTFyDtriLqxhpc6BDaKog5gV1R3Y4+aU5+N Fpq/Y52M0lE22AkPvLe82cYGepO/ME53Ahb3ir5l/MTMk7qIS7KIleAMvpE3o52PqxPn rE7rhBsMeviK0zn7uzdkrFubDTyKQsMLqiJll3wEYlMb8a/zb9W+uaH2+qt+NBYzroSy pS2JF2Opkg1NFe/0keCqWTlUdvNIjhskjxepzjJAvDMQoMT/ejggw7HWXVeZyfeHD9en OvTY8ptwScAb1rQYZHut2SNlD02d0P1cOt9UxxF8C84FMYoYwpXxAt9zDtkIMduGChqQ 5mdA== X-Gm-Message-State: AOJu0Yy3A8Fu5uI1GDchWBVwIP3zF5TRZzzHXZWgbOEfcNS/GFGEyB4+ MJbTliOIFJv984bgWPT1DnAZLRFa9J3TgdjSdhGU0bF1SSHjoKfWz43cyEcNIFZcRaN9S6HFOTa U9gXZVR+4/ASQgYEjP3boxCTKR/M+Sr54KyfNTBkVYAR2ksOnQBY2vHEQMR9k6vGvqiM= X-Gm-Gg: ATEYQzwO73Q1nNRDnFxmB+FOrsizJJkI0/O6F/t7zIDowX82Rjk51Ss8MwTJf3/I9YG Fiu4Mu4YriOr+NIVGjponu41GdNr4XyEVJY1eKcI457YvMUCIErn0dhi54bNI7eiHjHMsFEjL33 sEClWRmteOUqqD29Z3yfoR7NdTLHyE0exDaaS90htsdYPavmqH3CvB9rk9DDOTpLSSNZbvnTUsY 3vr07FLG2fkqaNWQQuqW5H2PaVhGmB4AFDcynNDx+thu0bXyXz3rlmpRnWbtKGoTTh8z2LLKsW+ shVDREcO1wZNVdJWlujDzwTF/jcTc7uhxucjz6aVCr+Z/Kl6ZELtsW5fV47OMoU0+tb8dicwXBA RFLU09PmQCUfWZNiMlfz2K0RYz8eyYUgpgTvsS3wbKmh0QISBHza9rKTRJhI9FNPSMNGNuWgHFS +6E3Vw X-Received: by 2002:a05:7022:608e:b0:127:9cad:f3d5 with SMTP id a92af1059eb24-128b6fa44acmr609760c88.7.1772626658669; Wed, 04 Mar 2026 04:17:38 -0800 (PST) X-Received: by 2002:a05:7022:608e:b0:127:9cad:f3d5 with SMTP id a92af1059eb24-128b6fa44acmr609755c88.7.1772626657961; Wed, 04 Mar 2026 04:17:37 -0800 (PST) Received: from u20-san1p10573.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-127899dfc47sm22171276c88.6.2026.03.04.04.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 04:17:37 -0800 (PST) From: Linlin Zhang To: linux-block@vger.kernel.org, ebiggers@kernel.org Cc: linux-kernel@vger.kernel.org, adrianvovk@gmail.com, dm-devel@lists.linux.dev, quic_mdalam@quicinc.com, gmazyland@gmail.com, israelr@nvidia.com, mpatocka@redhat.com Subject: [PATCH v1 2/3] dm-inlinecrypt: add target for inline block device encryption Date: Wed, 4 Mar 2026 04:17:27 -0800 Message-Id: <20260304121729.1532469-3-linlin.zhang@oss.qualcomm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260304121729.1532469-1-linlin.zhang@oss.qualcomm.com> References: <20260304121729.1532469-1-linlin.zhang@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=AJS1/0o2 c=1 sm=1 tr=0 ts=69a822e3 cx=c_pps a=JYo30EpNSr/tUYqK9jHPoA==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=1XWaLZrsAAAA:8 a=EUspDBNiAAAA:8 a=bWmaV-3qS8QClun7j00A:9 a=Fk4IpSoW4aLDllm1B1p-:22 X-Proofpoint-ORIG-GUID: pRK4eNW1FQrUVYTdsFDXu3TDJfX0slNT X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA0MDA5NyBTYWx0ZWRfX6QK5Dr6D83Uv zb+97WT/BUuimPwhkOg7RTgttSuAtPeu1kl9qEjRdMkiQzWUJVbijHr02DlEK7RLP81uV32vupo rQbSkMcfXYk4GdZfRo/iljVTnDKvqf/Pr6mq5CsrGuq0h+WGqIBAhgeR1bDmJbZXa7WFN2Pf12s hh8jwosrp6FCcyW562OtSzsqjQiPSB60hujzM2fPyfRN4jHq2x3WLWJjXNsGL3HPi+RnVrW9I8W Gn+njV65kH/WTrSu/WyvP/K+kg/+FFVpcF+X0IcSFzNVSlD5IMCDvlx9q+j/3/avJt/fmxKoX/o BojFnMNvs4R0NWXM2dpT57ckFEvreSv+RXYJOPUucFc8Jf/ha8vdfTsE+kIxGeDxUU+Wsn+0VI2 LNSnogLp1edh7q9ZpKmvnTAUpk9Mp7hAT60yL8p4ZYccONK+xkqiVkmR58cHeaJJ6kFdoeiurjY WMl9bJLihluh6WhasPA== X-Proofpoint-GUID: pRK4eNW1FQrUVYTdsFDXu3TDJfX0slNT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-04_05,2026-03-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 priorityscore=1501 clxscore=1011 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603040097 Content-Type: text/plain; charset="utf-8" From: Eric Biggers Add a new device-mapper target "dm-inlinecrypt" that is similar to dm-crypt but uses the blk-crypto API instead of the regular crypto API. This allows it to take advantage of inline encryption hardware such as that commonly built into UFS host controllers. The table syntax matches dm-crypt's, but for now only a stripped-down set of parameters is supported. For example, for now AES-256-XTS is the only supported cipher. dm-inlinecrypt is based on Android's dm-default-key with the controversial passthrough support removed. Note that due to the removal of passthrough support, use of dm-inlinecrypt in combination with fscrypt causes double encryption of file contents (similar to dm-crypt + fscrypt), with the fscrypt layer not being able to use the inline encryption hardware. This makes dm-inlinecrypt unusable on systems such as Android that use fscrypt and where a more optimized approach is needed. It is however suitable as a replacement for dm-crypt. Signed-off-by: Eric Biggers Signed-off-by: Linlin Zhang --- drivers/md/Kconfig | 10 + drivers/md/Makefile | 1 + drivers/md/dm-inlinecrypt.c | 416 ++++++++++++++++++++++++++++++++++++ 3 files changed, 427 insertions(+) create mode 100644 drivers/md/dm-inlinecrypt.c diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index c58a9a8ea54e..aa541cc22ecc 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -313,6 +313,16 @@ config DM_CRYPT =20 If unsure, say N. =20 +config DM_INLINECRYPT + tristate "Inline encryption target support" + depends on BLK_DEV_DM + depends on BLK_INLINE_ENCRYPTION + help + This device-mapper target is similar to dm-crypt, but it uses the + blk-crypto API instead of the regular crypto API. This allows it to + take advantage of inline encryption hardware such as that commonly + built into UFS host controllers. + config DM_SNAPSHOT tristate "Snapshot target" depends on BLK_DEV_DM diff --git a/drivers/md/Makefile b/drivers/md/Makefile index c338cc6fbe2e..517d1f7d8288 100644 --- a/drivers/md/Makefile +++ b/drivers/md/Makefile @@ -55,6 +55,7 @@ obj-$(CONFIG_DM_UNSTRIPED) +=3D dm-unstripe.o obj-$(CONFIG_DM_BUFIO) +=3D dm-bufio.o obj-$(CONFIG_DM_BIO_PRISON) +=3D dm-bio-prison.o obj-$(CONFIG_DM_CRYPT) +=3D dm-crypt.o +obj-$(CONFIG_DM_INLINECRYPT) +=3D dm-inlinecrypt.o obj-$(CONFIG_DM_DELAY) +=3D dm-delay.o obj-$(CONFIG_DM_DUST) +=3D dm-dust.o obj-$(CONFIG_DM_FLAKEY) +=3D dm-flakey.o diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c new file mode 100644 index 000000000000..251760da9f7e --- /dev/null +++ b/drivers/md/dm-inlinecrypt.c @@ -0,0 +1,416 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2024 Google LLC + */ + +#include +#include +#include +#include + +#define DM_MSG_PREFIX "inlinecrypt" + +static const struct dm_inlinecrypt_cipher { + const char *name; + enum blk_crypto_mode_num mode_num; + int key_size; +} dm_inlinecrypt_ciphers[] =3D { + { + .name =3D "aes-xts-plain64", + .mode_num =3D BLK_ENCRYPTION_MODE_AES_256_XTS, + .key_size =3D 64, + }, +}; + +/** + * struct inlinecrypt_ctx - private data of an inlinecrypt target + * @dev: the underlying device + * @start: starting sector of the range of @dev which this target actually= maps. + * For this purpose a "sector" is 512 bytes. + * @cipher_string: the name of the encryption algorithm being used + * @iv_offset: starting offset for IVs. IVs are generated as if the targe= t were + * preceded by @iv_offset 512-byte sectors. + * @sector_size: crypto sector size in bytes (usually 4096) + * @sector_bits: log2(sector_size) + * @key: the encryption key to use + * @max_dun: the maximum DUN that may be used (computed from other params) + */ +struct inlinecrypt_ctx { + struct dm_dev *dev; + sector_t start; + const char *cipher_string; + u64 iv_offset; + unsigned int sector_size; + unsigned int sector_bits; + struct blk_crypto_key key; + u64 max_dun; +}; + +static const struct dm_inlinecrypt_cipher * +lookup_cipher(const char *cipher_string) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(dm_inlinecrypt_ciphers); i++) { + if (strcmp(cipher_string, dm_inlinecrypt_ciphers[i].name) =3D=3D 0) + return &dm_inlinecrypt_ciphers[i]; + } + return NULL; +} + +static void inlinecrypt_dtr(struct dm_target *ti) +{ + struct inlinecrypt_ctx *ctx =3D ti->private; + + if (ctx->dev) { + if (ctx->key.size) + blk_crypto_evict_key(ctx->dev->bdev, &ctx->key); + dm_put_device(ti, ctx->dev); + } + kfree_sensitive(ctx->cipher_string); + kfree_sensitive(ctx); +} + +static int inlinecrypt_ctr_optional(struct dm_target *ti, + unsigned int argc, char **argv) +{ + struct inlinecrypt_ctx *ctx =3D ti->private; + struct dm_arg_set as; + static const struct dm_arg _args[] =3D { + {0, 3, "Invalid number of feature args"}, + }; + unsigned int opt_params; + const char *opt_string; + bool iv_large_sectors =3D false; + char dummy; + int err; + + as.argc =3D argc; + as.argv =3D argv; + + err =3D dm_read_arg_group(_args, &as, &opt_params, &ti->error); + if (err) + return err; + + while (opt_params--) { + opt_string =3D dm_shift_arg(&as); + if (!opt_string) { + ti->error =3D "Not enough feature arguments"; + return -EINVAL; + } + if (!strcmp(opt_string, "allow_discards")) { + ti->num_discard_bios =3D 1; + } else if (sscanf(opt_string, "sector_size:%u%c", + &ctx->sector_size, &dummy) =3D=3D 1) { + if (ctx->sector_size < SECTOR_SIZE || + ctx->sector_size > 4096 || + !is_power_of_2(ctx->sector_size)) { + ti->error =3D "Invalid sector_size"; + return -EINVAL; + } + } else if (!strcmp(opt_string, "iv_large_sectors")) { + iv_large_sectors =3D true; + } else { + ti->error =3D "Invalid feature arguments"; + return -EINVAL; + } + } + + /* dm-inlinecrypt doesn't implement iv_large_sectors=3Dfalse. */ + if (ctx->sector_size !=3D SECTOR_SIZE && !iv_large_sectors) { + ti->error =3D "iv_large_sectors must be specified"; + return -EINVAL; + } + + return 0; +} + +/* + * Construct an inlinecrypt mapping: + * + * + * This syntax matches dm-crypt's, but the set of supported functionality = has + * been stripped down. + */ +static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char *= *argv) +{ + struct inlinecrypt_ctx *ctx; + const struct dm_inlinecrypt_cipher *cipher; + u8 raw_key[BLK_CRYPTO_MAX_ANY_KEY_SIZE]; + unsigned int dun_bytes; + unsigned long long tmpll; + char dummy; + int err; + + if (argc < 5) { + ti->error =3D "Not enough arguments"; + return -EINVAL; + } + + ctx =3D kzalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) { + ti->error =3D "Out of memory"; + return -ENOMEM; + } + ti->private =3D ctx; + + /* */ + ctx->cipher_string =3D kstrdup(argv[0], GFP_KERNEL); + if (!ctx->cipher_string) { + ti->error =3D "Out of memory"; + err =3D -ENOMEM; + goto bad; + } + cipher =3D lookup_cipher(ctx->cipher_string); + if (!cipher) { + ti->error =3D "Unsupported cipher"; + err =3D -EINVAL; + goto bad; + } + + /* */ + if (strlen(argv[1]) !=3D 2 * cipher->key_size) { + ti->error =3D "Incorrect key size for cipher"; + err =3D -EINVAL; + goto bad; + } + if (hex2bin(raw_key, argv[1], cipher->key_size) !=3D 0) { + ti->error =3D "Malformed key string"; + err =3D -EINVAL; + goto bad; + } + + /* */ + if (sscanf(argv[2], "%llu%c", &ctx->iv_offset, &dummy) !=3D 1) { + ti->error =3D "Invalid iv_offset sector"; + err =3D -EINVAL; + goto bad; + } + + /* */ + err =3D dm_get_device(ti, argv[3], dm_table_get_mode(ti->table), + &ctx->dev); + if (err) { + ti->error =3D "Device lookup failed"; + goto bad; + } + + /* */ + if (sscanf(argv[4], "%llu%c", &tmpll, &dummy) !=3D 1 || + tmpll !=3D (sector_t)tmpll) { + ti->error =3D "Invalid start sector"; + err =3D -EINVAL; + goto bad; + } + ctx->start =3D tmpll; + + /* optional arguments */ + ctx->sector_size =3D SECTOR_SIZE; + if (argc > 5) { + err =3D inlinecrypt_ctr_optional(ti, argc - 5, &argv[5]); + if (err) + goto bad; + } + ctx->sector_bits =3D ilog2(ctx->sector_size); + if (ti->len & ((ctx->sector_size >> SECTOR_SHIFT) - 1)) { + ti->error =3D "Device size is not a multiple of sector_size"; + err =3D -EINVAL; + goto bad; + } + + ctx->max_dun =3D (ctx->iv_offset + ti->len - 1) >> + (ctx->sector_bits - SECTOR_SHIFT); + dun_bytes =3D DIV_ROUND_UP(fls64(ctx->max_dun), 8); + + err =3D blk_crypto_init_key(&ctx->key, raw_key, cipher->key_size, + BLK_CRYPTO_KEY_TYPE_HW_WRAPPED, cipher->mode_num, + dun_bytes, ctx->sector_size); + if (err) { + ti->error =3D "Error initializing blk-crypto key"; + goto bad; + } + + err =3D blk_crypto_start_using_key(ctx->dev->bdev, &ctx->key); + if (err) { + ti->error =3D "Error starting to use blk-crypto"; + goto bad; + } + + ti->num_flush_bios =3D 1; + + err =3D 0; + goto out; + +bad: + inlinecrypt_dtr(ti); +out: + memzero_explicit(raw_key, sizeof(raw_key)); + return err; +} + +static int inlinecrypt_map(struct dm_target *ti, struct bio *bio) +{ + const struct inlinecrypt_ctx *ctx =3D ti->private; + sector_t sector_in_target; + u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE] =3D {}; + + bio_set_dev(bio, ctx->dev->bdev); + + /* + * If the bio is a device-level request which doesn't target a specific + * sector, there's nothing more to do. + */ + if (bio_sectors(bio) =3D=3D 0) + return DM_MAPIO_REMAPPED; + + /* + * The bio should never have an encryption context already, since + * dm-inlinecrypt doesn't pass through any inline encryption + * capabilities to the layer above it. + */ + if (WARN_ON_ONCE(bio_has_crypt_ctx(bio))) + return DM_MAPIO_KILL; + + /* Map the bio's sector to the underlying device. (512-byte sectors) */ + sector_in_target =3D dm_target_offset(ti, bio->bi_iter.bi_sector); + bio->bi_iter.bi_sector =3D ctx->start + sector_in_target; + /* + * If the bio doesn't have any data (e.g. if it's a DISCARD request), + * there's nothing more to do. + */ + if (!bio_has_data(bio)) + return DM_MAPIO_REMAPPED; + + /* Calculate the DUN and enforce data-unit (crypto sector) alignment. */ + dun[0] =3D ctx->iv_offset + sector_in_target; /* 512-byte sectors */ + if (dun[0] & ((ctx->sector_size >> SECTOR_SHIFT) - 1)) + return DM_MAPIO_KILL; + dun[0] >>=3D ctx->sector_bits - SECTOR_SHIFT; /* crypto sectors */ + + /* + * This check isn't necessary as we should have calculated max_dun + * correctly, but be safe. + */ + if (WARN_ON_ONCE(dun[0] > ctx->max_dun)) + return DM_MAPIO_KILL; + + bio_crypt_set_ctx(bio, &ctx->key, dun, GFP_NOIO); + + return DM_MAPIO_REMAPPED; +} + +static void inlinecrypt_status(struct dm_target *ti, status_type_t type, + unsigned int status_flags, char *result, + unsigned int maxlen) +{ + const struct inlinecrypt_ctx *ctx =3D ti->private; + unsigned int sz =3D 0; + int num_feature_args =3D 0; + + switch (type) { + case STATUSTYPE_INFO: + case STATUSTYPE_IMA: + result[0] =3D '\0'; + break; + + case STATUSTYPE_TABLE: + /* + * Warning: like dm-crypt, dm-inlinecrypt includes the key in + * the returned table. Userspace is responsible for redacting + * the key when needed. + */ + DMEMIT("%s %*phN %llu %s %llu", ctx->cipher_string, + ctx->key.size, ctx->key.bytes, ctx->iv_offset, + ctx->dev->name, ctx->start); + num_feature_args +=3D !!ti->num_discard_bios; + if (ctx->sector_size !=3D SECTOR_SIZE) + num_feature_args +=3D 2; + if (num_feature_args !=3D 0) { + DMEMIT(" %d", num_feature_args); + if (ti->num_discard_bios) + DMEMIT(" allow_discards"); + if (ctx->sector_size !=3D SECTOR_SIZE) { + DMEMIT(" sector_size:%u", ctx->sector_size); + DMEMIT(" iv_large_sectors"); + } + } + break; + } +} + +static int inlinecrypt_prepare_ioctl(struct dm_target *ti, + struct block_device **bdev, unsigned int cmd, + unsigned long arg, bool *forward) +{ + const struct inlinecrypt_ctx *ctx =3D ti->private; + const struct dm_dev *dev =3D ctx->dev; + + *bdev =3D dev->bdev; + + /* Only pass ioctls through if the device sizes match exactly. */ + return ctx->start !=3D 0 || ti->len !=3D bdev_nr_sectors(dev->bdev); +} + +static int inlinecrypt_iterate_devices(struct dm_target *ti, + iterate_devices_callout_fn fn, + void *data) +{ + const struct inlinecrypt_ctx *ctx =3D ti->private; + + return fn(ti, ctx->dev, ctx->start, ti->len, data); +} + +#ifdef CONFIG_BLK_DEV_ZONED +static int inlinecrypt_report_zones(struct dm_target *ti, + struct dm_report_zones_args *args, + unsigned int nr_zones) +{ + const struct inlinecrypt_ctx *ctx =3D ti->private; + + return dm_report_zones(ctx->dev->bdev, ctx->start, + ctx->start + dm_target_offset(ti, args->next_sector), + args, nr_zones); +} +#else +#define inlinecrypt_report_zones NULL +#endif + +static void inlinecrypt_io_hints(struct dm_target *ti, + struct queue_limits *limits) +{ + const struct inlinecrypt_ctx *ctx =3D ti->private; + const unsigned int sector_size =3D ctx->sector_size; + + limits->logical_block_size =3D + max_t(unsigned int, limits->logical_block_size, sector_size); + limits->physical_block_size =3D + max_t(unsigned int, limits->physical_block_size, sector_size); + limits->io_min =3D max_t(unsigned int, limits->io_min, sector_size); + limits->dma_alignment =3D limits->logical_block_size - 1; +} + +static struct target_type inlinecrypt_target =3D { + .name =3D "inlinecrypt", + .version =3D {1, 0, 0}, + /* + * Do not set DM_TARGET_PASSES_CRYPTO, since dm-inlinecrypt consumes the + * crypto capability itself. + */ + .features =3D DM_TARGET_ZONED_HM, + .module =3D THIS_MODULE, + .ctr =3D inlinecrypt_ctr, + .dtr =3D inlinecrypt_dtr, + .map =3D inlinecrypt_map, + .status =3D inlinecrypt_status, + .prepare_ioctl =3D inlinecrypt_prepare_ioctl, + .iterate_devices =3D inlinecrypt_iterate_devices, + .report_zones =3D inlinecrypt_report_zones, + .io_hints =3D inlinecrypt_io_hints, +}; + +module_dm(inlinecrypt); + +MODULE_AUTHOR("Eric Biggers "); +MODULE_AUTHOR("Linlin Zhang "); +MODULE_DESCRIPTION(DM_NAME " target for inline encryption"); +MODULE_LICENSE("GPL"); --=20 2.34.1 From nobody Wed Apr 15 16:24:34 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20C083A4528 for ; Wed, 4 Mar 2026 12:17:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772626662; cv=none; b=acNsQSgU27gySbCtg+xMM7wvEtEmz2n6q7LpJvtUnlBSBnGDWd90bqEZq8cK2SsLCOlJqR8WJ84oVkDEwtnxcHpiehhaG883zc+pIOqjr2vV07FVnLccj+kd4O9oIu8wtjwLlqQCtNsWX7NUCPx2R9TEf1mdCYqj2hbySXeAkvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772626662; c=relaxed/simple; bh=fTkFRABeWhqpHqR3fBTMOr/wX+GQmnvqFLFQIRi2PB4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xcpn1ROH6xZcL4ZZm9hx669EitsqTyrArzc4Pe2gOzqpCJpDtge21ril/lZHwz442GsZsAZ3SQ/srFdTbsltvElSanoqoWQQEtiayKqFMI3IaSGQImVj1ibBpNczlItFb23awB9pUthmeGGRiUwFdkpU/w1E9gshKY34uL0HfLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=EgHDJTQG; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=R4UNetfh; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="EgHDJTQG"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="R4UNetfh" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6245SktT152844 for ; Wed, 4 Mar 2026 12:17:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Uhi/pQDgQxc huJE4VRIyJvYlAizoY9xEMiE9yI+hg3Y=; b=EgHDJTQG50btnRIpcc8KC9VRvmU XTgncO8NzLwx+ak/YN+75UrSgd8fL3olG5w8/YXNWcHIcs6ScZKxUYhIaxKERXY1 X3uTidXt2R+p0rzyoLP5mXHUsu/NUuYHNMq3OSTwB0UiB5PZxzC9cA8etIgohAUR ALECvAHdt3TLByv3jI/juHt4E0ak7bvic42cZra5ld5bISzOt3eZL/yvGNTHLBq4 LcsAEmKCAXvtzHrANLGP+tvRPRsZE8GUrIkM07g1lBeELOwmlVRuT7M5Jc6AQVGT BYL7EAcvCkSJeRLwwePxxrs9nkNSj1vAoeN5wJ8eSWxOtg7kxaME282GxQw== Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cp3tvkj8r-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 04 Mar 2026 12:17:40 +0000 (GMT) Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-1273886efc6so6641626c88.1 for ; Wed, 04 Mar 2026 04:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772626660; x=1773231460; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uhi/pQDgQxchuJE4VRIyJvYlAizoY9xEMiE9yI+hg3Y=; b=R4UNetfhtsGnCLonM84Me93C3yG03WA4nVwuH0r5YpxjssOSxqp4tQvY/ZF6GwsEAV BU4UiQASOtwgzvkV7e0pQ/dDOI62vdvLpRomgoelaHn8kgqXMm9BPvGozwr2QKS5YQ1G nfkL3w9kfMqSSEkyi9ECUWZDlN8PpHKr+StKO+P5rsPLaw5KzBradb2Q+MyTxV7vparw WTBEx3JTUx4m/VZ0qMC1byeuKe07vq7JwgcMJYn4WCHRB/suc0oBuwgBJq8JOjw6hmGH 0jtHripDo+PqhE32NUjgdeLkwIKTHOyYWKDWrddjDCKWUIiIaVVSn6sFEViH3FtMYJoy Simg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772626660; x=1773231460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Uhi/pQDgQxchuJE4VRIyJvYlAizoY9xEMiE9yI+hg3Y=; b=bAItv/q92OIxb9JRJJxhu1ZaBZPhWrrnziu7czdK1SmqMmMghpkX6jQg7ZYfLc3hwv 2luv4VVfCHrlP2vgJMCLDsZX4f/uYkaEauao4UJzanD1/cjp8V2kLvSvG9wE10mY0HcW 5ki4b2odwLIN7AALIeh8UtcZRlhwD8hIATWttKPLopYWvD1nA3jG7PzcOm/b+s0dvgtl JntmzIAtubCTU6K9PArGJsg+F6HCOqMAWar3V5nA1WU35eb8NRKIN3fPOmH2B/EA71CS cTLdVqnFK4dyyt3tEvqvPza7xTdbrgsuQV4uvFYFPhs9daeOucFPKUYTsWG1YqldrJa8 TdRw== X-Gm-Message-State: AOJu0Ywc0g1GMu+IHDuUZcbmKgAI9e4fXQoh6Q6HKDwuNMZ8rCLO0jpn X9kfkbQKkTqL4GcTNFtUhEFK8FBLHM4EmKPeRvAurXfBYZYhf6dCNbV4MGhTHbUEnSYTU4TUIr6 mFyXHpGkb2Rntwr65LQslYBkJPiHl/4ZdFwtDHia9R50h3jCBdAQL+aaOa2K0DR+ZXlo= X-Gm-Gg: ATEYQzwlW1tF5nxseLgnY/shN8pLZ7ApwkgWHL3GL9PFAnyRwlQtU6qdM3uBZVshfXe nzfn11n5lX2w0y+/V4xELWbXhTfgy1k0o9p+b1JnF44eIS5EgTbs3c7sz5kZODv0pHKgSGVopnD i7kKyOeQr0Fd2/dDrNZUNIx5t78wG5dIkgoZ8qsVQzFtiED4SQBV0bFlyEqvjqcmrkokyv8VmS0 btnEMciHfEP/1xlVuN2F2ERzrWnK/8xTR/1dalD9bRJmC7Ln3+vTtGqA8oGEzZniJ7gNXYU6+3w QL6QxmJ6EvkedhxIJVxs0pR6X0NIY37zIx/9udpmWAR3i3LwRIxonwaFMn3cf8SOA8nd6E00EGM FNwQmWHiDpUG65i8MfyIsPlNGFdlpGO7nlKlx0/9ne/zTKX4/J6COMj7lbDmRfxHE0lsOZ1gmR+ WadbRp X-Received: by 2002:a05:7022:a9c:b0:11a:37a7:3d2f with SMTP id a92af1059eb24-128b70edff0mr571786c88.37.1772626659714; Wed, 04 Mar 2026 04:17:39 -0800 (PST) X-Received: by 2002:a05:7022:a9c:b0:11a:37a7:3d2f with SMTP id a92af1059eb24-128b70edff0mr571774c88.37.1772626659165; Wed, 04 Mar 2026 04:17:39 -0800 (PST) Received: from u20-san1p10573.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-127899dfc47sm22171276c88.6.2026.03.04.04.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 04:17:38 -0800 (PST) From: Linlin Zhang To: linux-block@vger.kernel.org, ebiggers@kernel.org Cc: linux-kernel@vger.kernel.org, adrianvovk@gmail.com, dm-devel@lists.linux.dev, quic_mdalam@quicinc.com, gmazyland@gmail.com, israelr@nvidia.com, mpatocka@redhat.com Subject: [PATCH v1 3/3] dm-inlinecrypt: Expose inline crypto caps to the device Date: Wed, 4 Mar 2026 04:17:28 -0800 Message-Id: <20260304121729.1532469-4-linlin.zhang@oss.qualcomm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260304121729.1532469-1-linlin.zhang@oss.qualcomm.com> References: <20260304121729.1532469-1-linlin.zhang@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA0MDA5NyBTYWx0ZWRfX515m1oO9pJ3z xF+f7ma+tA4LWkidZIwOOJjla3Hogoi/WMmATuQnG2XDzDk3U2xZviUm9r0M7wreTOHWv8tEwtT 0wJQnNJBuwvIZsbPzSmgB0dhys34q+xmlb8onG/t2DbdIU2c+cr8+lmPfsHQuzRW1SlKRO32Vd4 sO9KgP/tawtcC5zJPz27IpT8vkJtG5zJbKGjDZjWn+waK+fJvfFFJcRQHECcUvF2S4cmGG6HSWO sqAcFoc8unnyu7DehgXoohNb2EqZymGLwu4Jdv8c8zf6s4iVIYzGAiZs1rbcOqolVgDXdP5HMuO ZiBXX1brZZ561G6ZTUOIotEGc+McTuiiuX9nKybmdYsx9OSJ1mJPYpGVxkRawTK5yFZrZqU3CxO d+qS49NpapBNyfPtG0u368WXfaMwwjeXUsrfDMtggmrnPktqToQJOUCcxVIhMy+FV0ywWT6gJeW o9i7yNxsU7gmHQ56lyA== X-Authority-Analysis: v=2.4 cv=VYv6/Vp9 c=1 sm=1 tr=0 ts=69a822e4 cx=c_pps a=JYo30EpNSr/tUYqK9jHPoA==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=3zJYx2Ns6XLEkWF3d8kA:9 a=Fk4IpSoW4aLDllm1B1p-:22 X-Proofpoint-GUID: _yorhzb-my173t50YQ5Strc785EDLVDc X-Proofpoint-ORIG-GUID: _yorhzb-my173t50YQ5Strc785EDLVDc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-04_05,2026-03-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603040097 Content-Type: text/plain; charset="utf-8" Add a new DM flag, which means the inline crypto capabilities from underlying devices can be exposed to the DM device, and the DM device consumes these capabilities, rather pass through them to the upper layer. Signed-off-by: Linlin Zhang --- drivers/md/dm-inlinecrypt.c | 2 +- drivers/md/dm-table.c | 3 ++- include/linux/device-mapper.h | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-inlinecrypt.c b/drivers/md/dm-inlinecrypt.c index 251760da9f7e..eda56893d430 100644 --- a/drivers/md/dm-inlinecrypt.c +++ b/drivers/md/dm-inlinecrypt.c @@ -396,7 +396,7 @@ static struct target_type inlinecrypt_target =3D { * Do not set DM_TARGET_PASSES_CRYPTO, since dm-inlinecrypt consumes the * crypto capability itself. */ - .features =3D DM_TARGET_ZONED_HM, + .features =3D DM_TARGET_CONSUME_CRYPTO | DM_TARGET_ZONED_HM, .module =3D THIS_MODULE, .ctr =3D inlinecrypt_ctr, .dtr =3D inlinecrypt_dtr, diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 7be1d8dc8bdd..f0580935394a 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1407,7 +1407,8 @@ static int dm_table_construct_crypto_profile(struct d= m_table *t) for (i =3D 0; i < t->num_targets; i++) { struct dm_target *ti =3D dm_table_get_target(t, i); =20 - if (!dm_target_passes_crypto(ti->type)) { + if (!dm_target_passes_crypto(ti->type) + && !dm_target_consume_crypto(ti->type)) { blk_crypto_intersect_capabilities(profile, NULL); break; } diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 38f625af6ab4..6abd1b4fcb76 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -306,6 +306,13 @@ struct target_type { #define dm_target_supports_mixed_zoned_model(type) (false) #endif =20 +/* + * A target consumes inline crypto capabilities itself and doesn't support + * passing through inline crypto support. + */ +#define DM_TARGET_CONSUME_CRYPTO 0x00000300 +#define dm_target_consume_crypto(type) ((type)->features & DM_TARGET_CONSU= ME_CRYPTO) + #define DM_TARGET_ATOMIC_WRITES 0x00000400 #define dm_target_supports_atomic_writes(type) ((type)->features & DM_TARG= ET_ATOMIC_WRITES) =20 --=20 2.34.1