Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4025629imm; Mon, 20 Aug 2018 08:35:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwtCo+BPMbFLP7eYq2sKdT5ndK+LwQPLqD/7XX0h1FZSqP2cXJ59cOjlv5TBtpnRwtkZk1N X-Received: by 2002:a62:280a:: with SMTP id o10-v6mr45658793pfo.129.1534779323334; Mon, 20 Aug 2018 08:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534779323; cv=none; d=google.com; s=arc-20160816; b=PhrsTF4Po5fgFOr5HlTcjMJMFN6hMt0UWingUWTwYQLEur+8Q6rA2eTFjfXdUA4Y12 BgHXtxz2gcKxjAZhx1TCkYVXEkFoq/2B7RXYTReSwGaKPZRRvb+SUTA3y8FIqtQMKuT2 nFqrpBRXJsEyM4PnxpU0AVq71C4ahF/QVWRnRLvEAQWqsA5K3m8gF7pZjY9A3a4ZrvQV ZF/aIyEexhslAGKUKkDZd4cvyY5jsH2d15Ljl2sfmtK7G0hBoyicuUaKWQ7yGyLVvOVm D5jAegTKG3hi4ASKufZhL1l6I8o7TxGJjey0wCuwyEspEjavJ9bMGfXU7Yy6HqxJHT4i +1mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=TIcAiLTpHS0xugpLbpXk7A/rDN0kYiSAmPsGIcuQXpc=; b=0PR/onC70zO8PCNMyTRLInB7jNojd/zV5FsKDLZr32DwH9u1nQMjK4OfePxvvRkq1g 4rOYspxZvjO1FA91Sh9FmNM0V5oDO5jKXdeR4R7vGQowOi6RSYDMW0GN51S1QTgr1TbB q1otPtcPJjrrbgcKah27hKEsRrf7HLySw7Tum2p+HGZpaambJhxULh9Lg1s8qBCCWnTQ Pk3rXhMpOHzhrRuEffJY4snhBkWTdRqzySQJA+eLiBr0JlJqKd5Ht/dtRpwEBLsqj8jb fAbxnAXZnXUpHPlTkpKXs25445hFr9eAISvwRcjb4LhVd+Ut0G3NgaiXmY8ZVTOuR0FX LA7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 82-v6si10087877pfo.229.2018.08.20.08.35.08; Mon, 20 Aug 2018 08:35:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727086AbeHTSk2 (ORCPT + 99 others); Mon, 20 Aug 2018 14:40:28 -0400 Received: from mx2.suse.de ([195.135.220.15]:58282 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726021AbeHTSk2 (ORCPT ); Mon, 20 Aug 2018 14:40:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A9BDAACB7; Mon, 20 Aug 2018 15:24:22 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org Cc: boris.ostrovsky@oracle.com, hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, Juergen Gross Subject: [PATCH RESEND] x86/xen: enable early use of set_fixmap in 32-bit Xen PV guest Date: Mon, 20 Aug 2018 17:24:20 +0200 Message-Id: <20180820152420.16004-1-jgross@suse.com> X-Mailer: git-send-email 2.13.7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 7b25b9cb0dad83 ("x86/xen/time: Initialize pv xen time in init_hypervisor_platform()") moved the mapping of the shared info area before pagetable_init(). This breaks booting as 32-bit PV guest as the use of set_fixmap isn't possible at this time on 32-bit. This can be worked around by populating the needed PMD on 32-bit kernel earlier. In order not to reimplement populate_extra_pte() using extend_brk() for allocating new page tables extend alloc_low_pages() to do that in case the early page table pool is not yet available. Fixes: 7b25b9cb0dad83 ("x86/xen/time: Initialize pv xen time in init_hypervisor_platform()") Signed-off-by: Juergen Gross Reviewed-by: Thomas Gleixner --- Resending with corrected Fixes: tag Boris, please take this via the Xen tree (Thomas asked us to do so) --- arch/x86/mm/init.c | 17 ++++++++++++----- arch/x86/xen/enlighten_pv.c | 2 ++ arch/x86/xen/mmu_pv.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index acfab322fbe0..5c32a7665492 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -99,15 +99,22 @@ __ref void *alloc_low_pages(unsigned int num) } if ((pgt_buf_end + num) > pgt_buf_top || !can_use_brk_pgt) { - unsigned long ret; - if (min_pfn_mapped >= max_pfn_mapped) - panic("alloc_low_pages: ran out of memory"); - ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT, + unsigned long ret = 0; + + if (min_pfn_mapped < max_pfn_mapped) { + ret = memblock_find_in_range( + min_pfn_mapped << PAGE_SHIFT, max_pfn_mapped << PAGE_SHIFT, PAGE_SIZE * num , PAGE_SIZE); + } + if (ret) + memblock_reserve(ret, PAGE_SIZE * num); + else if (can_use_brk_pgt) + ret = __pa(extend_brk(PAGE_SIZE * num, PAGE_SIZE)); + if (!ret) panic("alloc_low_pages: can not alloc memory"); - memblock_reserve(ret, PAGE_SIZE * num); + pfn = ret >> PAGE_SHIFT; } else { pfn = pgt_buf_end; diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index ee3b00c7acda..d7b2022ee301 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -122,6 +122,8 @@ static void __init xen_banner(void) static void __init xen_pv_init_platform(void) { + populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP)); + set_fixmap(FIX_PARAVIRT_BOOTMAP, xen_start_info->shared_info); HYPERVISOR_shared_info = (void *)fix_to_virt(FIX_PARAVIRT_BOOTMAP); diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 52206ad81e4b..9e7012858420 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -2171,6 +2171,8 @@ void __init xen_relocate_p2m(void) #else /* !CONFIG_X86_64 */ static RESERVE_BRK_ARRAY(pmd_t, initial_kernel_pmd, PTRS_PER_PMD); static RESERVE_BRK_ARRAY(pmd_t, swapper_kernel_pmd, PTRS_PER_PMD); +RESERVE_BRK(fixup_kernel_pmd, PAGE_SIZE); +RESERVE_BRK(fixup_kernel_pte, PAGE_SIZE); static void __init xen_write_cr3_init(unsigned long cr3) { -- 2.13.7