From patchwork Wed Nov 15 19:34:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 10060091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83E14604D4 for ; Wed, 15 Nov 2017 19:36:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 744812A281 for ; Wed, 15 Nov 2017 19:36:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67EE12A286; Wed, 15 Nov 2017 19:36:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CA8BF2A286 for ; Wed, 15 Nov 2017 19:36:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eF3S1-0006Tf-UN; Wed, 15 Nov 2017 19:34:21 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eF3S1-0006TM-6R for xen-devel@lists.xen.org; Wed, 15 Nov 2017 19:34:21 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 72/B3-00983-CB69C0A5; Wed, 15 Nov 2017 19:34:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsXiVRvkpLt7Gk+ UwYceE4slHxezODB6HN39mymAMYo1My8pvyKBNePbl1WsBRPkKnZse83SwHhSrIuRi0NIYCKj RPOLmewgDovAPGaJK8tvsoA4EgL9rBKTzl4BynACOXkSh6ddZoWw0yTmnV7HBmFXSay/PB2og QNolJrEmjdREFP7mCQWdq5hAomzCehIrJtRC1IuIiAtce3zZUYQm1nAWeLdpC8sILawQIjE2b UdYHEWAVWJA0s/ga3iFbCWuP14FTPEKnmJXW0XWUFGcgrYSJw5HAwSFgIqmbRlNdMERsEFjAy rGDWKU4vKUot0jUz0kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzECw62egYFxB+Or 436HGCU5mJREeZ1/c0cJ8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuA9OJUnSkiwKDU9tSItMwcY+ DBpCQ4eJRHeUJA0b3FBYm5xZjpE6hSjJce+Pbf+MHE8m/m6gZlj2tXWJmYhlrz8vFQpcd4OkA YBkIaM0jy4cbDovMQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmHcayBSezLwSuK2vgA5iAjr I5gY3yEEliQgpqQZGK4O+ZEeF3Rxx86oXHXVpWCLUeja9bn90sUatwq6WP02TLD76WQebcuTr C195cOWw/hv++ILm11Uffk9Yd8ymTs7D7V7vyQOnl83+rlLrmTRj3p69s1+rHOd47ah6cUuaZ 6peEZeQGqPgfcdfi9frei4/5mD32+DsNJ65sqkzfjFfX/VFp+OKEktxRqKhFnNRcSIA4Wc9S8 kCAAA= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-31.messagelabs.com!1510774459!107581650!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 40637 invoked from network); 15 Nov 2017 19:34:19 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-7.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 15 Nov 2017 19:34:19 -0000 Received: by mail-wm0-f66.google.com with SMTP id b189so5191330wmd.0 for ; Wed, 15 Nov 2017 11:34:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3GonYT1RUyJUB5kRjdyEukSpzHjgTSgOBgh6QL/VeaU=; b=kEjJPJWOko3BXboDkMvlj2s5Tf9VYXmxC2IxRsX9C0naGyrx2PIRNGy3L8Jm50INWK QhRtTSjcRxJJ1PZr/AyGQcFGIMp7mQ0XjJvJHu3R4ZdcBU52BwCdGqeNt1t5lPm9biWk EZ3bEJzQqSaSHJAf8YPcSC8qgridqhOQ5d8Og= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3GonYT1RUyJUB5kRjdyEukSpzHjgTSgOBgh6QL/VeaU=; b=IRvlAM46StlHNYUbTvBbSk0t4Vz90ROMvFCEHvpLjSl+XYsmHMDd9H4Cv4b0KauUXH 7DpFH+XD5jB4Sa8PTzwFhd7WvKCFNzneJ5Cd584/ziAjfNTmcvGmbdPig+yUgcU/ytHo Dtk6tsoBVE0gClQoMbUk9RXe5PgMkxXvFXwO+Of3PIbOEj5yCJtls/Deezg4vHAr2VZp m+Lzo6jSyWeEz4qT7RiB5iCB9naakSaPC11ueaN6+IZoxNbzl4EzyZuVe3vXGJZn491i 0iETCzFkwwE+tsZErVtzS5XO6fz3uNuYONSpzt6YGE3yeZ89iYpQdd0HECeM6QsThyuL 5g6Q== X-Gm-Message-State: AJaThX6UkYRxnZ/66C/1inUc0bN+tzXaNBjcWgpitOM2rccD7Mk2mLIB 8ShVz9YTm8Vnyx1/d1LQ2MPPnT8PG/0= X-Google-Smtp-Source: AGs4zMZtwOBHl5MtXO+VdCiQRNs/Bp0wyPcHDudYQwiUTsYdw7RcLViR4KCmVkFOOl4QFG4CCop3kw== X-Received: by 10.28.66.215 with SMTP id k84mr13338764wmi.143.1510774459215; Wed, 15 Nov 2017 11:34:19 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id x63sm18534330wma.39.2017.11.15.11.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 11:34:18 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 15 Nov 2017 19:34:13 +0000 Message-Id: <20171115193414.7678-2-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171115193414.7678-1-julien.grall@linaro.org> References: <20171115193414.7678-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall Subject: [Xen-devel] [PATCH for-4.10 1/2] xen/arm: mm: Change the return value of gvirt_to_maddr X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, gvirt_to_maddr return -EFAULT when the translation failed. It might be useful to return the PAR_EL1 (Physical Address Register) in such a case to get a better idea of the reason. So modify the return value to use 0 on sucess or return the PAR on failure. The callers are modified to reflect the change of the return value. Note that with the change in gvirt_to_maddr, ma needs to be initialized to avoid GCC been confused (i.e value may be unitialized) with the new construction. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 8 ++++---- xen/arch/arm/kernel.c | 8 ++++---- xen/arch/arm/p2m.c | 6 +++--- xen/include/asm-arm/mm.h | 9 +++++++-- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index bf29299707..c74f4dd69d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2002,15 +2002,15 @@ static void initrd_load(struct kernel_info *kinfo) for ( offs = 0; offs < len; ) { - int rc; - paddr_t s, l, ma; + uint64_t par; + paddr_t s, l, ma = 0; void *dst; s = offs & ~PAGE_MASK; l = min(PAGE_SIZE - s, len); - rc = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); - if ( rc ) + par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); + if ( par ) { panic("Unable to translate guest address"); return; diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index c2755a9ab9..a6c6413712 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -167,15 +167,15 @@ static void kernel_zimage_load(struct kernel_info *info) paddr, load_addr, load_addr + len); for ( offs = 0; offs < len; ) { - int rc; - paddr_t s, l, ma; + uint64_t par; + paddr_t s, l, ma = 0; void *dst; s = offs & ~PAGE_MASK; l = min(PAGE_SIZE - s, len); - rc = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); - if ( rc ) + par = gvirt_to_maddr(load_addr + offs, &ma, GV2M_WRITE); + if ( par ) { panic("Unable to map translate guest address"); return; diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 68b488997d..f6b3d8e421 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1414,7 +1414,7 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, struct p2m_domain *p2m = p2m_get_hostp2m(d); struct page_info *page = NULL; paddr_t maddr = 0; - int rc; + uint64_t par; /* * XXX: To support a different vCPU, we would need to load the @@ -1425,9 +1425,9 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, p2m_read_lock(p2m); - rc = gvirt_to_maddr(va, &maddr, flags); + par = gvirt_to_maddr(va, &maddr, flags); - if ( rc ) + if ( par ) goto err; if ( !mfn_valid(maddr_to_mfn(maddr)) ) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index cd6dfb54b9..ad2f2a43dc 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -266,11 +266,16 @@ static inline void *maddr_to_virt(paddr_t ma) } #endif -static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags) +/* + * Translate a guest virtual address to a machine address. + * Return the fault information if the translation has failed else 0. + */ +static inline uint64_t gvirt_to_maddr(vaddr_t va, paddr_t *pa, + unsigned int flags) { uint64_t par = gva_to_ma_par(va, flags); if ( par & PAR_F ) - return -EFAULT; + return par; *pa = (par & PADDR_MASK & PAGE_MASK) | ((unsigned long) va & ~PAGE_MASK); return 0; }