From patchwork Mon Jan 28 11:50:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 156714 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3333243jaa; Mon, 28 Jan 2019 03:52:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN7mCQMdQ5sRGepGuWMeXZ+dkmDDDPE9bBjhEQZwCA9SUksBLV/24CLsfmvZf54vmgS+05Zi X-Received: by 2002:a25:2fd0:: with SMTP id v199mr19992222ybv.194.1548676345849; Mon, 28 Jan 2019 03:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548676345; cv=none; d=google.com; s=arc-20160816; b=wFUdJAlZnVzyfc8PhXNgzl2CuMe+s0mLbp77Vc0MZYm4uk+TIbRVuNdCOyIVH/hHa1 MF5EZL/TPP+zcK7iFRv7UzgC1XGtBbM6CeTQig3/t/ogvXl9QPYnI7U3hxUQajC3/q10 7qs1eWQFn0ekpuDGtedOEErp4MRxQs0SmgLyMGd2JG0jBQ66MKoP0Awe9l9ocaHj8UK2 kPU9iPsuk+vi/f9Yyt1vXUbQKSt1R6wxKG0aZShR1SHeWj92CAYr+SiplIHH4CJrr4OH t41+RW5xV2jZRH3NrY2AOyKd1OS+gln0B/ZoGbdDy8yca8BlcqCfTCH0OtAvsrFX17Dc nQVQ== 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; bh=tWQYAfjFw2fDTyceRNHUburZ+I14pa/6cXLkw1biBtQ=; b=WUunlhq/CRXTB6pX1QAyw0hLhWEAFWCGNJq6MhWlX307VWrox2Olx4GWxZew3CneDX TtN+SLFtp1jH7ecwmPbbcS/WEY4oCKDmBYYEjCvi9IqkE7/lUzNwdPdeRMxHF70/cD2o ZrqD70kdFaoeWMvcA4JD92/KW3cUuTxbsjyngA7SGwQqyrlHjhk2krW+y7H3CZHqb8Vv g8HQfYzd8SrsFLo7JjCRqMbyDj7AHWjDmFlwl095AcYxqO4IXteIv4MsqpZQl4BwnjL2 i9h5gBi4akTljTlSGeJp5wXGLM/FLFO9MQ0+Ba0l9kaKI4ex2WsVT9Iwq7Y2wBlAmM4c HZ5w== 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 h6si20480333ywf.363.2019.01.28.03.52.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 03:52:25 -0800 (PST) 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 1go5Qz-00034u-7K; Mon, 28 Jan 2019 11:50:37 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1go5Qx-00034b-Rb for xen-devel@lists.xenproject.org; Mon, 28 Jan 2019 11:50:35 +0000 X-Inumbo-ID: ebef88aa-22f2-11e9-b8be-b7a5f292b228 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id ebef88aa-22f2-11e9-b8be-b7a5f292b228; Mon, 28 Jan 2019 11:50: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 83BD9EBD; Mon, 28 Jan 2019 03:50:34 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9482E3F59C; Mon, 28 Jan 2019 03:50:33 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 28 Jan 2019 11:50:21 +0000 Message-Id: <20190128115026.3336-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190128115026.3336-1-julien.grall@arm.com> References: <20190128115026.3336-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 v2 2/7] xen/arm: p2m: Provide an helper to generate the VTTBR 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, Andrii Anisov MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A follow-up patch will need to generate the VTTBR in a few places. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Andrii's and Stefano's reviewed-by --- xen/arch/arm/p2m.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 059a39157a..38bfa9964f 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -41,6 +41,11 @@ static const paddr_t level_masks[] = static const uint8_t level_orders[] = { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER }; +static uint64_t generate_vttbr(uint16_t vmid, mfn_t root_mfn) +{ + return (mfn_to_maddr(root_mfn) | ((uint64_t)vmid << 48)); +} + /* Unlock the flush and do a P2M TLB flush if necessary */ void p2m_write_unlock(struct p2m_domain *p2m) { @@ -1364,7 +1369,7 @@ static int p2m_alloc_table(struct domain *d) p2m->root = page; - p2m->vttbr = page_to_maddr(p2m->root) | ((uint64_t)p2m->vmid << 48); + p2m->vttbr = generate_vttbr(p2m->vmid, page_to_mfn(p2m->root)); /* * Make sure that all TLBs corresponding to the new VMID are flushed