From patchwork Tue Dec 16 20:08:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 42358 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 878EA25E25 for ; Tue, 16 Dec 2014 20:12:00 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf9232295lbj.3 for ; Tue, 16 Dec 2014 12:11:59 -0800 (PST) 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:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=hAbw++iW9P7bcCv9V7BklMujVfXW5/EYGQJNbElS0UI=; b=bqPDad22sKCFqHBVVljvg77sF9ZsQFhoVXz3yI8kPLgp5anyRnMF6aQJwDiuUKo+rU mZin8G1g80+1gk3X4BG8oFNb7Lc7cGiNBaKRHGOVzq13C56Scs1KdHUuonjMfd4zDBnV bEElUR1ZC1STHBl2zHAp3mqIVKcYPZzZAhqrllBSErtMQKvTNTgvx94NLYL9bjclx3MW khl4bLBCyCW3HmldMwXTn95nZG+GwE1zzAE7NO48WpW/vOn8xJE2Jvf8OGkmVknUfUKb dNO9yXSg4sHRhm/dwdaiNfYkZT5+B8k9np15sdP3EjIU7wOc0QvgCOpwdr3DwP2rxg8x fwFw== X-Gm-Message-State: ALoCoQn2wz2NKHyy9dz1OveVavmM0PCb1glk5jpjcwpvsSNFO6Ilc4GslUJ9SNF/5aYI8+d9YFUL X-Received: by 10.194.92.34 with SMTP id cj2mr9945wjb.5.1418760719470; Tue, 16 Dec 2014 12:11:59 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.98 with SMTP id d2ls940096lae.19.gmail; Tue, 16 Dec 2014 12:11:59 -0800 (PST) X-Received: by 10.152.44.129 with SMTP id e1mr18456497lam.43.1418760719307; Tue, 16 Dec 2014 12:11:59 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id sd7si1815533lbb.51.2014.12.16.12.11.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 12:11:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id gd6so12074276lab.29 for ; Tue, 16 Dec 2014 12:11:59 -0800 (PST) X-Received: by 10.152.87.12 with SMTP id t12mr25246124laz.31.1418760719231; Tue, 16 Dec 2014 12:11:59 -0800 (PST) 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.142.69 with SMTP id ru5csp1149090lbb; Tue, 16 Dec 2014 12:11:58 -0800 (PST) X-Received: by 10.220.170.134 with SMTP id d6mr23775913vcz.20.1418760711327; Tue, 16 Dec 2014 12:11:51 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id te8si637056vdc.52.2014.12.16.12.11.50 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Dec 2014 12:11:51 -0800 (PST) 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 1Y0yQu-0004lh-KY; Tue, 16 Dec 2014 20:09:24 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Y0yQt-0004lD-TT for xen-devel@lists.xenproject.org; Tue, 16 Dec 2014 20:09:24 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id 63/BF-27584-37190945; Tue, 16 Dec 2014 20:09:23 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-4.tower-206.messagelabs.com!1418760562!13733923!1 X-Originating-IP: [74.125.82.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6578 invoked from network); 16 Dec 2014 20:09:22 -0000 Received: from mail-wg0-f42.google.com (HELO mail-wg0-f42.google.com) (74.125.82.42) by server-4.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 16 Dec 2014 20:09:22 -0000 Received: by mail-wg0-f42.google.com with SMTP id k14so2230477wgh.1 for ; Tue, 16 Dec 2014 12:09:22 -0800 (PST) X-Received: by 10.194.89.3 with SMTP id bk3mr11484775wjb.92.1418760561921; Tue, 16 Dec 2014 12:09:21 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id b10sm3382705wiw.9.2014.12.16.12.09.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Dec 2014 12:09:21 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 16 Dec 2014 20:08:44 +0000 Message-Id: <1418760534-18163-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418760534-18163-1-git-send-email-julien.grall@linaro.org> References: <1418760534-18163-1-git-send-email-julien.grall@linaro.org> Cc: Keir Fraser , ian.campbell@citrix.com, tim@xen.org, manish.jaggi@caviumnetworks.com, Julien Grall , Ian Jackson , stefano.stabellini@citrix.com, Jan Beulich Subject: [Xen-devel] [PATCH for 4.6 03/13] xen: Introduce ACCESS_ONCE macro 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: , MIME-Version: 1.0 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: julien.grall@linaro.org 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.42 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: This macro can be used in drivers imported from Linux. Signed-off-by: Julien Grall CC: Ian Jackson CC: Jan Beulich CC: Keir Fraser --- xen/include/xen/compiler.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index 4b3472d..57eb7a6 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -90,4 +90,18 @@ __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ (typeof(ptr)) (__ptr + (off)); }) +/* + * Prevent the compiler from merging or refetching accesses. The compiler + * is also forbidden from reordering successive instances of ACCESS_ONCE(), + * but only when the compiler is aware of some particular ordering. One way + * to make the compiler aware of ordering is to put the two invocations of + * ACCESS_ONCE() in different C statements. + * + * This macro does absolutely -nothing- to prevent the CPU from reordering, + * merging, or refetching absolutely anything at any time. Its main intended + * use is to mediate communication between process-level code and irq/NMI + * handlers, all running on the same CPU. + */ +#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) + #endif /* __LINUX_COMPILER_H */