From patchwork Thu Oct 23 16:18:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 39386 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 7F1AE24022 for ; Thu, 23 Oct 2014 16:20:57 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf790169lab.3 for ; Thu, 23 Oct 2014 09:20:56 -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=s114kU1mfUngDReV4M+7/u22szytfhVfbFMDO3uax9k=; b=boW0jJxaYGrg5U47EOH8Aiapn9QKBnzNzHBGp1LXrsaNeV0Hj17PIxUHmLWL5FLJtS 7bxSdKQab6jtU3z0BZM7hezsIblu0r76WDRivfi+oaWXb4krzox1GZSm9jlL+H9vOH73 1tqLP0nIrkfwZ3EphLzBq0BZRfK9atMREIt6Gx5X6JMe4RrFqxNrYxsbLwoy+Yq3PTP0 8U8vYMK5zTsVUe5fx+q3SyFfvAI7goA/XeuDWiyYnk4jD+F7u57PBwojrMR7Y4rFsSZg 5np2CD10EXCeHLzGIs+oFaGUGBedrsg4NnxeTF639KIFVmSFXfXyg2Z0lZMwfYEMbxxu ckTg== X-Gm-Message-State: ALoCoQmkThcTmKTJN4F5r9xLSuNqNK+AsqnmhuEjSsmpkGk9+ab4VuaXfJ9ZKiZ4Ho0nf+hnzi4O X-Received: by 10.112.225.135 with SMTP id rk7mr1258984lbc.6.1414081255817; Thu, 23 Oct 2014 09:20:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.5 with SMTP id f5ls336576lah.62.gmail; Thu, 23 Oct 2014 09:20:55 -0700 (PDT) X-Received: by 10.112.173.100 with SMTP id bj4mr6340607lbc.78.1414081255672; Thu, 23 Oct 2014 09:20:55 -0700 (PDT) Received: from mail-la0-x22f.google.com (mail-la0-x22f.google.com. [2a00:1450:4010:c03::22f]) by mx.google.com with ESMTPS id w5si3334404lae.80.2014.10.23.09.20.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 09:20:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22f as permitted sender) client-ip=2a00:1450:4010:c03::22f; Received: by mail-la0-f47.google.com with SMTP id pv20so1170821lab.34 for ; Thu, 23 Oct 2014 09:20:55 -0700 (PDT) X-Received: by 10.112.14.69 with SMTP id n5mr6301676lbc.34.1414081255581; Thu, 23 Oct 2014 09:20:55 -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 c5csp284284lbz; Thu, 23 Oct 2014 09:20:54 -0700 (PDT) X-Received: by 10.52.233.164 with SMTP id tx4mr1632059vdc.65.1414081253800; Thu, 23 Oct 2014 09:20:53 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ka13si1262619vdb.22.2014.10.23.09.20.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Oct 2014 09:20:53 -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 1XhL6G-0000Dy-Bn; Thu, 23 Oct 2014 16:18:56 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XhL6F-0000Dk-3y for xen-devel@lists.xen.org; Thu, 23 Oct 2014 16:18:55 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 72/04-02704-E6A29445; Thu, 23 Oct 2014 16:18:54 +0000 X-Env-Sender: freddy77@gmail.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1414081132!11382698!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 30104 invoked from network); 23 Oct 2014 16:18:53 -0000 Received: from mail-vc0-f176.google.com (HELO mail-vc0-f176.google.com) (209.85.220.176) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 23 Oct 2014 16:18:53 -0000 Received: by mail-vc0-f176.google.com with SMTP id hq11so875086vcb.7 for ; Thu, 23 Oct 2014 09:18:52 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.52.170.4 with SMTP id ai4mr1649416vdc.48.1414081132316; Thu, 23 Oct 2014 09:18:52 -0700 (PDT) Received: by 10.52.160.129 with HTTP; Thu, 23 Oct 2014 09:18:52 -0700 (PDT) Date: Thu, 23 Oct 2014 17:18:52 +0100 Message-ID: From: Frediano Ziglio To: Ian Campbell Cc: Stefano Stabellini , xen-devel@lists.xen.org, Julien Grall , Tim Deegan Subject: [Xen-devel] [PATCH for-xen-4-5 v4] 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::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 | 24 ++++++++++++++++++++---- xen/arch/arm/traps.c | 2 +- 2 files changed, 21 insertions(+), 5 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 v3: - removed a possible false warning from some compilers. 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..bad2b18 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1176,13 +1176,29 @@ struct page_info *get_page_from_gva(struct domain *d { struct p2m_domain *p2m = &d->arch.p2m; struct page_info *page = NULL; - paddr_t maddr; - - ASSERT(d == current->domain); + paddr_t maddr = 0; + 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 ) {