From patchwork Fri Jul 28 10:23:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 9868363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5DA04603FA for ; Fri, 28 Jul 2017 10:25:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 404B92883A for ; Fri, 28 Jul 2017 10:25:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3539F2886C; Fri, 28 Jul 2017 10:25:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 857DC28869 for ; Fri, 28 Jul 2017 10:25:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1db2QV-0007Ra-FO; Fri, 28 Jul 2017 10:23:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1db2QT-0007Q9-Oc for xen-devel@lists.xenproject.org; Fri, 28 Jul 2017 10:23:21 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id D0/7F-03582-9901B795; Fri, 28 Jul 2017 10:23:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVyuP0Ov+4Mgep Ig1PbNS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owf/xeyFcwXqji/rpWpgfEzXxcjJ4eEgJHE 24n/mLoYuTiEBBYySrw4/YUFJMEmoCqx4fopVhBbRCBIYkNHKxOIzSxQIdHy/xJQDQeHsICDx NV9wSBhFqDyDxu/s4PYvAImElNW/GaFmC8v0XFgMthITgFTid5/x8FsIaCaK9sfMk1g5F7AyL CKUb04tagstUjXWC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9C3DECwg7Hjn9M hRkkOJiVR3kmmFZFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgb+asjhQSLUtNTK9Iyc4BBBpOW 4OBREuGdDpLmLS5IzC3OTIdInWLU5Xg14f83JiGWvPy8VClxXmOQIgGQoozSPLgRsIC/xCgrJ czLCHSUEE9BalFuZgmq/CtGcQ5GJWHe9SBTeDLzSuA2vQI6ggnoiIlNlSBHlCQipKQaGPPNPb 9KHFvw6rGnxh/G8HfuSxIrTs51mhWZv+aCRjJjTLRf56+4NNUzXJEFhy//1jV9JmOuFcDiedH vbpy88c2p1XNzDpe4L79zzsQuyvW1+On9fD5nCsvi9++SlNi8x8NCoURmB5tpHFvY7ulbhc4k 1G/7XufadSTF9reY9b0d3+f5tTzsU2Ipzkg01GIuKk4EACwkKiRzAgAA X-Env-Sender: jgross@suse.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1501237400!77477936!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27624 invoked from network); 28 Jul 2017 10:23:20 -0000 Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by server-11.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 28 Jul 2017 10:23:20 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3D59DAE5B; Fri, 28 Jul 2017 10:23:20 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org Date: Fri, 28 Jul 2017 12:23:13 +0200 Message-Id: <20170728102314.29100-3-jgross@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170728102314.29100-1-jgross@suse.com> References: <20170728102314.29100-1-jgross@suse.com> Cc: Juergen Gross , boris.ostrovsky@oracle.com, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com Subject: [Xen-devel] [PATCH v2 2/3] xen: split up xen_hvm_init_shared_info() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of calling xen_hvm_init_shared_info() on boot and resume split it up into a boot time function searching for the pfn to use and a mapping function doing the hypervisor mapping call. Signed-off-by: Juergen Gross --- arch/x86/xen/enlighten_hvm.c | 45 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index 87d791356ea9..d23531f5f17e 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -21,29 +21,9 @@ #include "mmu.h" #include "smp.h" -void __ref xen_hvm_init_shared_info(void) +void xen_hvm_init_shared_info(void) { struct xen_add_to_physmap xatp; - u64 pa; - - if (HYPERVISOR_shared_info == &xen_dummy_shared_info) { - /* - * Search for a free page starting at 4kB physical address. - * Low memory is preferred to avoid an EPT large page split up - * by the mapping. - * Starting below X86_RESERVE_LOW (usually 64kB) is fine as - * the BIOS used for HVM guests is well behaved and won't - * clobber memory other than the first 4kB. - */ - for (pa = PAGE_SIZE; - !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) || - memblock_is_reserved(pa); - pa += PAGE_SIZE) - ; - - memblock_reserve(pa, PAGE_SIZE); - HYPERVISOR_shared_info = __va(pa); - } xatp.domid = DOMID_SELF; xatp.idx = 0; @@ -53,6 +33,28 @@ void __ref xen_hvm_init_shared_info(void) BUG(); } +static void __init reserve_shared_info(void) +{ + u64 pa; + + /* + * Search for a free page starting at 4kB physical address. + * Low memory is preferred to avoid an EPT large page split up + * by the mapping. + * Starting below X86_RESERVE_LOW (usually 64kB) is fine as + * the BIOS used for HVM guests is well behaved and won't + * clobber memory other than the first 4kB. + */ + for (pa = PAGE_SIZE; + !e820__mapped_all(pa, pa + PAGE_SIZE, E820_TYPE_RAM) || + memblock_is_reserved(pa); + pa += PAGE_SIZE) + ; + + memblock_reserve(pa, PAGE_SIZE); + HYPERVISOR_shared_info = __va(pa); +} + static void __init init_hvm_pv_info(void) { int major, minor; @@ -153,6 +155,7 @@ static void __init xen_hvm_guest_init(void) init_hvm_pv_info(); + reserve_shared_info(); xen_hvm_init_shared_info(); /*