From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13C5AC10F14 for ; Thu, 3 Oct 2019 16:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D93A9222BE for ; Thu, 3 Oct 2019 16:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120336; bh=W4cYAWP0Qa/Qu3TFBSpjTV0C26MYzIiXO1hQPqY2Z/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yHCNoNkyObf26/YS0W+huPoSdkhl4LpSLsPlfRre7kbYwS05hwwsqfccl6p2gxVuV hUnP4K7JpRXmbUChJ7b+sGIrnR9i8AB6KlUxN2Uz7P8agrLrA6cJ6ZttNdxapnyjy3 PAfqffH4wo5yl+2RJTl6Gqlax83ictBW7F73cHSM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391891AbfJCQcQ (ORCPT ); Thu, 3 Oct 2019 12:32:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:39660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391878AbfJCQcN (ORCPT ); Thu, 3 Oct 2019 12:32:13 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7DF6B215EA; Thu, 3 Oct 2019 16:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120333; bh=W4cYAWP0Qa/Qu3TFBSpjTV0C26MYzIiXO1hQPqY2Z/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sJWZi18au82bI/7YWmOnmbgMHjnQRIiiAr2PRnnOGj+4Z4PHj0RLPRh1F6ifYWu9q BFxp1SF/Vczlj8XmeziFBjSp9rX3UxnXSGjwZXciV7m/NDYjukYiMCo1W87o0POCeU Rzj+zKrpVqECF3cCK5FZ80Q8/lK587lJCf0jo1Bc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "M. Vefa Bicakci" , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.2 183/313] platform/x86: intel_pmc_core: Do not ioremap RAM Date: Thu, 3 Oct 2019 17:52:41 +0200 Message-Id: <20191003154551.007317335@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@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: M. Vefa Bicakci [ Upstream commit 7d505758b1e556cdf65a5e451744fe0ae8063d17 ] On a Xen-based PVH virtual machine with more than 4 GiB of RAM, intel_pmc_core fails initialization with the following warning message from the kernel, indicating that the driver is attempting to ioremap RAM: ioremap on RAM at 0x00000000fe000000 - 0x00000000fe001fff WARNING: CPU: 1 PID: 434 at arch/x86/mm/ioremap.c:186 __ioremap_caller.constprop.0+0x2aa/0x2c0 ... Call Trace: ? pmc_core_probe+0x87/0x2d0 [intel_pmc_core] pmc_core_probe+0x87/0x2d0 [intel_pmc_core] This issue appears to manifest itself because of the following fallback mechanism in the driver: if (lpit_read_residency_count_address(&slp_s0_addr)) pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT; The validity of address PMC_BASE_ADDR_DEFAULT (i.e., 0xFE000000) is not verified by the driver, which is what this patch introduces. With this patch, if address PMC_BASE_ADDR_DEFAULT is in RAM, then the driver will not attempt to ioremap the aforementioned address. Signed-off-by: M. Vefa Bicakci Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- drivers/platform/x86/intel_pmc_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c index be6cda89dcf5b..01a530e2f8017 100644 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@ -882,10 +882,14 @@ static int pmc_core_probe(struct platform_device *pdev) if (pmcdev->map == &spt_reg_map && !pci_dev_present(pmc_pci_ids)) pmcdev->map = &cnp_reg_map; - if (lpit_read_residency_count_address(&slp_s0_addr)) + if (lpit_read_residency_count_address(&slp_s0_addr)) { pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT; - else + + if (page_is_ram(PHYS_PFN(pmcdev->base_addr))) + return -ENODEV; + } else { pmcdev->base_addr = slp_s0_addr - pmcdev->map->slp_s0_offset; + } pmcdev->regbase = ioremap(pmcdev->base_addr, pmcdev->map->regmap_length); -- 2.20.1