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: 118994 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp3885468edl; Wed, 15 Nov 2017 11:36:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMYhJ4KmfNEMQDrBx0pwPi/2xMRdT3nbs0g86inY6wnw+fUuuY8hLxgNrfXlf1GItoEqvCTF X-Received: by 10.107.204.1 with SMTP id c1mr2469235iog.76.1510774594950; Wed, 15 Nov 2017 11:36:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510774594; cv=none; d=google.com; s=arc-20160816; b=bNC5BRn9cusimx0ErdO4YFeEMik+d3SQ2AeXMJtL+3ShN/LDrTXKAj/v3Ah1zLpcIO 8y5OnC1UNFTZgWBlGiA3h6B06I9Qfh+tr1bhXlb19sADDIYXtxc1eV3b68clxYj7Iu2t Xy0jv9J9fds/1dy9lSj8Zknz+Xcfya6JNZjxZEYO9Ac36f686R+QvKmq8hxOe0xgReHN GgM/mMZi5x4p7IVcAb6VSy/rr8elgETAUHq8pwZqNleUfLvpclantufcCLct6V1UGGP5 Nwzm1V6liugV954jGjCM1+R0bF7aqgcOKaGTNhADCHYP8luGvq/nRZTIMK7yjIV8xArt ZYTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=qKL+hto7G5XSFRp4DV0ePM//Dp+shZjcfDH+LXoR+4E=; b=IcIw+bohJFLAtTAbxU4vpOkytphgx0aqsy4DdGKE2rbn8wzWMiSzTWIulE58+1gKN9 52jCky8ND7NiEWfAnwfoQkRnhQrzoiyFu+pNL+BfjZStMCkBtGmWDr/i0gKm2nBkkLaF equ2ChTslHtMJhDF5xSKtK5y/U3yQtkcPIoTrD+TuEzsig8y8Cq4P102icPdtNvP99gq vwya2Zw7TcptscFSDuP6nD3MsNkm+wkYZzgRPfQjWLFPwEA6rXbAqI81ESU6UUWmuFil FPsgUBI4UCUQBYdZ+lK7c5zy8bRzBrBTsc9nOqZx4ybHbJO34uKTV3/H5FK7809dsByj pEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kEjJPJWO; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c3si15638599iob.93.2017.11.15.11.36.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 11:36:34 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kEjJPJWO; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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" 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; }