ia64/xen-unstable

changeset 19021:bf847041d98f

New XENMAPSPACE_gmfn parameter for XENMEM_add_to_physmap.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 09 11:44:35 2009 +0000 (2009-01-09)
parents f75567adad9b
children b84345ee0d41
files xen/arch/ia64/xen/mm.c xen/arch/x86/mm.c xen/include/public/memory.h
line diff
     1.1 --- a/xen/arch/ia64/xen/mm.c	Fri Jan 09 10:04:24 2009 +0000
     1.2 +++ b/xen/arch/ia64/xen/mm.c	Fri Jan 09 11:44:35 2009 +0000
     1.3 @@ -3295,38 +3295,40 @@ arch_memory_op(int op, XEN_GUEST_HANDLE(
     1.4  
     1.5              spin_unlock(&d->grant_table->lock);
     1.6              break;
     1.7 -        case XENMAPSPACE_mfn:
     1.8 -        {
     1.9 -            if ( get_page_from_pagenr(xatp.idx, d) ) {
    1.10 -                struct xen_ia64_memmap_info memmap_info;
    1.11 -                efi_memory_desc_t md;
    1.12 -                int ret;
    1.13 -
    1.14 -                mfn = xatp.idx;
    1.15 -                page = mfn_to_page(mfn);
    1.16 -
    1.17 -                memmap_info.efi_memmap_size = sizeof(md);
    1.18 -                memmap_info.efi_memdesc_size = sizeof(md);
    1.19 -                memmap_info.efi_memdesc_version =
    1.20 -                    EFI_MEMORY_DESCRIPTOR_VERSION;
    1.21 -
    1.22 -                md.type = EFI_CONVENTIONAL_MEMORY;
    1.23 -                md.pad = 0;
    1.24 -                md.phys_addr = xatp.gpfn << PAGE_SHIFT;
    1.25 -                md.virt_addr = 0;
    1.26 -                md.num_pages = 1UL << (PAGE_SHIFT - EFI_PAGE_SHIFT);
    1.27 -                md.attribute = EFI_MEMORY_WB;
    1.28 -
    1.29 -                ret = __dom0vp_add_memdesc(d, &memmap_info, (char*)&md);
    1.30 -                if (ret != 0) {
    1.31 -                    put_page(page);
    1.32 -                    rcu_unlock_domain(d);
    1.33 -                    gdprintk(XENLOG_DEBUG,
    1.34 -                             "%s:%d td %d gpfn 0x%lx mfn 0x%lx ret %d\n",
    1.35 -                             __func__, __LINE__,
    1.36 -                             d->domain_id, xatp.gpfn, xatp.idx, ret);
    1.37 -                    return ret;
    1.38 -                }
    1.39 +        case XENMAPSPACE_gmfn:
    1.40 +            xatp.idx = gmfn_to_mfn(d, xatp.idx);
    1.41 +        case XENMAPSPACE_mfn: {
    1.42 +            struct xen_ia64_memmap_info memmap_info;
    1.43 +            efi_memory_desc_t md;
    1.44 +            int ret;
    1.45 +
    1.46 +            if ( !get_page_from_pagenr(xatp.idx, d) )
    1.47 +                break;
    1.48 +
    1.49 +            mfn = xatp.idx;
    1.50 +            page = mfn_to_page(mfn);
    1.51 +
    1.52 +            memmap_info.efi_memmap_size = sizeof(md);
    1.53 +            memmap_info.efi_memdesc_size = sizeof(md);
    1.54 +            memmap_info.efi_memdesc_version =
    1.55 +                EFI_MEMORY_DESCRIPTOR_VERSION;
    1.56 +
    1.57 +            md.type = EFI_CONVENTIONAL_MEMORY;
    1.58 +            md.pad = 0;
    1.59 +            md.phys_addr = xatp.gpfn << PAGE_SHIFT;
    1.60 +            md.virt_addr = 0;
    1.61 +            md.num_pages = 1UL << (PAGE_SHIFT - EFI_PAGE_SHIFT);
    1.62 +            md.attribute = EFI_MEMORY_WB;
    1.63 +
    1.64 +            ret = __dom0vp_add_memdesc(d, &memmap_info, (char*)&md);
    1.65 +            if (ret != 0) {
    1.66 +                put_page(page);
    1.67 +                rcu_unlock_domain(d);
    1.68 +                gdprintk(XENLOG_DEBUG,
    1.69 +                         "%s:%d td %d gpfn 0x%lx mfn 0x%lx ret %d\n",
    1.70 +                         __func__, __LINE__,
    1.71 +                         d->domain_id, xatp.gpfn, xatp.idx, ret);
    1.72 +                return ret;
    1.73              }
    1.74              break;
    1.75          }
     2.1 --- a/xen/arch/x86/mm.c	Fri Jan 09 10:04:24 2009 +0000
     2.2 +++ b/xen/arch/x86/mm.c	Fri Jan 09 11:44:35 2009 +0000
     2.3 @@ -3808,14 +3808,14 @@ long arch_memory_op(int op, XEN_GUEST_HA
     2.4  
     2.5              spin_unlock(&d->grant_table->lock);
     2.6              break;
     2.7 +        case XENMAPSPACE_gmfn:
     2.8 +            xatp.idx = gmfn_to_mfn(d, xatp.idx);
     2.9          case XENMAPSPACE_mfn:
    2.10 -        {
    2.11 -            if ( get_page_from_pagenr(xatp.idx, d) ) {
    2.12 -                mfn = xatp.idx;
    2.13 -                page = mfn_to_page(mfn);
    2.14 -            }
    2.15 +            if ( !get_page_from_pagenr(xatp.idx, d) )
    2.16 +                break;
    2.17 +            mfn = xatp.idx;
    2.18 +            page = mfn_to_page(mfn);
    2.19              break;
    2.20 -        }
    2.21          default:
    2.22              break;
    2.23          }
     3.1 --- a/xen/include/public/memory.h	Fri Jan 09 10:04:24 2009 +0000
     3.2 +++ b/xen/include/public/memory.h	Fri Jan 09 11:44:35 2009 +0000
     3.3 @@ -206,7 +206,8 @@ struct xen_add_to_physmap {
     3.4      /* Source mapping space. */
     3.5  #define XENMAPSPACE_shared_info 0 /* shared info page */
     3.6  #define XENMAPSPACE_grant_table 1 /* grant table page */
     3.7 -#define XENMAPSPACE_mfn         2 /* usual MFN */
     3.8 +#define XENMAPSPACE_mfn         2 /* MFN */
     3.9 +#define XENMAPSPACE_gmfn        3 /* GMFN */
    3.10      unsigned int space;
    3.11  
    3.12      /* Index into source mapping space. */