From patchwork Wed Nov 28 16:49:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 152314 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1321485ljp; Wed, 28 Nov 2018 08:52:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/VjKSs6vS1b2TEX7Inx94acL7bPDesWVOtuBb814Th/tZNrjBW0syQE4Y0S7DfduubHiOOS X-Received: by 2002:a25:9c09:: with SMTP id c9-v6mr38695413ybo.1.1543423946491; Wed, 28 Nov 2018 08:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543423946; cv=none; d=google.com; s=arc-20160816; b=DxK7L7ECGS6N6MXAJ5fod7EZSSy886nTyLo/ugJVBy4XmGwHxjvpv8mxwXCfCpUiWr HS37w3Q9dy/YgtINdbelU/8HL6U0mKpNnnh7wbXni5hQN5bhR6X4FBbWGhkWfxBncxHy x+ru+GfJqrt6Vt6Eqi6mvCwuHEX7arWCPc3WlCusv5JfBreds9bIM+uEFOAx7HthVQn/ J2zBdd1mDUCBFbF1hXOMCJmOdc5tTQxqd7oaquhgGXL9Ey6TCZct6qo60vBSn5/Gr5TH xVtmZk/8ruF+jKFqHT+FlwehikEh1r0EB7uL0urf62L6+U/usBX+t1NNUpfTFDcxFECd mXEA== 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=WPg3novGpngwZxssf5JutRxohN2dIPf9r1qMlX1naSc=; b=Hn9mN2IKSYYR34SkRVaFz0dpOySbBNKX2bcjpUHt3OHGNSUz/AReCGrcX77EjEh+kc Fj8gVv483gArHR4/ruElV6cHiVcK8tJCT1otWm1oijlrkUZawRvaKtKhGC/oZWp7OUsF Av28efdiaS3KDkDg9QGT3EwSC715d1Z5iXgUUyJ8HmfyMsNGlPZjDd6/ALuoHAOjDl3I 6k3nCr0dXRCsPjFkj7/CHzJWHllnrItIp7Z8pOPKnZHMBEJ4QHl5nJxXCowVGphZs2yB fKBSp+L08bezd7ax3tFu0Z/PaYipBCFIEFy4/EcEs0C0Fse8Ni1m1QqYRZyNDDWZGuD0 4nZg== 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 i17-v6si5497481ybe.230.2018.11.28.08.52.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Nov 2018 08:52:26 -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 1gS32c-0001hh-0D; Wed, 28 Nov 2018 16:50:22 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gS32a-0001hC-JB for xen-devel@lists.xenproject.org; Wed, 28 Nov 2018 16:50:20 +0000 X-Inumbo-ID: b0ba2ba6-f32d-11e8-9a16-bc764e045a96 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id b0ba2ba6-f32d-11e8-9a16-bc764e045a96; Wed, 28 Nov 2018 16:50:19 +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 A9A25382C; Wed, 28 Nov 2018 08:49:49 -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 BCC2A3F575; Wed, 28 Nov 2018 08:49:48 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 28 Nov 2018 16:49:33 +0000 Message-Id: <20181128164939.8329-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181128164939.8329-1-julien.grall@arm.com> References: <20181128164939.8329-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 2/8] 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: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org 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 --- 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 6c76298ebc..8ebf1e8dba 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -47,6 +47,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) { @@ -1147,7 +1152,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