Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp696908pxb; Wed, 20 Jan 2021 18:58:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWk7igL8middjbsXB4BPA30fLyJMCHnPNOmu7+DN9q39m+RccrzQlrfZZDRuavkm+ZWx0L X-Received: by 2002:a17:906:3792:: with SMTP id n18mr7706302ejc.47.1611197932924; Wed, 20 Jan 2021 18:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611197932; cv=none; d=google.com; s=arc-20160816; b=RQEwPWlBGJPVRSfxccYYBT+KvYnItngoRsgUpDkR+44SkqrIQMjTzm9VHn59WL6/sh 0Cl9hGGpVb0pfHM9GXyW+8/tT4g+o8y73i8/8G4EqqbbnubLnURjLxj3IsY/4+TY9/Dd jkSYatNA3hob+BOX9RUgoEZjLBzIo/sqmm9MsCo53i5VU2rW1zAWEcsp5pJFHyz3tG2u pz4uS142hVJvziVFr6/9sy15r0riHDVp+D4q2Y3WSpry1QBjafmy5pRzi1OVN8zYejp9 qMjgb1Eqw/qdMaj3PHbUbiKH2zRlzyyZw5/EQmMpJuDDNesW2rz1oKDXZ5WHBD5b+HvN PweQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kLrz6OekkJ/L2QNsj4u3kTnZxq06Ecc2K12cttXxD8k=; b=rKkJHju/wMwPCZ72ks64hYMVwfkY8KRXqqRWkIcAwy7ejSKzEa+/8aFrOVCywxufEm AEoKerlFgyyWlfeV8GE9RMuuLJKy8J4c87uE+6aQ9EDmylyOGAqh+KcXf/DB8XHirSjL QpCBE4LCnSr6C+/1v3ikjr1RWSaS+Xk9ng8Ptw0Og9U2Z+vFlo4cbUJyTPQ/6EYhY5+N kx1KmV6gLwbGtkW/ugPe6YQ2eVfju6zW2VMHiynT5JwAiZaB0tuj9J2Iy/ImHWt05GaP tbSsSKt8qhjMfkX3qN5P2+ZzWTLrjrVK8A1H64l61Hpl/yHKlqn3Fyqp4jMpKWLcegrN 29Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iWnwvweN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ho11si1397024ejc.260.2021.01.20.18.58.18; Wed, 20 Jan 2021 18:58:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=k20201202 header.b=iWnwvweN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1733252AbhAUBDQ (ORCPT + 99 others); Wed, 20 Jan 2021 20:03:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:33986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732789AbhAUAbf (ORCPT ); Wed, 20 Jan 2021 19:31:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 032102376F; Thu, 21 Jan 2021 00:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611189054; bh=4yI1tHsy7IU5ZtsfF68rC47orrOygZ+JpaM2hnsfqGo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iWnwvweNrT/zWAAr1o94ACIxD2d52gIZHO+DTKnrAoZA6C/8yHZEvXA/g9pK8Q1bD exhyyXx7mFrbBgemBuOtJDjF8KSqWe2y/0bG+MN0XtDIcgVCK8NeSbhDVVbpcwjuOs obGchRMqgE35o0yO2ZtUCAID2uGxaJfjgXVblXfW0Ygvg+gCZMc7ruWWHENwAZDHeF lHBh6RGuTkKmGx6hjor4lDKUyTFQRfBW2MKkcd7n/+FAj85XZlMvcWif/s7nmpY/cl HEXPj57fK1zqZUo27sHESK4p7msj1Xpx+zlGAtmLzZytkJuvtiogf8DxfAa6bXy5U4 th4s3WlGBNfgQ== Date: Thu, 21 Jan 2021 02:30:49 +0200 From: Jarkko Sakkinen To: Sean Christopherson Cc: Tianjia Zhang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang Subject: Re: [PATCH v2] x86/sgx: Remove redundant if conditions in sgx_encl_create Message-ID: References: <20210120035328.19868-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 20, 2021 at 09:47:53AM -0800, Sean Christopherson wrote: > On Wed, Jan 20, 2021, Tianjia Zhang wrote: > > In this scenario, there is no case where va_page is NULL, and > > the error has been checked. The if condition statement here is > > redundant, so remove the condition detection. > > > > Reported-by: Jia Zhang > > Suggested-by: Sean Christopherson > > Signed-off-by: Tianjia Zhang > > --- > > arch/x86/kernel/cpu/sgx/ioctl.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c > > index 1c6ecf9fbeff..efad2fb61c76 100644 > > --- a/arch/x86/kernel/cpu/sgx/ioctl.c > > +++ b/arch/x86/kernel/cpu/sgx/ioctl.c > > @@ -66,9 +66,12 @@ static int sgx_encl_create(struct sgx_encl *encl, struct sgx_secs *secs) > > va_page = sgx_encl_grow(encl); > > if (IS_ERR(va_page)) > > return PTR_ERR(va_page); > > - else if (va_page) > > - list_add(&va_page->list, &encl->va_pages); > > - /* else the tail page of the VA page list had free slots. */ > > + > > + if (WARN_ONCE(!va_page, > > + "the tail page of the VA page list had free slots\n")) > > IMO it's worth trimming down the message to keep this on a single line. The > newline isn't necessary, and this code expects a completely empty list, e.g. it > can be reworded to something like: > > if (WARN_ONCE(!va_page, "non-empty VA page list before ECREATE")) Agreed. If I recall correctly, these days you can have at least 100 characters per line (if not more, cannot recall the exact number). /Jarkko > > > + return -EIO; > > + > > + list_add(&va_page->list, &encl->va_pages); > > > > /* The extra page goes to SECS. */ > > encl_size = secs->size + PAGE_SIZE; > > -- > > 2.19.1.3.ge56e4f7 > > >