]> xenbits.xensource.com Git - people/iwj/xen.git/commit
memory: add check_get_page_from_gfn() as a wrapper...
authorPaul Durrant <paul.durrant@citrix.com>
Fri, 5 Oct 2018 14:22:37 +0000 (16:22 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 5 Oct 2018 14:22:37 +0000 (16:22 +0200)
commit02ede7dc0390a135bc5bdff6a39f46c79bfc34be
tree57872dc8ab221453d14589cfd160ab40f734a8a9
parent98164cf5a8a7381967ff985a600ae53fd567cdd4
memory: add check_get_page_from_gfn() as a wrapper...

...for some uses of get_page_from_gfn().

There are many occurrences of the following pattern in the code:

    q = <readonly look-up> ? P2M_ALLOC : P2M_UNSHARE;
    page = get_page_from_gfn(d, gfn, &p2mt, q);

    if ( p2m_is_paging(p2mt) )
    {
        if ( page )
            put_page(page);

        p2m_mem_paging_populate(d, gfn);
        return <-EAGAIN or equivalent>;
    }

    if ( (q & P2M_UNSHARE) && p2m_is_shared(p2mt) )
    {
        if ( page )
            put_page(page);

        return <-EAGAIN or equivalent>;
    }

    if ( !page )
        return <-EINVAL or equivalent>;

There are some small differences between the exact way the occurrences
are coded but the desired semantic is the same.

This patch introduces a new common implementation of this code in
check_get_page_from_gfn() and then converts the various open-coded patterns
into calls to this new function.

NOTE: A forward declaration of p2m_type_t enum has been introduced in
      p2m-common.h so that it is possible to declare
      check_get_page_from_gfn() there rather than having to add
      duplicate declarations in the per-architecture p2m headers.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monne <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/hvm/hvm.c
xen/common/grant_table.c
xen/common/memory.c
xen/include/asm-arm/p2m.h
xen/include/asm-x86/p2m.h
xen/include/xen/p2m-common.h