From nobody Sun May 5 09:23:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1576172005; cv=none; d=zohomail.com; s=zohoarc; b=OZMHj+rSJ90QoeqX1sSYyY30VCNjo0aQiI/k5/Nj0syVRhPwRaa4oJmBCjEAt2sIU6boXTEQKQDbnfV1To4Hms61MA9daJiwJEcWvUk3efkPMd2uzekkE9TsdedgC1OIjmsuRekKC8bl5Un8IxB1B/6Hgu8jWsFgkqGfcBcTQO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576172005; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Vfp3TQFwT3xsXSZck8DLzhnxRCt+zSJ6NNXv24VulfQ=; b=WltaWXWQw8wJypS2ZNcV0jyb+TpDvUHb7M7aiaehZe+5QLR5SYCMUq9Fz6V3sIXzBkm6pc77JGVAdCqMzYt++SWR3JDUUcfMXIp++zN+IGsC3mvesERTT2s4fKZ6CKeVHh6mHQ1lvzWYqfjavrAaiozlWcSeJXoncoWQXqdsCU4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1576172005111705.2163842493866; Thu, 12 Dec 2019 09:33:25 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSKA-0002SP-8p; Thu, 12 Dec 2019 17:32:26 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSK8-0002SK-S1 for xen-devel@lists.xenproject.org; Thu, 12 Dec 2019 17:32:24 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5b563bf0-1d05-11ea-8dd6-12813bfff9fa; Thu, 12 Dec 2019 17:32:23 +0000 (UTC) X-Inumbo-ID: 5b563bf0-1d05-11ea-8dd6-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576171943; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BONvafvW7Xehu3KlD6QfL+lTUEkUwUanZ7dAlhNMZG4=; b=e/j2Y4qCBEzSMlpja0h6fi0gKdKZjDPaZ5EjClO+l3mDsHYxgdPq12ZO 18UAtTx9QVrhq7XrTAM+wYpDdGxgJz8cev6KSTPvNl6YTNRG9HG22uTxI 3Y8uUAi3UHbvdWRYuo0TPRQgnkdNHR6C9cNNjTmVfoV3GBhgz0z3do6l2 c=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: XFd0hG5L7Ta2/CtgTkT82O25vEaz0c45jBuJz0anPaDKnR/cBGhVnwUTs19KosdsnKoCcSGlmk LZTtxSiGZ3UgijgSwwM1EFOg5dzue7yca73JUlFJBrjme5hR5QRpQAAYUjsWzVTft/E1UTz/Dm 5Sw1vD9T2jfj0SS+OibAgKb9adLxWcGqGTVpRzoOMMVpX0ugd6bwm96B9GBEOuYRb4fR22ez6X bO6awkJOr3q7NUgU7V3sGH0G+SdGVIiUTc3kXEdnw5YbYDPJY+apmOVlMIqgP1BEIwnHRElSPY TeU= X-SBRS: 2.7 X-MesageID: 9961409 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,306,1571716800"; d="scan'208";a="9961409" From: George Dunlap To: Date: Thu, 12 Dec 2019 17:32:00 +0000 Message-ID: <20191212173203.1692762-2-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191212173203.1692762-1-george.dunlap@citrix.com> References: <20191212173203.1692762-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/4] x86/mm: Refactor put_page_from_l*e to reduce code duplication X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) put_page_from_l[234]e have identical functionality for devalidating an N-1 entry which is a pagetable. But mystifyingly, they duplicate the code in slightly different arrangements that make it hard to tell that it's the same. Create a new function, put_pt_page(), which handles the common functionality; and refactor all the functions to be symmetric, differing only in the level of pagetable expected (and in whether they handle superpages). No functional change intended. Signed-off-by: George Dunlap Reviewed-by: Andrew Cooper --- CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/mm.c | 89 +++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 61 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 7d4dd80a85..d8a0eb2aa5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1297,6 +1297,28 @@ static void put_data_page(struct page_info *page, bo= ol writeable) put_page(page); } =20 +static int put_pt_page(struct page_info *pg, struct page_info *ptpg, + unsigned int flags) +{ + int rc =3D 0; + + if ( flags & PTF_defer ) + { + ASSERT(!(flags & PTF_partial_set)); + current->arch.old_guest_ptpg =3D ptpg; + current->arch.old_guest_table =3D pg; + current->arch.old_guest_table_partial =3D false; + } + else + { + rc =3D _put_page_type(pg, flags | PTF_preemptible, ptpg); + if ( likely(!rc) ) + put_page(pg); + } + + return rc; +} + /* * NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. * Note also that this automatically deals correctly with linear p.t.'s. @@ -1304,8 +1326,6 @@ static void put_data_page(struct page_info *page, boo= l writeable) static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn, unsigned int flags) { - int rc =3D 0; - if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || (l2e_get_pfn(l2e) =3D=3D= pfn) ) return 1; =20 @@ -1319,35 +1339,16 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsi= gned long pfn, ((1UL << (L2_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1))); for ( i =3D 0; i < (1u << PAGETABLE_ORDER); i++, page++ ) put_data_page(page, writeable); - } - else - { - struct page_info *pg =3D l2e_get_page(l2e); - struct page_info *ptpg =3D mfn_to_page(_mfn(pfn)); =20 - if ( flags & PTF_defer ) - { - current->arch.old_guest_ptpg =3D ptpg; - current->arch.old_guest_table =3D pg; - current->arch.old_guest_table_partial =3D false; - } - else - { - rc =3D _put_page_type(pg, flags | PTF_preemptible, ptpg); - if ( likely(!rc) ) - put_page(pg); - } + return 0; } =20 - return rc; + return put_pt_page(l2e_get_page(l2e), mfn_to_page(_mfn(pfn)), flags); } =20 static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, unsigned int flags) { - struct page_info *pg; - int rc; - if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || (l3e_get_pfn(l3e) =3D=3D= pfn) ) return 1; =20 @@ -1365,50 +1366,16 @@ static int put_page_from_l3e(l3_pgentry_t l3e, unsi= gned long pfn, return 0; } =20 - pg =3D l3e_get_page(l3e); - - if ( flags & PTF_defer ) - { - ASSERT(!(flags & PTF_partial_set)); - current->arch.old_guest_ptpg =3D mfn_to_page(_mfn(pfn)); - current->arch.old_guest_table =3D pg; - current->arch.old_guest_table_partial =3D false; - return 0; - } - - rc =3D _put_page_type(pg, flags | PTF_preemptible, mfn_to_page(_mfn(pf= n))); - if ( likely(!rc) ) - put_page(pg); - - return rc; + return put_pt_page(l3e_get_page(l3e), mfn_to_page(_mfn(pfn)), flags); } =20 static int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, unsigned int flags) { - int rc =3D 1; - - if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && - (l4e_get_pfn(l4e) !=3D pfn) ) - { - struct page_info *pg =3D l4e_get_page(l4e); - - if ( flags & PTF_defer ) - { - ASSERT(!(flags & PTF_partial_set)); - current->arch.old_guest_ptpg =3D mfn_to_page(_mfn(pfn)); - current->arch.old_guest_table =3D pg; - current->arch.old_guest_table_partial =3D false; - return 0; - } - - rc =3D _put_page_type(pg, flags | PTF_preemptible, - mfn_to_page(_mfn(pfn))); - if ( likely(!rc) ) - put_page(pg); - } + if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) || (l4e_get_pfn(l4e) =3D=3D= pfn) ) + return 1; =20 - return rc; + return put_pt_page(l4e_get_page(l4e), mfn_to_page(_mfn(pfn)), flags); } =20 static int alloc_l1_table(struct page_info *page) --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 09:23:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1576171999; cv=none; d=zohomail.com; s=zohoarc; b=nPN6/GgC4fVxV2/hIQEhuhdJYsmgaeYNuIumUsVS6lB484Sp+Hh0T0GDtZU3N2O7yq6xoKXi52D/jccAqzJhs1bwEfqixtFrVbf6I5XbAXmPrnD2quL/3hFv1DBhsSh1j1wMPutfN1A2QN8euEtZOXr0jvX/gpMQ+Ut1v8GDjCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576171999; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sjiFjnxTKjCHrVde1QHbOYBoEz514eextstS2McjiQ8=; b=G5+AZIOW/FolG3uJ+hklbS2eH9U+rMG0hs2LqvauRr3GYfhgyr2+1smDl1xC7WKEHlMoapSq6L6abEWgPbbMnY9qBUIipNNjEMmjIFTXIa2efTTTXU53VOMNE6UH8eIA8TjYbQhNdlxceU6SY90ETS2INRtsHrUCc4eiwjgdgnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1576171999794567.284907906664; Thu, 12 Dec 2019 09:33:19 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSKF-0002Sj-Hi; Thu, 12 Dec 2019 17:32:31 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSKD-0002SV-QG for xen-devel@lists.xenproject.org; Thu, 12 Dec 2019 17:32:29 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5b563bf2-1d05-11ea-8dd6-12813bfff9fa; Thu, 12 Dec 2019 17:32:24 +0000 (UTC) X-Inumbo-ID: 5b563bf2-1d05-11ea-8dd6-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576171944; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S3XOjE923yJW50Y3WjCDBdwMxrtN/r34Znt75Upw2U4=; b=dmm+YR8xEipY9mV2+m07uOA/i0bcotttdVbDF8cHp6NuWrZgILZX7k49 eSKSzdGU4nfbM/NEaD2uyNb0WYzeQYMgHc+0ENypDIe5RAQhxwy6DpRsI +q3Lby+bZcVisAViZAw+tGo493555ISq0NjImbdU5qylpXZHSYYhFbcn8 Q=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: ZwA3rOBYAS0bps1kTi5Ma6yzTYotUqBOa5Rs7w7Z1gziRt83FHkDWUNkLDsV6l577ySudHktpn CP+Pd9Zmc1nUFdGIbDi+XKe46ELVnfwJgcIIEKEvGb8NWWyfpdN1GUr6uIoOaL/cCzrT3H5U++ FHiebq5s4mbxSaaNE+DibeY0sYGAtGxUMbzMH3RiaPjzX6O1A+4AgH6g16n9Mo8aLGgEf8MmXc +5t7jMGmCG8ydo14MW7cVExYtCXX2CGLrkrMraRBX0iZYCMMfp1gwGPbhAVJf+uQio0Bgn7/vx WTQ= X-SBRS: 2.7 X-MesageID: 9961410 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,306,1571716800"; d="scan'208";a="9961410" From: George Dunlap To: Date: Thu, 12 Dec 2019 17:32:01 +0000 Message-ID: <20191212173203.1692762-3-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191212173203.1692762-1-george.dunlap@citrix.com> References: <20191212173203.1692762-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/4] x86/mm: Implement common put_data_pages for put_page_from_l[23]e X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Both put_page_from_l2e and put_page_from_l3e handle having superpage entries by looping over each page and "put"-ing each one individually. As with putting page table entries, this code is functionally identical, but for some reason different. Moreover, there is already a common function, put_data_page(), to handle automatically swapping between put_page() (for read-only pages) or put_page_and_type() (for read-write pages). Replace this with put_data_pages() (plural), which does the entire loop, as well as the put_page / put_page_and_type switch. Signed-off-by: George Dunlap Reviewed-by: Jan Beulich --- NB that I've used the "simple for loop" version to make it easy to see what's going on, rather than the "do { } while()" version which uses & and compare to zero rather than comparing to the max. CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/mm.c | 52 ++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index d8a0eb2aa5..c05039ab21 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1289,14 +1289,6 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct doma= in *l1e_owner) } =20 #ifdef CONFIG_PV -static void put_data_page(struct page_info *page, bool writeable) -{ - if ( writeable ) - put_page_and_type(page); - else - put_page(page); -} - static int put_pt_page(struct page_info *pg, struct page_info *ptpg, unsigned int flags) { @@ -1319,6 +1311,20 @@ static int put_pt_page(struct page_info *pg, struct = page_info *ptpg, return rc; } =20 +static int put_data_pages(struct page_info *page, bool writeable, int pt_s= hift) +{ + int i, count =3D 1 << (pt_shift - PAGE_SHIFT); + + ASSERT(!(mfn_x(page_to_mfn(page)) & (count - 1))); + for ( i =3D 0; i < count ; i++, page++ ) + if ( writeable ) + put_page_and_type(page); + else + put_page(page); + + return 0; +} + /* * NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. * Note also that this automatically deals correctly with linear p.t.'s. @@ -1330,18 +1336,9 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsig= ned long pfn, return 1; =20 if ( l2e_get_flags(l2e) & _PAGE_PSE ) - { - struct page_info *page =3D l2e_get_page(l2e); - bool writeable =3D l2e_get_flags(l2e) & _PAGE_RW; - unsigned int i; - - ASSERT(!(mfn_x(page_to_mfn(page)) & - ((1UL << (L2_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1))); - for ( i =3D 0; i < (1u << PAGETABLE_ORDER); i++, page++ ) - put_data_page(page, writeable); - - return 0; - } + return put_data_pages(l2e_get_page(l2e), + l2e_get_flags(l2e) & _PAGE_RW, + L2_PAGETABLE_SHIFT); =20 return put_pt_page(l2e_get_page(l2e), mfn_to_page(_mfn(pfn)), flags); } @@ -1353,18 +1350,9 @@ static int put_page_from_l3e(l3_pgentry_t l3e, unsig= ned long pfn, return 1; =20 if ( unlikely(l3e_get_flags(l3e) & _PAGE_PSE) ) - { - unsigned long mfn =3D l3e_get_pfn(l3e); - bool writeable =3D l3e_get_flags(l3e) & _PAGE_RW; - - ASSERT(!(flags & PTF_partial_set)); - ASSERT(!(mfn & ((1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1))); - do { - put_data_page(mfn_to_page(_mfn(mfn)), writeable); - } while ( ++mfn & ((1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1)= ); - - return 0; - } + return put_data_pages(l3e_get_page(l3e), + l3e_get_flags(l3e) & _PAGE_RW, + L3_PAGETABLE_SHIFT); =20 return put_pt_page(l3e_get_page(l3e), mfn_to_page(_mfn(pfn)), flags); } --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 09:23:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1576171998; cv=none; d=zohomail.com; s=zohoarc; b=mfzRPaTzCZouVGpp+H/2rZdFZA4N1ZFnu//i/jEPdBq8qL5st0641TlgI4gtuIRsO0bdI3FSeeOcLVhQ18lve4/LUXI++ytHdm4fTnSd3VVvMfkqIaRGL+ldDa+FrNlt4F8rWmuu93LrC6QCwV3OEhcUm98YgeyR1Brb1ZAcMLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576171998; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pmZENARzzsS3Mb5Hu+AEqpZsAYAuXeanhOAmjr8XGuw=; b=lRjlaLU4JYXJV9HKiI4zLiXAEO5fkJzZEDWapqHKBHETIb2UevHHWBBZ6xIG3ZCi8geN3PdG/VpcVS4FShTfb3Th/PDAjcrOaJ+S4C36NM3LIjddZ3UjxhlhQesaK2xvhzHCCl2dSgl2G9wnJO6krt4qvnixyuEw0ncYzB4q+9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1576171998872823.354434872665; Thu, 12 Dec 2019 09:33:18 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSKK-0002TG-2i; Thu, 12 Dec 2019 17:32:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSKI-0002T5-Qa for xen-devel@lists.xenproject.org; Thu, 12 Dec 2019 17:32:34 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5c3aaad8-1d05-11ea-8dd6-12813bfff9fa; Thu, 12 Dec 2019 17:32:25 +0000 (UTC) X-Inumbo-ID: 5c3aaad8-1d05-11ea-8dd6-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576171945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SHF9F4pwZNaZVojZjNUspgBmPNiZebNFFLw8ukzciHI=; b=L/YH4Gt3rpAhiFH4ayWPEDRjjPVSfvj4XVydHJ8Cud7r2WSLDZAoiZC5 mXGfTZ7OhIHnyR0nmGPAHXrBmNnq3hMFjaZeg5icFXYVVYLPzuWFHQxvx yIiDWOIfFeBOai3FG2VSj0C2aR+Mw4Ztacr5KGJtN6ppLVx7AulO9ImOZ s=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: ounWkTLONB89HA2q4ebpPBBfynm72kdVBtbfZuorvNmDgyJSteVbfqfefdgLiCG9z16L3u6f7F l4GNGI86oYYRM46npiT7ZwLD2RWcAdEzS2u6HIICL+VGkNKtLqNzjVe9noQKJnstA/NY5SHMVx cxB6/w8V/OfTKkwnKsegZcOo4BRCY0YOWqhHd8PTGyWm8G4FsEcIxu5Rgngo6UgMG++bU0n2vI vcCdqCtd/bGgr7sGOV6wmtGaNVukfcIxhT2nVe7h5rGtHeLDVQyv41XUdlRrpnwXVgP9AC6mPP xAA= X-SBRS: 2.7 X-MesageID: 9961411 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,306,1571716800"; d="scan'208";a="9961411" From: George Dunlap To: Date: Thu, 12 Dec 2019 17:32:02 +0000 Message-ID: <20191212173203.1692762-4-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191212173203.1692762-1-george.dunlap@citrix.com> References: <20191212173203.1692762-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/4] x86/mm: Use a more descriptive name for pagetable mfns X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In many places, a PTE being modified is accompanied by the pagetable mfn which contains the PTE (primarily in order to be able to maintain linear mapping counts). In many cases, this mfn is stored in the non-descript variable (or argement) "pfn". Replace these names with lNmfn, to indicate that 1) this is a pagetable mfn, and 2) that it is the same level as the PTE in question. This should be enough to remind readers that it's the mfn containing the PTE. No functional change. Signed-off-by: George Dunlap Acked-by: Andrew Cooper --- CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/mm.c | 50 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index c05039ab21..54b4100d55 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1141,7 +1141,7 @@ static int get_page_and_type_from_mfn( define_get_linear_pagetable(l2); static int get_page_from_l2e( - l2_pgentry_t l2e, unsigned long pfn, struct domain *d, unsigned int fl= ags) + l2_pgentry_t l2e, unsigned long l2mfn, struct domain *d, unsigned int = flags) { unsigned long mfn =3D l2e_get_pfn(l2e); int rc; @@ -1156,7 +1156,7 @@ get_page_from_l2e( ASSERT(!(flags & PTF_preemptible)); =20 rc =3D get_page_and_type_from_mfn(_mfn(mfn), PGT_l1_page_table, d, fla= gs); - if ( unlikely(rc =3D=3D -EINVAL) && get_l2_linear_pagetable(l2e, pfn, = d) ) + if ( unlikely(rc =3D=3D -EINVAL) && get_l2_linear_pagetable(l2e, l2mfn= , d) ) rc =3D 0; =20 return rc; @@ -1165,7 +1165,7 @@ get_page_from_l2e( define_get_linear_pagetable(l3); static int get_page_from_l3e( - l3_pgentry_t l3e, unsigned long pfn, struct domain *d, unsigned int fl= ags) + l3_pgentry_t l3e, unsigned long l3mfn, struct domain *d, unsigned int = flags) { int rc; =20 @@ -1180,7 +1180,7 @@ get_page_from_l3e( l3e_get_mfn(l3e), PGT_l2_page_table, d, flags | PTF_preemptible); if ( unlikely(rc =3D=3D -EINVAL) && !is_pv_32bit_domain(d) && - get_l3_linear_pagetable(l3e, pfn, d) ) + get_l3_linear_pagetable(l3e, l3mfn, d) ) rc =3D 0; =20 return rc; @@ -1189,7 +1189,7 @@ get_page_from_l3e( define_get_linear_pagetable(l4); static int get_page_from_l4e( - l4_pgentry_t l4e, unsigned long pfn, struct domain *d, unsigned int fl= ags) + l4_pgentry_t l4e, unsigned long l4mfn, struct domain *d, unsigned int = flags) { int rc; =20 @@ -1202,7 +1202,7 @@ get_page_from_l4e( =20 rc =3D get_page_and_type_from_mfn( l4e_get_mfn(l4e), PGT_l3_page_table, d, flags | PTF_preemptible); - if ( unlikely(rc =3D=3D -EINVAL) && get_l4_linear_pagetable(l4e, pfn, = d) ) + if ( unlikely(rc =3D=3D -EINVAL) && get_l4_linear_pagetable(l4e, l4mfn= , d) ) rc =3D 0; =20 return rc; @@ -1460,13 +1460,13 @@ static int create_pae_xen_mappings(struct domain *d= , l3_pgentry_t *pl3e) static int alloc_l2_table(struct page_info *page, unsigned long type) { struct domain *d =3D page_get_owner(page); - unsigned long pfn =3D mfn_x(page_to_mfn(page)); + unsigned long l2mfn =3D mfn_x(page_to_mfn(page)); l2_pgentry_t *pl2e; unsigned int i; int rc =3D 0; unsigned int partial_flags =3D page->partial_flags; =20 - pl2e =3D map_domain_page(_mfn(pfn)); + pl2e =3D map_domain_page(_mfn(l2mfn)); =20 /* * NB that alloc_l2_table will never set partial_pte on an l2; but @@ -1492,7 +1492,7 @@ static int alloc_l2_table(struct page_info *page, uns= igned long type) rc =3D -EINTR; } else - rc =3D get_page_from_l2e(l2e, pfn, d, partial_flags); + rc =3D get_page_from_l2e(l2e, l2mfn, d, partial_flags); =20 /* * It shouldn't be possible for get_page_from_l2e to return @@ -1559,14 +1559,14 @@ static int alloc_l2_table(struct page_info *page, u= nsigned long type) static int alloc_l3_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); - unsigned long pfn =3D mfn_x(page_to_mfn(page)); + unsigned long l3mfn =3D mfn_x(page_to_mfn(page)); l3_pgentry_t *pl3e; unsigned int i; int rc =3D 0; unsigned int partial_flags =3D page->partial_flags; l3_pgentry_t l3e =3D l3e_empty(); =20 - pl3e =3D map_domain_page(_mfn(pfn)); + pl3e =3D map_domain_page(_mfn(l3mfn)); =20 /* * PAE guests allocate full pages, but aren't required to initialize @@ -1603,7 +1603,7 @@ static int alloc_l3_table(struct page_info *page) rc =3D -EINTR; } else - rc =3D get_page_from_l3e(l3e, pfn, d, + rc =3D get_page_from_l3e(l3e, l3mfn, d, partial_flags | PTF_retain_ref_on_resta= rt); =20 if ( rc =3D=3D -ERESTART ) @@ -1786,8 +1786,8 @@ void zap_ro_mpt(mfn_t mfn) static int alloc_l4_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); - unsigned long pfn =3D mfn_x(page_to_mfn(page)); - l4_pgentry_t *pl4e =3D map_domain_page(_mfn(pfn)); + unsigned long l4mfn =3D mfn_x(page_to_mfn(page)); + l4_pgentry_t *pl4e =3D map_domain_page(_mfn(l4mfn)); unsigned int i; int rc =3D 0; unsigned int partial_flags =3D page->partial_flags; @@ -1809,7 +1809,7 @@ static int alloc_l4_table(struct page_info *page) rc =3D -EINTR; } else - rc =3D get_page_from_l4e(l4e, pfn, d, + rc =3D get_page_from_l4e(l4e, l4mfn, d, partial_flags | PTF_retain_ref_on_resta= rt); =20 if ( rc =3D=3D -ERESTART ) @@ -1869,7 +1869,7 @@ static int alloc_l4_table(struct page_info *page) =20 if ( !rc ) { - init_xen_l4_slots(pl4e, _mfn(pfn), + init_xen_l4_slots(pl4e, _mfn(l4mfn), d, INVALID_MFN, VM_ASSIST(d, m2p_strict)); atomic_inc(&d->arch.pv.nr_l4_pages); } @@ -1896,18 +1896,18 @@ static void free_l1_table(struct page_info *page) static int free_l2_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); - unsigned long pfn =3D mfn_x(page_to_mfn(page)); + unsigned long l2mfn =3D mfn_x(page_to_mfn(page)); l2_pgentry_t *pl2e; int rc =3D 0; unsigned int partial_flags =3D page->partial_flags, i =3D page->nr_validated_ptes - !(partial_flags & PTF_partial_set); =20 - pl2e =3D map_domain_page(_mfn(pfn)); + pl2e =3D map_domain_page(_mfn(l2mfn)); =20 for ( ; ; ) { if ( is_guest_l2_slot(d, page->u.inuse.type_info, i) ) - rc =3D put_page_from_l2e(pl2e[i], pfn, partial_flags); + rc =3D put_page_from_l2e(pl2e[i], l2mfn, partial_flags); if ( rc < 0 ) break; =20 @@ -1948,17 +1948,17 @@ static int free_l2_table(struct page_info *page) static int free_l3_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); - unsigned long pfn =3D mfn_x(page_to_mfn(page)); + unsigned long l3mfn =3D mfn_x(page_to_mfn(page)); l3_pgentry_t *pl3e; int rc =3D 0; unsigned int partial_flags =3D page->partial_flags, i =3D page->nr_validated_ptes - !(partial_flags & PTF_partial_set); =20 - pl3e =3D map_domain_page(_mfn(pfn)); + pl3e =3D map_domain_page(_mfn(l3mfn)); =20 for ( ; ; ) { - rc =3D put_page_from_l3e(pl3e[i], pfn, partial_flags); + rc =3D put_page_from_l3e(pl3e[i], l3mfn, partial_flags); if ( rc < 0 ) break; =20 @@ -1995,15 +1995,15 @@ static int free_l3_table(struct page_info *page) static int free_l4_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); - unsigned long pfn =3D mfn_x(page_to_mfn(page)); - l4_pgentry_t *pl4e =3D map_domain_page(_mfn(pfn)); + unsigned long l4mfn =3D mfn_x(page_to_mfn(page)); + l4_pgentry_t *pl4e =3D map_domain_page(_mfn(l4mfn)); int rc =3D 0; unsigned partial_flags =3D page->partial_flags, i =3D page->nr_validated_ptes - !(partial_flags & PTF_partial_set); =20 do { if ( is_guest_l4_slot(d, i) ) - rc =3D put_page_from_l4e(pl4e[i], pfn, partial_flags); + rc =3D put_page_from_l4e(pl4e[i], l4mfn, partial_flags); if ( rc < 0 ) break; partial_flags =3D 0; --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun May 5 09:23:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1576172002; cv=none; d=zohomail.com; s=zohoarc; b=aj1QymKlut+2Z7YqgpHy8bIoWJEVdKBjl7wCb0PON6VJMCjCcF3bIbo7OwmDm7N5o+VlYOzVyoa/HiyN45gfTCUvp0f+25qGYaygAkErEPflKK2ddOK3NQwnF0QK2yf6Rmx2I7c8PjNv/yzDtk5MdN+Y1W6wEwcCidvQx06/8RU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576172002; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bfSilE1C8UN3/b9LC4dRsCBFRN/pENaPB5zvHOm2AdQ=; b=IQaYvhpGh6xhqXua4//3bwjlKYTue9XFgtdT7lIV6/p86ig2uK8tkPGRsmA8czFq6wup417ye1EqnPGIOdqKZmJrLic7SaaZLg7CLrSCaoIuoR+uNjFMSofJ+LMPkKTJQV7yUl9gwJhfmCUXnb5YTr9oux/5Wj2u1i/4JTLgOz0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1576172002765531.9328401091249; Thu, 12 Dec 2019 09:33:22 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSKO-0002Uc-FK; Thu, 12 Dec 2019 17:32:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSKN-0002UM-QO for xen-devel@lists.xenproject.org; Thu, 12 Dec 2019 17:32:39 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5ca19054-1d05-11ea-8dd6-12813bfff9fa; Thu, 12 Dec 2019 17:32:25 +0000 (UTC) X-Inumbo-ID: 5ca19054-1d05-11ea-8dd6-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576171945; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IQYS1FSlgjfx6KcHUVViiO4BU3+QbaVPK9Qqw7JrFwk=; b=BRgj3C5bFDaetE960jVwj5ofbt3ZUcQCCLqZ7ygCFQim2hQqbiqtcPfM t2W1v5Wnost51rLcc0Tar50KwgCKEChfRrl7JinZU9Y+PpYeRwuRypZUm dR5bie9YN700oGsh9IGXEFppc7Be+XVdqpMnS9uZsYum6uOTWNxTwoqXg Y=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: zjoSRAsUEXzPrUa5H26R0bs19J11sqnHwS1pHy9EEmtmnAmCNMADuOcXmzdy8iguMMgxCs907B ktdCRULpQ2URObRGShgb1OZJQXpbTa2A6dtzXGrQpCGqn4fW2dStNL19z6MS9DPWQDxSe/WWqk M4te1S/EwWQSdsPcLStXf3Ak+Ffl0JUKA6o/EjTErxeur2LUqmZVCSQD1iSdVshfYSmcablJpQ pKa1MlB1dsvt0zt2LB50hBImQ7NTdNdNiqtCmh4bqLwDzhO5iNWdefsxPS4NhR6pyupKwMm0dF XN4= X-SBRS: 2.7 X-MesageID: 9961412 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,306,1571716800"; d="scan'208";a="9961412" From: George Dunlap To: Date: Thu, 12 Dec 2019 17:32:03 +0000 Message-ID: <20191212173203.1692762-5-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191212173203.1692762-1-george.dunlap@citrix.com> References: <20191212173203.1692762-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/4] x86/mm: More discriptive names for page de/validation functions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The functions alloc_page_type(), alloc_lN_table(), free_page_type() and free_lN_table() are confusingly named: nothing is being allocated or freed. Rather, the page being passed in is being either validated or devalidated for use as the specific type. Rename these functions to "validate" and "devalidate" respectively to be more clear. No functional change. Signed-off-by: George Dunlap --- CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/domain.c | 2 +- xen/arch/x86/mm.c | 62 ++++++++++++++++++++-------------------- xen/include/asm-x86/mm.h | 4 +-- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index f5c0c378ef..ee20de6493 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2032,7 +2032,7 @@ static int relinquish_memory( if ( likely(y =3D=3D x) ) { /* No need for atomic update of type_info here: noone else= updates it. */ - switch ( ret =3D free_page_type(page, x, 1) ) + switch ( ret =3D devalidate_page_type(page, x, 1) ) { case 0: break; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 54b4100d55..dc1463123c 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -1366,7 +1366,7 @@ static int put_page_from_l4e(l4_pgentry_t l4e, unsign= ed long pfn, return put_pt_page(l4e_get_page(l4e), mfn_to_page(_mfn(pfn)), flags); } =20 -static int alloc_l1_table(struct page_info *page) +static int validate_l1_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); l1_pgentry_t *pl1e; @@ -1408,7 +1408,7 @@ static int alloc_l1_table(struct page_info *page) =20 fail: gdprintk(XENLOG_WARNING, - "Failure %d in alloc_l1_table: slot %#x\n", ret, i); + "Failure %d in validate_l1_table: slot %#x\n", ret, i); out: while ( i-- > 0 ) put_page_from_l1e(pl1e[i], d); @@ -1441,7 +1441,7 @@ static int create_pae_xen_mappings(struct domain *d, = l3_pgentry_t *pl3e) * 1. Cannot appear in slots !=3D 3 because get_page_type() checks the * PGT_pae_xen_l2 flag, which is asserted iff the L2 appears in sl= ot 3 * 2. Cannot appear in another page table's L3: - * a. alloc_l3_table() calls this function and this check will fail + * a. validate_l3_table() calls this function and this check will = fail * b. mod_l3_entry() disallows updates to slot 3 in an existing ta= ble */ page =3D l3e_get_page(l3e3); @@ -1457,7 +1457,7 @@ static int create_pae_xen_mappings(struct domain *d, = l3_pgentry_t *pl3e) return 1; } =20 -static int alloc_l2_table(struct page_info *page, unsigned long type) +static int validate_l2_table(struct page_info *page, unsigned long type) { struct domain *d =3D page_get_owner(page); unsigned long l2mfn =3D mfn_x(page_to_mfn(page)); @@ -1469,8 +1469,8 @@ static int alloc_l2_table(struct page_info *page, uns= igned long type) pl2e =3D map_domain_page(_mfn(l2mfn)); =20 /* - * NB that alloc_l2_table will never set partial_pte on an l2; but - * free_l2_table might if a linear_pagetable entry is interrupted + * NB that validate_l2_table will never set partial_pte on an l2; but + * devalidate_l2_table might if a linear_pagetable entry is interrupted * partway through de-validation. In that circumstance, * get_page_from_l2e() will always return -EINVAL; and we must * retain the type ref by doing the normal partial_flags tracking. @@ -1497,7 +1497,7 @@ static int alloc_l2_table(struct page_info *page, uns= igned long type) /* * It shouldn't be possible for get_page_from_l2e to return * -ERESTART, since we never call this with PTF_preemptible. - * (alloc_l1_table may return -EINTR on an L1TF-vulnerable + * (validate_l1_table may return -EINTR on an L1TF-vulnerable * entry.) * * NB that while on a "clean" promotion, we can never get @@ -1518,12 +1518,12 @@ static int alloc_l2_table(struct page_info *page, u= nsigned long type) else if ( rc < 0 && rc !=3D -EINTR ) { gdprintk(XENLOG_WARNING, - "Failure %d in alloc_l2_table: slot %#x\n", rc, i); + "Failure %d in validate_l2_table: slot %#x\n", rc, i); ASSERT(current->arch.old_guest_table =3D=3D NULL); if ( i ) { /* - * alloc_l1_table() doesn't set old_guest_table; it does + * validate_l1_table() doesn't set old_guest_table; it does * its own tear-down immediately on failure. If it * did we'd need to check it and set partial_flags as we * do in alloc_l[34]_table(). @@ -1556,7 +1556,7 @@ static int alloc_l2_table(struct page_info *page, uns= igned long type) return rc; } =20 -static int alloc_l3_table(struct page_info *page) +static int validate_l3_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); unsigned long l3mfn =3D mfn_x(page_to_mfn(page)); @@ -1629,7 +1629,7 @@ static int alloc_l3_table(struct page_info *page) if ( rc < 0 && rc !=3D -ERESTART && rc !=3D -EINTR ) { gdprintk(XENLOG_WARNING, - "Failure %d in alloc_l3_table: slot %#x\n", rc, i); + "Failure %d in validate_l3_table: slot %#x\n", rc, i); if ( i ) { page->nr_validated_ptes =3D i; @@ -1680,7 +1680,7 @@ void init_xen_pae_l2_slots(l2_pgentry_t *l2t, const s= truct domain *d) * Fill an L4 with Xen entries. * * This function must write all ROOT_PAGETABLE_PV_XEN_SLOTS, to clobber any - * values a guest may have left there from alloc_l4_table(). + * values a guest may have left there from validate_l4_table(). * * l4t and l4mfn are mandatory, but l4mfn doesn't need to be the mfn under * *l4t. All other parameters are optional and will either fill or zero t= he @@ -1783,7 +1783,7 @@ void zap_ro_mpt(mfn_t mfn) } =20 #ifdef CONFIG_PV -static int alloc_l4_table(struct page_info *page) +static int validate_l4_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); unsigned long l4mfn =3D mfn_x(page_to_mfn(page)); @@ -1822,7 +1822,7 @@ static int alloc_l4_table(struct page_info *page) { if ( rc !=3D -EINTR ) gdprintk(XENLOG_WARNING, - "Failure %d in alloc_l4_table: slot %#x\n", rc, i= ); + "Failure %d in validate_l4_table: slot %#x\n", rc= , i); if ( i ) { page->nr_validated_ptes =3D i; @@ -1878,7 +1878,7 @@ static int alloc_l4_table(struct page_info *page) return rc; } =20 -static void free_l1_table(struct page_info *page) +static void devalidate_l1_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); l1_pgentry_t *pl1e; @@ -1893,7 +1893,7 @@ static void free_l1_table(struct page_info *page) } =20 =20 -static int free_l2_table(struct page_info *page) +static int devalidate_l2_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); unsigned long l2mfn =3D mfn_x(page_to_mfn(page)); @@ -1945,7 +1945,7 @@ static int free_l2_table(struct page_info *page) return rc; } =20 -static int free_l3_table(struct page_info *page) +static int devalidate_l3_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); unsigned long l3mfn =3D mfn_x(page_to_mfn(page)); @@ -1992,7 +1992,7 @@ static int free_l3_table(struct page_info *page) return rc > 0 ? 0 : rc; } =20 -static int free_l4_table(struct page_info *page) +static int devalidate_l4_table(struct page_info *page) { struct domain *d =3D page_get_owner(page); unsigned long l4mfn =3D mfn_x(page_to_mfn(page)); @@ -2592,7 +2592,7 @@ static void get_page_light(struct page_info *page) while ( unlikely(y !=3D x) ); } =20 -static int alloc_page_type(struct page_info *page, unsigned long type, +static int validate_page_type(struct page_info *page, unsigned long type, int preemptible) { #ifdef CONFIG_PV @@ -2606,25 +2606,25 @@ static int alloc_page_type(struct page_info *page, = unsigned long type, switch ( type & PGT_type_mask ) { case PGT_l1_page_table: - rc =3D alloc_l1_table(page); + rc =3D validate_l1_table(page); break; case PGT_l2_page_table: ASSERT(preemptible); - rc =3D alloc_l2_table(page, type); + rc =3D validate_l2_table(page, type); break; case PGT_l3_page_table: ASSERT(preemptible); - rc =3D alloc_l3_table(page); + rc =3D validate_l3_table(page); break; case PGT_l4_page_table: ASSERT(preemptible); - rc =3D alloc_l4_table(page); + rc =3D validate_l4_table(page); break; case PGT_seg_desc_page: rc =3D alloc_segdesc_page(page); break; default: - printk("Bad type in alloc_page_type %lx t=3D%" PRtype_info " c=3D%= lx\n", + printk("Bad type in validate_page_type %lx t=3D%" PRtype_info " c= =3D%lx\n", type, page->u.inuse.type_info, page->count_info); rc =3D -EINVAL; @@ -2672,7 +2672,7 @@ static int alloc_page_type(struct page_info *page, un= signed long type, } =20 =20 -int free_page_type(struct page_info *page, unsigned long type, +int devalidate_page_type(struct page_info *page, unsigned long type, int preemptible) { #ifdef CONFIG_PV @@ -2700,20 +2700,20 @@ int free_page_type(struct page_info *page, unsigned= long type, switch ( type & PGT_type_mask ) { case PGT_l1_page_table: - free_l1_table(page); + devalidate_l1_table(page); rc =3D 0; break; case PGT_l2_page_table: ASSERT(preemptible); - rc =3D free_l2_table(page); + rc =3D devalidate_l2_table(page); break; case PGT_l3_page_table: ASSERT(preemptible); - rc =3D free_l3_table(page); + rc =3D devalidate_l3_table(page); break; case PGT_l4_page_table: ASSERT(preemptible); - rc =3D free_l4_table(page); + rc =3D devalidate_l4_table(page); break; default: gdprintk(XENLOG_WARNING, "type %" PRtype_info " mfn %" PRI_mfn "\n= ", @@ -2733,7 +2733,7 @@ int free_page_type(struct page_info *page, unsigned l= ong type, static int _put_final_page_type(struct page_info *page, unsigned long type, bool preemptible, struct page_info *ptpg) { - int rc =3D free_page_type(page, type, preemptible); + int rc =3D devalidate_page_type(page, type, preemptible); =20 if ( ptpg && PGT_type_equal(type, ptpg->u.inuse.type_info) && (type & PGT_validated) && rc !=3D -EINTR ) @@ -3016,7 +3016,7 @@ static int _get_page_type(struct page_info *page, uns= igned long type, page->partial_flags =3D 0; } page->linear_pt_count =3D 0; - rc =3D alloc_page_type(page, type, preemptible); + rc =3D validate_page_type(page, type, preemptible); } =20 out: diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index 320c6cd196..a837f69548 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -355,8 +355,8 @@ static inline void *__page_to_virt(const struct page_in= fo *pg) (PAGE_SIZE / (sizeof(*pg) & -sizeof(*pg)))); } =20 -int free_page_type(struct page_info *page, unsigned long type, - int preemptible); +int devalidate_page_type(struct page_info *page, unsigned long type, + int preemptible); =20 void init_xen_pae_l2_slots(l2_pgentry_t *l2t, const struct domain *d); void init_xen_l4_slots(l4_pgentry_t *l4t, mfn_t l4mfn, --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel