From patchwork Mon Dec 3 18:05:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10710197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A62E15A6 for ; Mon, 3 Dec 2018 18:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F7BA2B47E for ; Mon, 3 Dec 2018 18:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5332F2B48F; Mon, 3 Dec 2018 18:06:50 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCAB42B47E for ; Mon, 3 Dec 2018 18:06:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B4396B69DD; Mon, 3 Dec 2018 13:06:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 65F486B6A31; Mon, 3 Dec 2018 13:06:48 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 529EB6B6A32; Mon, 3 Dec 2018 13:06:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by kanga.kvack.org (Postfix) with ESMTP id 26E756B69DD for ; Mon, 3 Dec 2018 13:06:48 -0500 (EST) Received: by mail-oi1-f199.google.com with SMTP id w80so8787296oiw.19 for ; Mon, 03 Dec 2018 10:06:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0O0wJfuc0UzHpAlq92San4mKfKpE+8UwtpVszOGCwwk=; b=kWoqbkONazG7cAek4Afu+nQtSAEIVPV5Ly7Sharp55CQlzKdpXkc/Mk+A3JqF/sw9u WUd+85+SNEuFGBTTMy+IYy1febn39tf8gKz5iuGLscUs2DXRKiE99ra2D8BvahG/yqbm 6/MeAWyVW0cbIgNtTvaXLEZ440GCSdcm3+FFydf5snfZ8PIMW8PyxhX9fHi9EyP9M5EE 6SiB4b3XLvJrViPjgP2MAPksC5eD9yrGp+RM/f+lGufYs8Ob0mqy/Kw20W+3fGi07vYo 9Qv/+NbO/WuL99hcdAv8EGjBvW/nfPS4zngx7gCXTXQHD6gaIKMMsSrjtRtt6OpMAHZf kXvg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com X-Gm-Message-State: AA+aEWaGh3JusRz4pn73tbJOTYpeibZRuScO98f/m0mUUzqGTCR3WhQk VmBjOSVgkvbQ7DQsjDboZZFwuHfVEJ+nrMEupGSkeXkfMdA4hTpL9KY6hwsNC89FVz1KI1HGLuJ zt6SwdfCCtf5ndWPGX5+PjnEVPjWi4mPgAxP93d9GDPYfTyQRveNVm36cunY9qtIhZw== X-Received: by 2002:aca:db41:: with SMTP id s62mr9987205oig.349.1543860407899; Mon, 03 Dec 2018 10:06:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/UaxyqidY04adsIYt20IcvUrvtkvj4s2ZQU+05Xnm8VhFgLnwwxm0byE9HAU/2STMJGDVXW X-Received: by 2002:aca:db41:: with SMTP id s62mr9987167oig.349.1543860407165; Mon, 03 Dec 2018 10:06:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860407; cv=none; d=google.com; s=arc-20160816; b=qSVuyVOJSxGa/Bm+9zsm/DB78mSNlTozoIA5FTgW2+mILIiOXqswEBMMIJV++BJCMx arbQKcHJ0mL3P7EM5I6289P+yRo8K1XwgD95qJIwCnaVYlDAefzArNE/XW9t3+CuV/XC 7l0R1qvW7EAmNTK8TycknWFXRrwevsiO+KO0wcvhNvUyQyEYQbTInDPDFYaan0qJRhR+ 6PhDvEDSdXblU35OhOY5s52u5wAhAnT+dIVCwUnN7YfjTc1/QF0phdO1Ht1JlWOZ11NZ meQm4k0DwHb1PhgjQ1u0DODH+bwQZK7hw9SfxGZlcXA0xxMjwQ/LP/554SImmEFBPDhB 06vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=0O0wJfuc0UzHpAlq92San4mKfKpE+8UwtpVszOGCwwk=; b=ao/65vBw4q3fx6t5mWwGQoQpyeqOEjATxaoZdc+qUfPKJ5cfwo1uS7CiIMz9Y4ssoM Wmhfp/iXJkVUM2FHvJOdeRXNFzz3RnYfvhl/SLe/9fDK4tMYYJ+INWFrFsf5c08W9ouk WEMcCElfmTAEbNZtkJf4aZDEO8pB0s4l340guLU9nzayJrbysTWlR/zV7djvX0ycEDf1 fh5R3HgEHOodFdB2JaMV8y1cHL9y77n3YKxlRUHyQmUUpDKpOaj+cKqTTyXxGgWARUpD lNgUDMTvkkVVJcqhmKMCJRuX9kyN7X2mLdD+tVx/aLvijRnfWHm9bsb1GXpL7df+BRv4 PPYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id n1si6879652otn.272.2018.12.03.10.06.46 for ; Mon, 03 Dec 2018 10:06:46 -0800 (PST) Received-SPF: pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7DB36169E; Mon, 3 Dec 2018 10:06:46 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD9163F59C; Mon, 3 Dec 2018 10:06:43 -0800 (PST) From: James Morse To: linux-acpi@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Borislav Petkov , Marc Zyngier , Christoffer Dall , Will Deacon , Catalin Marinas , Naoya Horiguchi , Rafael Wysocki , Len Brown , Tony Luck , Dongjiu Geng , Xie XiuQi , Fan Wu , James Morse Subject: [PATCH v7 03/25] ACPI / APEI: Switch estatus pool to use vmalloc memory Date: Mon, 3 Dec 2018 18:05:51 +0000 Message-Id: <20181203180613.228133-4-james.morse@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181203180613.228133-1-james.morse@arm.com> References: <20181203180613.228133-1-james.morse@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The ghes code is careful to parse and round firmware's advertised memory requirements for CPER records, up to a maximum of 64K. However when ghes_estatus_pool_expand() does its work, it splits the requested size into PAGE_SIZE granules. This means if firmware generates 5K of CPER records, and correctly describes this in the table, __process_error() will silently fail as it is unable to allocate more than PAGE_SIZE. Switch the estatus pool to vmalloc() memory. On x86 vmalloc() memory may fault and be fixed up by vmalloc_fault(). To prevent this call vmalloc_sync_all() before an NMI handler could discover the memory. Signed-off-by: James Morse Reviewed-by: Borislav Petkov --- drivers/acpi/apei/ghes.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index e8503c7d721f..c15264f2dc4b 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -170,40 +170,40 @@ static int ghes_estatus_pool_init(void) return 0; } -static void ghes_estatus_pool_free_chunk_page(struct gen_pool *pool, +static void ghes_estatus_pool_free_chunk(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data) { - free_page(chunk->start_addr); + vfree((void *)chunk->start_addr); } static void ghes_estatus_pool_exit(void) { gen_pool_for_each_chunk(ghes_estatus_pool, - ghes_estatus_pool_free_chunk_page, NULL); + ghes_estatus_pool_free_chunk, NULL); gen_pool_destroy(ghes_estatus_pool); } static int ghes_estatus_pool_expand(unsigned long len) { - unsigned long i, pages, size, addr; - int ret; + unsigned long size, addr; ghes_estatus_pool_size_request += PAGE_ALIGN(len); size = gen_pool_size(ghes_estatus_pool); if (size >= ghes_estatus_pool_size_request) return 0; - pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE; - for (i = 0; i < pages; i++) { - addr = __get_free_page(GFP_KERNEL); - if (!addr) - return -ENOMEM; - ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1); - if (ret) - return ret; - } - return 0; + addr = (unsigned long)vmalloc(PAGE_ALIGN(len)); + if (!addr) + return -ENOMEM; + + /* + * New allocation must be visible in all pgd before it can be found by + * an NMI allocating from the pool. + */ + vmalloc_sync_all(); + + return gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1); } static int map_gen_v2(struct ghes *ghes)