From patchwork Thu Oct 2 10:02:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38284 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3FF4920549 for ; Thu, 2 Oct 2014 10:06:36 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf973602lbg.1 for ; Thu, 02 Oct 2014 03:06:35 -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=IOjtTsdlQM6xc6Ew8mVGGX6BDSrsSndVYuOwzjtC8QU=; b=KLYQVo6oPDWgk0pyMVzWYZe5dOJ21Q5HPFWdCHbewfpEVcCV6akmx2mKSwdHw0NPky tp3MB59H2kea6A0HV9hsLEncNoXMNkhZPHwKjoebWaHaD/4Ek1EMQBHXFoBbCGGQrFQy iXV48WyxJfbKR84bX0T6gRXDiopMscq8iSsa/Pdo/uXjtlqEr2vgcXH8Yjn3dVZ5I/12 m8KyLj1PjdyXCnNQ9UUVI0IZuQAV7/n9xCqnXkWl81eawZbmGVYwZQd5QtE80VwodVEA ChJQhFTPhqF4+GaN6CfTBHOBBRpFXcVerll1+vRFfiwWFpTwy29I2OoiXtV3FmENE0Rs 1LLQ== X-Gm-Message-State: ALoCoQkOHvMhUOORDc4spblaYEtxCqrzF71CxmHeZivFHp2ECY9hcJEDMnVrp3sxPXBbuqgr71Wk X-Received: by 10.112.157.193 with SMTP id wo1mr311696lbb.19.1412244394991; Thu, 02 Oct 2014 03:06:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.212 with SMTP id q20ls279039lal.22.gmail; Thu, 02 Oct 2014 03:06:34 -0700 (PDT) X-Received: by 10.112.149.2 with SMTP id tw2mr58360511lbb.21.1412244394828; Thu, 02 Oct 2014 03:06:34 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id lt4si5766915lac.82.2014.10.02.03.06.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 03:06:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so1876489lbv.24 for ; Thu, 02 Oct 2014 03:06:34 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr27549171lad.40.1412244394713; Thu, 02 Oct 2014 03:06:34 -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.130.169 with SMTP id of9csp25656lbb; Thu, 2 Oct 2014 03:06:34 -0700 (PDT) X-Received: by 10.221.29.5 with SMTP id rw5mr385205vcb.49.1412244393522; Thu, 02 Oct 2014 03:06:33 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id o10si2761352vci.61.2014.10.02.03.06.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Oct 2014 03:06:33 -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 1XZdFo-00019q-9P; Thu, 02 Oct 2014 10:04:56 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZdFn-00019Y-Ch for xen-devel@lists.xensource.com; Thu, 02 Oct 2014 10:04:55 +0000 Received: from [85.158.139.211:59999] by server-5.bemta-5.messagelabs.com id 70/AE-11546-6432D245; Thu, 02 Oct 2014 10:04:54 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1412244292!11575707!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.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31376 invoked from network); 2 Oct 2014 10:04:54 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-12.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 2 Oct 2014 10:04:54 -0000 X-IronPort-AV: E=Sophos;i="5.04,638,1406592000"; d="scan'208";a="177412876" 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; Thu, 2 Oct 2014 06:04:51 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XZdFe-0001pd-Ke; Thu, 02 Oct 2014 11:04:46 +0100 From: Stefano Stabellini To: Date: Thu, 2 Oct 2014 11:02:35 +0100 Message-ID: <1412244158-12124-1-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 1/4] 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.217.179 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;