From patchwork Mon Jul 16 17:27:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 142073 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2677597ljj; Mon, 16 Jul 2018 10:29:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcbrA13f8xk3sWMMjvoKnLW0mAL/J8cqwn0sU4lTn100s/FNxVl8nMrS8umMIIn1sZyrZwV X-Received: by 2002:a6b:6c0b:: with SMTP id a11-v6mr40145356ioh.175.1531762174715; Mon, 16 Jul 2018 10:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531762174; cv=none; d=google.com; s=arc-20160816; b=DnISaBQVs4muef5aadvnMV4o2uH1pxobBclvbtSkY8hq44ahRlmJH2h7NJg7ruXQP7 /dhfEbEIsubG4IUJKaxYXLPiIuWOBovg8y002cX0D91rDRRQPpNS+Gew7Ncp5F6rX1pI SLIhKQLiyy4EL177PlCqU9B1t+mDLtnb64ZaZ28X+va+W5VdytDA44Rnj4Gu/UvPHb4l GHz187QjWpu1DlP1zAw4NDVhzGV6WD4+qxgdZwfdrH8tRz00hwAuV+6in7Vnke3uRmjz DG0E60VZelyRERzAX3sxMkvRfohNUtim2jvxXndByYn6sv63evqz0q+aDdGBpCxUgmv3 uovw== 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=v2ovJxw8nCFJlhCSZlaF4Ol6l0OcCHMaF9K0/b11+aY=; b=NUog+quE4rJIWEsuGKDDpbu+cbkUNs8TBbd1l4tXcKwxapu6yCkRiWBsV76AsM1KOr WlWKit5J+LOrEsrG/WfX9pXgJKjN+FY6jdwCP+9NQ6C5vI8PFMkkiH6xhdpYxL/GSxxw NNKNe2JVy8a/pw1w2Lz8uKL0CpVGznYxDhEFdMGgnTHVCZINFl0Ccvkogz2kFkT54NGG r32Ee38VfJhzHQz1A1TgQ2zHQYbWBwKbkpPuve/DOQNegRASVfkg2ejk+yjWGJ6b5oLU 4zmQNfu7usKvd3RgWfnHVaK4g/ESvq+veLjWMqdbvVHJ8LTA5jQmQnRH5jLqF8yiDsZm K+Kw== 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 r143-v6si9884292itb.122.2018.07.16.10.29.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 10:29:34 -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 1ff7HR-0006RJ-Pe; Mon, 16 Jul 2018 17:27:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7HQ-0006RC-Op for xen-devel@lists.xenproject.org; Mon, 16 Jul 2018 17:27:24 +0000 X-Inumbo-ID: 85efcc13-891d-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 85efcc13-891d-11e8-a6a9-d7ebe60f679a; Mon, 16 Jul 2018 17:27:33 +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 5BB4C7A9; Mon, 16 Jul 2018 10:27:23 -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 9519D3F5B1; Mon, 16 Jul 2018 10:27:22 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jul 2018 18:27:01 +0100 Message-Id: <20180716172712.20294-5-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 04/15] xen/arm: p2m: Reduce the locking section 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 MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The p2m lock is only necessary to prevent gvirt_to_maddr failing when break-before-make sequence is used in the P2M update concurrently on another pCPU. So reduce the locking section. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Note a newline has been dropped to keep the block together. --- xen/arch/arm/p2m.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 14791388ad..5ca7ffe41b 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1415,9 +1415,13 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, if ( v != current ) return NULL; + /* + * The lock is here to protect us against the break-before-make + * sequence used when updating the entry. + */ p2m_read_lock(p2m); - par = gvirt_to_maddr(va, &maddr, flags); + p2m_read_unlock(p2m); if ( par ) { @@ -1445,8 +1449,6 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, } err: - p2m_read_unlock(p2m); - if ( !page && p2m->mem_access_enabled ) page = p2m_mem_access_check_and_get_page(va, flags, v);