Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4699399imm; Sun, 26 Aug 2018 01:24:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYD/Ln0fsT2x15gKBSGLugaGBYL/OLPyOFEtpWfxmXfYi9JrLCpkUKZzTBo/Ml7ROYeNAbM X-Received: by 2002:a62:a65a:: with SMTP id t87-v6mr9060678pfe.225.1535271854196; Sun, 26 Aug 2018 01:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535271854; cv=none; d=google.com; s=arc-20160816; b=ph/jcqJIC3iyT1VGhR9E723LjoPyEKMfvoz90BKLPn4AmT5XPexkIvTHjnDfIWWT3p JA7R3rbAMZgGnu19j6S2hxJNnC7wwYfelQ+RjxNwcJNtOW0nmOCkjVYzkG44tGWxeNoc stpz+c4WBULpDR+Gspt0YylAfq0kwjgWMOaku1F36JECs6ROSF8afQMHxXM67dnWs6vC VSPWtSoyYrP2+sAWDoYvRSP48GNss4Z5Awvd7fUUgqQfgOvqhlCtjGeH5BCVXkWRpX/X yuZywez3ecAoKrbtkcWb4AKqRJlCAafDDqV5S8Ulek1oOsK0qD0W3XRzOyFAvYatAaWR 6RxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=iv8vMp7U6kpiizLVr4U54BzhKMFYPmA2/siXMyoADMM=; b=NrBrzlln4N9z56cZKdOZQI7PGcpZX5vQlG+I+Jo7zYeIYp98S2P3hB6HL0sYSb5vqG D/b13KQOSsxzy8/FpVVk2B0LJNpkhopUyF3Rjox8j6HbHUEG0J7864jMiidEH+yzB60E DFe9CBxDNZkxJl01gTXUZ8hdHPF8w2Xy81kVqlxkAUD7GlOs3gO4omp86FFTJV0MOBVW l3BTGNiAkybRs3ruL1/dcSWQaxeQLMXerpJoJtn/4Zz7nyaohDLvkWIB39GCvCYSuJ3s a8nqweSWyhpotrzr/q8nHDgrLP1CJZYeAgW81LH/uCSmoIDhs1t8J3NIElIzfSMewbj2 cjqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CsYfY7uU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 87-v6si12608546pfi.60.2018.08.26.01.23.56; Sun, 26 Aug 2018 01:24:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CsYfY7uU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726726AbeHZMEf (ORCPT + 99 others); Sun, 26 Aug 2018 08:04:35 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:39037 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbeHZMEf (ORCPT ); Sun, 26 Aug 2018 08:04:35 -0400 Received: by mail-it0-f66.google.com with SMTP id t69-v6so6943047itb.4 for ; Sun, 26 Aug 2018 01:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=iv8vMp7U6kpiizLVr4U54BzhKMFYPmA2/siXMyoADMM=; b=CsYfY7uUiznY4QVL55BTKkl5LXEVO5s54pTIP2Va3AmTnLCwnVILEmHVBMrPkZDzvx lxWFhY99Zult+9nIdczOYJASU2q6MCRb1G/F8vA1k+3pwFljrUI1ZWI8oVcZVCIPdKTw 5W1n5v7EV3Ofn62V1BsqVCduntCx8DOQUiIbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=iv8vMp7U6kpiizLVr4U54BzhKMFYPmA2/siXMyoADMM=; b=TN/0g0QgFSUOpAJyPM2Q8rcLEtdHsEriOTViqN9vOeOrZ0bvEEhb/PMYD8YUu9eCgq yOVTWxLBrV/Q5Zs+LOpMhiEPBAv+utAdR75riHgPt7lr6PP6w7wQgIb4bk5DWkLD4G6v kdS0kup0I/nxKAsDLYkibeve3Uc1jGakTkwidqSck2t7YOUtW7QgtpnUzAvbbaftGzJ6 hdY46mlAq/0aeibWOzSPjXHkagIT3LLeFdFMaURulbYx6ieOZGd/WJpPy6j8RVk3exOG 2a67tmFwscnnWm14l0P9vsD5ztGFoitqp6IAAt580dbt1S/EKhlLOtTzgRB92NluzP+X LYGQ== X-Gm-Message-State: APzg51AXVYv/JkrunxkAlp7ctpAJY/XQqXk19MesrIJmyHaxVApm6cvg Tp9CAL1KUZxW7KKOHIQieWzYxSA3xUgXEi7AlNN7cw== X-Received: by 2002:a02:1515:: with SMTP id j21-v6mr6818250jad.2.1535271764642; Sun, 26 Aug 2018 01:22:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Sun, 26 Aug 2018 01:22:43 -0700 (PDT) In-Reply-To: <20180826024006.13800-4-martin.petersen@oracle.com> References: <20180825061205.ygrjjazkooqghrqy@gondor.apana.org.au> <20180826024006.13800-1-martin.petersen@oracle.com> <20180826024006.13800-4-martin.petersen@oracle.com> From: Ard Biesheuvel Date: Sun, 26 Aug 2018 09:22:43 +0100 Message-ID: Subject: Re: [PATCH 4/4] block: Integrity profile init function to trigger module loads To: "Martin K. Petersen" Cc: Herbert Xu , Jeffrey Lien , David Darrington , Christoph Hellwig , Jeff Furlong , linux-block@vger.kernel.org, "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Linux Kernel Mailing List , linux-scsi@vger.kernel.org, Tim Chen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Martin, On 26 August 2018 at 03:40, Martin K. Petersen wrote: > The T10 CRC library function is built into the kernel and therefore > registered early. The hardware-accelerated CRC helpers are typically > loaded as modules and only become available later in the boot > sequence. A separate patch modifies the T10 CRC library to subscribe > to notifications from crypto and permits switching from the > table-based algorithm to a hardware accelerated ditto once the > relevant module is loaded. > > However, since the dependency for "crc10dif" is already satisfied, > nothing is going to cause the hardware-accelerated kernel modules to > get loaded. This is not true. All accelerated implementations based on SIMD polynomial multiplication are tried to the respective CPU features bits. This applies to x86, power, ARM and arm64. E.g., for x86 you have alias: cpu:type:x86,ven*fam*mod*:feature:*0081* which will be matched by udev if /sys/devices/system/cpu/modalias contains feature 0081, and so the modules will be loaded automatically at boot. > Introduce an init_fn in the integrity profile that can be > called to trigger a load of modules providing the T10 CRC calculation > capability. This function will ony get called when a new integrity > profile is registered during device discovery. > > Signed-off-by: Martin K. Petersen > --- > block/blk-integrity.c | 5 +++++ > block/t10-pi.c | 10 ++++++++++ > include/linux/blkdev.h | 2 ++ > 3 files changed, 17 insertions(+) > > diff --git a/block/blk-integrity.c b/block/blk-integrity.c > index 6121611e1316..5cacae9a2dc2 100644 > --- a/block/blk-integrity.c > +++ b/block/blk-integrity.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > #include "blk.h" > > @@ -391,6 +392,7 @@ static blk_status_t blk_integrity_nop_fn(struct blk_integrity_iter *iter) > > static const struct blk_integrity_profile nop_profile = { > .name = "nop", > + .init_fn = NULL, > .generate_fn = blk_integrity_nop_fn, > .verify_fn = blk_integrity_nop_fn, > }; > @@ -418,6 +420,9 @@ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template > bi->tuple_size = template->tuple_size; > bi->tag_size = template->tag_size; > > + if (bi->profile->init_fn) > + bi->profile->init_fn(); > + > disk->queue->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; > } > EXPORT_SYMBOL(blk_integrity_register); > diff --git a/block/t10-pi.c b/block/t10-pi.c > index a98db384048f..b83278f9163a 100644 > --- a/block/t10-pi.c > +++ b/block/t10-pi.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > #include > > typedef __be16 (csum_fn) (void *, unsigned int); > @@ -157,8 +158,14 @@ static blk_status_t t10_pi_type3_verify_ip(struct blk_integrity_iter *iter) > return t10_pi_verify(iter, t10_pi_ip_fn, 3); > } > > +static void t10_pi_crc_init(void) > +{ > + request_module_nowait(CRC_T10DIF_STRING); > +} > + > const struct blk_integrity_profile t10_pi_type1_crc = { > .name = "T10-DIF-TYPE1-CRC", > + .init_fn = t10_pi_crc_init, > .generate_fn = t10_pi_type1_generate_crc, > .verify_fn = t10_pi_type1_verify_crc, > }; > @@ -166,6 +173,7 @@ EXPORT_SYMBOL(t10_pi_type1_crc); > > const struct blk_integrity_profile t10_pi_type1_ip = { > .name = "T10-DIF-TYPE1-IP", > + .init_fn = NULL, > .generate_fn = t10_pi_type1_generate_ip, > .verify_fn = t10_pi_type1_verify_ip, > }; > @@ -173,6 +181,7 @@ EXPORT_SYMBOL(t10_pi_type1_ip); > > const struct blk_integrity_profile t10_pi_type3_crc = { > .name = "T10-DIF-TYPE3-CRC", > + .init_fn = t10_pi_crc_init, > .generate_fn = t10_pi_type3_generate_crc, > .verify_fn = t10_pi_type3_verify_crc, > }; > @@ -180,6 +189,7 @@ EXPORT_SYMBOL(t10_pi_type3_crc); > > const struct blk_integrity_profile t10_pi_type3_ip = { > .name = "T10-DIF-TYPE3-IP", > + .init_fn = NULL, > .generate_fn = t10_pi_type3_generate_ip, > .verify_fn = t10_pi_type3_verify_ip, > }; > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index 79226ca8f80f..a43c02e4f43d 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -1806,10 +1806,12 @@ struct blk_integrity_iter { > }; > > typedef blk_status_t (integrity_processing_fn) (struct blk_integrity_iter *); > +typedef void (integrity_init_fn) (void); > > struct blk_integrity_profile { > integrity_processing_fn *generate_fn; > integrity_processing_fn *verify_fn; > + integrity_init_fn *init_fn; > const char *name; > }; > > -- > 2.17.1 >