From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755322AbbICM0j (ORCPT ); Thu, 3 Sep 2015 08:26:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:49395 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752965AbbICM0h (ORCPT ); Thu, 3 Sep 2015 08:26:37 -0400 Subject: Re: [PATCH] xen/p2m: fix extra memory regions accounting To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , linux-kernel@vger.kernel.org References: <1441281916-38284-1-git-send-email-roger.pau@citrix.com> <55E839CF.5080303@citrix.com> Cc: Konrad Rzeszutek Wilk , Boris Ostrovsky , David Vrabel , xen-devel@lists.xenproject.org From: Juergen Gross Message-ID: <55E83C78.8090002@suse.com> Date: Thu, 3 Sep 2015 14:26:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55E839CF.5080303@citrix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/03/2015 02:15 PM, Roger Pau Monné wrote: > El 03/09/15 a les 14.05, Roger Pau Monne ha escrit: >> On systems with memory maps with ranges that don't end at page boundaries, >> like: >> >> [...] >> (XEN) 0000000000100000 - 00000000dfdf9c00 (usable) >> (XEN) 00000000dfdf9c00 - 00000000dfe4bc00 (ACPI NVS) >> [...] >> >> xen_add_extra_mem will create a protected range that ends up at 0xdfdf9c00, >> but the function used to check if a memory address is inside of a protected >> range works with pfns, which means that an attempt to map 0xdfdf9c00 will be >> refused because the check is performed against 0xdfdf9000 instead of >> 0xdfdf9c00. >> >> In order to fix this, make sure that the ranges that are added to the >> xen_extra_mem array are aligned to page boundaries. >> >> Signed-off-by: Roger Pau Monné >> Cc: Konrad Rzeszutek Wilk >> Cc: Boris Ostrovsky >> Cc: David Vrabel >> Cc: Juergen Gross >> Cc: xen-devel@lists.xenproject.org >> --- >> AFAICT this patch needs to be backported to 3.19, 4.0, 4.1 and 4.2. >> --- >> arch/x86/xen/setup.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c >> index 55f388e..dcf5865 100644 >> --- a/arch/x86/xen/setup.c >> +++ b/arch/x86/xen/setup.c >> @@ -68,6 +68,9 @@ static void __init xen_add_extra_mem(phys_addr_t start, phys_addr_t size) >> { >> int i; >> >> + start = PAGE_ALIGN(start); > > Sorry, I didn't remember to update the patch before sending it, but I > think this should instead be: > > start = round_up(start, PAGE_SIZE); No, PAGE_ALIGN() already does that. Juergen > > Here and below. > >> + size &= PAGE_MASK; >> + >> for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) { >> /* Add new region. */ >> if (xen_extra_mem[i].size == 0) { >> @@ -92,6 +95,9 @@ static void __init xen_del_extra_mem(phys_addr_t start, phys_addr_t size) >> int i; >> phys_addr_t start_r, size_r; >> >> + start = PAGE_ALIGN(start); >> + size &= PAGE_MASK; >> + >> for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) { >> start_r = xen_extra_mem[i].start; >> size_r = xen_extra_mem[i].size; >> > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ >