From patchwork Mon Sep 22 15:42:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 37686 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA0FB202A1 for ; Mon, 22 Sep 2014 15:45:29 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id c13sf2027588eek.11 for ; Mon, 22 Sep 2014 08:45:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:from:to:date:in-reply-to :references:organization:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=nOflh32yiiipQnWZyJjOL+Kg6GVk4rmpyDeGL31EYP8=; b=Ra1UnavjwVTtSr1q9zyGMt8T7zKFROZ2B862qMo1D1y7jXMuMXMN405WNmuoaewIHN Fayb13oTk0gRufEpMxk23AbpVtdSI8L0Dp6nCrbiHf2crvD0KiUjdmXoGNH2ghMTZUKo JWf2O+0lcXz3dkLoSzz4xvO/NQgaTJuFHKQwYDyso/9NvrE0HnHrkLGkF108afC59dx4 /BIiFkrPVmAmvc/N+zgjs2+vqqW9dlHb+M8kteaFuSl1CVQvyDL2yhcV3b9x3dHdiSVU gTpTuMNb5/CUYlUvZh55VQXGkQ0cioWnrCDn3m3fmAblCuMu+Xp6dPpTgleioqR13011 /R3A== X-Gm-Message-State: ALoCoQlgnz5NpI/fUDIffF8tckutUZSnNTpSFqfEymDckRHhe8BKFb3zSUBMkDy+SMdpnTdhKrKO X-Received: by 10.152.6.9 with SMTP id w9mr558835law.7.1411400729024; Mon, 22 Sep 2014 08:45:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.175 with SMTP id az15ls526825lab.96.gmail; Mon, 22 Sep 2014 08:45:28 -0700 (PDT) X-Received: by 10.112.202.1 with SMTP id ke1mr25359909lbc.33.1411400728823; Mon, 22 Sep 2014 08:45:28 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) by mx.google.com with ESMTPS id 2si14910158lak.120.2014.09.22.08.45.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 08:45:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id l4so7020556lbv.19 for ; Mon, 22 Sep 2014 08:45:28 -0700 (PDT) X-Received: by 10.152.5.168 with SMTP id t8mr4104303lat.67.1411400725419; Mon, 22 Sep 2014 08:45:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp261128lbb; Mon, 22 Sep 2014 08:45:24 -0700 (PDT) X-Received: by 10.224.88.3 with SMTP id y3mr23839831qal.65.1411400723108; Mon, 22 Sep 2014 08:45:23 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id x1si9471379qcq.30.2014.09.22.08.45.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 22 Sep 2014 08:45:23 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XW5lo-0005oE-D0; Mon, 22 Sep 2014 15:43:20 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XW5ln-0005o9-6A for xen-devel@lists.xen.org; Mon, 22 Sep 2014 15:43:19 +0000 Received: from [85.158.139.211:43928] by server-16.bemta-5.messagelabs.com id 39/5F-01029-69340245; Mon, 22 Sep 2014 15:43:18 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1411400595!11316790!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 6.12.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16898 invoked from network); 22 Sep 2014 15:43:17 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 22 Sep 2014 15:43:17 -0000 X-IronPort-AV: E=Sophos;i="5.04,572,1406592000"; d="scan'208";a="173901851" Message-ID: <1411400579.26552.13.camel@kazak.uk.xensource.com> From: Ian Campbell To: Julien Grall Date: Mon, 22 Sep 2014 16:42:59 +0100 In-Reply-To: <541B2F90.5080008@linaro.org> References: <1410988836.23505.65.camel@citrix.com> <1410988863-15238-2-git-send-email-ian.campbell@citrix.com> <541B2F90.5080008@linaro.org> Organization: Citrix Systems, Inc. X-Mailer: Evolution 3.12.2-1+b1 MIME-Version: 1.0 X-DLP: MIA1 Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, xen-devel@lists.xen.org, Roy Franz , Jan Beulich , Fu Wei Subject: Re: [Xen-devel] [PATCH for-4.5 v3 2/3] xen: add helpers for PDX mask initialisation calculations X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: On Thu, 2014-09-18 at 12:16 -0700, Julien Grall wrote: > > +u64 pdx_region_mask(u64 base, u64 len) > > fill_mask is marked as __init. For consistency, those 2 functions should > be marked too. Just resending that one patch: -------------------------- >From 6a554cc2d7dc076eb4f6ed6f922fa95eea113fa5 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 16 Sep 2014 21:01:41 +0100 Subject: [PATCH] xen: add helpers for PDX mask initialisation calculations I wanted to make fill_mask a public function so I could use it on ARM, but it was actually easier to think of a (semi) reasonable public name for the users of it, so that is what I have done. Signed-off-by: Ian Campbell Acked-by: Jan Beulich Reviewed-by: Julien Grall --- v3.1: Added __init to new functions. v3: New patch --- xen/arch/x86/srat.c | 16 +++------------- xen/common/pdx.c | 18 ++++++++++++++++++ xen/include/xen/pdx.h | 3 +++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c index 2b05272..29fc724 100644 --- a/xen/arch/x86/srat.c +++ b/xen/arch/x86/srat.c @@ -339,13 +339,6 @@ void __init acpi_numa_arch_fixup(void) {} static u64 __initdata srat_region_mask; -static u64 __init fill_mask(u64 mask) -{ - while (mask & (mask + 1)) - mask |= mask + 1; - return mask; -} - static int __init srat_parse_region(struct acpi_subtable_header *header, const unsigned long end) { @@ -366,8 +359,7 @@ static int __init srat_parse_region(struct acpi_subtable_header *header, ma->base_address, ma->base_address + ma->length - 1); srat_region_mask |= ma->base_address | - fill_mask(ma->base_address ^ - (ma->base_address + ma->length - 1)); + pdx_region_mask(ma->base_address, ma->length); return 0; } @@ -381,7 +373,7 @@ void __init srat_parse_regions(u64 addr) acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) return; - srat_region_mask = fill_mask(addr - 1); + srat_region_mask = pdx_init_mask(addr); acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY, srat_parse_region, 0); @@ -389,9 +381,7 @@ void __init srat_parse_regions(u64 addr) if (e820.map[i].type != E820_RAM) continue; - if (~mask & - fill_mask(e820.map[i].addr ^ - (e820.map[i].addr + e820.map[i].size - 1))) + if (~mask & pdx_region_mask(e820.map[i].addr, e820.map[i].size)) mask = 0; } diff --git a/xen/common/pdx.c b/xen/common/pdx.c index 11349a7..cf8b9b5 100644 --- a/xen/common/pdx.c +++ b/xen/common/pdx.c @@ -41,6 +41,24 @@ int __mfn_valid(unsigned long mfn) pdx_group_valid)); } +/* Sets all bits from the most-significant 1-bit down to the LSB */ +static u64 __init fill_mask(u64 mask) +{ + while (mask & (mask + 1)) + mask |= mask + 1; + return mask; +} + +u64 __init pdx_init_mask(u64 base_addr) +{ + return fill_mask(base_addr - 1); +} + +u64 __init pdx_region_mask(u64 base, u64 len) +{ + return fill_mask(base ^ (base + len - 1)); +} + void set_pdx_range(unsigned long smfn, unsigned long emfn) { unsigned long idx, eidx; diff --git a/xen/include/xen/pdx.h b/xen/include/xen/pdx.h index 624f04f..18fe8e5 100644 --- a/xen/include/xen/pdx.h +++ b/xen/include/xen/pdx.h @@ -13,6 +13,9 @@ extern unsigned long pfn_top_mask, ma_top_mask; (sizeof(*frame_table) & -sizeof(*frame_table))) extern unsigned long pdx_group_valid[]; +extern u64 pdx_init_mask(u64 base_addr); +extern u64 pdx_region_mask(u64 base, u64 len); + extern void set_pdx_range(unsigned long smfn, unsigned long emfn); #define page_to_pdx(pg) ((pg) - frame_table)