From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E97BC433DB for ; Tue, 19 Jan 2021 20:29:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1FE192310D for ; Tue, 19 Jan 2021 20:29:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FE192310D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8C3B46B0005; Tue, 19 Jan 2021 15:29:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 899876B0006; Tue, 19 Jan 2021 15:29:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B01B6B0007; Tue, 19 Jan 2021 15:29:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id 67BB36B0005 for ; Tue, 19 Jan 2021 15:29:22 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3689C824999B for ; Tue, 19 Jan 2021 20:29:22 +0000 (UTC) X-FDA: 77723664564.27.cup28_3208d2c27554 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin27.hostedemail.com (Postfix) with ESMTP id EBE993D66D for ; Tue, 19 Jan 2021 20:29:21 +0000 (UTC) X-HE-Tag: cup28_3208d2c27554 X-Filterd-Recvd-Size: 4779 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 Jan 2021 20:29:21 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id x18so11206862pln.6 for ; Tue, 19 Jan 2021 12:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tB/SKLCPwSzSquO5fiUc4D+SVjGaQxxEWky+zQ2MRC8=; b=L9Pkrnhj9MgnfHYQvR+iRBUV5BbrfSuVlaPnCgA33yuSpga1n0XXRV9FVvyNWT7kXM qMf/N6jyy80qn2Sl2jZeSQvKZc/FLw82MD7/yUKQ+b0nJWh7x0aRhdLphSsQ9nANzCzZ 9uLOBxwO+NpcD5g+5Uxknc+ZQqgUkb8XHhN9lCmpgG5/ayt4dE2xdv/wypIkccUXWZIj CzF7ayETv/9uT1+ecZXxkrdSBQvLI1Bm0gyoWaatB4h25+STGr1oGOwUowMBLY53n6iV MtLDje3ueobKYUZH35szcFZWVDCbiCP76bdxYo+tegjBpXIbpKXn1BE+jBo4W+yyJLdf zsNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tB/SKLCPwSzSquO5fiUc4D+SVjGaQxxEWky+zQ2MRC8=; b=ID2O40ZTsNxLNcvh/BiFJNx/F8OceVNkspVeMdFgjGNJLUBf6DrccJHwuHevkrzdUi itbX7I9uzSEcT5AkJRU9OJBQDv+gpgn6F1yqxAer1q8bmD2v8PJWu7OG+SMsPvONHhzD ma4QeaQIGW9zrZjeZOALzv2s1Rk6NpGEEKHIeioHgphoLTaDcLRKLgWe/FJDApfdg8TE EcYplXeJSXEh60gNllXrrovGxjK23OBouLTsn3IJLpnUlGUn86uCzlAOjKO1i3ZCwl7b p4kKuZkH2s64dsEeclBN1GFFmxWcXYBYz1UEkboBiBfebNp0fj9AmWDY35AYcVYshLe+ dS9g== X-Gm-Message-State: AOAM533f4DyDJDkpaA/JYDqSLSyjmFfcqwCYuybcN4Mk3eiklvxQTxIy 4YNfBgN/Q12rTEYsTQLQlQa8lQ== X-Google-Smtp-Source: ABdhPJyHst8rpJfU0OKWtbSvpdPC7WXg9YC6Hb3jdcyfJboBdkuXF0s4ve1w/ooaebr3IHZ4VqAHpA== X-Received: by 2002:a17:90b:ec2:: with SMTP id gz2mr1552296pjb.143.1611088160483; Tue, 19 Jan 2021 12:29:20 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id y16sm18379491pgg.20.2021.01.19.12.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 12:29:19 -0800 (PST) Date: Tue, 19 Jan 2021 12:29:12 -0800 From: Sean Christopherson To: Tianjia Zhang Cc: Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Andrew Morton , Shuah Khan , haitao.huang@intel.com, Kai Huang , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Jia Zhang Subject: Re: [PATCH] x86/sgx: Remove redundant if conditions in sgx_encl_create Message-ID: References: <20210118133358.99311-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210118133358.99311-1-tianjia.zhang@linux.alibaba.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jan 18, 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 > Signed-off-by: Tianjia Zhang > --- > arch/x86/kernel/cpu/sgx/ioctl.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c > index 90a5caf76939..f45957c05f69 100644 > --- a/arch/x86/kernel/cpu/sgx/ioctl.c > +++ b/arch/x86/kernel/cpu/sgx/ioctl.c > @@ -66,9 +66,8 @@ 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. */ > + > + list_add(&va_page->list, &encl->va_pages); Maybe add a WARN_ONCE to document/enforce the behavior? va_page = sgx_encl_grow(encl); if (IS_ERR(va_page)) return PTR_ERR(va_page); if (WARN_ONCE(!va_page, "clever comment goes here)) 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 >