From patchwork Mon Oct 20 16:58:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39062 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BF2D1203C5 for ; Mon, 20 Oct 2014 17:02:16 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf958288eek.6 for ; Mon, 20 Oct 2014 10:02:15 -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=WJwGB63wwSD0wZKaComJvKKkedGAZX7njcfMrNuAHdlaDmz3I7pydvrltsUJSAx0Bc ExdxJDqdIxn3UtRt17Vsa5aNjQMpF6WcJjrhUrDP3TpOkSWVP39SK5ZAYO2Pqdkv/+pi uKxGQLG08JV5ERIRAdeTSDjN4esM+b0SEmNtHaDrzBrrY/XQYrYnQuAKTl1lYQXu8a3P qpmHIdwUYyB2cSWy/v+B512KJ4FYVqZbKoknAa+bmHMX9SudAJOSE15+4wpxgQwcPCq2 4Ndng2+wKiN04B8BdcX3Hiha/vSRHgfypZv6wo2lfjz4yLncIVFPqmaLL6dCRMbM8/nl zv8g== X-Gm-Message-State: ALoCoQnMvokjRD5CTDeE2tdViRCDc9P6oww0Q3CRRbjW2ftTP47imyAcgtpb0rXXzDPwA7Zi3Eu8 X-Received: by 10.112.95.133 with SMTP id dk5mr4257734lbb.3.1413824535950; Mon, 20 Oct 2014 10:02:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.170 with SMTP id l10ls407996lah.18.gmail; Mon, 20 Oct 2014 10:02:15 -0700 (PDT) X-Received: by 10.152.28.134 with SMTP id b6mr29579428lah.12.1413824535304; Mon, 20 Oct 2014 10:02:15 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id w4si15214000laj.78.2014.10.20.10.02.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 10:02:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id w7so4267252lbi.37 for ; Mon, 20 Oct 2014 10:02:14 -0700 (PDT) X-Received: by 10.112.221.197 with SMTP id qg5mr28615345lbc.32.1413824534926; Mon, 20 Oct 2014 10:02: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.84.229 with SMTP id c5csp346358lbz; Mon, 20 Oct 2014 10:02:13 -0700 (PDT) X-Received: by 10.224.24.131 with SMTP id v3mr23712850qab.81.1413824533155; Mon, 20 Oct 2014 10:02:13 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id f63si17364631qgf.83.2014.10.20.10.02.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 20 Oct 2014 10:02:13 -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 1XgGKJ-0001WW-Db; Mon, 20 Oct 2014 17:00:59 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XgGKG-0001UJ-DF for xen-devel@lists.xensource.com; Mon, 20 Oct 2014 17:00:56 +0000 Received: from [193.109.254.147:27892] by server-1.bemta-14.messagelabs.com id A3/63-24760-7CF35445; Mon, 20 Oct 2014 17:00:55 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1413824450!8544882!3 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 3264 invoked from network); 20 Oct 2014 17:00:54 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-11.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 20 Oct 2014 17:00:54 -0000 X-IronPort-AV: E=Sophos;i="5.04,757,1406592000"; d="scan'208";a="184250882" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Mon, 20 Oct 2014 13:00:48 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XgGK2-0002Wv-Rt; Mon, 20 Oct 2014 18:00:42 +0100 From: Stefano Stabellini To: Date: Mon, 20 Oct 2014 17:58:13 +0100 Message-ID: <1413824297-2805-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: MIA1 Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com, JBeulich@suse.com, Stefano Stabellini Subject: [Xen-devel] [PATCH v9 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.217.178 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;