Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp744231ybl; Wed, 4 Dec 2019 10:08:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyGN5Gvo/vaYAbuJfy4UugUg+K7L/CflldWLTS4rvInb1kVdcGXB8Vd9E/yOlYpqakFIwiu X-Received: by 2002:a05:6808:6cc:: with SMTP id m12mr3503762oih.111.1575482920531; Wed, 04 Dec 2019 10:08:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575482920; cv=none; d=google.com; s=arc-20160816; b=KmPseiJ7RmICJSzoX69LWisZNelrkMpaugkjDgtHRy9vIznfmyDvLr4GXEo1VkZ+Sr ZKL4kbmsintmcAWdyIPc/8tpgyVAG1ZDpFjEHgoKqrvr67QB9/E7iVnglIEGSK+Wm7Vu Qf40aIU+mbyQxbywB+qTc4yD6FTFEi6phCrulV6PmBi7sODTOhW8QSk1l61xQ4/IA7ZF L/vOe8MR5y+dhK0UZKaGNlGgzIag43HffEWWl30QsThweB/HmhyHG3HKpfYnD1L83Z1s F59yWMEFpO8pPdMwYLCDDZVkw8Ljqe2+9VJjNarwwi1l9fjWpsRWSIGLNp4wzndMHi6E U4XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=t04x5ef9P8fjBL0qw1bE+a1bpnobg4lRwjS7kxrWeUA=; b=DtNtZxbqippHDVFS2n1od4Dxl176iihyfNVs8SHqOG3DrUsK/ecm50WjQgbazacwti duXwEWypcCbAulmzHqLquXvM/YuMR+KEQ3hlgMYjR97hzE1OfjTnN3JNNvyHZxoBaFQa qO89c5NUfSYtBlsttIaLUAoSp0fMxYqlhnS/kHU9sr/DA5MPcVyXFM5ox4ckjub255ad 0meBJf2dfGBpz+g3ceuynyEkBwZkWrf8UTrdGEDBUCcDkuNsGZp65YZzPRyzIF2Gh8nR L7fOl0G0Y5wrZBIcMQjhL8C+6nA1WaQ4oTw8elICXCJ5TmRfQZxOZfXZTTUdCe9AzxqM tbog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gf7sqid0; 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 d23si3146257oti.158.2019.12.04.10.08.25; Wed, 04 Dec 2019 10:08:40 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=gf7sqid0; 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 S1730718AbfLDSHM (ORCPT + 99 others); Wed, 4 Dec 2019 13:07:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:56460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730700AbfLDSHI (ORCPT ); Wed, 4 Dec 2019 13:07:08 -0500 Received: from localhost (unknown [217.68.49.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3BDC20674; Wed, 4 Dec 2019 18:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482827; bh=HS84tFKpKufgsJQxZKLcluRkNCzY3Fs/Uh0TZmuPb40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gf7sqid04AhN/kQPJmtiHQobhxig0zqaeGyP15SVa29iXwvagQ7FMztT74vt7TMCg zf5VvFK1WI1K9SuZmvlGlr8vyp/QXdWjF2eb+mpGkijLlSg6rt7DrC+pzYm0qfvV6M 2aTy6PTJ+ePC3WM8YCc0YiC1T4vEuyn426cEkPEo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Morse , Borislav Petkov , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.14 151/209] ACPI / APEI: Switch estatus pool to use vmalloc memory Date: Wed, 4 Dec 2019 18:56:03 +0100 Message-Id: <20191204175333.892862473@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175321.609072813@linuxfoundation.org> References: <20191204175321.609072813@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Morse [ Upstream commit 0ac234be1a9497498e57d958f4251f5257b116b4 ] 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 Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- 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 9c31c7cd5cb5e..cd6fae6ad4c2a 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) -- 2.20.1