From patchwork Fri Jan 12 14:34:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 10161145 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 71A7260327 for ; Fri, 12 Jan 2018 14:35:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 613D4223C6 for ; Fri, 12 Jan 2018 14:35:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55789287ED; Fri, 12 Jan 2018 14:35: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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B13B223C6 for ; Fri, 12 Jan 2018 14:35:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933940AbeALOft (ORCPT ); Fri, 12 Jan 2018 09:35:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60020 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934026AbeALOfs (ORCPT ); Fri, 12 Jan 2018 09:35:48 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E1D4C08EC1A; Fri, 12 Jan 2018 14:35:48 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id E261A65628; Fri, 12 Jan 2018 14:35:45 +0000 (UTC) From: David Hildenbrand To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Huth , Christian Borntraeger , Cornelia Huck , David Hildenbrand Subject: [PATCH kvm-unit-tests v2 07/11] s390x: initialize the physical allocator Date: Fri, 12 Jan 2018 15:34:13 +0100 Message-Id: <20180112143417.16743-8-david@redhat.com> In-Reply-To: <20180112143417.16743-1-david@redhat.com> References: <20180112143417.16743-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 12 Jan 2018 14:35:48 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We now have the range of free memory, let's initialize the physical allocator. It is now possible to use alloc_page()/alloc_pages(). Signed-off-by: David Hildenbrand --- lib/s390x/sclp.c | 12 ++++++++++++ s390x/Makefile | 3 +++ 2 files changed, 15 insertions(+) diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c index 199405c..c7471b1 100644 --- a/lib/s390x/sclp.c +++ b/lib/s390x/sclp.c @@ -15,11 +15,21 @@ #include #include #include "sclp.h" +#include + +extern unsigned long stacktop; static uint64_t storage_increment_size; static uint64_t max_ram_size; static uint64_t ram_size; +static void mem_init(phys_addr_t mem_end) +{ + phys_addr_t freemem_start = (phys_addr_t)&stacktop & PAGE_MASK; + + phys_alloc_init(freemem_start, mem_end - freemem_start); +} + void sclp_memory_setup(void) { ReadInfo *ri = (void *)_sccb; @@ -55,4 +65,6 @@ void sclp_memory_setup(void) break; ram_size += storage_increment_size; } + + mem_init(ram_size); } diff --git a/s390x/Makefile b/s390x/Makefile index ce63dd1..4198fdc 100644 --- a/s390x/Makefile +++ b/s390x/Makefile @@ -21,6 +21,9 @@ asm-offsets = lib/$(ARCH)/asm-offsets.h include $(SRCDIR)/scripts/asm-offsets.mak cflatobjs += lib/util.o +cflatobjs += lib/alloc.o +cflatobjs += lib/alloc_phys.o +cflatobjs += lib/alloc_page.o cflatobjs += lib/alloc_phys.o cflatobjs += lib/s390x/io.o cflatobjs += lib/s390x/stack.o