Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3736081ybl; Tue, 20 Aug 2019 01:15:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfH185uGT85Q7/ES+Te3Y5aAXRa6/80NyF51ppYkcsr0LJ860dNq0hLySPl8dpT07FQ462 X-Received: by 2002:a17:90a:be02:: with SMTP id a2mr24992855pjs.94.1566288917054; Tue, 20 Aug 2019 01:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566288917; cv=none; d=google.com; s=arc-20160816; b=PwRF/mdN+0MEzOYpJawT5JeyEIUg48nkJdUO3lg1SXkiQcRXsHW8I7m5qT+nQMgPZy a56DkNSqdfcI6r7Q9ka0sq5e58gq20i9rqBZK0vppXfTrD5m3fyfBlMCl2TAGM6+yItf C8C8UJ+kh0kqKZsRnzHWsCf0Eg79XLlceeXQlAxDKXa/ObIv9toGmXL0HCZgHRYS/eMp TrWcEIj1dmZ3J7XxSe0qouPB5UQIpSzbrCrls2NixFpWONjv9q6mHmY/d9Lt6iLZTwhD EA9/Jtg44iP588UwEerhbe4to58hVO6EapWOUY0+NgTBAi+ghgq7NA4mUp7oGtKwQuOy Ck+w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XQA3UCdGC7caS48ij4zC/iNWJe//yYh8xmEXn6HYb5Q=; b=eqItocxk6ZVjpchJwWJrGiacTpvGKslOnR2u8xhqb79iOrYsbMFzf6Q8c5g/HvwXSL aXVoDZSD58i7gdYSYNUjbfCEER/ms5Z1JpiF9H0NbnTqIq6JxVB33L+q9wu3BiogrbKj /FM1hrnPGrzD7g+fYoqHQMY6OXEAEU25kteIS44hNa2Qju8iBMgYPn+X5sjrSBXUaEDM buJ9oJfbGqtx+KFBNj8XGXgejnT+BuOMxYFvmYqNpwlekGyZ+2NvSUTn7L3mpuamMtDu QCzE7RgGA2hizgpLKN5e7Dip6Z9InXo0a/jYCJs9GVK4AWq9oRPzeKF/232eZze1UIS7 hXvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fossix-org.20150623.gappssmtp.com header.s=20150623 header.b=ZaxOt8lk; 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 n10si11800450pgr.27.2019.08.20.01.15.01; Tue, 20 Aug 2019 01:15:17 -0700 (PDT) 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=@fossix-org.20150623.gappssmtp.com header.s=20150623 header.b=ZaxOt8lk; 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 S1729409AbfHTIOI (ORCPT + 99 others); Tue, 20 Aug 2019 04:14:08 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:44115 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729395AbfHTIOH (ORCPT ); Tue, 20 Aug 2019 04:14:07 -0400 Received: by mail-pl1-f193.google.com with SMTP id t14so2353267plr.11 for ; Tue, 20 Aug 2019 01:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fossix-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XQA3UCdGC7caS48ij4zC/iNWJe//yYh8xmEXn6HYb5Q=; b=ZaxOt8lk22Z21ulmXMLkeo0R/2PTzZDR0R59vKVCfgZDN+uL7ZpYx1PvlCJfYueDro 0+iBPqErLvoipl5xvSp7vEG5falbWHLpEPg5ypzBjEf8/k1FBngvApv3z67S5WLsZJMt mnMgTwgsaNsf9qzaMKnwiJ36s+EIsL+8fLtrDdWbyrexuraTZIp8JMe9ECT4fp0zQbSv lfOwLIRUpV7X8afUFwENMwTu2KajbnGZpMxfWW4Fh68lFD4sdthbwcapSbGieEc32Ddc n9FJo7AcVmmXhFBst/qWjg54KCZJ8XK61xbCBHNv5qtO0PpQvjDw6gnY5bc0QMok60VT i7Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XQA3UCdGC7caS48ij4zC/iNWJe//yYh8xmEXn6HYb5Q=; b=XA9UtXoIR8HXfd8ohQzDutvW18uA8MNsX26PJQrQaGZHCYVVTMgY7a8xOsqiLG+7P4 t8FE6skWMXoQvzkWWG1yWf7OWsBi88uJfNeUqhAjNtC4auM+P9nW8/FDPJqOe276nEOQ htil4xYPleKHaiVTW1dvPdnka30G88UXkegrppantR3iZFhRLvLh3HASY5JxYaZdXlUb Pd/zox8DxP6OebllrA8MSOTuvN3K7RyN4Vk1KhDI3EbukJn7OonIBGla7PNJbJDA3cZ5 +LdHS5NZpD7kai2D0xHVBX/ovJixH9VMNdpVGRULtSq0Z9IOdUxtdzk2ld1RNrzp4b4/ vlOg== X-Gm-Message-State: APjAAAVRO14qp5AD/3teMxCoh/Zh3VKBKUjwhk3p+P5zsPn5VEeuGSk2 YIlNrdcy5tjAITvRp77TOXqN1w== X-Received: by 2002:a17:902:fe06:: with SMTP id g6mr26976368plj.265.1566288847004; Tue, 20 Aug 2019 01:14:07 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.78]) by smtp.gmail.com with ESMTPSA id b14sm18949265pfo.15.2019.08.20.01.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 01:14:06 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev , Linux Kernel Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Reza Arbab , Chandan Rajendra , Nicholas Piggin , Michael Ellerman , Balbir Singh , Mahesh Salgaonkar , stable@vger.kernel.org Subject: [PATCH v11 2/7] powerpc/mce: Fix MCE handling for huge pages Date: Tue, 20 Aug 2019 13:43:47 +0530 Message-Id: <20190820081352.8641-3-santosh@fossix.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190820081352.8641-1-santosh@fossix.org> References: <20190820081352.8641-1-santosh@fossix.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Balbir Singh The current code would fail on huge pages addresses, since the shift would be incorrect. Use the correct page shift value returned by __find_linux_pte() to get the correct physical address. The code is more generic and can handle both regular and compound pages. Fixes: ba41e1e1ccb9 ("powerpc/mce: Hookup derror (load/store) UE errors") Signed-off-by: Balbir Singh [arbab@linux.ibm.com: Fixup pseries_do_memory_failure()] Signed-off-by: Reza Arbab Tested-by: Mahesh Salgaonkar Signed-off-by: Santosh Sivaraj Cc: stable@vger.kernel.org # v4.15+ --- arch/powerpc/kernel/mce_power.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c index a814d2dfb5b0..714a98e0927f 100644 --- a/arch/powerpc/kernel/mce_power.c +++ b/arch/powerpc/kernel/mce_power.c @@ -26,6 +26,7 @@ unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr) { pte_t *ptep; + unsigned int shift; unsigned long flags; struct mm_struct *mm; @@ -35,13 +36,18 @@ unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr) mm = &init_mm; local_irq_save(flags); - if (mm == current->mm) - ptep = find_current_mm_pte(mm->pgd, addr, NULL, NULL); - else - ptep = find_init_mm_pte(addr, NULL); + ptep = __find_linux_pte(mm->pgd, addr, NULL, &shift); local_irq_restore(flags); + if (!ptep || pte_special(*ptep)) return ULONG_MAX; + + if (shift > PAGE_SHIFT) { + unsigned long rpnmask = (1ul << shift) - PAGE_SIZE; + + return pte_pfn(__pte(pte_val(*ptep) | (addr & rpnmask))); + } + return pte_pfn(*ptep); } @@ -344,7 +350,7 @@ static const struct mce_derror_table mce_p9_derror_table[] = { MCE_INITIATOR_CPU, MCE_SEV_SEVERE, true }, { 0, false, 0, 0, 0, 0, 0 } }; -static int mce_find_instr_ea_and_pfn(struct pt_regs *regs, uint64_t *addr, +static int mce_find_instr_ea_and_phys(struct pt_regs *regs, uint64_t *addr, uint64_t *phys_addr) { /* @@ -541,7 +547,8 @@ static int mce_handle_derror(struct pt_regs *regs, * kernel/exception-64s.h */ if (get_paca()->in_mce < MAX_MCE_DEPTH) - mce_find_instr_ea_and_pfn(regs, addr, phys_addr); + mce_find_instr_ea_and_phys(regs, addr, + phys_addr); } found = 1; } -- 2.21.0