From patchwork Mon Jul 16 17:27:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 142077 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2677688ljj; Mon, 16 Jul 2018 10:29:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfonDz2lGDJQ38+1UwMBezp4lXGQqxfhbwHNDzgjjI0Anr51tTAWrWAu4cA+/Juld5wJmcC X-Received: by 2002:a24:d80a:: with SMTP id b10-v6mr13349136itg.141.1531762180451; Mon, 16 Jul 2018 10:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531762180; cv=none; d=google.com; s=arc-20160816; b=nK8alsQzq/JHt7SpGvnhnsNSOy2p46DAfRC1Sk1nfwOJLV7kxOzukWn6T82XYus3/p ehDoNgkD30YoGJ5KS1jg1qkXq924ZsqElJ7vVIx40XKHD/61U0jaA9a1Aj0rQGsKJcuE lbhAkEkHNTmnXPoW5V0Tz/X7RdgT0tSWItDTHjsYLTV8sao/K9U1SOPHURNNAgymrQ5B WmUkN21U2Dv5Fhs2XBQN4P06mFf67r5QV4QFoe5K9YhiyFNjrzHyF+IV0Iz13iOCmpOO 4/xM6JhlC0ezOudHjkIcjnxmwwrVrPBfUCuWp1FwFmDFor6DFStfUt4pySrQOd9l8Gnc s6hw== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=iTFZLTmy8rqy8NmGHWQ/O2JbhTZXp13H+mM1kmb6P8o=; b=b5Gela0T26z6/t9wq7OzF2QWcwiddyqYF3kMVNMrUjQ5A69XtiTmAfdfRdM02RExSE 0cVMy6ZS4/4P0HtG9sKIV2TrgrpHbHEZH3xhHfQZMlcfBiIxETly/I9FnMPMTdPc/FSf H3FG73NrzUb+ly5dbqI+0OnxfXhDCoISKKhSROEeuknuXN29G6GISkeic7CeAFFXkF6A BPYG0jQJXyvEHTb4HiU2sTrH496fq21e3b3j543+fasDhXzEBGkP2FqlejwTFycMFSQW hpzle48d2WngYexLGWb4UVz6KB0QEFax9F9r16y5nFn5yAYNtETXpyf5QORBygdK29Z/ K6uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c10-v6si22222146ioh.248.2018.07.16.10.29.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 10:29:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7HT-0006RV-3A; Mon, 16 Jul 2018 17:27:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7HR-0006RM-UU for xen-devel@lists.xenproject.org; Mon, 16 Jul 2018 17:27:25 +0000 X-Inumbo-ID: 86b7cead-891d-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 86b7cead-891d-11e8-a6a9-d7ebe60f679a; Mon, 16 Jul 2018 17:27:34 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A7B0E15AD; Mon, 16 Jul 2018 10:27:24 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9A5183F5B1; Mon, 16 Jul 2018 10:27:23 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jul 2018 18:27:02 +0100 Message-Id: <20180716172712.20294-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180716172712.20294-1-julien.grall@arm.com> References: <20180716172712.20294-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 05/15] xen/arm: p2m: Limit call to mem access code use in get_page_from_gva X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org, Tamas K Lengyel , Razvan Cojocaru MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Mem access has only an impact on the hardware translation between a guest virtual address and the machine physical address. So it is not necessary to fallback to memaccess for all the other case (e.g when it is not possible to acquire the page behind the MFN). Signed-off-by: Julien Grall Acked-by: Razvan Cojocaru Reviewed-by: Stefano Stabellini --- Cc: Razvan Cojocaru Cc: Tamas K Lengyel --- xen/arch/arm/p2m.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 5ca7ffe41b..ebf74760fa 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1425,17 +1425,24 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, if ( par ) { + /* + * When memaccess is enabled, the translation GVA to MADDR may + * have failed because of a permission fault. + */ + if ( p2m->mem_access_enabled ) + return p2m_mem_access_check_and_get_page(va, flags, v); + dprintk(XENLOG_G_DEBUG, "%pv: gvirt_to_maddr failed va=%#"PRIvaddr" flags=0x%lx par=%#"PRIx64"\n", v, va, flags, par); - goto err; + return NULL; } if ( !mfn_valid(maddr_to_mfn(maddr)) ) { dprintk(XENLOG_G_DEBUG, "%pv: Invalid MFN %#"PRI_mfn"\n", v, mfn_x(maddr_to_mfn(maddr))); - goto err; + return NULL; } page = mfn_to_page(maddr_to_mfn(maddr)); @@ -1445,13 +1452,9 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, { dprintk(XENLOG_G_DEBUG, "%pv: Failing to acquire the MFN %#"PRI_mfn"\n", v, mfn_x(maddr_to_mfn(maddr))); - page = NULL; + return NULL; } -err: - if ( !page && p2m->mem_access_enabled ) - page = p2m_mem_access_check_and_get_page(va, flags, v); - return page; }