Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp140863rwb; Tue, 4 Oct 2022 01:42:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UnkbVnPvc4cLU6dfCD04g8kcBhyrHT9uTmSzroHE/7y8XZ7lgo5VNxJHV2sBC+ZIZgVZ4 X-Received: by 2002:a17:903:2445:b0:178:38ee:70f with SMTP id l5-20020a170903244500b0017838ee070fmr25548440pls.164.1664872951242; Tue, 04 Oct 2022 01:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664872951; cv=none; d=google.com; s=arc-20160816; b=Jq4ELK5LrhwH4nUJqIwrThORsr/bSdOCIe320daMRQ/X06GHM9sLxn9ZfMz5KIFW+S wyLSiR+y4e7IGwt3VcpKDYpF3c+C6ArpUTNTqNhdplrrOkuUvCjJqWIto7eUH/6I0pvh 80ynuvcBzk4V7u6D2kCmYhD7Mi8NqNwuTC8qWQ20U3rzl5it+8qZpWQLJG8UobGTIl4a ItgU4WZgpPykhm/oX6FBlWT7uqT8ljJjHChYoOdcJHq9mf7u7eBy1EMtFBtwSF0hCMBU 8aWHB6ETzqMKkmY4mngz0DjjrhKzSJ1n0qnuL99bZoJF40pdlhH1qxpxp+Ag3P2nGRdi sc0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=c09apFURTZHi8Ds+drxvHV6zzdwMMRZaOtqtAb0OMeE=; b=acWZRQd+H3y9VNyW6ni1tTLTYm6XifwvUaPoT+lzR1u0T0xcKfqX/uWCmZbRVZbEbt L3vB1yIIplvuM3JUhK+JI0D74vd8W52xr2VYWLCbnParXcr/v17+KFiKdl+09t1BEmSJ t3/D9kI5jMcY3nWC2Rfv062EVoG+QvAkGFZY7QnSo+4SiVpNTF1cihg3rYpDe9ycZiKD BCAPvHM3pVSbmPQq5OrADyjoqW8CVa978wG03a2og8+XjHMUJAkvKjYISIVhSkHBJaNb yxyKMbNDQ4Do9zOSB3y8M2++MNHClBJaJDEy+QzOM/vbSxBHIc6QsV0F+NABeS04i9f9 qQ3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SoumhSBu; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o10-20020a655bca000000b0043a348b6198si13716809pgr.109.2022.10.04.01.42.08; Tue, 04 Oct 2022 01:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SoumhSBu; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbiJDIZL (ORCPT + 99 others); Tue, 4 Oct 2022 04:25:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbiJDIZI (ORCPT ); Tue, 4 Oct 2022 04:25:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E25913F25 for ; Tue, 4 Oct 2022 01:25:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1B36E612B7 for ; Tue, 4 Oct 2022 08:25:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C875C43470 for ; Tue, 4 Oct 2022 08:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664871906; bh=c09apFURTZHi8Ds+drxvHV6zzdwMMRZaOtqtAb0OMeE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SoumhSBuPaDhfjrF1ejix70xvFZzYu090BPlNa4hh7+svDUjPGPGX8/PLGcUjeeT6 jwotAsOFbbucv1B1aFPscCP1kogrsxY8eYYGcWI79JGbsL9i4lrYZf/kLyx14ccM0j 80uzdI4IdO4MEp8MH44Fw6V6W8M18Tp8OxKRLunmwr0ERlBHugIm07MSrOA5xLgRfA 9xeyFdYiwQ8tnZJrHCSrSACULeanL6FtyZmt4eJbGm5Wc5Ao72g6GzeQxTk9Slq9GE pkV8hDFgZ71Z8ds14ggmxUCGuo7lIGIcmLiPtyIp9SywBHK+4/vOFCDG5C/zZ/6Fhr uiLUNh2YSmsGA== Received: by mail-lf1-f44.google.com with SMTP id y5so422179lfl.4 for ; Tue, 04 Oct 2022 01:25:06 -0700 (PDT) X-Gm-Message-State: ACrzQf2nbeQqH4SmcgP/fNnKOlIXu64dfkRRS3ltM4uU7VKD2apcojyR 5PxXkJCdCUPVAUHq7pE5KiYHHiZXiKH777Wrbmw= X-Received: by 2002:a05:6512:261b:b0:4a1:abd7:3129 with SMTP id bt27-20020a056512261b00b004a1abd73129mr9105614lfb.637.1664871904526; Tue, 04 Oct 2022 01:25:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Tue, 4 Oct 2022 10:24:53 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Early init for few crypto modules for Secure Guests To: "Nikunj A. Dadhania" Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org, Tom Lendacky , ketanch@iitk.ac.in Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, 4 Oct 2022 at 06:41, Nikunj A. Dadhania wrote: > > Hi! > > We are trying to implement Secure TSC feature for AMD SNP guests [1]. During the boot-up of the > secondary cpus, SecureTSC enabled guests need to query TSC info from Security processor (PSP). > This communication channel is encrypted between the security processor and the guest, > hypervisor is just the conduit to deliver the guest messages to the security processor. > Each message is protected with an AEAD (AES-256 GCM). > > As the TSC info is needed during the smpboot phase, few crypto modules need to be loaded early > to use the crypto api for encryption/decryption of SNP Guest messages. > > I was able to get the SNP Guest messages working with initializing few crypto modules using > early_initcall() instead of subsys_initcall(). > > Require suggestion/inputs if this is acceptable. List of modules that was changed > to early_initcall: > > early_initcall(aes_init); > early_initcall(cryptomgr_init); > early_initcall(crypto_ctr_module_init); > early_initcall(crypto_gcm_module_init); > early_initcall(ghash_mod_init); > I understand the need for this, but I think it is a bad idea. These will run even before SMP bringup, and before pure initcalls, which are documented as