From patchwork Wed Oct 22 13:36:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 39297 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 C0A25202DB for ; Wed, 22 Oct 2014 13:38:21 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id b6sf2042865lbj.11 for ; Wed, 22 Oct 2014 06:38:20 -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=0zIvj6ykTMsOOz7QtMUHuJygx6kpEMbO/IKLEv1mPIA=; b=OO19k7NyxwXTaNMnXZws1vwZBLB7xLf5mZDMGWxI55cQXqIcSJq6xFlgPXNrQCUmhG JcDAUUwGGWCl4/8NHvlnCFyvgnWB+blEuHei+mIWEenZ5XNpazNYRvThoofD+a70D+SV xCMth19DR/Ul/1QlfYtjpEh/CU2BJ3OIBWI9aV4+W7LPretw8NEQDZy4+QgmzxlHEgHx oG6STT4bD9dvMYmmt5WCr6r5RDVXhMaXxUjGVSNtTjiO2qz36v2Hsc5x68t0vgkuw6Kq TbWywseISoLT84JnDIPZJvY1NXeEF5zATJ/kmCeK/Bsxhkao02Mj9scX2UzxYOZT7OvU e6HQ== X-Gm-Message-State: ALoCoQlPRkM9FoXADpMAD0pW0/kvkHBfnheuqzT09lmgIoZ13e7WXmEVchchdde+3rzIMcOMPUre X-Received: by 10.112.254.226 with SMTP id al2mr6552988lbd.1.1413985100572; Wed, 22 Oct 2014 06:38:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.72 with SMTP id q8ls162592laq.98.gmail; Wed, 22 Oct 2014 06:38:20 -0700 (PDT) X-Received: by 10.152.37.136 with SMTP id y8mr12434508laj.69.1413985100424; Wed, 22 Oct 2014 06:38:20 -0700 (PDT) Received: from mail-la0-x230.google.com (mail-la0-x230.google.com. [2a00:1450:4010:c03::230]) by mx.google.com with ESMTPS id ps4si23421609lbb.16.2014.10.22.06.38.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 06:38:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::230 as permitted sender) client-ip=2a00:1450:4010:c03::230; Received: by mail-la0-f48.google.com with SMTP id gi9so2882822lab.21 for ; Wed, 22 Oct 2014 06:38:20 -0700 (PDT) X-Received: by 10.153.8.164 with SMTP id dl4mr41813141lad.29.1413985100251; Wed, 22 Oct 2014 06:38:20 -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 c5csp72653lbz; Wed, 22 Oct 2014 06:38:19 -0700 (PDT) X-Received: by 10.194.82.74 with SMTP id g10mr3722423wjy.116.1413985099583; Wed, 22 Oct 2014 06:38:19 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id e9si18471045wjy.35.2014.10.22.06.38.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Oct 2014 06:38:19 -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 1Xgw5E-00043y-EO; Wed, 22 Oct 2014 13:36:12 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xgw5C-00043t-5J for xen-devel@lists.xen.org; Wed, 22 Oct 2014 13:36:10 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 42/CA-02861-8C2B7445; Wed, 22 Oct 2014 13:36:08 +0000 X-Env-Sender: freddy77@gmail.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1413984966!10884145!1 X-Originating-IP: [209.85.220.172] 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 30233 invoked from network); 22 Oct 2014 13:36:08 -0000 Received: from mail-vc0-f172.google.com (HELO mail-vc0-f172.google.com) (209.85.220.172) by server-7.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 22 Oct 2014 13:36:08 -0000 Received: by mail-vc0-f172.google.com with SMTP id lf12so1969393vcb.17 for ; Wed, 22 Oct 2014 06:36:06 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.221.3.195 with SMTP id nz3mr8060059vcb.43.1413984966414; Wed, 22 Oct 2014 06:36:06 -0700 (PDT) Received: by 10.52.160.129 with HTTP; Wed, 22 Oct 2014 06:36:06 -0700 (PDT) Date: Wed, 22 Oct 2014 14:36:06 +0100 Message-ID: From: Frediano Ziglio To: Julien Grall Cc: Tim Deegan , Stefano Stabellini , Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH 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:c03::230 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. 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. Signed-off-by: Frediano Ziglio --- xen/arch/arm/p2m.c | 22 +++++++++++++++++++--- xen/arch/arm/traps.c | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) Changed from v2: - add comment suggested by Julien Grall (I have some doubt about removing my initial comments or keep it, I kept it removing the code explanation); - 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"); 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 ) {