Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp986639pxp; Wed, 16 Mar 2022 23:33:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY9m8KmTO8i5f8V5zOG/w8iC1NP2MA8o4n2bj2t2qNA3IinynB3cLsXJw+goUQv5N36yD2 X-Received: by 2002:a63:2a95:0:b0:37c:46b0:2088 with SMTP id q143-20020a632a95000000b0037c46b02088mr2591988pgq.150.1647498813109; Wed, 16 Mar 2022 23:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647498813; cv=none; d=google.com; s=arc-20160816; b=lk05W9KZw9e1QjHrccfUgTvvgfW+p3D4brIcfzPxtABfJdig/xPSFSbV4NebHJ2wxj 5AZmCDp//aQ3wjZh0Rpg++PYYI0AakLCBPxLFnPSL/nc965sGCclxp1HAGX6mX+VQ53/ CUi9suXt9atRxFJFraJTXGLR+UHwUw40+8U+Vp+IHxK45skdBFvC8Keg94/JfyKbKlPD /HVBkisqChtO12rCn4msCl/wR5JcWjgtQG1RBBXBeopoQrc/y3J0jz7gFcYZQBM0gh1f MNi8QQEk5sj7pl1DKyEkuLdSfUFERMVD5lj6A2uLWd8ykJuYCsoskSIERMw6y1M5MyyW nfAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=pqEtRRluTdcqyicuZ3uViocrXZh7WOAHX11wx61Vhzs=; b=RqLLLs18tzS5XfVyEs9uf4oDXMNnlc2dbVGD68kquL2qGKIKJ/oHIxyAEWTF8bIJXr qxLt9M7hrAKS4Pv540iFyWvnZ6s3XlwMp48ZyNRRRKj28KwftmNgCFcFhfr/tpk497mK i6848ish4uon5vffUuiM2SXEN8/J8cnw+JpT1JetFuT9I0GE90bbHBnJjC5AZhI/pJ/K z3L47Hl0U1B2CKUPxhyewrXNhz8DRkW4hybSX8VWi6rfDaF1tNSTZ3M8098gCxzxUN1l uqF45wU8+HUXI+W+utU/MC4T3bNb9pcMV9KiBW8yAn6NkhYwbdi9DJBOHplMdPwXXzJ4 Up2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="qyq/3FcT"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 8-20020a17090a0c0800b001c64d4aebf8si1478562pjs.97.2022.03.16.23.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 23:33:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="qyq/3FcT"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 189562A9113; Wed, 16 Mar 2022 22:19:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355195AbiCPK7Y (ORCPT + 99 others); Wed, 16 Mar 2022 06:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347406AbiCPK7W (ORCPT ); Wed, 16 Mar 2022 06:59:22 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6BEDE81; Wed, 16 Mar 2022 03:58:09 -0700 (PDT) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22GAkNhe029949; Wed, 16 Mar 2022 10:57:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=pqEtRRluTdcqyicuZ3uViocrXZh7WOAHX11wx61Vhzs=; b=qyq/3FcT7lW08wy86AfF5YcyJ4M2Xfa8xUImtiANcjURw+I5Kli3Vy30gDfzTvslBbnY xRG9tc6FV2PFw9acgFVZqCXmWejAgM0pN33TYrJhxDf7H5hJS6v9+qkMJB9dlUCJg1na CaxdnWteUBEUWmCFeObXJQV/KgLRbH+NQ5Ysu2w3tEadW75kJt+7AbFi98npqwi2VqIg Di68f/hoJ62wecZiNlKTatqsuW90kjmz2OhBCrBS5b3e6bq/CAOP4mOYVvALDIWUFmTJ RQtgwdTPl+Cng7e3BzSmbUg20zE/eBhNNUYJwATKzu+/S4YYEnYcthpc9azC75ErC3FB ZA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eueef8656-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Mar 2022 10:57:04 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22GAqaOw021546; Wed, 16 Mar 2022 10:57:04 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eueef864b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Mar 2022 10:57:03 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 22GAqwHQ004747; Wed, 16 Mar 2022 10:57:01 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3et95wv4d8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Mar 2022 10:57:01 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22GAuwnT23789856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Mar 2022 10:56:58 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 071CDA404D; Wed, 16 Mar 2022 10:56:58 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C6D9A4053; Wed, 16 Mar 2022 10:56:56 +0000 (GMT) Received: from thinkpad (unknown [9.171.18.20]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Wed, 16 Mar 2022 10:56:56 +0000 (GMT) Date: Wed, 16 Mar 2022 11:56:54 +0100 From: Gerald Schaefer To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , linux-mm@kvack.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, Christian Borntraeger Subject: Re: [PATCH v1 5/7] s390/pgtable: support __HAVE_ARCH_PTE_SWP_EXCLUSIVE Message-ID: <20220316115654.12823b78@thinkpad> In-Reply-To: <55b6b582-51ca-b869-2055-674fe4c563e6@redhat.com> References: <20220315141837.137118-1-david@redhat.com> <20220315141837.137118-6-david@redhat.com> <20220315172102.771bd2cf@thinkpad> <8b13b6c0-78d4-48e3-06f0-ec0680d013a9@redhat.com> <55b6b582-51ca-b869-2055-674fe4c563e6@redhat.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; 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-Proofpoint-GUID: LNrEZRUbiCjvuMs3vypCO_bwoZe7D75W X-Proofpoint-ORIG-GUID: L41oykoEMXECEBvnbt61pfruSn_s2QSZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-16_03,2022-03-15_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 spamscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203160064 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Mar 2022 18:12:16 +0100 David Hildenbrand wrote: > On 15.03.22 17:58, David Hildenbrand wrote: > > > >>> This would mean that it is not OK to have bit 52 not zero for swap PTEs. > >>> But if I read the POP correctly, all bits except for the DAT-protection > >>> would be ignored for invalid PTEs, so maybe this comment needs some update > >>> (for both bits 52 and also 55). > >>> > >>> Heiko might also have some more insight. > >> > >> Indeed, I wonder why we should get a specification exception when the > >> PTE is invalid. I'll dig a bit into the PoP. > > > > SA22-7832-12 6-46 ("Translation-Specification Exception") is clearer > > > > "The page-table entry used for the translation is > > valid, and bit position 52 does not contain zero." > > > > "The page-table entry used for the translation is > > valid, EDAT-1 does not apply, the instruction-exe- > > cution-protection facility is not installed, and bit > > position 55 does not contain zero. It is model > > dependent whether this condition is recognized." > > > > I wonder if the following matches reality: > > diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h > index 008a6c856fa4..6a227a8c3712 100644 > --- a/arch/s390/include/asm/pgtable.h > +++ b/arch/s390/include/asm/pgtable.h > @@ -1669,18 +1669,16 @@ static inline int has_transparent_hugepage(void) > /* > * 64 bit swap entry format: > * A page-table entry has some bits we have to treat in a special way. > - * Bits 52 and bit 55 have to be zero, otherwise a specification > - * exception will occur instead of a page translation exception. The > - * specification exception has the bad habit not to store necessary > - * information in the lowcore. > * Bits 54 and 63 are used to indicate the page type. > * A swap pte is indicated by bit pattern (pte & 0x201) == 0x200 > - * This leaves the bits 0-51 and bits 56-62 to store type and offset. > - * We use the 5 bits from 57-61 for the type and the 52 bits from 0-51 > - * for the offset. > - * | offset |01100|type |00| > + * | offset |XX1XX|type |S0| > * |0000000000111111111122222222223333333333444444444455|55555|55566|66| > * |0123456789012345678901234567890123456789012345678901|23456|78901|23| > + * > + * Bits 0-51 store the offset. > + * Bits 57-62 store the type. > + * Bit 62 (S) is used for softdirty tracking. > + * Bits 52, 53, 55 and 56 (X) are unused. > */ > > #define __SWP_OFFSET_MASK ((1UL << 52) - 1) > > > I'm not sure why bit 53 was indicated as "1" and bit 55 was indicated as > "0". At least for 52 and 55 there was a clear description. Bit 53 is the invalid bit, and that is always 1 for swap ptes, in addition to protection bit 54. Bit 55, along with bit 52, has to be zero according to the (potentially deprecated) comment. It is interesting that bit 56 seems to be unused, at least according to the comment, but that would also mention bit 62 as unused, so that clearly needs some update. If bit 56 could be used for _PAGE_SWP_EXCLUSIVE, that would be better than stealing a bit from the offset, or using potentially dangerous bit 52. It is defined as _PAGE_UNUSED and only used for kvm, not sure if this is also relevant for swap ptes, similar to bit 62. Adding Christian on cc, maybe he has some insight on _PAGE_UNUSED bit 56 and swap ptes.