From patchwork Mon Mar 23 09:41:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11452569 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B4CC1667 for ; Mon, 23 Mar 2020 09:42:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07D7E2074D for ; Mon, 23 Mar 2020 09:42:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=xen.org header.i=@xen.org header.b="P1mNf3sW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07D7E2074D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass 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 1jGJao-0004Hv-6c; Mon, 23 Mar 2020 09:41:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jGJam-0004HV-UF for xen-devel@lists.xenproject.org; Mon, 23 Mar 2020 09:41:56 +0000 X-Inumbo-ID: 88fb948a-6cea-11ea-b34e-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 88fb948a-6cea-11ea-b34e-bc764e2007e4; Mon, 23 Mar 2020 09:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=LO9Ux1uCue1Zi020/RhpT9BHvEBosZNq+XbjQWDoGr8=; b=P1mNf3sWCRHjMgsAfwmnm3kvoY au+rvCHyf4QUKNm8AnHZRZwk4El7h8/xcr1x/Ti3OLbpiNx8cCSwDmcapFDRj9wEFstzJ+iEme3hG NLp74R0bvYUC2pAKvKlAYKyrccw7DNRSM9rV+vbKDHIQqr6WLyRafRbcQK/Ja9kM2UU0=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jGJam-00006T-6i; Mon, 23 Mar 2020 09:41:56 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=u1bbd043a57dd5a.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jGJal-00041e-Sr; Mon, 23 Mar 2020 09:41:56 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Date: Mon, 23 Mar 2020 09:41:38 +0000 Message-Id: <1acfafbd8ebada1538c9e06323ef0b3bf3f6897c.1584955616.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [Xen-devel] [PATCH 1/5] x86/shim: map and unmap page tables in replace_va_mapping 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: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Reviewed-by: Hongyan Xia --- xen/arch/x86/pv/shim.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index ed2ece8a8a..1229d5ffb3 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -169,15 +169,19 @@ static void __init replace_va_mapping(struct domain *d, l4_pgentry_t *l4start, unsigned long va, mfn_t mfn) { l4_pgentry_t *pl4e = l4start + l4_table_offset(va); - l3_pgentry_t *pl3e = l4e_to_l3e(*pl4e) + l3_table_offset(va); - l2_pgentry_t *pl2e = l3e_to_l2e(*pl3e) + l2_table_offset(va); - l1_pgentry_t *pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(va); + l3_pgentry_t *pl3e = map_l3t_from_l4e(*pl4e) + l3_table_offset(va); + l2_pgentry_t *pl2e = map_l2t_from_l3e(*pl3e) + l2_table_offset(va); + l1_pgentry_t *pl1e = map_l1t_from_l2e(*pl2e) + l1_table_offset(va); struct page_info *page = mfn_to_page(l1e_get_mfn(*pl1e)); put_page_and_type(page); *pl1e = l1e_from_mfn(mfn, (!is_pv_32bit_domain(d) ? L1_PROT : COMPAT_L1_PROT)); + + UNMAP_DOMAIN_PAGE(pl1e); + UNMAP_DOMAIN_PAGE(pl2e); + UNMAP_DOMAIN_PAGE(pl3e); } static void evtchn_reserve(struct domain *d, unsigned int port)