From patchwork Tue Oct 21 18:10:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39221 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 74E3D2039B for ; Tue, 21 Oct 2014 18:15:09 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf1078455lab.11 for ; Tue, 21 Oct 2014 11:15:08 -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=O1/Y2LhAcdlurZAtI9P4RDBImGZeKvXiCF1mDqvH6JM=; b=T8sfRd55obfWIYufJpYSpP4UG85d5RcQHdG7gtQK9e9zu5bVw3rppaD4+Fvuw4SX4f aSTti+AThevKXq/Wh2hgE6miZ9YbQUt1zx8kZ5jlMGkknKUznmDdTQwzIdihvxXXw7dw AzMc4z7IhmHeg2pzYXT2yDAiZBqd+qjsiz8On1Vq/wrf4w/GWp0wb/ENRXtQ045TaWE7 wpSQvU9hwaIm9jhA5E0MaKQQoH0w1krzNMzh8uragNwCrYw81l67msLn24bfZvc8y9VM N2usSZMRHNLADxMgZRwVb2aBB5KK2qmeF0NARxPdVp+kd2PoBxXPrWxRnTcsrXCt3I60 LrEA== X-Gm-Message-State: ALoCoQmXsiBKH/JQl4BMKjeSlcj6PxHHwQMGrxidC0ba90ManKFNtmi7gb1ld7NxcurHxknHA5/A X-Received: by 10.152.3.168 with SMTP id d8mr5454726lad.0.1413915308271; Tue, 21 Oct 2014 11:15:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.233 with SMTP id uh9ls88353lac.70.gmail; Tue, 21 Oct 2014 11:15:08 -0700 (PDT) X-Received: by 10.112.150.68 with SMTP id ug4mr18285961lbb.82.1413915308094; Tue, 21 Oct 2014 11:15:08 -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 bm5si3658825lbb.59.2014.10.21.11.15.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 11:15:08 -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 gq15so1527559lab.26 for ; Tue, 21 Oct 2014 11:15:08 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr36276716lbc.23.1413915308003; Tue, 21 Oct 2014 11:15:08 -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.84.229 with SMTP id c5csp556143lbz; Tue, 21 Oct 2014 11:15:07 -0700 (PDT) X-Received: by 10.220.73.1 with SMTP id o1mr3374628vcj.67.1413915306550; Tue, 21 Oct 2014 11:15:06 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id z12si8945905vcz.54.2014.10.21.11.15.05 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 21 Oct 2014 11:15:06 -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 1Xgdvu-00029D-Am; Tue, 21 Oct 2014 18:13:22 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xgdvs-00026H-5d for xen-devel@lists.xensource.com; Tue, 21 Oct 2014 18:13:20 +0000 Received: from [85.158.139.211] by server-8.bemta-5.messagelabs.com id 43/72-03671-F32A6445; Tue, 21 Oct 2014 18:13:19 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1413915197!10926958!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10564 invoked from network); 21 Oct 2014 18:13:18 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 21 Oct 2014 18:13:18 -0000 X-IronPort-AV: E=Sophos;i="5.04,763,1406592000"; d="scan'208";a="184785997" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Tue, 21 Oct 2014 14:13:13 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xgdvg-0001jK-AU; Tue, 21 Oct 2014 19:13:08 +0100 From: Stefano Stabellini To: Date: Tue, 21 Oct 2014 19:10:34 +0100 Message-ID: <1413915038-17490-4-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA2 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, JBeulich@suse.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v10 4/8] xen/arm: introduce invalidate_dcache_va_range 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: stefano.stabellini@eu.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: Take care of handling non-cacheline aligned addresses and sizes. Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall Acked-by: Ian Campbell --- Changes in v5: - return int from invalidate_dcache_va_range. Changes in v4: - rename invalidate_xen_dcache_va_range to invalidate_dcache_va_range. --- xen/include/asm-arm/arm32/page.h | 3 +++ xen/include/asm-arm/arm64/page.h | 3 +++ xen/include/asm-arm/page.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/xen/include/asm-arm/arm32/page.h b/xen/include/asm-arm/arm32/page.h index 20a6a7f..a07e217 100644 --- a/xen/include/asm-arm/arm32/page.h +++ b/xen/include/asm-arm/arm32/page.h @@ -19,6 +19,9 @@ static inline void write_pte(lpae_t *p, lpae_t pte) : : "r" (pte.bits), "r" (p) : "memory"); } +/* Inline ASM to invalidate dcache on register R (may be an inline asm operand) */ +#define __invalidate_dcache_one(R) STORE_CP32(R, DCIMVAC) + /* Inline ASM to flush dcache on register R (may be an inline asm operand) */ #define __clean_dcache_one(R) STORE_CP32(R, DCCMVAC) diff --git a/xen/include/asm-arm/arm64/page.h b/xen/include/asm-arm/arm64/page.h index 101d7a8..1fd416d 100644 --- a/xen/include/asm-arm/arm64/page.h +++ b/xen/include/asm-arm/arm64/page.h @@ -14,6 +14,9 @@ static inline void write_pte(lpae_t *p, lpae_t pte) : : "r" (pte.bits), "r" (p) : "memory"); } +/* Inline ASM to invalidate dcache on register R (may be an inline asm operand) */ +#define __invalidate_dcache_one(R) "dc ivac, %" #R ";" + /* Inline ASM to flush dcache on register R (may be an inline asm operand) */ #define __clean_dcache_one(R) "dc cvac, %" #R ";" diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 69e9a61..53d4b63 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -268,6 +268,38 @@ extern size_t cacheline_bytes; /* Functions for flushing medium-sized areas. * if 'range' is large enough we might want to use model-specific * full-cache flushes. */ + +static inline int invalidate_dcache_va_range(const void *p, unsigned long size) +{ + size_t off; + const void *end = p + size; + + dsb(sy); /* So the CPU issues all writes to the range */ + + off = (unsigned long)p % cacheline_bytes; + if ( off ) + { + p -= off; + asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (p)); + p += cacheline_bytes; + size -= cacheline_bytes - off; + } + off = (unsigned long)end % cacheline_bytes; + if ( off ) + { + end -= off; + size -= off; + asm volatile (__clean_and_invalidate_dcache_one(0) : : "r" (end)); + } + + for ( ; p < end; p += cacheline_bytes ) + asm volatile (__invalidate_dcache_one(0) : : "r" (p)); + + dsb(sy); /* So we know the flushes happen before continuing */ + + return 0; +} + static inline int clean_dcache_va_range(const void *p, unsigned long size) { const void *end;