From patchwork Fri Apr 17 09:52:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11494647 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 0B233174A for ; Fri, 17 Apr 2020 09:52:55 +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 DBC8B21D94 for ; Fri, 17 Apr 2020 09:52:54 +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="fsoDzbLe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBC8B21D94 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 1jPNfe-0000M6-Nm; Fri, 17 Apr 2020 09:52:26 +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 1jPNfd-0000Lc-0p for xen-devel@lists.xenproject.org; Fri, 17 Apr 2020 09:52:25 +0000 X-Inumbo-ID: 2030b313-8091-11ea-8c9b-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2030b313-8091-11ea-8c9b-12813bfff9fa; Fri, 17 Apr 2020 09:52:20 +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=fgPHa6/lewyPUGLpvLuUr7Qnl8FXYus9SeBUggwCmRY=; b=fsoDzbLe09VaPA4VGTGG/T2hUA ng16FFZwNw0bU5Df2LGAgfBie/sIqtw/GHzip1fzwercdIajGh2lUi7UvIwZvPcWUSzbZpRQ+4sr2 JC12EYZYIOBOWUlpfl1yhEqZxMD+E54kgExpa6CVvZy3QCRiEiQ/dvIiOVgsZM4x9HFo=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfX-0002fd-9o; Fri, 17 Apr 2020 09:52:19 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] 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 1jPNfW-000304-TS; Fri, 17 Apr 2020 09:52:19 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH 1/6] x86_64/mm: map and unmap page tables in cleanup_frame_table Date: Fri, 17 Apr 2020 10:52:03 +0100 Message-Id: <12c4fe0c0c05b9f76377c085d8a6558beae64003.1587116799.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 , julien@xen.org, Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Also fix a weird indentation. Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall Reviewed-by: Julien Grall Reviewed-by: Jan Beulich --- xen/arch/x86/x86_64/mm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index e85ef449f3..18210405f4 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -737,8 +737,8 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) while (sva < eva) { - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(sva)])[ - l3_table_offset(sva)]; + l3e = l3e_from_l4e(idle_pg_table[l4_table_offset(sva)], + l3_table_offset(sva)); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || (l3e_get_flags(l3e) & _PAGE_PSE) ) { @@ -747,7 +747,7 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) continue; } - l2e = l3e_to_l2e(l3e)[l2_table_offset(sva)]; + l2e = l2e_from_l3e(l3e, l2_table_offset(sva)); ASSERT(l2e_get_flags(l2e) & _PAGE_PRESENT); if ( (l2e_get_flags(l2e) & (_PAGE_PRESENT | _PAGE_PSE)) == @@ -763,10 +763,10 @@ static void cleanup_frame_table(struct mem_hotadd_info *info) continue; } - ASSERT(l1e_get_flags(l2e_to_l1e(l2e)[l1_table_offset(sva)]) & - _PAGE_PRESENT); - sva = (sva & ~((1UL << PAGE_SHIFT) - 1)) + - (1UL << PAGE_SHIFT); + ASSERT(l1e_get_flags(l1e_from_l2e(l2e, l1_table_offset(sva))) & + _PAGE_PRESENT); + + sva = (sva & ~((1UL << PAGE_SHIFT) - 1)) + (1UL << PAGE_SHIFT); } /* Brute-Force flush all TLB */ From patchwork Fri Apr 17 09:52:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11494649 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 B552913B2 for ; Fri, 17 Apr 2020 09:53:15 +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 91E1621D94 for ; Fri, 17 Apr 2020 09:53:15 +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="FPk6Z1cK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91E1621D94 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 1jPNfj-0000Nv-An; Fri, 17 Apr 2020 09:52:31 +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 1jPNfi-0000NQ-0x for xen-devel@lists.xenproject.org; Fri, 17 Apr 2020 09:52:30 +0000 X-Inumbo-ID: 21d23984-8091-11ea-8c9b-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 21d23984-8091-11ea-8c9b-12813bfff9fa; Fri, 17 Apr 2020 09:52:21 +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=tEeVOsGMSDjBCM+osSPHmTi/618O72vOFb/JLOuqfjw=; b=FPk6Z1cKcufcm78XCUmuoAsxxg NB3bUWLYiTVSS/9IGOxLLksT8xkRnHri/hH9X25+ldy7DqY3dAxpaUOvJy/7srSgxcNkRUC8X6CIT qf0PaoDxzvVgRwDGesPf3H/FRcBDOLUa/0Pm4j8vLlNFK0NeMdi+zzvlyjh2PVzilojw=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfY-0002fk-Lb; Fri, 17 Apr 2020 09:52:20 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] 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 1jPNfY-000304-B3; Fri, 17 Apr 2020 09:52:20 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH 2/6] x86_64/mm: map and unmap page tables in subarch_init_memory Date: Fri, 17 Apr 2020 10:52:04 +0100 Message-Id: <0e14533f516ee5ce410e2cd8050f085aec4b4961.1587116799.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 , julien@xen.org, Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall Acked-by: Jan Beulich --- xen/arch/x86/x86_64/mm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 18210405f4..5714e5ba62 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -852,14 +852,14 @@ void __init subarch_init_memory(void) v += n << PAGE_SHIFT ) { n = L2_PAGETABLE_ENTRIES * L1_PAGETABLE_ENTRIES; - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + l3e = l3e_from_l4e(idle_pg_table[l4_table_offset(v)], + l3_table_offset(v)); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; if ( !(l3e_get_flags(l3e) & _PAGE_PSE) ) { n = L1_PAGETABLE_ENTRIES; - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + l2e = l2e_from_l3e(l3e, l2_table_offset(v)); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; m2p_start_mfn = l2e_get_pfn(l2e); @@ -878,11 +878,11 @@ void __init subarch_init_memory(void) v != RDWR_COMPAT_MPT_VIRT_END; v += 1 << L2_PAGETABLE_SHIFT ) { - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + l3e = l3e_from_l4e(idle_pg_table[l4_table_offset(v)], + l3_table_offset(v)); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) continue; - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + l2e = l2e_from_l3e(l3e, l2_table_offset(v)); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) continue; m2p_start_mfn = l2e_get_pfn(l2e); From patchwork Fri Apr 17 09:52:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11494659 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 E82EB13B2 for ; Fri, 17 Apr 2020 09:53:50 +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 C45BA2053B for ; Fri, 17 Apr 2020 09:53:50 +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="U/vQRxFi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C45BA2053B 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 1jPNfc-0000LT-Dh; Fri, 17 Apr 2020 09:52:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfb-0000LM-40 for xen-devel@lists.xenproject.org; Fri, 17 Apr 2020 09:52:23 +0000 X-Inumbo-ID: 226fb0b0-8091-11ea-b4f4-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 226fb0b0-8091-11ea-b4f4-bc764e2007e4; Fri, 17 Apr 2020 09:52:22 +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=7I49opomVxvB6V8PzhNVtuuo+Ifnpql27GLDjPB32Kw=; b=U/vQRxFirIgOsjhpUeE1YKAn/1 ioly0B4M83S0EK0PELN1eGIbRSPaod2Z1wJwZzJvz4kK+YGbQGqQ/dmAUfaydE8dBlSU3HiS2UW7S nBlomGh2Ejn/9aVTANwypSQcq2bKlplr6hG/Vl6S8f1o7Wo/wazxJ0ri8nM7jf2wDYz4=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfa-0002fp-2R; Fri, 17 Apr 2020 09:52:22 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] 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 1jPNfZ-000304-Os; Fri, 17 Apr 2020 09:52:22 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH 3/6] x86_64/mm: map and unmap page tables in subarch_memory_op Date: Fri, 17 Apr 2020 10:52:05 +0100 Message-Id: <1c88c785eb9537983a1692cc379604233ff13025.1587116799.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 , julien@xen.org, Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall Acked-by: Jan Beulich --- xen/arch/x86/x86_64/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 5714e5ba62..6d52183559 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -932,13 +932,13 @@ long subarch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) (v < (unsigned long)(machine_to_phys_mapping + max_page)); i++, v += 1UL << L2_PAGETABLE_SHIFT ) { - l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ - l3_table_offset(v)]; + l3e = l3e_from_l4e(idle_pg_table[l4_table_offset(v)], + l3_table_offset(v)); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) mfn = last_mfn; else if ( !(l3e_get_flags(l3e) & _PAGE_PSE) ) { - l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; + l2e = l2e_from_l3e(l3e, l2_table_offset(v)); if ( l2e_get_flags(l2e) & _PAGE_PRESENT ) mfn = l2e_get_pfn(l2e); else From patchwork Fri Apr 17 09:52:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11494651 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 7701813B2 for ; Fri, 17 Apr 2020 09:53:16 +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 53FA021D94 for ; Fri, 17 Apr 2020 09:53:16 +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="g3HnPNSW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53FA021D94 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 1jPNfn-0000Qx-KK; Fri, 17 Apr 2020 09:52:35 +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 1jPNfn-0000Qc-18 for xen-devel@lists.xenproject.org; Fri, 17 Apr 2020 09:52:35 +0000 X-Inumbo-ID: 232cfa12-8091-11ea-8c9b-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 232cfa12-8091-11ea-8c9b-12813bfff9fa; Fri, 17 Apr 2020 09:52:23 +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=TtfDNJhA8tjoCGd8nfl59DQgpyHwzck4uvav7srJyZM=; b=g3HnPNSWrF201Ln96S0X0V/JcW wroUnjXehYGLMAV4J6FGf/LZz+Cb5M0eHPm7Uit2Ahbyyp080Cd7ak33v8QUeCSxka8THYJSgwbB7 hXKpv/5fMSRJbedRVuycqIxJJdh5+Ckl6+oU+foZDHO9fLzjdIRZ6B0GGPM0rRpGRNSk=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfb-0002fw-Fo; Fri, 17 Apr 2020 09:52:23 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] 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 1jPNfb-000304-6P; Fri, 17 Apr 2020 09:52:23 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH 4/6] x86/smpboot: map and unmap page tables in cleanup_cpu_root_pgt Date: Fri, 17 Apr 2020 10:52:06 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 , julien@xen.org, Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall Acked-by: Jan Beulich --- xen/arch/x86/smpboot.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 09264b02d1..275ce7661d 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -858,23 +858,27 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) r < root_table_offset(HYPERVISOR_VIRT_END); ++r ) { l3_pgentry_t *l3t; + mfn_t l3mfn; unsigned int i3; if ( !(root_get_flags(rpt[r]) & _PAGE_PRESENT) ) continue; - l3t = l4e_to_l3e(rpt[r]); + l3mfn = l4e_get_mfn(rpt[r]); + l3t = map_domain_page(l3mfn); for ( i3 = 0; i3 < L3_PAGETABLE_ENTRIES; ++i3 ) { l2_pgentry_t *l2t; + mfn_t l2mfn; unsigned int i2; if ( !(l3e_get_flags(l3t[i3]) & _PAGE_PRESENT) ) continue; ASSERT(!(l3e_get_flags(l3t[i3]) & _PAGE_PSE)); - l2t = l3e_to_l2e(l3t[i3]); + l2mfn = l3e_get_mfn(l3t[i3]); + l2t = map_domain_page(l2mfn); for ( i2 = 0; i2 < L2_PAGETABLE_ENTRIES; ++i2 ) { @@ -882,13 +886,15 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) continue; ASSERT(!(l2e_get_flags(l2t[i2]) & _PAGE_PSE)); - free_xen_pagetable(l2e_to_l1e(l2t[i2])); + free_xen_pagetable_new(l2e_get_mfn(l2t[i2])); } - free_xen_pagetable(l2t); + unmap_domain_page(l2t); + free_xen_pagetable_new(l2mfn); } - free_xen_pagetable(l3t); + unmap_domain_page(l3t); + free_xen_pagetable_new(l3mfn); } free_xen_pagetable(rpt); @@ -896,11 +902,14 @@ static void cleanup_cpu_root_pgt(unsigned int cpu) /* Also zap the stub mapping for this CPU. */ if ( stub_linear ) { - l3_pgentry_t *l3t = l4e_to_l3e(common_pgt); - l2_pgentry_t *l2t = l3e_to_l2e(l3t[l3_table_offset(stub_linear)]); - l1_pgentry_t *l1t = l2e_to_l1e(l2t[l2_table_offset(stub_linear)]); + l3_pgentry_t l3e = l3e_from_l4e(common_pgt, + l3_table_offset(stub_linear)); + l2_pgentry_t l2e = l2e_from_l3e(l3e, l2_table_offset(stub_linear)); + l1_pgentry_t *l1t = map_l1t_from_l2e(l2e); l1t[l1_table_offset(stub_linear)] = l1e_empty(); + + unmap_domain_page(l1t); } } From patchwork Fri Apr 17 09:52:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11494653 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 A429D174A for ; Fri, 17 Apr 2020 09:53:16 +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 7E2F321D94 for ; Fri, 17 Apr 2020 09:53:16 +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="6Wg/PSgP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E2F321D94 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 1jPNfh-0000Mq-18; Fri, 17 Apr 2020 09:52:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfg-0000Me-1B for xen-devel@lists.xenproject.org; Fri, 17 Apr 2020 09:52:28 +0000 X-Inumbo-ID: 241c2132-8091-11ea-b58d-bc764e2007e4 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 241c2132-8091-11ea-b58d-bc764e2007e4; Fri, 17 Apr 2020 09:52:25 +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=3PKlc7n3xS/jV0u6XuY6+PkL5866S2noi39EkmZJHLk=; b=6Wg/PSgPxch2MIXxZCIZTcAGU2 e+xUte2YS7ssUZFYv3wFEa/duhWo1Ggen13MRH11jSCORyfcUeRbyKWsDQDL6mNvXVJ1/HexFz1DW fygtm8y+pMpFDHAveHIAoqHwbPYOc4iAYVihpCinG71neeIk6++Dvyj3pRxvpxhj1a3U=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfc-0002g2-TE; Fri, 17 Apr 2020 09:52:24 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] 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 1jPNfc-000304-Ju; Fri, 17 Apr 2020 09:52:24 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH 5/6] x86/pv: map and unmap page tables in mark_pv_pt_pages_rdonly Date: Fri, 17 Apr 2020 10:52:07 +0100 Message-Id: <9287363e13924f4a633b47b53c23b3466e26e4a8.1587116799.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 , julien@xen.org, Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall --- xen/arch/x86/pv/dom0_build.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 5678da782d..28a939b68a 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -50,17 +50,17 @@ static __init void mark_pv_pt_pages_rdonly(struct domain *d, unsigned long count; struct page_info *page; l4_pgentry_t *pl4e; - l3_pgentry_t *pl3e; - l2_pgentry_t *pl2e; - l1_pgentry_t *pl1e; + l3_pgentry_t *pl3e, *l3t; + l2_pgentry_t *pl2e, *l2t; + l1_pgentry_t *pl1e, *l1t; pl4e = l4start + l4_table_offset(vpt_start); - pl3e = l4e_to_l3e(*pl4e); - pl3e += l3_table_offset(vpt_start); - pl2e = l3e_to_l2e(*pl3e); - pl2e += l2_table_offset(vpt_start); - pl1e = l2e_to_l1e(*pl2e); - pl1e += l1_table_offset(vpt_start); + l3t = map_l3t_from_l4e(*pl4e); + pl3e = l3t + l3_table_offset(vpt_start); + l2t = map_l2t_from_l3e(*pl3e); + pl2e = l2t + l2_table_offset(vpt_start); + l1t = map_l1t_from_l2e(*pl2e); + pl1e = l1t + l1_table_offset(vpt_start); for ( count = 0; count < nr_pt_pages; count++ ) { l1e_remove_flags(*pl1e, _PAGE_RW); @@ -85,12 +85,20 @@ static __init void mark_pv_pt_pages_rdonly(struct domain *d, if ( !((unsigned long)++pl2e & (PAGE_SIZE - 1)) ) { if ( !((unsigned long)++pl3e & (PAGE_SIZE - 1)) ) - pl3e = l4e_to_l3e(*++pl4e); - pl2e = l3e_to_l2e(*pl3e); + { + unmap_domain_page(l3t); + pl3e = l3t = map_l3t_from_l4e(*++pl4e); + } + unmap_domain_page(l2t); + pl2e = l2t = map_l2t_from_l3e(*pl3e); } - pl1e = l2e_to_l1e(*pl2e); + unmap_domain_page(l1t); + pl1e = l1t = map_l1t_from_l2e(*pl2e); } } + unmap_domain_page(l1t); + unmap_domain_page(l2t); + unmap_domain_page(l3t); } static __init void setup_pv_physmap(struct domain *d, unsigned long pgtbl_pfn, From patchwork Fri Apr 17 09:52:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyan Xia X-Patchwork-Id: 11494661 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 5026613B2 for ; Fri, 17 Apr 2020 09:53:53 +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 2D56F2053B for ; Fri, 17 Apr 2020 09:53:53 +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="D3+GJWuL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D56F2053B 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 1jPNft-0000UJ-3c; Fri, 17 Apr 2020 09:52:41 +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 1jPNfs-0000Tf-1F for xen-devel@lists.xenproject.org; Fri, 17 Apr 2020 09:52:40 +0000 X-Inumbo-ID: 24f1209e-8091-11ea-8c9b-12813bfff9fa Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 24f1209e-8091-11ea-8c9b-12813bfff9fa; Fri, 17 Apr 2020 09:52:26 +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=Dfu+OgKnJzFWoXe/gPFe0obtWomHwJiB46S0uhovLc0=; b=D3+GJWuLGIwR19dKVk0QfvNpEP cq5z41eQ+J/4T7c2UgY0l1mUsBfDgyPYxRoCHvFEVty/RdmTdnBAeHoDv2QLHpo989tqmXDP8/zq8 aqAaX/Nm3UKdNTMnSmr4X/cLjNmWJY6ox7HCtSFN9clvlm85ITsPGB8cccDyzXW+xf+w=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jPNfe-0002g8-Aj; Fri, 17 Apr 2020 09:52:26 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] 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 1jPNfe-000304-15; Fri, 17 Apr 2020 09:52:26 +0000 From: Hongyan Xia To: xen-devel@lists.xenproject.org Subject: [PATCH 6/6] x86/pv: map and unmap page table in dom0_construct_pv Date: Fri, 17 Apr 2020 10:52:08 +0100 Message-Id: <18fda6bdeb4f20bf2272503e45c7c420e51673ac.1587116799.git.hongyxia@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 , julien@xen.org, Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_?= =?utf-8?q?Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Wei Liu Signed-off-by: Wei Liu Signed-off-by: Hongyan Xia Reviewed-by: Julien Grall Acked-by: Jan Beulich --- xen/arch/x86/pv/dom0_build.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 28a939b68a..a03f0501ab 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -677,6 +677,8 @@ int __init dom0_construct_pv(struct domain *d, if ( is_pv_32bit_domain(d) ) { + l2_pgentry_t *l2t; + /* Ensure the first four L3 entries are all populated. */ for ( i = 0, l3tab = l3start; i < 4; ++i, ++l3tab ) { @@ -691,7 +693,9 @@ int __init dom0_construct_pv(struct domain *d, l3e_get_page(*l3tab)->u.inuse.type_info |= PGT_pae_xen_l2; } - init_xen_pae_l2_slots(l3e_to_l2e(l3start[3]), d); + l2t = map_l2t_from_l3e(l3start[3]); + init_xen_pae_l2_slots(l2t, d); + unmap_domain_page(l2t); } /* Pages that are part of page tables must be read only. */