From patchwork Wed Apr 7 12:42:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 12187955 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 B6E4FC43616 for ; Wed, 7 Apr 2021 12:42:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B92A61359 for ; Wed, 7 Apr 2021 12:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347296AbhDGMm3 (ORCPT ); Wed, 7 Apr 2021 08:42:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47156 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235440AbhDGMm1 (ORCPT ); Wed, 7 Apr 2021 08:42:27 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 137CYYJ4056634; Wed, 7 Apr 2021 08:42:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Gd41gENkxHAaZ8oztdNdXzHrnicaigC19RAcl2IQgjM=; b=AsbEU4N5ky+uZHuqUlx79oAxCEsMnW30gNoyEGuQlzkFYTCemIvALqkRM51pAcPSWWYa 6O422VGKbX4Ri0hHltrfeSwHftFyDA/u7pxrIcGeiqY8RyNSiQDUBLKwzBGvrg6mJugf X8ZjM6tkPmX9OtcvFqHvakbrViNyOln8I8csDSRHxWqJxh5AOoLcIujmHzJL7NEeN+NU hGqCBdBYUeBWMQHieqooPF3BVlvc7H4G+sURupUmpQGPzbJLSIHC/bGBPHzJeUczujAn QoH3xCOfGoxp9OQiBCddNKBpDK8IgfU87U0RbHEiOBJ1UjNj+9sRrsnZTMh0VnDJQoeK og== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 37rvy77x7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Apr 2021 08:42:17 -0400 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 137CYbkv057350; Wed, 7 Apr 2021 08:42:16 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 37rvy77x7d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Apr 2021 08:42:16 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 137CXEMB009135; Wed, 7 Apr 2021 12:42:15 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 37rvbw8q74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 07 Apr 2021 12:42:15 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 137CgCv739977426 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 Apr 2021 12:42:12 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F4FF5204F; Wed, 7 Apr 2021 12:42:12 +0000 (GMT) Received: from ibm-vm.ibmuc.com (unknown [9.145.2.56]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id CF4A35204E; Wed, 7 Apr 2021 12:42:11 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, david@redhat.com, thuth@redhat.com, frankja@linux.ibm.com, cohuck@redhat.com, pmorel@linux.ibm.com Subject: [kvm-unit-tests PATCH v3 4/7] s390x: lib: Add idte and other huge pages functions/macros Date: Wed, 7 Apr 2021 14:42:06 +0200 Message-Id: <20210407124209.828540-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210407124209.828540-1-imbrenda@linux.ibm.com> References: <20210407124209.828540-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jIIaJ4OOKXMO7T-lw92ZHfFsdP29Rfvt X-Proofpoint-ORIG-GUID: gtXaGqnLtfghSCfsj4N9CeIfI8Fd9ubI X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-04-07_08:2021-04-07,2021-04-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 phishscore=0 spamscore=0 priorityscore=1501 mlxscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104070087 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Improve pgtable.h: * add macros to check whether a pmd or a pud are large / huge * add idte functions for pmd, pud, p4d and pgd Signed-off-by: Claudio Imbrenda Acked-by: Janosch Frank --- lib/s390x/asm/pgtable.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/s390x/asm/pgtable.h b/lib/s390x/asm/pgtable.h index 1a21f175..f166dcc6 100644 --- a/lib/s390x/asm/pgtable.h +++ b/lib/s390x/asm/pgtable.h @@ -100,6 +100,9 @@ #define pmd_none(entry) (pmd_val(entry) & SEGMENT_ENTRY_I) #define pte_none(entry) (pte_val(entry) & PAGE_ENTRY_I) +#define pud_huge(entry) (pud_val(entry) & REGION3_ENTRY_FC) +#define pmd_large(entry) (pmd_val(entry) & SEGMENT_ENTRY_FC) + #define pgd_addr(entry) __va(pgd_val(entry) & REGION_ENTRY_ORIGIN) #define p4d_addr(entry) __va(p4d_val(entry) & REGION_ENTRY_ORIGIN) #define pud_addr(entry) __va(pud_val(entry) & REGION_ENTRY_ORIGIN) @@ -216,6 +219,34 @@ static inline void ipte(unsigned long vaddr, pteval_t *p_pte) : : "a" (table_origin), "a" (vaddr) : "memory"); } +static inline void idte(unsigned long table_origin, unsigned long vaddr) +{ + vaddr &= SEGMENT_ENTRY_SFAA; + asm volatile( + " idte %0,0,%1\n" + : : "a" (table_origin), "a" (vaddr) : "memory"); +} + +static inline void idte_pmdp(unsigned long vaddr, pmdval_t *pmdp) +{ + idte((unsigned long)(pmdp - pmd_index(vaddr)) | ASCE_DT_SEGMENT, vaddr); +} + +static inline void idte_pudp(unsigned long vaddr, pudval_t *pudp) +{ + idte((unsigned long)(pudp - pud_index(vaddr)) | ASCE_DT_REGION3, vaddr); +} + +static inline void idte_p4dp(unsigned long vaddr, p4dval_t *p4dp) +{ + idte((unsigned long)(p4dp - p4d_index(vaddr)) | ASCE_DT_REGION2, vaddr); +} + +static inline void idte_pgdp(unsigned long vaddr, pgdval_t *pgdp) +{ + idte((unsigned long)(pgdp - pgd_index(vaddr)) | ASCE_DT_REGION1, vaddr); +} + void configure_dat(int enable); #endif /* _ASMS390X_PGTABLE_H_ */