Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2009555rdb; Sun, 4 Feb 2024 10:32:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzdq1ZajqgzNEWggzFmZhuYZgQBi2wUNftz9jmasB2BifiBrVhZ2DtdoW3rO5ds0AC/i9y X-Received: by 2002:a05:6a21:33a1:b0:19e:5d02:12d6 with SMTP id yy33-20020a056a2133a100b0019e5d0212d6mr4633871pzb.26.1707071575184; Sun, 04 Feb 2024 10:32:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707071575; cv=pass; d=google.com; s=arc-20160816; b=h2XA/j18XOm7OBrH9V0m+nQJTzcd7EXKk4WZ3ZOqx8m8GPBc7Ku8SvZuOhhLS9bS3f r40d2soAQa0D9T69wiL1yaq6Vh/+MeDYKPnxC1pAmAq0t3pdoUsabxO2SL4LE+ROVjpt eeaXaS14I5RqOcYvdZScize11CvRffjQT+DNKY88xy1L+w/HTSZ/Cx7yHCG9dOt0dXOT BPpe1ctnysA25Rcl9qDlEYTBIBqi6M0Hl91IuLtnhOLcWXHPGHO+Xkye0Y/tsPBpjqwf 8o0h0nkvbCyrsbPWYJi82LgF8X3bCiEhtzoFoir/+IlFs6e8hcw0FljSa+0ZMJDCrdqz sLgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=s2TWXxbk1O39WIKgnGYQbW++dB7WqbpabTQYcEP9Epg=; fh=dDUl5LqqYDY56A18n6Oq+5A9GKy9K9a2/cc8cvKw6pw=; b=ETFt5sOnrDt8sU7vBGTx34GnnxvWzMk753WQvfNzGZQyGsk3NXIPby9sPdD9dXOt+5 vuy3YXDGP2haodqX4/tWlxV0dRkMXG9orPFr34365aTYg9koUFboOif74PoX9fz2WIFP l9ghkkomLQfUC2P0s64sHAbZ981HfAqUgn9mDt06UI5O6rX4njs5YbXwiFVZIw0DyQEH FK45Ul/JNSuwVUGSdQTx5/zEvzE9Z+c3BIg9+yKv/gy3RVaxAq2Y9b4xW0vDc3UAVlpo wn6i6gKfv9ew48UP+Q0XBDLb1F0/hTSYNDwRnIHQ6OW/h/P0bTwSqEvqnCskdrECYUzm 2Icg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NEtxkGF0; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-crypto+bounces-1829-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com X-Forwarded-Encrypted: i=1; AJvYcCVJAzXs/enAjPqGz1JSU2Hhbz/Xo8+ZjCSbIZvlssiA0qzHfkuSk9rH9rpjNSccWh7n+3Rgfd5/BXtDiUAeiza/qRm0jOET6YYVZALtYg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 28-20020a630d5c000000b005dbedf04f68si4910019pgn.10.2024.02.04.10.32.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 10:32:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1829-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NEtxkGF0; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-crypto+bounces-1829-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id EE16FB20E76 for ; Sun, 4 Feb 2024 18:32:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C5BB24B33; Sun, 4 Feb 2024 18:32:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="NEtxkGF0" X-Original-To: linux-crypto@vger.kernel.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 83352249EE; Sun, 4 Feb 2024 18:32:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707071563; cv=none; b=ZuPt7597U8ny3KZPHT+jdJWKuJXPr39yW101VI5T2Pcc5antz/IZ5YaUvmq9lNT+8Di3kY8sVrivEe/kQyGdBpXnawfU5Myt41nX339nVlJASgL+rPQA0ha7cJpAtUBexLX4ZxQWwqfGKl/wwr0TOmmb3apnKEvRzmXWNovsOEk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707071563; c=relaxed/simple; bh=0+rTMhidwrziDNcAPA5ZtRDC2hGitSVJlE07G60n9N8=; h=From:To:CC:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=qShD9XtWUVITc3Il4N4SCr4bbsKq/dV3vHZoR+rVTtkKBgJDoFXEQd3a7/Z/AbHpc1v5N3NaCm+UhYJmyt4YmxlmWMBZpOE7cCUhuM2zYuXoJnbnHryAxyptC4C1Zyrp5w/RHgZEVz1NLfhlH2+2qBlyBrXjbuc9Sg/ew2hGP+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=NEtxkGF0; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 414IW9Ft020319; Sun, 4 Feb 2024 12:32:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707071529; bh=s2TWXxbk1O39WIKgnGYQbW++dB7WqbpabTQYcEP9Epg=; h=From:To:CC:Subject:In-Reply-To:References:Date; b=NEtxkGF0LK9XaN9HqFJjU9aFr3taztUE4uxi+uN7w/z6xRWBwV/f5C1nBHVQUOsNW l2APL7p+wukyZK+oneR50K5qf3nPn8zPfiJ1y1sbJjJZiOI4epbkRk6XcpzUsAxHoS dquzwtolCOfUc11IG0xiylFmsBeN9TaCsknOPWVc= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 414IW9NI020112 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 4 Feb 2024 12:32:09 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sun, 4 Feb 2024 12:32:09 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Sun, 4 Feb 2024 12:32:09 -0600 Received: from localhost (kamlesh.dhcp.ti.com [172.24.227.123]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 414IW86i038451; Sun, 4 Feb 2024 12:32:08 -0600 From: Kamlesh Gurudasani To: Gaurav Kashyap , , , , , , , , , CC: , , , , , , , , , , , , , , , Gaurav Kashyap Subject: Re: [EXTERNAL] [PATCH v4 04/15] soc: qcom: ice: add hwkm support in ice In-Reply-To: <20240127232436.2632187-5-quic_gaurkash@quicinc.com> References: <20240127232436.2632187-1-quic_gaurkash@quicinc.com> <20240127232436.2632187-5-quic_gaurkash@quicinc.com> Date: Mon, 5 Feb 2024 00:02:07 +0530 Message-ID: <87jznkytaw.fsf@kamlesh.i-did-not-set--mail-host-address--so-tickle-me> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Gaurav Kashyap writes: ... > + /* > + * When ICE is in standard (hwkm) mode, it supports HW wrapped > + * keys, and when it is in legacy mode, it only supports standard > + * (non HW wrapped) keys. > + * > + * Put ICE in standard mode, ICE defaults to legacy mode. > + * Legacy mode - ICE HWKM slave not supported. > + * Standard mode - ICE HWKM slave supported. > + * > + * Depending on the version of HWKM, it is controlled by different > + * registers in ICE. > + */ > + if (ice->hwkm_version >= 2) { > + val = qcom_ice_readl(ice, QCOM_ICE_REG_CONTROL); > + val = val & 0xFFFFFFFE; From the code I understand that the last bit is used for setting the mode. Was wondering if it would make more sense to use ~BIT(0) or GENMASK to generate this value and #define this value to express the work it does. In this case, something like #define xx_SET_MODE_MASK (~BIT(0)) or use GENMASK This would make it easier for a person who is taking a look at the code for first time. This is just my perspective. If you do agree, you can change them at multiple places accross this patch, wherever magic numbers are used for val and masking the value. Regards, Kamlesh > + qcom_ice_writel(ice, val, QCOM_ICE_REG_CONTROL); > + } else { > + qcom_ice_writel(ice, 0x7, HWKM_OFFSET(QCOM_ICE_REG_HWKM_TZ_KM_CTL)); > + } > +} > + > +static void qcom_ice_hwkm_init(struct qcom_ice *ice) > +{ > + /* Disable CRC checks. This HWKM feature is not used. */ > + qcom_ice_writel(ice, 0x6, > + HWKM_OFFSET(QCOM_ICE_REG_HWKM_TZ_KM_CTL)); > + > + /* > + * Give register bank of the HWKM slave access to read and modify > + * the keyslots in ICE HWKM slave. Without this, trustzone will not > + * be able to program keys into ICE. > + */ > + qcom_ice_writel(ice, 0xFFFFFFFF, HWKM_OFFSET(QCOM_ICE_REG_HWKM_BANK0_BBAC_0)); > + qcom_ice_writel(ice, 0xFFFFFFFF, HWKM_OFFSET(QCOM_ICE_REG_HWKM_BANK0_BBAC_1)); > + qcom_ice_writel(ice, 0xFFFFFFFF, HWKM_OFFSET(QCOM_ICE_REG_HWKM_BANK0_BBAC_2)); > + qcom_ice_writel(ice, 0xFFFFFFFF, HWKM_OFFSET(QCOM_ICE_REG_HWKM_BANK0_BBAC_3)); > + qcom_ice_writel(ice, 0xFFFFFFFF, HWKM_OFFSET(QCOM_ICE_REG_HWKM_BANK0_BBAC_4)); > + > + /* Clear HWKM response FIFO before doing anything */ > + qcom_ice_writel(ice, 0x8, HWKM_OFFSET(QCOM_ICE_REG_HWKM_BANK0_BANKN_IRQ_STATUS)); > + ice->hwkm_init_complete = true; > +} ...