From patchwork Wed Oct 8 13:00:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38474 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 04E28202E7 for ; Wed, 8 Oct 2014 13:04:32 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id b15sf3422969eek.8 for ; Wed, 08 Oct 2014 06:04:32 -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=MWxHvCJ34TwdN53Ko5iNtj6sKK0H7xlO7gDwSzoEF+M=; b=jWU0U72m6rVNWQ6OEDVV6iuIfElchBSjxyGx/akGGHwxx+fKLrPqQOUwdtElDsElP5 wvI3179TLNsC89UPFmIDWWa64Gws8WkFct21QpHtpho/BYi6BTQKt8zmZppLU6kO8K3A tRyQbc+cnB327xBmCJUQ9lbrNhcTjm5g1Ek/52binMM9L5hVpeTaXgVPfK8MEGPj38zA Hk7qIdR0asnleUoBCzbgNvs5YXoKG76/FpwM8epchZv1aNL2YGR/5qNDux9SNPVuTaVj 0vJ5mc4IWOutRDJVipVgsOEa2GF6uO6ObkscHDoVF1gpT9Xzb1TzlRXxL89Q1+drT67L adlg== X-Gm-Message-State: ALoCoQkliim73uGb10lGw6jPQ1G1v+jle9frSqJ0SjEvEPdB2teaONLt6wqf9QjRwJU+HOJbl8dW X-Received: by 10.112.89.8 with SMTP id bk8mr1570574lbb.6.1412773471974; Wed, 08 Oct 2014 06:04:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.226 with SMTP id q2ls55507lae.15.gmail; Wed, 08 Oct 2014 06:04:31 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr11268446lac.44.1412773471319; Wed, 08 Oct 2014 06:04:31 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx.google.com with ESMTPS id wh3si32938030lbb.118.2014.10.08.06.04.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Oct 2014 06:04:31 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hz20so8318439lab.39 for ; Wed, 08 Oct 2014 06:04:31 -0700 (PDT) X-Received: by 10.152.28.167 with SMTP id c7mr11228282lah.27.1412773471185; Wed, 08 Oct 2014 06:04:31 -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 c5csp57605lbz; Wed, 8 Oct 2014 06:04:28 -0700 (PDT) X-Received: by 10.140.92.98 with SMTP id a89mr25774333qge.85.1412773467411; Wed, 08 Oct 2014 06:04:27 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id n11si34362822qaa.108.2014.10.08.06.04.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 08 Oct 2014 06:04:27 -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 1Xbqth-0000zt-HE; Wed, 08 Oct 2014 13:03:17 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xbqtf-0000zO-Qn for xen-devel@lists.xensource.com; Wed, 08 Oct 2014 13:03:15 +0000 Received: from [193.109.254.147:54158] by server-3.bemta-14.messagelabs.com id C1/17-23707-31635345; Wed, 08 Oct 2014 13:03:15 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1412773392!14105614!2 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.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9501 invoked from network); 8 Oct 2014 13:03:14 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 8 Oct 2014 13:03:14 -0000 X-IronPort-AV: E=Sophos;i="5.04,677,1406592000"; d="scan'208";a="180482193" 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; Wed, 8 Oct 2014 09:02:49 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xbqt0-0003n2-UV; Wed, 08 Oct 2014 14:02:34 +0100 From: Stefano Stabellini To: Date: Wed, 8 Oct 2014 14:00:18 +0100 Message-ID: <1412773221-15150-2-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, Stefano Stabellini Subject: [Xen-devel] [PATCH v3 2/5] xen/arm: introduce invalidate_xen_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.52 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 --- xen/include/asm-arm/arm32/page.h | 3 +++ xen/include/asm-arm/arm64/page.h | 3 +++ xen/include/asm-arm/page.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/xen/include/asm-arm/arm32/page.h b/xen/include/asm-arm/arm32/page.h index 9740672..6fb2e68 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_xen_dcache_one(R) STORE_CP32(R, DCIMVAC) + /* Inline ASM to flush dcache on register R (may be an inline asm operand) */ #define __clean_xen_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 bb10164..f181b1b 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_xen_dcache_one(R) "dc ivac, %" #R ";" + /* Inline ASM to flush dcache on register R (may be an inline asm operand) */ #define __clean_xen_dcache_one(R) "dc cvac, %" #R ";" diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index d758b61..da02e97 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -268,6 +268,36 @@ 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 void invalidate_xen_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_xen_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_xen_dcache_one(0) : : "r" (end)); + } + + for ( ; p < end; p += cacheline_bytes ) + asm volatile (__invalidate_xen_dcache_one(0) : : "r" (p)); + + dsb(sy); /* So we know the flushes happen before continuing */ +} + static inline void clean_xen_dcache_va_range(const void *p, unsigned long size) { const void *end;