Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3010640pxb; Tue, 13 Apr 2021 16:20:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ97Hz7sESJsAPQolOItdVuDabzL+cvoAXoAl/kEijhwt2/rIjNLlniIl32iVMg/Rgwahf X-Received: by 2002:a50:d0d8:: with SMTP id g24mr24579834edf.290.1618356023225; Tue, 13 Apr 2021 16:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618356023; cv=none; d=google.com; s=arc-20160816; b=cVaDc5XuDg1xNrbHk4olzEYoTOMbFiJ3nwxEPMSQqtNaUJAW9BoZ8tH/F8ERdjZouc EtQUfPAeTo9aWnmaLo57mYydCCtqkzROOHZHO7x4nmH8n84gaAwFukYHME544XLpkzt8 Am4G7Gk3wqNPiFfNIVu3GZhTqA2+QvZ/8GAXJcAihBptY/PSto7+nK79xip1pbt5rllu 6HIcJqViBxW6q1rWxEmPnkOdzEb0/JsiWNsHhdpraVj6WO2R7CAYM4rdyo0MEmJRrLi4 EeR+MQ198jD04IRvsImcYtin+p6+4PqW7M0zH44b9awdmRwaxoAgFZPdFE99Xy9kPsH3 aHtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=b8ZN7Qwwd5Ix7pE604LHRgxVLUozgSWTjN9Rn065Nm0=; b=cR8Ni9XIxRCnaYmnjNuzVWT0m+aK0sJd5fP31WcoiNDOhcqeUJXynzCwG1C3wzWn4M GBV4sHU9VKVsGWQLwDOJKPSYbfPsDik12oB5uBqS9uQ8JCm3KheCuOdWDfFTPPz/lWMl 8qf1lu9ET1rG5FAemTKYhAb6A1Lcuq7gKqYIFILV7q8n0IIbVbFV3q4WrVqN1j+96vUz VQ4ru5f1my9bIx5SrQLqmDPn5p+c3gRoQFNSy46kTBQNmkru7lP8nE9uQXXz4JPBBXfg cq8+pIvN8SASgzlMASXaiGbS0j8fOWbejGSRgGEaFij783xTVLGWhTlgtLAi8piy1anM 3wug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PP3iAuCA; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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. [23.128.96.18]) by mx.google.com with ESMTP id q19si1215956ejd.250.2021.04.13.16.19.50; Tue, 13 Apr 2021 16:20:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PP3iAuCA; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S229837AbhDMT2q (ORCPT + 99 others); Tue, 13 Apr 2021 15:28:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbhDMT2p (ORCPT ); Tue, 13 Apr 2021 15:28:45 -0400 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F550C061574 for ; Tue, 13 Apr 2021 12:28:25 -0700 (PDT) Received: by mail-qv1-xf35.google.com with SMTP id iu14so8689356qvb.4 for ; Tue, 13 Apr 2021 12:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=b8ZN7Qwwd5Ix7pE604LHRgxVLUozgSWTjN9Rn065Nm0=; b=PP3iAuCANMnnD5BG2ntiGPA2FwlNMHOgU6s6gp6rNGpbGZM3IdJFhOdCXLoQMrGL5c LBuPYHM0UfsnoZYKR8l0HFmi1aS3DSZrmSSUljyJq0GqLDhDMjew7VG90wfCLeIaY41D PX5fQ52pvCpxSsVSsoUFliEo3vEMoi5g4fkGpRtersFBJWXjc+TIjU/AMkiHk7e6stdG IKCYYTgJxoN3r6X8cGorkQYGD6yGZQjn4HuIaUs/JumRsiQOUNGbJexrqIeX6PFZzBeM fXsfdkwRm1+2N3JMv2SkO0C7ePbmsST034Fq6JpuZWuRumencTEu0NbM9SzV8IzCow0I uifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=b8ZN7Qwwd5Ix7pE604LHRgxVLUozgSWTjN9Rn065Nm0=; b=Aeyhc4JP1kUQ5jXZWt+W4KVi20LK0rxbpR4lu4WGIqmKTwaC1GAsDXAJK5kLfzlRIL pA6AtsoMMKoIqzFT4QkoEXXMAwWDbUhpzh6qMCc2sALd9TEsqSboKhVKfWfgbRoF+k/S aHdtv3WHJ1s0hjETjHB3oX8zaK6p3cKC94Zwy+Noz3RC4YAZPc1etrwQY488QBwobBAr /8SPHE3Q3jBBXYAwUYdANSgJwBReoZXsZViVNiSHj1By58Nmfqfzc1wc3vuR2dkWCi4j qGiFoCvP3j2/ghqvuW7zvUrNgmjDmgVJigXdpR7KV9Lr7QNOBlndZyz0h+BT582Cyyu8 /RtQ== X-Gm-Message-State: AOAM530/mJ/SFqhn/S9O+zPLk+SLqK2QBOcfG4QxtuB960WFjkTqmUyt kz7T0WO4FKVaYRdZOT8G6OxrBA== X-Received: by 2002:a05:6214:248f:: with SMTP id gi15mr34367277qvb.40.1618342104272; Tue, 13 Apr 2021 12:28:24 -0700 (PDT) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id e13sm10797545qtm.35.2021.04.13.12.28.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Apr 2021 12:28:23 -0700 (PDT) Subject: Re: [PATCH 1/7] crypto: qce: common: Add MAC failed error checking To: Bjorn Andersson Cc: herbert@gondor.apana.org.au, davem@davemloft.net, ebiggers@google.com, ardb@kernel.org, sivaprak@codeaurora.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210225182716.1402449-1-thara.gopinath@linaro.org> <20210225182716.1402449-2-thara.gopinath@linaro.org> <20210405173600.GZ904837@yoga> From: Thara Gopinath Message-ID: <1c3523d6-ac4d-f0b7-ad89-724ed1e4f485@linaro.org> Date: Tue, 13 Apr 2021 15:28:22 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210405173600.GZ904837@yoga> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Bjorn, Thanks for the reviews. I realized that I had these replies in my draft for a while and forgot to send them! On 4/5/21 1:36 PM, Bjorn Andersson wrote: > On Thu 25 Feb 12:27 CST 2021, Thara Gopinath wrote: > >> MAC_FAILED gets set in the status register if authenthication fails >> for ccm algorithms(during decryption). Add support to catch and flag >> this error. >> >> Signed-off-by: Thara Gopinath >> --- >> drivers/crypto/qce/common.c | 11 ++++++++--- >> 1 file changed, 8 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c >> index dceb9579d87a..7c3cb483749e 100644 >> --- a/drivers/crypto/qce/common.c >> +++ b/drivers/crypto/qce/common.c >> @@ -403,7 +403,8 @@ int qce_start(struct crypto_async_request *async_req, u32 type) >> } >> >> #define STATUS_ERRORS \ >> - (BIT(SW_ERR_SHIFT) | BIT(AXI_ERR_SHIFT) | BIT(HSD_ERR_SHIFT)) >> + (BIT(SW_ERR_SHIFT) | BIT(AXI_ERR_SHIFT) | \ >> + BIT(HSD_ERR_SHIFT) | BIT(MAC_FAILED_SHIFT)) >> >> int qce_check_status(struct qce_device *qce, u32 *status) >> { >> @@ -417,8 +418,12 @@ int qce_check_status(struct qce_device *qce, u32 *status) >> * use result_status from result dump the result_status needs to be byte >> * swapped, since we set the device to little endian. >> */ >> - if (*status & STATUS_ERRORS || !(*status & BIT(OPERATION_DONE_SHIFT))) >> - ret = -ENXIO; >> + if (*status & STATUS_ERRORS || !(*status & BIT(OPERATION_DONE_SHIFT))) { >> + if (*status & BIT(MAC_FAILED_SHIFT)) > > Afaict MAC_FAILED indicates a different category of errors from the > others. So I would prefer that the conditionals are flattened. > > Is OPERATION_DONE set when MAC_FAILED? Yes it is. I will change the check to the pattern you have suggested. It is less confusing.. > > If so: > > if (errors || !done) > return -ENXIO; > else if (*status & BIT(MAC_FAILED)) > return -EBADMSG; > > Would be cleaner in my opinion. > > Regards, > Bjorn > >> + ret = -EBADMSG; >> + else >> + ret = -ENXIO; >> + } >> >> return ret; >> } >> -- >> 2.25.1 >> -- Warm Regards Thara