From patchwork Fri Oct 17 16:14: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: 38895 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 348FA20973 for ; Fri, 17 Oct 2014 16:16:42 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf759881wiw.11 for ; Fri, 17 Oct 2014 09:16:41 -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:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive :content-type:content-transfer-encoding; bh=g5JRHq0Z0DJJe6f13b0iO7IKTJaPAvnOhPoNr45qn6M=; b=NJj38JsD+4kGyQEypLb8ENnRx6etJZ+aPXx//UsgrKV5g+BItspgVFVoK++dVBp8sa +/H9K2+mkOWtNEB3Hqpawbw2gpWoftStjaE++HBtZzM2lpDhq4MXDjOk6XQfPzkrvDc7 8RUDlYLVRs9Q0ioFOqAshKO3R16/chZ8vv/eWqFTq0SGhTCkr/LYaRSgfW6VFo7E6obZ WA33rHZSFlk5rRh2/WlBtrQdVZKGwerw5ZLGICU/nuyaPuzuDbTmu59cHTmbP3/EwVA1 5YEwUXQPq0bFHkiItIt17qqrTsPswGryGiC9y3uz8NwXIT93ddE05nujZ9UMx+JyncVI do3g== X-Gm-Message-State: ALoCoQkbOyADu9F1hZ5pCFlhTFmTqF455zpHtXaR2ybF8gTu7dZTj8uaEdZahppqekdXi2/G2mnK X-Received: by 10.112.217.102 with SMTP id ox6mr20470lbc.19.1413562601305; Fri, 17 Oct 2014 09:16:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.133 with SMTP id b5ls252832lah.26.gmail; Fri, 17 Oct 2014 09:16:41 -0700 (PDT) X-Received: by 10.112.172.231 with SMTP id bf7mr4041784lbc.100.1413562601159; Fri, 17 Oct 2014 09:16:41 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id kr10si2747071lac.72.2014.10.17.09.16.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Oct 2014 09:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ge10so983376lab.10 for ; Fri, 17 Oct 2014 09:16:41 -0700 (PDT) X-Received: by 10.152.29.8 with SMTP id f8mr9926817lah.56.1413562601042; Fri, 17 Oct 2014 09:16:41 -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 c5csp257524lbz; Fri, 17 Oct 2014 09:16:40 -0700 (PDT) X-Received: by 10.140.101.120 with SMTP id t111mr13039268qge.6.1413562599855; Fri, 17 Oct 2014 09:16:39 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id q4si3038730qci.39.2014.10.17.09.16.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 17 Oct 2014 09:16:39 -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 1XfAB6-0003Ap-79; Fri, 17 Oct 2014 16:14:56 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XfAB5-0003Ad-7G for xen-devel@lists.xenproject.org; Fri, 17 Oct 2014 16:14:55 +0000 Received: from [85.158.137.68:54435] by server-7.bemta-3.messagelabs.com id E1/2C-01084-E7041445; Fri, 17 Oct 2014 16:14:54 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-2.tower-31.messagelabs.com!1413562493!11399149!1 X-Originating-IP: [209.85.212.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8707 invoked from network); 17 Oct 2014 16:14:53 -0000 Received: from mail-wi0-f173.google.com (HELO mail-wi0-f173.google.com) (209.85.212.173) by server-2.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 17 Oct 2014 16:14:53 -0000 Received: by mail-wi0-f173.google.com with SMTP id fb4so2536285wid.0 for ; Fri, 17 Oct 2014 09:14:53 -0700 (PDT) X-Received: by 10.194.62.166 with SMTP id z6mr11732923wjr.44.1413562493180; Fri, 17 Oct 2014 09:14:53 -0700 (PDT) Received: from belegaer.uk.xensource.com ([185.25.64.249]) by mx.google.com with ESMTPSA id u5sm3408wiz.9.2014.10.17.09.14.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Oct 2014 09:14:52 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 17 Oct 2014 17:14:44 +0100 Message-Id: <1413562484-13383-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH for 4.5] xen/arm: flush_tlb_domain: Disable IRQ when flushing TLB of another domain 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.51 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: When Xen is flushing the TLB for another domain than current, it has to switch temporaly to the P2M of this domain. If the IRQs are enabled, it may be possible to receive an interrupt that require to use the P2M of the current domain, or even temporaly switch to another P2M. For the former case, the translation would be wrong. For the latter one, as the handler would restore the current P2M, Xen would flush the wrong domain TLB. Thankfully we don't have such interrupt handler, but it may be necessary in the future to do that during when the user asks to dump domain stack via a keystroke. Signed-off-by: Julien Grall --- I'd like to see this patch in Xen 4.5. This may help people that want to implement a such keystroke handler (and even fix the current '0'). It will also avoid to introduce possible security issue on their own Xen-based product. The code is self contained and the interrupt is disabled/enabled within the same function and same check. --- xen/arch/arm/p2m.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 1585d35..c02bb2c 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -112,17 +112,25 @@ void p2m_restore_state(struct vcpu *n) void flush_tlb_domain(struct domain *d) { + unsigned long flags = 0; + /* Update the VTTBR if necessary with the domain d. In this case, * it's only necessary to flush TLBs on every CPUs with the current VMID * (our domain). */ if ( d != current->domain ) + { + local_irq_save(flags); p2m_load_VTTBR(d); + } flush_tlb(); if ( d != current->domain ) + { p2m_load_VTTBR(current->domain); + local_irq_restore(flags); + } } /*