From nobody Tue Feb 10 15:45:50 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=Ebo3BGGMFoM+cIWuBL0va5PfssJOxZM8lR9Ypy2ZVgrZ4HppQxo9z5J4nTmh8VjjTK/eZfy9esQZirKA7bz7lpysBQf3U3maqSYe2saicCKs6/Ry86Bg2paTJaOR+ewET+s3kDj1O6y0KWfbNRdKxrGUoVcw4DvYwVfrDvjQ2P0= 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=jin88EomQ4twcxLv+vkvTqRQXrDjbmKtqPRpnuya6f8=; b=LDyzenHS7p/KY7e53RA/6t1aCk+tdWFmPAZjFXpvmTRlNG7oB0+3VJG8KgOTRqzPeQysuguRkVnahJe+vF1AHMECoWqdSFrRNj0wcjRv6HA41YzeJx9SUBQtnqRBcVRb8bKO2Gzwru9EI0jWo0pQavSRsRLFK9wYg0qmhKpaO7g= 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 158489375645282.02772736322481; 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 1jG3FF-0004Yi-DB; Sun, 22 Mar 2020 16:14:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jG3FD-0004Y0-ER for xen-devel@lists.xenproject.org; Sun, 22 Mar 2020 16:14:35 +0000 Received: from mail-ed1-f67.google.com (unknown [209.85.208.67]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 33f9bad0-6c58-11ea-bec1-bc764e2007e4; Sun, 22 Mar 2020 16:14:27 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id u59so13455282edc.12 for ; Sun, 22 Mar 2020 09:14:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2020 09:14:26 -0700 (PDT) X-Inumbo-ID: 33f9bad0-6c58-11ea-bec1-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=4DuAipu9BSo2SCY2T0JAchJqXJO/XZINnXRDSNDPO8s=; b=ukXJipr9caP1gYnzvXN+q0d5mnSPoHNp+MpFlMe0CDCjQJ2isNeJxXE+LZS77lVevU qg4ny4wIoX/BDMXJfONKR7SkCwwlJIJPsDbnKxshZSdh9S4dTgaFKD//3hWc89thpWv7 xEVWp5nDOmCihtatXRqJehAa0yvESJgVxI1E+BtZKqFNvCgZl96fJ+CiTJmGYWHrEgJo YvhXakzpFvuJfxz+CAX+e1XyhKTasDs/k+KiVOCsLNDFA3yUIjQIBzG8xqnNgtGheBrk UtIb/7TjTNf5yu4yitUMPvcw+b9lM5L9dBl8g3+iDkI8NFxPksyqx1VnonqLrhCYPx3i AOuQ== X-Gm-Message-State: ANhLgQ0cjj98acXErq0etg2BbYFK8gri+RtNd/gKauFSSfCz49BQj3Mt c8788vbf28MzA9E6PsnSw+hdPNE8JLtR3w== X-Google-Smtp-Source: ADFU+vvxMcIR+VB0vYNJ38BmDBhUKdxLqJy9IzwgKNq1EtLeTTHt2Qy9NSX0FJZR6PjSoUXEnMJ5+A== X-Received: by 2002:a50:a9a6:: with SMTP id n35mr9058218edc.57.1584893666593; Sun, 22 Mar 2020 09:14:26 -0700 (PDT) From: julien@xen.org To: xen-devel@lists.xenproject.org Date: Sun, 22 Mar 2020 16:14:04 +0000 Message-Id: <20200322161418.31606-4-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 03/17] xen/mm: Move the MM types in a separate header 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: Stefano Stabellini , julien@xen.org, Wei Liu , Andrew Cooper , Julien Grall , Ian Jackson , George Dunlap , Jan Beulich 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 It is getting incredibly difficult to use typesafe GFN/MFN/PFN in the headers because of circular dependency. For instance, asm-x86/page.h cannot include xen/mm.h. In order to convert more code to use typesafe, the types are now moved in a separate header that requires only a few dependencies. Signed-off-by: Julien Grall --- xen/include/xen/mm.h | 134 +------------------------------- xen/include/xen/mm_types.h | 155 +++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 133 deletions(-) create mode 100644 xen/include/xen/mm_types.h diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index d0d095d9c7..4337303f99 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -1,50 +1,7 @@ /*************************************************************************= ***** * include/xen/mm.h * - * Definitions for memory pages, frame numbers, addresses, allocations, et= c. - * * Copyright (c) 2002-2006, K A Fraser - * - * +---------------------+ - * Xen Memory Management - * +---------------------+ - * - * Xen has to handle many different address spaces. It is important not to - * get these spaces mixed up. The following is a consistent terminology w= hich - * should be adhered to. - * - * mfn: Machine Frame Number - * The values Xen puts into its own pagetables. This is the host physic= al - * memory address space with RAM, MMIO etc. - * - * gfn: Guest Frame Number - * The values a guest puts in its own pagetables. For an auto-translated - * guest (hardware assisted with 2nd stage translation, or shadowed), gf= n !=3D - * mfn. For a non-translated guest which is aware of Xen, gfn =3D=3D mf= n. - * - * pfn: Pseudophysical Frame Number - * A linear idea of a guest physical address space. For an auto-translat= ed - * guest, pfn =3D=3D gfn while for a non-translated guest, pfn !=3D gfn. - * - * dfn: Device DMA Frame Number (definitions in include/xen/iommu.h) - * The linear frame numbers of device DMA address space. All initiators = for - * (i.e. all devices assigned to) a guest share a single DMA address spa= ce - * and, by default, Xen will ensure dfn =3D=3D pfn. - * - * WARNING: Some of these terms have changed over time while others have b= een - * used inconsistently, meaning that a lot of existing code does not match= the - * definitions above. New code should use these terms as described here, = and - * over time older code should be corrected to be consistent. - * - * An incomplete list of larger work area: - * - Phase out the use of 'pfn' from the x86 pagetable code. Callers shou= ld - * know explicitly whether they are talking about mfns or gfns. - * - Phase out the use of 'pfn' from the ARM mm code. A cursory glance - * suggests that 'mfn' and 'pfn' are currently used interchangeably, whe= re - * 'mfn' is the appropriate term to use. - * - Phase out the use of gpfn/gmfn where pfn/mfn are meant. This excludes - * the x86 shadow code, which uses gmfn/smfn pairs with different, - * documented, meanings. */ =20 #ifndef __XEN_MM_H__ @@ -54,100 +11,11 @@ #include #include #include -#include #include +#include #include #include =20 -TYPE_SAFE(unsigned long, mfn); -#define PRI_mfn "05lx" -#define INVALID_MFN _mfn(~0UL) -/* - * To be used for global variable initialization. This workaround a bug - * in GCC < 5.0. - */ -#define INVALID_MFN_INITIALIZER { ~0UL } - -#ifndef mfn_t -#define mfn_t /* Grep fodder: mfn_t, _mfn() and mfn_x() are defined above = */ -#define _mfn -#define mfn_x -#undef mfn_t -#undef _mfn -#undef mfn_x -#endif - -static inline mfn_t mfn_add(mfn_t mfn, unsigned long i) -{ - return _mfn(mfn_x(mfn) + i); -} - -static inline mfn_t mfn_max(mfn_t x, mfn_t y) -{ - return _mfn(max(mfn_x(x), mfn_x(y))); -} - -static inline mfn_t mfn_min(mfn_t x, mfn_t y) -{ - return _mfn(min(mfn_x(x), mfn_x(y))); -} - -static inline bool_t mfn_eq(mfn_t x, mfn_t y) -{ - return mfn_x(x) =3D=3D mfn_x(y); -} - -TYPE_SAFE(unsigned long, gfn); -#define PRI_gfn "05lx" -#define INVALID_GFN _gfn(~0UL) -/* - * To be used for global variable initialization. This workaround a bug - * in GCC < 5.0 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64856 - */ -#define INVALID_GFN_INITIALIZER { ~0UL } - -#ifndef gfn_t -#define gfn_t /* Grep fodder: gfn_t, _gfn() and gfn_x() are defined above = */ -#define _gfn -#define gfn_x -#undef gfn_t -#undef _gfn -#undef gfn_x -#endif - -static inline gfn_t gfn_add(gfn_t gfn, unsigned long i) -{ - return _gfn(gfn_x(gfn) + i); -} - -static inline gfn_t gfn_max(gfn_t x, gfn_t y) -{ - return _gfn(max(gfn_x(x), gfn_x(y))); -} - -static inline gfn_t gfn_min(gfn_t x, gfn_t y) -{ - return _gfn(min(gfn_x(x), gfn_x(y))); -} - -static inline bool_t gfn_eq(gfn_t x, gfn_t y) -{ - return gfn_x(x) =3D=3D gfn_x(y); -} - -TYPE_SAFE(unsigned long, pfn); -#define PRI_pfn "05lx" -#define INVALID_PFN (~0UL) - -#ifndef pfn_t -#define pfn_t /* Grep fodder: pfn_t, _pfn() and pfn_x() are defined above = */ -#define _pfn -#define pfn_x -#undef pfn_t -#undef _pfn -#undef pfn_x -#endif - struct page_info; =20 void put_page(struct page_info *); diff --git a/xen/include/xen/mm_types.h b/xen/include/xen/mm_types.h new file mode 100644 index 0000000000..f14359f571 --- /dev/null +++ b/xen/include/xen/mm_types.h @@ -0,0 +1,155 @@ +/*************************************************************************= ***** + * include/xen/mm_types.h + * + * Definitions for memory pages, frame numbers, addresses, allocations, et= c. + * + * Copyright (c) 2002-2006, K A Fraser + * + * +---------------------+ + * Xen Memory Management + * +---------------------+ + * + * Xen has to handle many different address spaces. It is important not to + * get these spaces mixed up. The following is a consistent terminology w= hich + * should be adhered to. + * + * mfn: Machine Frame Number + * The values Xen puts into its own pagetables. This is the host physic= al + * memory address space with RAM, MMIO etc. + * + * gfn: Guest Frame Number + * The values a guest puts in its own pagetables. For an auto-translated + * guest (hardware assisted with 2nd stage translation, or shadowed), gf= n !=3D + * mfn. For a non-translated guest which is aware of Xen, gfn =3D=3D mf= n. + * + * pfn: Pseudophysical Frame Number + * A linear idea of a guest physical address space. For an auto-translat= ed + * guest, pfn =3D=3D gfn while for a non-translated guest, pfn !=3D gfn. + * + * dfn: Device DMA Frame Number (definitions in include/xen/iommu.h) + * The linear frame numbers of device DMA address space. All initiators = for + * (i.e. all devices assigned to) a guest share a single DMA address spa= ce + * and, by default, Xen will ensure dfn =3D=3D pfn. + * + * WARNING: Some of these terms have changed over time while others have b= een + * used inconsistently, meaning that a lot of existing code does not match= the + * definitions above. New code should use these terms as described here, = and + * over time older code should be corrected to be consistent. + * + * An incomplete list of larger work area: + * - Phase out the use of 'pfn' from the x86 pagetable code. Callers shou= ld + * know explicitly whether they are talking about mfns or gfns. + * - Phase out the use of 'pfn' from the ARM mm code. A cursory glance + * suggests that 'mfn' and 'pfn' are currently used interchangeably, whe= re + * 'mfn' is the appropriate term to use. + * - Phase out the use of gpfn/gmfn where pfn/mfn are meant. This excludes + * the x86 shadow code, which uses gmfn/smfn pairs with different, + * documented, meanings. + */ + +#ifndef __XEN_MM_TYPES_H__ +#define __XEN_MM_TYPES_H__ + +#include +#include + +TYPE_SAFE(unsigned long, mfn); +#define PRI_mfn "05lx" +#define INVALID_MFN _mfn(~0UL) +/* + * To be used for global variable initialization. This workaround a bug + * in GCC < 5.0. + */ +#define INVALID_MFN_INITIALIZER { ~0UL } + +#ifndef mfn_t +#define mfn_t /* Grep fodder: mfn_t, _mfn() and mfn_x() are defined above = */ +#define _mfn +#define mfn_x +#undef mfn_t +#undef _mfn +#undef mfn_x +#endif + +static inline mfn_t mfn_add(mfn_t mfn, unsigned long i) +{ + return _mfn(mfn_x(mfn) + i); +} + +static inline mfn_t mfn_max(mfn_t x, mfn_t y) +{ + return _mfn(max(mfn_x(x), mfn_x(y))); +} + +static inline mfn_t mfn_min(mfn_t x, mfn_t y) +{ + return _mfn(min(mfn_x(x), mfn_x(y))); +} + +static inline bool_t mfn_eq(mfn_t x, mfn_t y) +{ + return mfn_x(x) =3D=3D mfn_x(y); +} + +TYPE_SAFE(unsigned long, gfn); +#define PRI_gfn "05lx" +#define INVALID_GFN _gfn(~0UL) +/* + * To be used for global variable initialization. This workaround a bug + * in GCC < 5.0 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64856 + */ +#define INVALID_GFN_INITIALIZER { ~0UL } + +#ifndef gfn_t +#define gfn_t /* Grep fodder: gfn_t, _gfn() and gfn_x() are defined above = */ +#define _gfn +#define gfn_x +#undef gfn_t +#undef _gfn +#undef gfn_x +#endif + +static inline gfn_t gfn_add(gfn_t gfn, unsigned long i) +{ + return _gfn(gfn_x(gfn) + i); +} + +static inline gfn_t gfn_max(gfn_t x, gfn_t y) +{ + return _gfn(max(gfn_x(x), gfn_x(y))); +} + +static inline gfn_t gfn_min(gfn_t x, gfn_t y) +{ + return _gfn(min(gfn_x(x), gfn_x(y))); +} + +static inline bool_t gfn_eq(gfn_t x, gfn_t y) +{ + return gfn_x(x) =3D=3D gfn_x(y); +} + +TYPE_SAFE(unsigned long, pfn); +#define PRI_pfn "05lx" +#define INVALID_PFN (~0UL) + +#ifndef pfn_t +#define pfn_t /* Grep fodder: pfn_t, _pfn() and pfn_x() are defined above = */ +#define _pfn +#define pfn_x +#undef pfn_t +#undef _pfn +#undef pfn_x +#endif + +#endif /* __XEN_MM_TYPES_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel