From patchwork Fri Aug 16 12:03:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavitrakumar Managutte X-Patchwork-Id: 13766035 X-Patchwork-Delegate: herbert@gondor.apana.org.au Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE795156C62 for ; Fri, 16 Aug 2024 12:03:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723809828; cv=none; b=ACd+yditGpPV2IqoYgvwiLUr7Bv1TZU0Ws8qsEuU+mcx8GZZW8rqn2zZz7KlhZfIY6p0S2bzmmUUg5r069TWtmgstyqKiMByGDrFG1vEsWfeSy/sHVe3mpcKJ96+ytX2ndUBSOTm1hKcjo32JFbPjuGurYXpN+0b6XxJ9lwqkqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723809828; c=relaxed/simple; bh=ycB76cnwmlz6HwU0ZIJ3jiNrpoFUTcORUl9xOpdgyBY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ag+K810dRiOp6deW99g8bCT2S6J+wm92jERJGX5+YqfwxBctr3k+H62+cb05DXF1UCfP+bBR/SCs2AxKcgaPBuLtAYlJsH0gn1G0Rfw8Vzqx2q0epSBu0HZlMjiyQ41rhZILt3tWGqCd1SAB74Rt7tCV09eoF8w7lwFM5Wq5XNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=vayavyalabs.com; spf=pass smtp.mailfrom=vayavyalabs.com; dkim=pass (1024-bit key) header.d=vayavyalabs.com header.i=@vayavyalabs.com header.b=nmqjqlJA; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=vayavyalabs.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vayavyalabs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=vayavyalabs.com header.i=@vayavyalabs.com header.b="nmqjqlJA" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1fec34f94abso18906215ad.2 for ; Fri, 16 Aug 2024 05:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vayavyalabs.com; s=google; t=1723809826; x=1724414626; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4vkBuUCzWA9nwoqD9tlt5sayA4LwP9cf9M8hrIll+Hs=; b=nmqjqlJAxS0XtvSNxLARH8FvdqQLGULXjAW07IfjMB5wcXxtz4lg2XDRIWqixl1eTJ +zpDvwIx+V6q8cQrh03jwIlkXKZMS9nLIBlPP14NhOqVtOmebqOmu9S9WCosZiTucfAu ktvGL6Gsv486Ysf7H5TIlnpEO5e7RTLWz+svI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723809826; x=1724414626; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4vkBuUCzWA9nwoqD9tlt5sayA4LwP9cf9M8hrIll+Hs=; b=wxVQHb255kiaCWmukqwvECsn+x+FDBDs/m5fZ2a4W3RFA2G2PfNaNe8T1lEUBI1vI6 KmnlaTILudRiWLHJQvTeqnHndXBk81/vMjTL4gVOW0MWrPavfXvbG7RVld+Jv7I1J+r0 NlRZBaL6/+H7cjSDy1HPlcjENDnyizEcOtzEwskf1TDF2K8pJ6kt7LlNvIL5gTcLaj6y n56BGJCipCExl8UmZ7u4YwkedgJFEtEi6l9Hc1bOPn9eaLZ9/mzZnnPc/8D26/wb3+vH 5hAXJ7OeQ7pyeR6p7bXoq4xy72HxVf+BpNUSEg3uCJv2g+pT5Fi3groiVJCkrpAAZZE9 d4Aw== X-Forwarded-Encrypted: i=1; AJvYcCW3hkE+OohvkwRGnirv44x8OY0Fe8FI8ebacFVhOg1hjsVVH/3oFb9ZrrAT7fdvMxpBuhlgL//QujtVxBrvUl+dbmvMrBdhMVGkvwez X-Gm-Message-State: AOJu0YwJ5VHjhELAHFxGHGxqNCLG9BhLq6jZuIF4USig/O7rB8aEiJrF al1J/q4lAUxMNLF6Kz9ghtk15t/pS4w92/vLmbf0/vnp71GEABlOsemG7Dpwypg= X-Google-Smtp-Source: AGHT+IHSNuZySpx7CyX9PkLvUvjA/kgkripE7kLD3AlpRKMeZlZratQEghax2E7KfuFFXSAY2gJ2Jw== X-Received: by 2002:a17:902:d2c1:b0:202:ac8:991f with SMTP id d9443c01a7336-2020ac89cecmr13873805ad.26.1723809825973; Fri, 16 Aug 2024 05:03:45 -0700 (PDT) Received: from localhost.localdomain ([103.108.57.9]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f03751f6sm24401725ad.169.2024.08.16.05.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:03:45 -0700 (PDT) From: Pavitrakumar M To: herbert@gondor.apana.org.au, dan.carpenter@linaro.org, linux-crypto@vger.kernel.org Cc: Ruud.Derwig@synopsys.com, manjunath.hadli@vayavyalabs.com, bhoomikak@vayavyalabs.com, Pavitrakumar M Subject: [PATCH v1 1/2] Fix counter width checks Date: Fri, 16 Aug 2024 17:33:32 +0530 Message-Id: <20240816120333.791577-1-pavitrakumarm@vayavyalabs.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch fixes counter width checks according to the version extension3 register. The counter widths can be 8, 16, 32 and 64 bits as per the extension3 register. Signed-off-by: Bhoomika K Signed-off-by: Pavitrakumar M Acked-by: Ruud Derwig --- drivers/crypto/dwc-spacc/spacc_skcipher.c | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) base-commit: 2d6213bd592b4731b53ece3492f9d1d18e97eb5e diff --git a/drivers/crypto/dwc-spacc/spacc_skcipher.c b/drivers/crypto/dwc-spacc/spacc_skcipher.c index 488c03ff6c36..d55bcfe8c3c5 100644 --- a/drivers/crypto/dwc-spacc/spacc_skcipher.c +++ b/drivers/crypto/dwc-spacc/spacc_skcipher.c @@ -406,40 +406,42 @@ static int spacc_cipher_process(struct skcipher_request *req, int enc_dec) for (i = 0; i < 16; i++) ivc1[i] = req->iv[i]; - /* 32-bit counter width */ - if (readl(device_h->regmap + SPACC_REG_VERSION_EXT_3) & (0x2)) { + /* 64-bit counter width */ + if (readl(device_h->regmap + SPACC_REG_VERSION_EXT_3) & (0x3)) { - for (i = 12; i < 16; i++) { - num_iv <<= 8; - num_iv |= ivc1[i]; + for (i = 8; i < 16; i++) { + num_iv64 <<= 8; + num_iv64 |= ivc1[i]; } - diff = SPACC_CTR_IV_MAX32 - num_iv; + diff64 = SPACC_CTR_IV_MAX64 - num_iv64; - if (len > diff) { + if (len > diff64) { name = salg->calg->cra_name; ret = spacc_skcipher_fallback(name, req, enc_dec); return ret; } + /* 32-bit counter width */ } else if (readl(device_h->regmap + SPACC_REG_VERSION_EXT_3) - & (0x3)) { /* 64-bit counter width */ + & (0x2)) { - for (i = 8; i < 16; i++) { - num_iv64 <<= 8; - num_iv64 |= ivc1[i]; + for (i = 12; i < 16; i++) { + num_iv <<= 8; + num_iv |= ivc1[i]; } - diff64 = SPACC_CTR_IV_MAX64 - num_iv64; + diff = SPACC_CTR_IV_MAX32 - num_iv; - if (len > diff64) { + if (len > diff) { name = salg->calg->cra_name; ret = spacc_skcipher_fallback(name, req, enc_dec); return ret; } + /* 16-bit counter width */ } else if (readl(device_h->regmap + SPACC_REG_VERSION_EXT_3) - & (0x1)) { /* 16-bit counter width */ + & (0x1)) { for (i = 14; i < 16; i++) { num_iv <<= 8; @@ -454,8 +456,9 @@ static int spacc_cipher_process(struct skcipher_request *req, int enc_dec) req, enc_dec); return ret; } - } else if (readl(device_h->regmap + SPACC_REG_VERSION_EXT_3) - & (0x0)) { /* 8-bit counter width */ + /* 8-bit counter width */ + } else if ((readl(device_h->regmap + SPACC_REG_VERSION_EXT_3) + & 0x7) == 0) { for (i = 15; i < 16; i++) { num_iv <<= 8; From patchwork Fri Aug 16 12:03:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavitrakumar Managutte X-Patchwork-Id: 13766036 X-Patchwork-Delegate: herbert@gondor.apana.org.au Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0401B156C62 for ; Fri, 16 Aug 2024 12:03:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723809832; cv=none; b=WOnR8aQu8p4yN+wWhR22pV582TAVaUhPsslhXGRRgAVm81Trsm1iWgzNtD3aUIWpVsRY+Yc3xfGRgvFarsJ8GWpcpXBqBOnXRMg1sVwkpednMkKgVtxfeWryXse78HLMcDgN+257zpMOkUEJSt94WTz1IH5CBfm067EPLG9iFwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723809832; c=relaxed/simple; bh=QsDoUS1ElqARPVJGKlEqs4yyR/pFU/tg9T7gF0bk0Fo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=njc5BmQvjjGQ30Xm/kuE0pjINu/6QKqenWWc26LWzm+0BWrlvzHQ/rPyag9n1R9gAf7IqBUgaDzijrJOCBj7BvAbEL0+DHBbctquYiYerT7IS4zX+2SgLurVCzWBte2yYiBm2szkAiQ5r2uDmypNWaHwh2n+wsJsa1Q1crsEEdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=vayavyalabs.com; spf=pass smtp.mailfrom=vayavyalabs.com; dkim=pass (1024-bit key) header.d=vayavyalabs.com header.i=@vayavyalabs.com header.b=eE23AeR+; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=vayavyalabs.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vayavyalabs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=vayavyalabs.com header.i=@vayavyalabs.com header.b="eE23AeR+" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-201e64607a5so14022165ad.2 for ; Fri, 16 Aug 2024 05:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vayavyalabs.com; s=google; t=1723809830; x=1724414630; 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=mRVQpU/KkLLWE9g7x2RE2OoWH8BnNFuTM4i4IOyBB0s=; b=eE23AeR+Gb/qYZ6r4aOMNwwy8WTQXAFxctlXauRxRIJ5/YlV+v8xACR4qjIZcXX5LP FBCbDC42j/0aJuaLs1fN1mb34Coen6Nh89zgWfZVRs7ci/ffec0Ip7+RfkijW6gxkh/3 CdwwuH2D0iTf1piudjsyHKs19Fw04l1HzWWgY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723809830; x=1724414630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mRVQpU/KkLLWE9g7x2RE2OoWH8BnNFuTM4i4IOyBB0s=; b=QRZJUCoJcB6UdMYjoy+UMWrIHBGdw1UeO7IU4oKIrzRA+APqbA1QTXiZvXKIfsChxZ 4fvfB6rdcNMNhBTU3pL2bIhQ1n+5p0Kw8U21u98wlkUZstkESIH9qctjAlDaEa1/EH/U GYYJ9GXuIN1QlJAI14QhTRAa89XVrU9FEPkcqkD/f5FAFl7BKVwi4U4sZm1Kir+5LiPZ 17PnfBccW2oAwejD94F0tfezWpp0tJOL+n5vDypngpvooJ+kI7maQhv60RDMoSPKjbAI +pDHZPECNS0Nr576QRDQj+K4jAh328+F6tYPTcDTwBGzx9eOfa0tTMga6p24fOFQ4+uG U02w== X-Forwarded-Encrypted: i=1; AJvYcCWyRjSIN+kIZI8aITiSehz51gaiV7woSVl3ZL+aApaw84+mxBIpWdSuhRriSga+1A2DE/xWglcUqi1Xid9400TtcW50TMxTYJOyq5BR X-Gm-Message-State: AOJu0YzxsOIQx55oDlJozNck6P3WB1TStEmTNpvzyfDdkEJKWJVQMl+6 9LPCmhP/+D3aWjDotOrb+2lcpacvrt/cEVWzQhpC5KIii/vL0EzHO5cq80tEmpE= X-Google-Smtp-Source: AGHT+IGmWu4PUsovmi2jSo6X9vXs+aWE4ndVf2RWGO1RGubzji0oY61Ll8ny+Ioiyo5tMB4q7ZHUyw== X-Received: by 2002:a17:902:f60f:b0:201:daee:6fae with SMTP id d9443c01a7336-20203f2c389mr35086095ad.48.1723809830285; Fri, 16 Aug 2024 05:03:50 -0700 (PDT) Received: from localhost.localdomain ([103.108.57.9]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f03751f6sm24401725ad.169.2024.08.16.05.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:03:50 -0700 (PDT) From: Pavitrakumar M To: herbert@gondor.apana.org.au, dan.carpenter@linaro.org, linux-crypto@vger.kernel.org Cc: Ruud.Derwig@synopsys.com, manjunath.hadli@vayavyalabs.com, bhoomikak@vayavyalabs.com, Pavitrakumar M Subject: [PATCH v1 2/2] Fixed return to CRYPTO_OK Date: Fri, 16 Aug 2024 17:33:33 +0530 Message-Id: <20240816120333.791577-2-pavitrakumarm@vayavyalabs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240816120333.791577-1-pavitrakumarm@vayavyalabs.com> References: <20240816120333.791577-1-pavitrakumarm@vayavyalabs.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Removed CRYPTO_USED_JB and returning CRYPTO_OK instead. Signed-off-by: Bhoomika K Signed-off-by: Pavitrakumar M Acked-by: Ruud Derwig --- drivers/crypto/dwc-spacc/spacc_core.c | 6 +++--- drivers/crypto/dwc-spacc/spacc_core.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/dwc-spacc/spacc_core.c b/drivers/crypto/dwc-spacc/spacc_core.c index 9bc49de06bb2..03495b4ae553 100644 --- a/drivers/crypto/dwc-spacc/spacc_core.c +++ b/drivers/crypto/dwc-spacc/spacc_core.c @@ -1103,7 +1103,7 @@ int spacc_packet_enqueue_ddt_ex(struct spacc_device *spacc, int use_jb, { int i; struct spacc_job *job; - int ret = CRYPTO_OK, proc_len; + int proc_len; if (job_idx < 0 || job_idx > SPACC_MAX_JOBS) return -ENXIO; @@ -1222,7 +1222,7 @@ int spacc_packet_enqueue_ddt_ex(struct spacc_device *spacc, int use_jb, job->ctrl &= ~SPACC_CTRL_MASK(SPACC_CTRL_KEY_EXP); } - return ret; + return CRYPTO_OK; fifo_full: /* try to add a job to the job buffers*/ @@ -1248,7 +1248,7 @@ int spacc_packet_enqueue_ddt_ex(struct spacc_device *spacc, int use_jb, spacc->jb_head = i; - return CRYPTO_USED_JB; + return CRYPTO_OK; } int spacc_packet_enqueue_ddt(struct spacc_device *spacc, int job_idx, diff --git a/drivers/crypto/dwc-spacc/spacc_core.h b/drivers/crypto/dwc-spacc/spacc_core.h index 399b7c976151..297a08eea0d2 100644 --- a/drivers/crypto/dwc-spacc/spacc_core.h +++ b/drivers/crypto/dwc-spacc/spacc_core.h @@ -333,8 +333,6 @@ enum { #define SPACC_MAX_JOB_BUFFERS 192 #endif -#define CRYPTO_USED_JB 256 - /* max DDT particle size */ #ifndef SPACC_MAX_PARTICLE_SIZE #define SPACC_MAX_PARTICLE_SIZE 4096