From patchwork Wed Sep 17 21:21:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 37542 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 9C5F92054D for ; Wed, 17 Sep 2014 21:22:15 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id b57sf56791eek.11 for ; Wed, 17 Sep 2014 14:22:14 -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:from:to:date:message-id:in-reply-to :references: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=ZTrz1W68yEvshJuecIgSoY+Xa7LVKk8n2GgBKQZP6ns=; b=JvoUruHnOfrbBQzJSFjiYFJ+WBw/XbZ/wQgLv6w8IwqxnYqd6I4TJjZL8AXc9rEpQB /IO25HSFFyzEcCBC3pvbZspdNbHYdKJjrmNhBOT1eQrIetz5u8bYim36MIg32F6xSn5j +8wiB4+YTQEq21w0KnYU3iE9tUSSnixYAN2+JkYdDSLopdgQIj67UyqjVetBbPzb6WnF WKxO90Zom/2Ro3JdnCP7018nUVG5Tfo241ypyE8ZLOjY2/2fKRXiMh50y2lLC9QsEhEg Bi07ZA0R8kliiSNy/FhmFO1HVlFlJgzHhTGSoEN49KbaEGzzAlp3LH820wdClyz95b9o oGrw== X-Gm-Message-State: ALoCoQkiD+3FI4FWtLnGz7iY1zongJM0DACvWkPoPGz7w+XcfWTBBz+iwnxjLfgSNNVUgkXWL6MM X-Received: by 10.180.24.225 with SMTP id x1mr181431wif.2.1410988934723; Wed, 17 Sep 2014 14:22:14 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.129 with SMTP id o1ls150548lal.75.gmail; Wed, 17 Sep 2014 14:22:14 -0700 (PDT) X-Received: by 10.152.7.212 with SMTP id l20mr355742laa.7.1410988934396; Wed, 17 Sep 2014 14:22:14 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) by mx.google.com with ESMTPS id g9si30145780lbv.86.2014.09.17.14.22.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Sep 2014 14:22:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id ge10so2656931lab.26 for ; Wed, 17 Sep 2014 14:22:14 -0700 (PDT) X-Received: by 10.112.75.233 with SMTP id f9mr8292lbw.102.1410988934277; Wed, 17 Sep 2014 14:22:14 -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 of9csp658525lbb; Wed, 17 Sep 2014 14:22:13 -0700 (PDT) X-Received: by 10.224.173.7 with SMTP id n7mr60695391qaz.15.1410988932847; Wed, 17 Sep 2014 14:22:12 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id q67si23880552qgd.122.2014.09.17.14.22.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 17 Sep 2014 14:22:12 -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 1XUMf5-0000NU-Fw; Wed, 17 Sep 2014 21:21:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XUMf3-0000Mh-S4 for xen-devel@lists.xen.org; Wed, 17 Sep 2014 21:21:13 +0000 Received: from [85.158.137.68:25507] by server-14.bemta-3.messagelabs.com id A2/ED-01575-94BF9145; Wed, 17 Sep 2014 21:21:13 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-5.tower-31.messagelabs.com!1410988868!15225725!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13508 invoked from network); 17 Sep 2014 21:21:12 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 17 Sep 2014 21:21:12 -0000 X-IronPort-AV: E=Sophos;i="5.04,542,1406592000"; d="scan'208";a="172617741" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.3.181.6; Wed, 17 Sep 2014 17:21:10 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XUMeu-0006w4-RO; Wed, 17 Sep 2014 22:21:05 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Wed, 17 Sep 2014 22:21:04 +0100 From: Ian Campbell To: Date: Wed, 17 Sep 2014 22:21:02 +0100 Message-ID: <1410988863-15238-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1410988836.23505.65.camel@citrix.com> References: <1410988836.23505.65.camel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell , stefano.stabellini@eu.citrix.com, julien.grall@linaro.org, tim@xen.org, Roy Franz , Jan Beulich , Fu Wei Subject: [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.215.53 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: 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 Cc: Jan Beulich Acked-by: Jan Beulich --- 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..a9c326f 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 pdx_init_mask(u64 base_addr) +{ + return fill_mask(base_addr - 1); +} + +u64 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)