From patchwork Thu Oct 23 08:46:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 39343 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A378920341 for ; Thu, 23 Oct 2014 08:48:39 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id d1sf575492wiv.2 for ; Thu, 23 Oct 2014 01:48:38 -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:mime-version:date:message-id:from :to: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=8KIhdCOMLrFtHA0HRUf/0IP20yq7CgiJ1968WhKLCtw=; b=kZk862aa0McY6VP0HG1fHS8/Q7bWSCPpkNUr3ZU/CncC4L/vdhOf0nwP3ZS/e6yyI+ s7B6d30wTk3uuZs+0eLj+oeYgbGqYmBpesGygd81sFdgPAk5GbHewqA7ghL7SY/2KQka 7XqxLYniV3DosYkUPk4DQb+cbWoKeOtxzRbQANxXXiScpXvN6FLXp8MAGc35wb5uk9IZ f39TP9l3xN/gMtAFPF4bBEISiikTqU2qPGZN2DGJryMLa2aMifHaOkuY4bBt5hhWbo1u Af7nl/UAhcvxygxP575YvgWbQHnF6awEwTKR48AyPiX4g0Pn2GbmmxJrOYDOniKcFZkD qCpw== X-Gm-Message-State: ALoCoQkJ8OO4rJdxR6PNSoEJYWL4FoDMTiU/qQ/3rn/GF1pP5hUduYxC8sVY+yfpORxOdTr7Cc2d X-Received: by 10.112.24.42 with SMTP id r10mr267506lbf.15.1414054118798; Thu, 23 Oct 2014 01:48:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.43 with SMTP id cj11ls288076lad.85.gmail; Thu, 23 Oct 2014 01:48:38 -0700 (PDT) X-Received: by 10.152.21.9 with SMTP id r9mr3545192lae.76.1414054118656; Thu, 23 Oct 2014 01:48:38 -0700 (PDT) Received: from mail-lb0-x22f.google.com (mail-lb0-x22f.google.com. [2a00:1450:4010:c04::22f]) by mx.google.com with ESMTPS id q1si1629774laq.20.2014.10.23.01.48.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 01:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) client-ip=2a00:1450:4010:c04::22f; Received: by mail-lb0-f175.google.com with SMTP id u10so442119lbd.20 for ; Thu, 23 Oct 2014 01:48:38 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr3411913laz.27.1414054118530; Thu, 23 Oct 2014 01:48:38 -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 c5csp219383lbz; Thu, 23 Oct 2014 01:48:37 -0700 (PDT) X-Received: by 10.224.25.197 with SMTP id a5mr4091117qac.74.1414054117103; Thu, 23 Oct 2014 01:48:37 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id u6si1906909qap.12.2014.10.23.01.48.36 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Oct 2014 01:48:37 -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 1XhE2M-0006DZ-PN; Thu, 23 Oct 2014 08:46:26 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XhE2L-0006DU-JE for xen-devel@lists.xen.org; Thu, 23 Oct 2014 08:46:25 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 08/34-03128-060C8445; Thu, 23 Oct 2014 08:46:24 +0000 X-Env-Sender: freddy77@gmail.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1414053983!11103203!1 X-Originating-IP: [209.85.220.175] X-SpamReason: No, hits=0.3 required=7.0 tests=RCVD_BY_IP X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22704 invoked from network); 23 Oct 2014 08:46:24 -0000 Received: from mail-vc0-f175.google.com (HELO mail-vc0-f175.google.com) (209.85.220.175) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 23 Oct 2014 08:46:24 -0000 Received: by mail-vc0-f175.google.com with SMTP id id10so347109vcb.6 for ; Thu, 23 Oct 2014 01:46:22 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.52.29.131 with SMTP id k3mr2310143vdh.2.1414053982731; Thu, 23 Oct 2014 01:46:22 -0700 (PDT) Received: by 10.52.160.129 with HTTP; Thu, 23 Oct 2014 01:46:22 -0700 (PDT) Date: Thu, 23 Oct 2014 09:46:22 +0100 Message-ID: From: Frediano Ziglio To: Konrad Rzeszutek Wilk Cc: Stefano Stabellini , Julien Grall , Tim Deegan , Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH for-xen-4-5 v3] xen/arm: dump guest stack even if not the current VCPU 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-Original-Sender: freddy77@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Frediano Ziglio If show_guest_stack was called from Xen context (for instance hitting '0' key on Xen console) get_page_from_gva was not able to get the page returning NULL. Detecting different domain and changing VTTBR register make get_page_from_gva works for different domains. Signed-off-by: Frediano Ziglio --- xen/arch/arm/p2m.c | 22 +++++++++++++++++++--- xen/arch/arm/traps.c | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) This is a bug fix to fix guest stack dumps. The function get_page_from_gva is used in hot path (see arch/arm/guestcopy.c) but always with the current domain. The function will be used with another domain than current only when the stack of the guest will be dumped. The code added is self-containted. Changed from v2: - add comment suggested by Julien Grall; - modify code path to avoid keeping IRQ disabled too much (Julien Grall); - collapse change in a single if to improve performances. Tested manually. printk("Failed to convert stack to physical address\n"); -- 1.9.1 diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 1585d35..2345199 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1177,12 +1177,28 @@ struct page_info *get_page_from_gva(struct domain *d, vaddr_t va, struct p2m_domain *p2m = &d->arch.p2m; struct page_info *page = NULL; paddr_t maddr; - - ASSERT(d == current->domain); + int rc; spin_lock(&p2m->lock); - if ( gvirt_to_maddr(va, &maddr, flags) ) + if ( unlikely(d != current->domain) ) + { + unsigned long irq_flags; + + local_irq_save(irq_flags); + p2m_load_VTTBR(d); + + rc = gvirt_to_maddr(va, &maddr, flags); + + p2m_load_VTTBR(current->domain); + local_irq_restore(irq_flags); + } + else + { + rc = gvirt_to_maddr(va, &maddr, flags); + } + + if ( rc ) goto err; if ( !mfn_valid(maddr >> PAGE_SHIFT) ) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index f6fc8f8..4c93250 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -892,7 +892,7 @@ static void show_guest_stack(struct vcpu *v, struct cpu_user_regs *regs) return; } - page = get_page_from_gva(current->domain, sp, GV2M_READ); + page = get_page_from_gva(v->domain, sp, GV2M_READ); if ( page == NULL ) {