From nobody Tue Feb 10 17:30:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1584893756; cv=none; d=zohomail.com; s=zohoarc; b=Tciunir72bmH1EjwqiPw1GHIG5xo1iEYTNPRowyMZcP4htNMdKlYujuuS6Mi23bqbLZrXpLYZ/I9GWT1Gpo4ZIk8IJ7E0AmyW8QclCVsPd6DkTGKjIg6/EbfdmcZqzhT7CIStKajD2kjexVhXj0jJj+jjflNAGEc0A/08AgHSdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584893756; 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=OdUaqFvDAbwa2jRqHfOxaLbnVLDVZ4VRqHGeE+cqa/A=; b=E67dappIX2MKSU+bQbiPrV86PCjFAOSWSryJWMQgUhwMYGOhoNUgGvDeSGFBABuWxML7Oq5Qutep55bpuafdX2iJTVSriFT5WucvZo00k0jaGhdpp45SW7ANSxet4GgP06+zKWQ66ryVlBBfM4MwAcwyocPq309KZsqzagsxnow= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1584893756882267.27485008026724; Sun, 22 Mar 2020 09:15:56 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jG3FJ-0004ba-6H; Sun, 22 Mar 2020 16:14:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jG3FI-0004b4-EL for xen-devel@lists.xenproject.org; Sun, 22 Mar 2020 16:14:40 +0000 Received: from mail-ed1-f66.google.com (unknown [209.85.208.66]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 36de31cc-6c58-11ea-92cf-bc764e2007e4; Sun, 22 Mar 2020 16:14:32 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id b21so13476193edy.9 for ; Sun, 22 Mar 2020 09:14:32 -0700 (PDT) Received: from ufe34d9ed68d054.ant.amazon.com (54-240-197-235.amazon.com. [54.240.197.235]) by smtp.gmail.com with ESMTPSA id v13sm106693edj.62.2020.03.22.09.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2020 09:14:30 -0700 (PDT) X-Inumbo-ID: 36de31cc-6c58-11ea-92cf-bc764e2007e4 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q0DjDcTGZuLAgG9ZdNmzRZsu9N7ZM1zKIaO4GQDqQOw=; b=HspJf153GXap7dOlACvUhnceLxDiisfXHVeB6BUMTRFM2aOnvEfp46zKISbtfITmEH 27GofipwIvqNDBKqhcd7ra/+kCwaPNtSc4FqSyBJ6uq7Nft1fo8bJPu3qbbaCvI6Yqn0 M0LT5fhMrg/Y/NILn+kDuDgsZadVg6DoqJwNSReSPp5iRtNtAQMkMtGrO9ZNRevEiddw FcWoBGaKLbFgRSbXEY40tdd9oGVZtXLhH/KdtKBFjBxS03q3mX6VUCkrvL6mTM3tP8JX iOX8K0SQ6EFWoT/BfeA1/0vr82ELVTW2oABwewvxxuDedi9AzRKtfNz17FEnMYWEWS8q uuVQ== X-Gm-Message-State: ANhLgQ1lr1jPznOxsFRR/qgZF9i0Gg2rTNoI+G4tZ1NBoamQa515LwLr oyjGfQZ7c7sXKmWt1PIzKv2hzSzl4eB8Cg== X-Google-Smtp-Source: ADFU+vvgTgEpJ8ob/YW7qtJesBCrWJv3xoArKcCEXeWNlhIZ+k+dpM4FZTqO0NuHdQDUFNqaMCt7Xg== X-Received: by 2002:a17:906:4e81:: with SMTP id v1mr5182103eju.259.1584893671540; Sun, 22 Mar 2020 09:14:31 -0700 (PDT) From: julien@xen.org To: xen-devel@lists.xenproject.org Date: Sun, 22 Mar 2020 16:14:08 +0000 Message-Id: <20200322161418.31606-8-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200322161418.31606-1-julien@xen.org> References: <20200322161418.31606-1-julien@xen.org> Subject: [Xen-devel] [PATCH 07/17] xen/x86: traps: Convert __page_fault_type() to use typesafe MFN 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: julien@xen.org, Wei Liu , Andrew Cooper , Julien Grall , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall Note that the code is now using cr3_to_mfn() to get the MFN. This is slightly different as the top 12-bits will now be masked. No functional changes intended. Signed-off-by: Julien Grall --- xen/arch/x86/traps.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 04a3ebc0a2..4f524dc71e 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1232,7 +1232,8 @@ enum pf_type { static enum pf_type __page_fault_type(unsigned long addr, const struct cpu_user_regs *regs) { - unsigned long mfn, cr3 =3D read_cr3(); + mfn_t mfn; + unsigned long cr3 =3D read_cr3(); l4_pgentry_t l4e, *l4t; l3_pgentry_t l3e, *l3t; l2_pgentry_t l2e, *l2t; @@ -1264,20 +1265,20 @@ static enum pf_type __page_fault_type(unsigned long= addr, =20 page_user =3D _PAGE_USER; =20 - mfn =3D cr3 >> PAGE_SHIFT; + mfn =3D cr3_to_mfn(cr3); =20 - l4t =3D map_domain_page(_mfn(mfn)); + l4t =3D map_domain_page(mfn); l4e =3D l4e_read_atomic(&l4t[l4_table_offset(addr)]); - mfn =3D l4e_get_pfn(l4e); + mfn =3D l4e_get_mfn(l4e); unmap_domain_page(l4t); if ( ((l4e_get_flags(l4e) & required_flags) !=3D required_flags) || (l4e_get_flags(l4e) & disallowed_flags) ) return real_fault; page_user &=3D l4e_get_flags(l4e); =20 - l3t =3D map_domain_page(_mfn(mfn)); + l3t =3D map_domain_page(mfn); l3e =3D l3e_read_atomic(&l3t[l3_table_offset(addr)]); - mfn =3D l3e_get_pfn(l3e); + mfn =3D l3e_get_mfn(l3e); unmap_domain_page(l3t); if ( ((l3e_get_flags(l3e) & required_flags) !=3D required_flags) || (l3e_get_flags(l3e) & disallowed_flags) ) @@ -1286,9 +1287,9 @@ static enum pf_type __page_fault_type(unsigned long a= ddr, if ( l3e_get_flags(l3e) & _PAGE_PSE ) goto leaf; =20 - l2t =3D map_domain_page(_mfn(mfn)); + l2t =3D map_domain_page(mfn); l2e =3D l2e_read_atomic(&l2t[l2_table_offset(addr)]); - mfn =3D l2e_get_pfn(l2e); + mfn =3D l2e_get_mfn(l2e); unmap_domain_page(l2t); if ( ((l2e_get_flags(l2e) & required_flags) !=3D required_flags) || (l2e_get_flags(l2e) & disallowed_flags) ) @@ -1297,9 +1298,9 @@ static enum pf_type __page_fault_type(unsigned long a= ddr, if ( l2e_get_flags(l2e) & _PAGE_PSE ) goto leaf; =20 - l1t =3D map_domain_page(_mfn(mfn)); + l1t =3D map_domain_page(mfn); l1e =3D l1e_read_atomic(&l1t[l1_table_offset(addr)]); - mfn =3D l1e_get_pfn(l1e); + mfn =3D l1e_get_mfn(l1e); unmap_domain_page(l1t); if ( ((l1e_get_flags(l1e) & required_flags) !=3D required_flags) || (l1e_get_flags(l1e) & disallowed_flags) ) --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel