From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752894AbbBSRfX (ORCPT ); Thu, 19 Feb 2015 12:35:23 -0500 Received: from queue01b.mail.zen.net.uk ([212.23.3.242]:57030 "EHLO queue01b.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751943AbbBSRfW (ORCPT ); Thu, 19 Feb 2015 12:35:22 -0500 Message-ID: <54E61ECE.4060609@cantab.net> Date: Thu, 19 Feb 2015 17:35:10 +0000 From: David Vrabel User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Juergen Gross , linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com, konrad.wilk@oracle.com, david.vrabel@citrix.com, boris.ostrovsky@oracle.com References: <1424242326-26611-1-git-send-email-jgross@suse.com> <1424242326-26611-9-git-send-email-jgross@suse.com> In-Reply-To: <1424242326-26611-9-git-send-email-jgross@suse.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 82.70.146.43 X-SA-Exim-Mail-From: dvrabel@cantab.net Subject: Re: [Xen-devel] [PATCH 08/13] xen: add service function to copy physical memory areas X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on pear.davidvrabel.org.uk) X-Originating-smarthost01a-IP: [82.70.146.41] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/02/2015 06:52, Juergen Gross wrote: > In case a pre-allocated memory area is to be moved in order to avoid > a conflict with the target E820 map we need a way to copy data between > physical addresses. > > Add a function doing this via early_memremap(). [...] > --- a/arch/x86/xen/setup.c > +++ b/arch/x86/xen/setup.c > @@ -766,6 +766,35 @@ phys_addr_t __init xen_find_free_area(phys_addr_t size) > } > > /* > + * Like memcpy, but with physical addresses for dest and src. > + */ > +void __init xen_phys_memcpy(phys_addr_t dest, phys_addr_t src, phys_addr_t n) > +{ > + phys_addr_t dest_off, src_off, dest_len, src_len, len; > + void *from, *to; > + > + while (n) { > + dest_off = dest & ~PAGE_MASK; > + src_off = src & ~PAGE_MASK; > + dest_len = n; > + if (dest_len > (NR_FIX_BTMAPS << PAGE_SHIFT) - dest_off) > + dest_len = (NR_FIX_BTMAPS << PAGE_SHIFT) - dest_off; > + src_len = n; > + if (src_len > (NR_FIX_BTMAPS << PAGE_SHIFT) - src_off) > + src_len = (NR_FIX_BTMAPS << PAGE_SHIFT) - src_off; > + len = min(dest_len, src_len); > + to = early_memremap(dest - dest_off, dest_len + dest_off); > + from = early_memremap(src - src_off, src_len + src_off); > + memcpy(to, from, len); > + early_iounmap(to, dest_len + dest_off); > + early_iounmap(from, src_len + src_off); early_memunmap surely? Otherwise, Reviewed-by: David Vrabel David