From patchwork Wed Sep 19 08:48:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janosch Frank X-Patchwork-Id: 10605517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71C6E6CB for ; Wed, 19 Sep 2018 08:49:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EFCB2B59F for ; Wed, 19 Sep 2018 08:49:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 538362B5AA; Wed, 19 Sep 2018 08:49:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA01B2B59F for ; Wed, 19 Sep 2018 08:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731084AbeISO0Q (ORCPT ); Wed, 19 Sep 2018 10:26:16 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56624 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731074AbeISO0P (ORCPT ); Wed, 19 Sep 2018 10:26:15 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8J8ikLb019288 for ; Wed, 19 Sep 2018 04:49:21 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2mkgkmxfs6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 19 Sep 2018 04:49:21 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Sep 2018 09:49:19 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 19 Sep 2018 09:49:17 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8J8nH4t56754256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 19 Sep 2018 08:49:17 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 76D8BAE04D; Wed, 19 Sep 2018 11:48:24 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE150AE051; Wed, 19 Sep 2018 11:48:23 +0100 (BST) Received: from s38lp20.boeblingen.de.ibm.com (unknown [9.145.184.145]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 19 Sep 2018 11:48:23 +0100 (BST) From: Janosch Frank To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, borntraeger@de.ibm.com, schwidefsky@de.ibm.com Subject: [RFC 13/14] s390/mm: Pull pmd invalid check in gmap_pmd_op_walk Date: Wed, 19 Sep 2018 10:48:01 +0200 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180919084802.183381-1-frankja@linux.ibm.com> References: <20180919084802.183381-1-frankja@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18091908-0016-0000-0000-000002076C36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091908-0017-0000-0000-0000325E5957 Message-Id: <20180919084802.183381-14-frankja@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-19_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=804 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809190091 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Not yet sure if I'll keep this. The walk should only walk and not check I, but then it looks way nicer. Signed-off-by: Janosch Frank --- arch/s390/mm/gmap.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index 0220a32aa2b9..8d5ce51637eb 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c @@ -952,7 +952,8 @@ static inline pmd_t *gmap_pmd_op_walk(struct gmap *gmap, unsigned long gaddr, } pmdp = (pmd_t *) gmap_table_walk(gmap, gaddr, 1); - if (!pmdp || pmd_none(*pmdp)) { + if (!pmdp || pmd_none(*pmdp) || + pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID) { if (*ptl) spin_unlock(*ptl); pmdp = NULL; @@ -1161,7 +1162,7 @@ static int gmap_protect_range(struct gmap *gmap, unsigned long gaddr, return vmaddr; vmaddr |= gaddr & ~PMD_MASK; pmdp = gmap_pmd_op_walk(gmap, gaddr, vmaddr, &ptl_pmd); - if (pmdp && !(pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID)) { + if (pmdp) { if (!pmd_large(*pmdp)) { ptep = gmap_pte_from_pmd(gmap, pmdp, gaddr, &ptl_pte); @@ -1266,7 +1267,7 @@ int gmap_read_table(struct gmap *gmap, unsigned long gaddr, unsigned long *val) if (IS_ERR_VALUE(vmaddr)) return vmaddr; pmdp = gmap_pmd_op_walk(gmap, gaddr, vmaddr, &ptl_pmd); - if (pmdp && !(pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID)) { + if (pmdp) { if (!pmd_large(*pmdp)) { ptep = gmap_pte_from_pmd(gmap, pmdp, vmaddr, &ptl_pte); if (ptep) { @@ -1380,7 +1381,7 @@ static int gmap_protect_rmap(struct gmap *sg, unsigned long raddr, return vmaddr; vmaddr |= paddr & ~PMD_MASK; pmdp = gmap_pmd_op_walk(parent, paddr, vmaddr, &ptl_pmd); - if (pmdp && !(pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID)) { + if (pmdp) { if (!pmd_large(*pmdp)) { ptl_pte = NULL; ptep = gmap_pte_from_pmd(parent, pmdp, paddr, @@ -2362,8 +2363,7 @@ int gmap_shadow_segment(struct gmap *sg, unsigned long saddr, pmd_t pmd) break; } spmd = *spmdp; - if (!(pmd_val(spmd) & _SEGMENT_ENTRY_INVALID) && - !((pmd_val(spmd) & _SEGMENT_ENTRY_PROTECT) && + if (!((pmd_val(spmd) & _SEGMENT_ENTRY_PROTECT) && !(pmd_val(pmd) & _SEGMENT_ENTRY_PROTECT))) { pmd_val(*spmdp) |= _SEGMENT_ENTRY_GMAP_VSIE; @@ -2436,7 +2436,7 @@ int gmap_shadow_page(struct gmap *sg, unsigned long saddr, pte_t pte) break; rc = -EAGAIN; spmdp = gmap_pmd_op_walk(parent, paddr, vmaddr, &ptl_pmd); - if (spmdp && !(pmd_val(*spmdp) & _SEGMENT_ENTRY_INVALID)) { + if (spmdp) { /* Get page table pointer */ tptep = (pte_t *) gmap_table_walk(sg, saddr, 0); if (!tptep) { @@ -2869,9 +2869,6 @@ EXPORT_SYMBOL_GPL(gmap_pmdp_idte_global); bool gmap_test_and_clear_dirty_pmd(struct gmap *gmap, pmd_t *pmdp, unsigned long gaddr, unsigned long vmaddr) { - if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID) - return false; - /* Already protected memory, which did not change is clean */ if (pmd_val(*pmdp) & _SEGMENT_ENTRY_PROTECT && !(pmd_val(*pmdp) & _SEGMENT_ENTRY_GMAP_UC))