From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Julien Grall <julien.grall@linaro.org>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH v3 for-next 3/4] xen/tmem: Convert the file common/tmem_xen.c to use typesafe MFN
Date: Wed, 1 Nov 2017 14:54:29 -0400 [thread overview]
Message-ID: <20171101185429.GC20519@char.us.oracle.com> (raw)
In-Reply-To: <20171101140316.31333-4-julien.grall@linaro.org>
On Wed, Nov 01, 2017 at 02:03:15PM +0000, Julien Grall wrote:
> The file common/tmem_xen.c is now converted to use typesafe. This is
> requiring to override the macro page_to_mfn to make it work with mfn_t.
>
> Note that all variables converted to mfn_t havem there initial value,
> when set, switch from 0 to INVALID_MFN. This is fine because the initial
> values was always overriden before used.
>
> Also add a couple of missing newlines suggested by Andrew in the code.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> ---
>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
But could you confirm that you did compile this on x86 and with CONFIG_TMEM=y in the .config?
Thanks!
>
> Changes in v2:
> - Add missing newlines
> - Add Andrew's reviewed-by
> ---
> xen/common/tmem_xen.c | 30 ++++++++++++++++++------------
> 1 file changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/xen/common/tmem_xen.c b/xen/common/tmem_xen.c
> index 20f74b268f..bd52e44faf 100644
> --- a/xen/common/tmem_xen.c
> +++ b/xen/common/tmem_xen.c
> @@ -14,6 +14,10 @@
> #include <xen/cpu.h>
> #include <xen/init.h>
>
> +/* Override macros from asm/page.h to make them work with mfn_t */
> +#undef page_to_mfn
> +#define page_to_mfn(pg) _mfn(__page_to_mfn(pg))
> +
> bool __read_mostly opt_tmem;
> boolean_param("tmem", opt_tmem);
>
> @@ -31,7 +35,7 @@ static DEFINE_PER_CPU_READ_MOSTLY(unsigned char *, dstmem);
> static DEFINE_PER_CPU_READ_MOSTLY(void *, scratch_page);
>
> #if defined(CONFIG_ARM)
> -static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn,
> +static inline void *cli_get_page(xen_pfn_t cmfn, mfn_t *pcli_mfn,
> struct page_info **pcli_pfp, bool cli_write)
> {
> ASSERT_UNREACHABLE();
> @@ -39,14 +43,14 @@ static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn,
> }
>
> static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp,
> - unsigned long cli_mfn, bool mark_dirty)
> + mfn_t cli_mfn, bool mark_dirty)
> {
> ASSERT_UNREACHABLE();
> }
> #else
> #include <asm/p2m.h>
>
> -static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn,
> +static inline void *cli_get_page(xen_pfn_t cmfn, mfn_t *pcli_mfn,
> struct page_info **pcli_pfp, bool cli_write)
> {
> p2m_type_t t;
> @@ -68,16 +72,17 @@ static inline void *cli_get_page(xen_pfn_t cmfn, unsigned long *pcli_mfn,
>
> *pcli_mfn = page_to_mfn(page);
> *pcli_pfp = page;
> - return map_domain_page(_mfn(*pcli_mfn));
> +
> + return map_domain_page(*pcli_mfn);
> }
>
> static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp,
> - unsigned long cli_mfn, bool mark_dirty)
> + mfn_t cli_mfn, bool mark_dirty)
> {
> if ( mark_dirty )
> {
> put_page_and_type(cli_pfp);
> - paging_mark_dirty(current->domain, _mfn(cli_mfn));
> + paging_mark_dirty(current->domain, cli_mfn);
> }
> else
> put_page(cli_pfp);
> @@ -88,14 +93,14 @@ static inline void cli_put_page(void *cli_va, struct page_info *cli_pfp,
> int tmem_copy_from_client(struct page_info *pfp,
> xen_pfn_t cmfn, tmem_cli_va_param_t clibuf)
> {
> - unsigned long tmem_mfn, cli_mfn = 0;
> + mfn_t tmem_mfn, cli_mfn = INVALID_MFN;
> char *tmem_va, *cli_va = NULL;
> struct page_info *cli_pfp = NULL;
> int rc = 1;
>
> ASSERT(pfp != NULL);
> tmem_mfn = page_to_mfn(pfp);
> - tmem_va = map_domain_page(_mfn(tmem_mfn));
> + tmem_va = map_domain_page(tmem_mfn);
> if ( guest_handle_is_null(clibuf) )
> {
> cli_va = cli_get_page(cmfn, &cli_mfn, &cli_pfp, 0);
> @@ -125,7 +130,7 @@ int tmem_compress_from_client(xen_pfn_t cmfn,
> unsigned char *wmem = this_cpu(workmem);
> char *scratch = this_cpu(scratch_page);
> struct page_info *cli_pfp = NULL;
> - unsigned long cli_mfn = 0;
> + mfn_t cli_mfn = INVALID_MFN;
> void *cli_va = NULL;
>
> if ( dmem == NULL || wmem == NULL )
> @@ -152,7 +157,7 @@ int tmem_compress_from_client(xen_pfn_t cmfn,
> int tmem_copy_to_client(xen_pfn_t cmfn, struct page_info *pfp,
> tmem_cli_va_param_t clibuf)
> {
> - unsigned long tmem_mfn, cli_mfn = 0;
> + mfn_t tmem_mfn, cli_mfn = INVALID_MFN;
> char *tmem_va, *cli_va = NULL;
> struct page_info *cli_pfp = NULL;
> int rc = 1;
> @@ -165,7 +170,8 @@ int tmem_copy_to_client(xen_pfn_t cmfn, struct page_info *pfp,
> return -EFAULT;
> }
> tmem_mfn = page_to_mfn(pfp);
> - tmem_va = map_domain_page(_mfn(tmem_mfn));
> + tmem_va = map_domain_page(tmem_mfn);
> +
> if ( cli_va )
> {
> memcpy(cli_va, tmem_va, PAGE_SIZE);
> @@ -181,7 +187,7 @@ int tmem_copy_to_client(xen_pfn_t cmfn, struct page_info *pfp,
> int tmem_decompress_to_client(xen_pfn_t cmfn, void *tmem_va,
> size_t size, tmem_cli_va_param_t clibuf)
> {
> - unsigned long cli_mfn = 0;
> + mfn_t cli_mfn = INVALID_MFN;
> struct page_info *cli_pfp = NULL;
> void *cli_va = NULL;
> char *scratch = this_cpu(scratch_page);
> --
> 2.11.0
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-11-01 18:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 14:03 [PATCH v3 for-next 0/4] xen: Convert __page_to_mfn and _mfn_to_page to use typesafe MFN Julien Grall
2017-11-01 14:03 ` [PATCH v3 for-next 1/4] xen/arm: domain_build: Clean-up insert_11_bank Julien Grall
2017-12-11 23:25 ` Stefano Stabellini
2017-11-01 14:03 ` [PATCH v3 for-next 2/4] xen/arm32: mm: Rework is_xen_heap_page to avoid nameclash Julien Grall
2017-12-11 23:25 ` Stefano Stabellini
2017-11-01 14:03 ` [PATCH v3 for-next 3/4] xen/tmem: Convert the file common/tmem_xen.c to use typesafe MFN Julien Grall
2017-11-01 18:54 ` Konrad Rzeszutek Wilk [this message]
2017-11-02 15:18 ` Julien Grall
2017-11-01 14:03 ` [PATCH v3 for-next 4/4] xen: Convert __page_to_mfn and __mfn_to_page " Julien Grall
2017-11-01 15:35 ` Paul Durrant
2017-11-01 15:43 ` Razvan Cojocaru
2017-11-01 18:38 ` Boris Ostrovsky
2017-11-02 2:52 ` Tian, Kevin
2017-11-02 8:35 ` Tim Deegan
2017-12-11 23:36 ` Stefano Stabellini
2017-11-06 11:37 ` [PATCH v3 for-next 0/4] xen: Convert __page_to_mfn and _mfn_to_page " Jan Beulich
2017-11-06 11:47 ` Julien Grall
2017-11-06 12:11 ` Jan Beulich
2017-11-06 12:16 ` Julien Grall
2017-11-06 12:44 ` Jan Beulich
2017-11-09 15:20 ` Julien Grall
2017-11-09 15:36 ` Jan Beulich
2017-11-09 15:39 ` Julien Grall
2017-11-09 15:47 ` Jan Beulich
2017-11-09 15:48 ` Julien Grall
2017-11-09 16:12 ` Jan Beulich
2017-12-11 23:37 ` Stefano Stabellini
2017-12-11 23:53 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171101185429.GC20519@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=julien.grall@linaro.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).