From patchwork Tue Jan 26 20:57:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 8127431 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 61B749F1C0 for ; Tue, 26 Jan 2016 21:03:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5173020212 for ; Tue, 26 Jan 2016 21:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D77F20279 for ; Tue, 26 Jan 2016 21:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbcAZU7q (ORCPT ); Tue, 26 Jan 2016 15:59:46 -0500 Received: from mail.skyhub.de ([78.46.96.112]:41617 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752042AbcAZU5o (ORCPT ); Tue, 26 Jan 2016 15:57:44 -0500 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (door.skyhub.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TwsaUHAhPgey; Tue, 26 Jan 2016 21:57:42 +0100 (CET) Received: from pd.tnic (p200300454B150D000A606EFFFE5584DC.dip0.t-ipconnect.de [IPv6:2003:45:4b15:d00:a60:6eff:fe55:84dc]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id C993D245AAF; Tue, 26 Jan 2016 21:57:38 +0100 (CET) Received: by pd.tnic (Postfix, from userid 1000) id ADC7A161AC6; Tue, 26 Jan 2016 21:57:33 +0100 (CET) From: Borislav Petkov To: Ingo Molnar Cc: LKML , Andrew Morton , Jarkko Nikula , Len Brown , linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm , linux-nvdimm@lists.01.org, "Rafael J. Wysocki" , Vishal Verma Subject: [PATCH 17/17] ACPI/EINJ: Allow memory error injection to NVDIMM Date: Tue, 26 Jan 2016 21:57:33 +0100 Message-Id: <1453841853-11383-18-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1453841853-11383-1-git-send-email-bp@alien8.de> References: <1453841853-11383-1-git-send-email-bp@alien8.de> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Toshi Kani In the case of memory error injection, einj_error_inject() checks if a target address is System RAM. Change this check to allow injecting a memory error into NVDIMM memory by calling region_intersects() with IORES_DESC_PERSISTENT_MEMORY. This enables memory error testing on both System RAM and NVDIMM. In addition, page_is_ram() is replaced with region_intersects() with IORESOURCE_SYSTEM_RAM, so that it can verify a target address range with the requested size. Reviewed-by: Dan Williams Acked-by: Tony Luck Signed-off-by: Toshi Kani Cc: Andrew Morton Cc: Jarkko Nikula Cc: Len Brown Cc: linux-acpi@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-mm Cc: linux-nvdimm@lists.01.org Cc: "Rafael J. Wysocki" Cc: Vishal Verma Link: http://lkml.kernel.org/r/1452020081-26534-17-git-send-email-toshi.kani@hpe.com Signed-off-by: Borislav Petkov --- drivers/acpi/apei/einj.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index 0431883653be..559c1173de1c 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -519,7 +519,7 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, u64 param4) { int rc; - unsigned long pfn; + u64 base_addr, size; /* If user manually set "flags", make sure it is legal */ if (flags && (flags & @@ -545,10 +545,17 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, /* * Disallow crazy address masks that give BIOS leeway to pick * injection address almost anywhere. Insist on page or - * better granularity and that target address is normal RAM. + * better granularity and that target address is normal RAM or + * NVDIMM. */ - pfn = PFN_DOWN(param1 & param2); - if (!page_is_ram(pfn) || ((param2 & PAGE_MASK) != PAGE_MASK)) + base_addr = param1 & param2; + size = ~param2 + 1; + + if (((param2 & PAGE_MASK) != PAGE_MASK) || + ((region_intersects(base_addr, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) + != REGION_INTERSECTS) && + (region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_PERSISTENT_MEMORY) + != REGION_INTERSECTS))) return -EINVAL; inject: