From patchwork Mon Oct 13 14:58:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38670 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 860522039B for ; Mon, 13 Oct 2014 15:03:13 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e51sf4363705eek.11 for ; Mon, 13 Oct 2014 08:03:12 -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=oxWW1hX4QbTYSitxqCoWHsyJKhSHKurHbQhXJgXwc30=; b=gasT+pEgpyZH1wuzcWT7tQEPUrzqQREI0qenKlERCXXPDVK87hNIYyNrBq0liFhY0y NewDIkRemRd/baXT+HniWR+Ge9sy1kfPEhMNMg2wYteN3+er3LeCdeax1TOHOUEgZwvw wcrixktTlLFbkLxUgBTvdJoenCulyEce1wyBYWzhpcpt9KtlaA9e4Rz8nIngngUXiRDs /36ZQq5UNlZcI9CzgxInI80MRecI1Gpxi0HIDH6kfpvZX164txLc+5qP5c/uHBTRIalV qvSOPGaAH/TB3qCN2P+W3ifhAbCE2Kag+eJ27UuVMbEh+yCytut1kmhDYaW9GbYLvqBg eYNw== X-Gm-Message-State: ALoCoQmQ5HA00RDNmlk/R0ObkQdopOOQiqhXBDRq3nDn94VqofPxexOffpKfZC26W9rRSIjD8mnd X-Received: by 10.112.132.37 with SMTP id or5mr4149793lbb.2.1413212592614; Mon, 13 Oct 2014 08:03:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.161.234 with SMTP id xv10ls488474lab.13.gmail; Mon, 13 Oct 2014 08:03:12 -0700 (PDT) X-Received: by 10.152.170.194 with SMTP id ao2mr4105694lac.78.1413212592448; Mon, 13 Oct 2014 08:03:12 -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 b2si22522537lbm.104.2014.10.13.08.03.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Oct 2014 08:03:12 -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 p9so6513876lbv.5 for ; Mon, 13 Oct 2014 08:03:12 -0700 (PDT) X-Received: by 10.112.138.202 with SMTP id qs10mr24342106lbb.66.1413212592323; Mon, 13 Oct 2014 08:03:12 -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 c5csp230845lbz; Mon, 13 Oct 2014 08:03:11 -0700 (PDT) X-Received: by 10.52.76.130 with SMTP id k2mr18180213vdw.9.1413212590975; Mon, 13 Oct 2014 08:03:10 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id c7si12624988vds.9.2014.10.13.08.03.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 13 Oct 2014 08:03:10 -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 1Xdh7k-0004Fj-W7; Mon, 13 Oct 2014 15:01:24 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xdh7j-0004FN-Ge for xen-devel@lists.xensource.com; Mon, 13 Oct 2014 15:01:23 +0000 Received: from [85.158.143.35:37840] by server-1.bemta-4.messagelabs.com id B3/71-05872-249EB345; Mon, 13 Oct 2014 15:01:22 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1413212480!12585469!1 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.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 28770 invoked from network); 13 Oct 2014 15:01:22 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 13 Oct 2014 15:01:22 -0000 X-IronPort-AV: E=Sophos;i="5.04,711,1406592000"; d="scan'208";a="180809044" 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, 13 Oct 2014 11:01:09 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xdh7P-0008Ho-P4; Mon, 13 Oct 2014 16:01:03 +0100 From: Stefano Stabellini To: Date: Mon, 13 Oct 2014 15:58:40 +0100 Message-ID: <1413212324-664-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, Stefano Stabellini Subject: [Xen-devel] [PATCH v5 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.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: 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 6265c45..33fbe66 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;