From patchwork Fri Oct 3 14:50:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 38327 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C86562057C for ; Fri, 3 Oct 2014 14:55:02 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id hi2sf913757wib.5 for ; Fri, 03 Oct 2014 07:55:01 -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=gJv6kizQ9ByEoI+W50yBMJtZMsATv7iLtXgF1gPx05svXF6X4fSd9ZSzK/oOrHEj48 O9Rcf8cs2ky6PzqZfDo0wd6Ck4Z9CwK0tV5nUFd5Qei9WoyiOiX3oZnlXypGIVc40TWz z3HtNWRTDW5RJGd+Z68yW22oVKEDX3YB9GncZ/1iQ+PmH+Uog3LgrNQYP7z2PtkOZ83D CKcrC2pk0ETnM5UhP/Vt98qTm93fLISwChX4QHOrg76otZJ8e9u5mo+b5nRBIRCJcII9 vpNvyI5LEFXJqvVibv+D+MakJK3qWIuEPlbmkwXKSjVGTQczVqUY6Pngon2oFvSEpWpQ f87g== X-Gm-Message-State: ALoCoQk4Y+UWLovuF5rHxsQSfrfgzAkCQzxkVYbjRioyiMNAG5xqp+e8Iqugo2E0k9J75iGdxeM1 X-Received: by 10.112.145.136 with SMTP id su8mr1079406lbb.9.1412348101902; Fri, 03 Oct 2014 07:55:01 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.133 with SMTP id am5ls27396lac.54.gmail; Fri, 03 Oct 2014 07:55:01 -0700 (PDT) X-Received: by 10.112.91.41 with SMTP id cb9mr6017467lbb.53.1412348101738; Fri, 03 Oct 2014 07:55:01 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by mx.google.com with ESMTPS id uf2si11510376lbb.103.2014.10.03.07.55.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 Oct 2014 07:55:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id b6so1148905lbj.31 for ; Fri, 03 Oct 2014 07:55:01 -0700 (PDT) X-Received: by 10.112.75.233 with SMTP id f9mr3760079lbw.102.1412348101332; Fri, 03 Oct 2014 07:55:01 -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 of9csp242265lbb; Fri, 3 Oct 2014 07:55:00 -0700 (PDT) X-Received: by 10.52.245.66 with SMTP id xm2mr1985521vdc.36.1412348100127; Fri, 03 Oct 2014 07:55:00 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id sh5si4567231vcb.12.2014.10.03.07.54.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 03 Oct 2014 07:55: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 1Xa4Eb-0002yK-2x; Fri, 03 Oct 2014 14:53:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xa4Ea-0002xt-Dh for xen-devel@lists.xensource.com; Fri, 03 Oct 2014 14:53:28 +0000 Received: from [85.158.137.68:53079] by server-1.bemta-3.messagelabs.com id E4/0A-30185-768BE245; Fri, 03 Oct 2014 14:53:27 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1412348005!11364255!2 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 1841 invoked from network); 3 Oct 2014 14:53:27 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-2.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 3 Oct 2014 14:53:27 -0000 X-IronPort-AV: E=Sophos;i="5.04,647,1406592000"; d="scan'208";a="177906022" 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; Fri, 3 Oct 2014 10:52:59 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xa4E2-0000Fl-8d; Fri, 03 Oct 2014 15:52:54 +0100 From: Stefano Stabellini To: Date: Fri, 3 Oct 2014 15:50:42 +0100 Message-ID: <1412347845-27755-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 v2 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.172 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;