From patchwork Wed Oct 22 14:17:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 39308 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2DEB0202DB for ; Wed, 22 Oct 2014 14:19:20 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf2055191lab.11 for ; Wed, 22 Oct 2014 07:19:18 -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=YIUnsA1Q61E78YwbMy7aNYZeBorK9SW7MDngNVr1Y28=; b=jdXOL6FIVCeObG+EI/QPOpY10XNYvzVByZn5VoTXV4Zelbao0bNm/eRTf8AW8kO2Sb keTGUP+2xbK8nzBWdYzxCoNqfGMpGe2RLHBASCLvwQULQyntxxNJZ/8cFK1T6WFAjRx4 7wXSkJxPVU7/j5SJuKoX6gzpC1y+wNUUv617gFnOoaeqorS8sPSN18AbssEjreNegUlp fO40LFvO83sEiESbZtTiZjPu1rPuiD+tlOoi+Y5TxV+u7Yovoqnvk0AqOsZ9T1scdnf5 /D/9ByWedLPxWHZmiPwk6wg79eZIlxnkRhQCRAnCgJMD8QBodycNBR0SCvDvLDysRz9l tQNA== X-Gm-Message-State: ALoCoQlU1MqbQ4HLgKQn6P0b73Yk3cSQQzHkRDuq6MvwqgeYs7ubgp0AbTNSil0IOVxhglRFCGUh X-Received: by 10.112.32.163 with SMTP id k3mr235108lbi.17.1413987558944; Wed, 22 Oct 2014 07:19:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.200 with SMTP id y8ls202232lal.93.gmail; Wed, 22 Oct 2014 07:19:18 -0700 (PDT) X-Received: by 10.152.10.99 with SMTP id h3mr3201678lab.94.1413987558776; Wed, 22 Oct 2014 07:19:18 -0700 (PDT) Received: from mail-la0-x22b.google.com (mail-la0-x22b.google.com. [2a00:1450:4010:c03::22b]) by mx.google.com with ESMTPS id l10si23550255lbd.29.2014.10.22.07.19.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 07:19:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22b as permitted sender) client-ip=2a00:1450:4010:c03::22b; Received: by mail-la0-f43.google.com with SMTP id mc6so3028270lab.16 for ; Wed, 22 Oct 2014 07:19:18 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr42293025lbb.46.1413987558672; Wed, 22 Oct 2014 07:19:18 -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 c5csp81188lbz; Wed, 22 Oct 2014 07:19:18 -0700 (PDT) X-Received: by 10.52.92.228 with SMTP id cp4mr697868vdb.77.1413987556608; Wed, 22 Oct 2014 07:19:16 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id se5si8513367vcb.39.2014.10.22.07.19.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Oct 2014 07:19:16 -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 1XgwjO-0006X2-DN; Wed, 22 Oct 2014 14:17:42 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XgwjM-0006Wj-Lg for xen-devel@lists.xen.org; Wed, 22 Oct 2014 14:17:40 +0000 Received: from [193.109.254.147:37644] by server-5.bemta-14.messagelabs.com id 22/F3-28255-48CB7445; Wed, 22 Oct 2014 14:17:40 +0000 X-Env-Sender: freddy77@gmail.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1413987458!11856695!1 X-Originating-IP: [209.85.220.176] 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 19540 invoked from network); 22 Oct 2014 14:17:39 -0000 Received: from mail-vc0-f176.google.com (HELO mail-vc0-f176.google.com) (209.85.220.176) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 22 Oct 2014 14:17:39 -0000 Received: by mail-vc0-f176.google.com with SMTP id hq11so1989986vcb.7 for ; Wed, 22 Oct 2014 07:17:38 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.220.12.18 with SMTP id v18mr36015092vcv.24.1413987455137; Wed, 22 Oct 2014 07:17:35 -0700 (PDT) Received: by 10.52.160.129 with HTTP; Wed, 22 Oct 2014 07:17:35 -0700 (PDT) Date: Wed, 22 Oct 2014 15:17:35 +0100 Message-ID: From: Frediano Ziglio To: Julien Grall Cc: Tim Deegan , Stefano Stabellini , Ian Campbell , xen-devel@lists.xen.org Subject: Re: [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::22b 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(-) 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"); 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 ) {