Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4266653ybb; Tue, 7 Apr 2020 04:12:36 -0700 (PDT) X-Google-Smtp-Source: APiQypJy+imCfwDXWDpJol84EqlPA1GaOb+csVdhlew+k+eD/NHF1VALJ1xyU8fkrefvcaJzq6vd X-Received: by 2002:aca:4b56:: with SMTP id y83mr1245639oia.142.1586257955818; Tue, 07 Apr 2020 04:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586257955; cv=none; d=google.com; s=arc-20160816; b=WK/WNr4LGj4UAWmnPCCLMDT9ZVrrM3KenvdmfngMcTVvpuagx588Gl++QS/eaJId5u 3eEgriTKgQunAQUQtYagxuQgfcqTjhEPLnaCJyqGBQUzF2qM5552WiAzPpbYvxcQ7SRK A2TtnDmk+OzODUUd/IBb1Lxg1deBDMKZ7wHY2fhMg0WnaA/XPrK2IwP8m/VMt17BgEMj cMsMRWHdbN0fl3g6xkzbYWa+Qx2xA2gGyoYzKmQtpFWy5EUeQFoeVmATSSAoX2Whdpol SeRoXXdchLCPpOzK2b9IqHTTpuPPywApx+ry5umhUOcylylUX/NOt+ly0JxJDpnsjB14 3lPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:organization:references:in-reply-to:subject:cc:to:from :date; bh=ztir4aQkSDrYwt4Pk2wuM556cSEvh8tKQfTNkGVMzl4=; b=xW55RGGJVCZ5K4pdfhafwKFSY8j+QvdmfLtR1GmXQJ8sb+V8JuVqDr/z+/8GhPgebk jYBMRVMCaLroEdUYjCmtEHhIgubybq3UAl8Qa8UfrpWl3ciiTqMZcxzpXUKWNqmAiQjg HJzBZ4/7VTxAhEiJcjT5DRcHMC4JEE77Vgh8KWNWCm3Mbd7Y8JQNu+65Bdmj3OYabwHW TGgo0+op4izm9ftQQled5Gi9UrULM9jHQvCghfmNMDni1cnUA5vkHjZbBGO9nwSNiWZJ yl9UWfbRoni9g6IJKB4TKK6MA56TWxKXwRWoPEIs19E0Yn3LtPUF+LBOJNcX4D2pdPh+ FaSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f26si1125251otc.182.2020.04.07.04.12.23; Tue, 07 Apr 2020 04:12:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728218AbgDGLKt (ORCPT + 99 others); Tue, 7 Apr 2020 07:10:49 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:27064 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726399AbgDGLKt (ORCPT ); Tue, 7 Apr 2020 07:10:49 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 037B4Zeo060498 for ; Tue, 7 Apr 2020 07:10:48 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 308eu86ab1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 07 Apr 2020 07:10:47 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Apr 2020 12:10:28 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 7 Apr 2020 12:10:24 +0100 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 037BAek565339494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Apr 2020 11:10:41 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4FC4A405F; Tue, 7 Apr 2020 11:10:40 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 34948A4054; Tue, 7 Apr 2020 11:10:40 +0000 (GMT) Received: from p-imbrenda (unknown [9.145.8.150]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 7 Apr 2020 11:10:40 +0000 (GMT) Date: Tue, 7 Apr 2020 13:10:17 +0200 From: Claudio Imbrenda To: David Hildenbrand Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Vasily Gorbik , Heiko Carstens , Cornelia Huck , Janosch Frank , Christian Borntraeger Subject: Re: [PATCH v2 5/5] KVM: s390: vsie: gmap_table_walk() simplifications In-Reply-To: <20200403153050.20569-6-david@redhat.com> References: <20200403153050.20569-1-david@redhat.com> <20200403153050.20569-6-david@redhat.com> Organization: IBM X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20040711-0008-0000-0000-0000036C1B68 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20040711-0009-0000-0000-00004A8DB4B4 Message-Id: <20200407131017.471d2ca4@p-imbrenda> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-07_03:2020-04-07,2020-04-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004070091 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 3 Apr 2020 17:30:50 +0200 David Hildenbrand wrote: > Let's use asce_type where applicable. Also, simplify our sanity check > for valid table levels and convert it into a WARN_ON_ONCE(). Check if > we even have a valid gmap shadow as the very first step. > > Signed-off-by: David Hildenbrand > --- > arch/s390/mm/gmap.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c > index 24ef30fb0833..a2bd8d7792e9 100644 > --- a/arch/s390/mm/gmap.c > +++ b/arch/s390/mm/gmap.c > @@ -788,19 +788,19 @@ static inline unsigned long > *gmap_table_walk(struct gmap *gmap, unsigned long gaddr, int level) > { > const int asce_type = gmap->asce & _ASCE_TYPE_MASK; > - unsigned long *table; > + unsigned long *table = gmap->table; > > - if ((gmap->asce & _ASCE_TYPE_MASK) + 4 < (level * 4)) > - return NULL; > if (gmap_is_shadow(gmap) && gmap->removed) > return NULL; > > + if (WARN_ON_ONCE(level > (asce_type >> 2) + 1)) > + return NULL; > + > if (WARN_ON_ONCE(asce_type != _ASCE_TYPE_REGION1 && > gaddr & (-1UL << (31 + (asce_type >> 2) * > 11)))) return NULL; > > - table = gmap->table; > - switch (gmap->asce & _ASCE_TYPE_MASK) { > + switch (asce_type) { > case _ASCE_TYPE_REGION1: > table += (gaddr & _REGION1_INDEX) >> _REGION1_SHIFT; > if (level == 4) Reviewed-by: Claudio Imbrenda