From patchwork Mon Oct 20 09:48:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39033 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0E25203C5 for ; Mon, 20 Oct 2014 09:53:03 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id gi9sf2268556lab.6 for ; Mon, 20 Oct 2014 02:53:02 -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=IslmB3LDAcBgoQCCMx5PQU9FVfYZKXo6fjn0Pd+ADI0=; b=Bg38xVl9qtV+G5hgYtALP6qSyXMD1yfrgkV7HXj2w1B2IZHWYS+iQzXeXD1RGxtVKv qm/QIuZAN1uVD34VBl6Uzd5v7mmL/IrVM9cBwcga6/iQusOdUYa4ktzr2D/EJjZTg7Yq 01qTl/P+s2d0y5llkED+uPAPOk6r4miItfP9qwHleL+0jtZk/bCqcRV3pseqKiGjZIDn MlVbc+6hJso/srO9CN4piOkuHmak37kOB5iAMK6OsMqe3ckHjpoCFBBfWfRCqvMEKclt H4kzsCZAiNKPEA+t/exjizfGWPrGpzquFm3YGTN1kaZohZOFvX7bmYpP1h6NEE+nsmWJ OIQg== X-Gm-Message-State: ALoCoQkQfE7OhbY+TC2MuqiHH/xehU8X3lVpipM/fSInlzpM6dCwrdI8XXAeJvlIGT6pqsmZbfLH X-Received: by 10.152.1.133 with SMTP id 5mr11555lam.8.1413798782629; Mon, 20 Oct 2014 02:53:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.9 with SMTP id o9ls367915lao.97.gmail; Mon, 20 Oct 2014 02:53:02 -0700 (PDT) X-Received: by 10.152.36.33 with SMTP id n1mr1849866laj.95.1413798782216; Mon, 20 Oct 2014 02:53:02 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id m2si13486795lbp.105.2014.10.20.02.53.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 02:53:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id z11so3494263lbi.41 for ; Mon, 20 Oct 2014 02:53:02 -0700 (PDT) X-Received: by 10.112.221.197 with SMTP id qg5mr25988351lbc.32.1413798782124; Mon, 20 Oct 2014 02:53:02 -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 c5csp272109lbz; Mon, 20 Oct 2014 02:53:01 -0700 (PDT) X-Received: by 10.140.85.233 with SMTP id n96mr32528588qgd.78.1413798780481; Mon, 20 Oct 2014 02:53:00 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id k2si15037550qai.124.2014.10.20.02.53.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 20 Oct 2014 02:53:00 -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 1Xg9c9-0003xe-4R; Mon, 20 Oct 2014 09:50:57 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xg9c6-0003wV-Op for xen-devel@lists.xensource.com; Mon, 20 Oct 2014 09:50:54 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id F5/9B-10419-EFAD4445; Mon, 20 Oct 2014 09:50:54 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1413798652!11904510!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 14569 invoked from network); 20 Oct 2014 09:50:53 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 20 Oct 2014 09:50:53 -0000 X-IronPort-AV: E=Sophos;i="5.04,755,1406592000"; d="scan'208";a="184078594" 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 05:50: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 1Xg9bw-0002Y1-FZ; Mon, 20 Oct 2014 10:50:44 +0100 From: Stefano Stabellini To: Date: Mon, 20 Oct 2014 10:48:15 +0100 Message-ID: <1413798499-28314-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 v8 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.182 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 26c5856..fdcc173 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;