From patchwork Tue Jul 25 09:50:12 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: 9861601 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 55047601A1 for ; Tue, 25 Jul 2017 09:52:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FBA128600 for ; Tue, 25 Jul 2017 09:52:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 347152860E; Tue, 25 Jul 2017 09:52:29 +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 AC71928600 for ; Tue, 25 Jul 2017 09:52:28 +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 1dZwTw-0008VG-7V; Tue, 25 Jul 2017 09:50:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dZwTv-0008Uu-6t for xen-devel@lists.xenproject.org; Tue, 25 Jul 2017 09:50:23 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id A2/7C-01862-E5417795; Tue, 25 Jul 2017 09:50:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVyuP0Ov26sSHm kwZcLphbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aP/wvZCuYLVZxf18rUwPiZr4uRk0NCwEji 7cR/TF2MXBxCAgsZJV7dvsYIkmATUJXYcP0UK4gtIhAksaGjlQnEZhaokGj5f4kFxBYWsJVYv bcPzGYBqn8z8w5YDa+AscTVa3OZIRbIS3QcmAxWwylgIjFj7lIgmwNombHEup+8Exi5FzAyrG JUL04tKkst0rXUSyrKTM8oyU3MzNE1NDDWy00tLk5MT81JTCrWS87P3cQI9G09AwPjDsbXP50 OMUpyMCmJ8qbvKosU4kvKT6nMSCzOiC8qzUktPsQow8GhJMErKlweKSRYlJqeWpGWmQMMMpi0 BAePkgjvPiGgNG9xQWJucWY6ROoUoy7Hqwn/vzEJseTl56VKifO6gMwQACnKKM2DGwEL+EuMs lLCvIwMDAxCPAWpRbmZJajyrxjFORiVhHm5QKbwZOaVwG16BXQEE9ARc2aUghxRkoiQkmpgtL QUSlV8aCsSsezFoqQo3ZkqHbc2meTFbI/SWdecJ1l59smsN+erVj2tm3L4/IGsCiMWzcWqJrM Tnmm+u3/obDiz8UThmLWcZ6dHl+26ptp8gO3f6V4LZr6Ia6cnXkr+vptPsGzp1UU3c0My2peY /H7OPnvp+RWRBT/Z5JX/ufRdvPlpb+T9lUosxRmJhlrMRcWJAHVQ+KBzAgAA X-Env-Sender: jgross@suse.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1500976221!51506102!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 45395 invoked from network); 25 Jul 2017 09:50:21 -0000 Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by server-9.tower-31.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 25 Jul 2017 09:50:21 -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 6A96CAAD0; Tue, 25 Jul 2017 09:50:18 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org Date: Tue, 25 Jul 2017 11:50:12 +0200 Message-Id: <20170725095013.2939-3-jgross@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170725095013.2939-1-jgross@suse.com> References: <20170725095013.2939-1-jgross@suse.com> Cc: Juergen Gross , boris.ostrovsky@oracle.com, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com Subject: [Xen-devel] [PATCH 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(); /*