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=-6.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 E9723C3A5A2 for ; Tue, 20 Aug 2019 01:48:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEF3022DA8 for ; Tue, 20 Aug 2019 01:48:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="xDgOvr7d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728907AbfHTBsB (ORCPT ); Mon, 19 Aug 2019 21:48:01 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42360 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728647AbfHTBsA (ORCPT ); Mon, 19 Aug 2019 21:48:00 -0400 Received: by mail-pf1-f194.google.com with SMTP id i30so2305715pfk.9 for ; Mon, 19 Aug 2019 18:48:00 -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:in-reply-to:references:date:message-id :mime-version; bh=RfLs+sRfBSDgb+tBIhChiANAEUhKiMw/rtbpKhN6zaY=; b=xDgOvr7dIvIKX4kULkDv9+SPhMsQwKzSH0sKoqyXx/wpx5DHVoyuaCtOBzG7HwuRYp jh8X8OfTPK5SowqYmxTCsg/xKHv5iG8CBBSXHn+pHgPpPDEBO3xZvClGHHr9/V5Osy+E FUAIaGka/yjKUD9VxaCbcIDwAuVdeaZdXfPqg/23hXjLcYhNGoTDXJEioXK2eF/wdcSj vINbNRuNtkq3oXEXtMgq/SXF3lXNzxo/PJrxwQUVM68i62c44Ofjb2IwbBDn0ZAJb/Mk vBUPUOUVATwFGL18ru1BrsD/w8Fnpivid49hcQhPvzboCRhk+cL4mfmFKt39vO552iHQ QkCw== 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:in-reply-to:references:date :message-id:mime-version; bh=RfLs+sRfBSDgb+tBIhChiANAEUhKiMw/rtbpKhN6zaY=; b=eq9cyHNjHatiPWML0fNKE4lXwrVOvLHR9YjQzmuZeo39CnEowS9jJeIQN97MhmsZLt p25Bwz38x1WoiZplwgY7wJ4CprCORbjqenscgM0z7CRIpo3oxkr3peji7ew/uXdCqJHn we/8oG8qDHLje/W0e8bEX0wbcEgcTb/KrcSNxFW9a9d8loh5MIRAKY0k0tlQN1LbsJo5 gcdd/PflL4BWc7UNGlt0PNX/0yHe6X6ap6081MmaO4lTKZrgcbw3ahlThwSnHJtuSW2n Su3MIp0RvODla6Keb/vq9qxSXeTwsz8QkzwuTiCswax1BxUkG7+mCyGwd5jsCNgYNMay W8KQ== X-Gm-Message-State: APjAAAVGu7eqx3Sy0rwwNkAGG1oVKI9TfyPQT1Bfi6tx8bPJ525ONkYh cqtwDJ57d36bu/+eRqxgCfoEhg== X-Google-Smtp-Source: APXvYqwVegiYT4hHAvpHnbXs+lPZw+l1k9sXk0MQ52n1ouVNqGK5erNtO31mcO6BFgTZIuKjY+o1eQ== X-Received: by 2002:a65:4841:: with SMTP id i1mr22588419pgs.316.1566265679652; Mon, 19 Aug 2019 18:47:59 -0700 (PDT) Received: from localhost ([49.205.218.65]) by smtp.gmail.com with ESMTPSA id s20sm16948435pfe.169.2019.08.19.18.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 18:47:59 -0700 (PDT) From: Santosh Sivaraj To: Nicholas Piggin , Linux Kernel , linuxppc-dev Cc: "Aneesh Kumar K.V" , Reza Arbab , Balbir Singh , Chandan Rajendra , christophe leroy , Mahesh Salgaonkar , Mahesh Salgaonkar , Michael Ellerman , stable@vger.kernel.org Subject: Re: [PATCH v10 2/7] powerpc/mce: Fix MCE handling for huge pages In-Reply-To: <1566223931.kpuwkor3n7.astroid@bobo.none> References: <20190815003941.18655-1-santosh@fossix.org> <20190815003941.18655-3-santosh@fossix.org> <1566223931.kpuwkor3n7.astroid@bobo.none> Date: Tue, 20 Aug 2019 07:17:56 +0530 Message-ID: <87ef1gppyr.fsf@santosiv.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nick, Nicholas Piggin writes: > Santosh Sivaraj's on August 15, 2019 10:39 am: >> 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 >> Co-developed-by: Santosh Sivaraj >> Signed-off-by: Santosh Sivaraj >> Tested-by: Mahesh Salgaonkar >> Cc: stable@vger.kernel.org # v4.15+ >> --- >> arch/powerpc/include/asm/mce.h | 2 +- >> arch/powerpc/kernel/mce_power.c | 55 ++++++++++++++-------------- >> arch/powerpc/platforms/pseries/ras.c | 9 ++--- >> 3 files changed, 32 insertions(+), 34 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h >> index a4c6a74ad2fb..f3a6036b6bc0 100644 >> --- a/arch/powerpc/include/asm/mce.h >> +++ b/arch/powerpc/include/asm/mce.h >> @@ -209,7 +209,7 @@ extern void release_mce_event(void); >> extern void machine_check_queue_event(void); >> extern void machine_check_print_event_info(struct machine_check_event *evt, >> bool user_mode, bool in_guest); >> -unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr); >> +unsigned long addr_to_phys(struct pt_regs *regs, unsigned long addr); >> #ifdef CONFIG_PPC_BOOK3S_64 >> void flush_and_reload_slb(void); >> #endif /* CONFIG_PPC_BOOK3S_64 */ >> diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c >> index a814d2dfb5b0..e74816f045f8 100644 >> --- a/arch/powerpc/kernel/mce_power.c >> +++ b/arch/powerpc/kernel/mce_power.c >> @@ -20,13 +20,14 @@ >> #include >> >> /* >> - * Convert an address related to an mm to a PFN. NOTE: we are in real >> - * mode, we could potentially race with page table updates. >> + * Convert an address related to an mm to a physical address. >> + * NOTE: we are in real mode, we could potentially race with page table updates. >> */ >> -unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr) >> +unsigned long addr_to_phys(struct pt_regs *regs, unsigned long addr) >> { >> - pte_t *ptep; >> - unsigned long flags; >> + pte_t *ptep, pte; >> + unsigned int shift; >> + unsigned long flags, phys_addr; >> struct mm_struct *mm; >> >> if (user_mode(regs)) >> @@ -35,14 +36,21 @@ 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; >> - return pte_pfn(*ptep); >> + >> + pte = *ptep; >> + if (shift > PAGE_SHIFT) { >> + unsigned long rpnmask = (1ul << shift) - PAGE_SIZE; >> + >> + pte = __pte(pte_val(pte) | (addr & rpnmask)); >> + } >> + phys_addr = pte_pfn(pte) << PAGE_SHIFT; >> + >> + return phys_addr; >> } > > This should remain addr_to_pfn I think. None of the callers care what > size page the EA was mapped with. 'pfn' is referring to the Linux pfn, > which is the small page number. > > if (shift > PAGE_SHIFT) > return (pte_pfn(*ptep) | ((addr & ((1UL << shift) - 1)) >> PAGE_SHIFT); > else > return pte_pfn(*ptep); > > Something roughly like that, then you don't have to change any callers > or am I missing something? Here[1] you asked to return the real address rather than pfn, which all callers care about. So made the changes accordingly. [1] https://www.spinics.net/lists/kernel/msg3187658.html Thanks, Santosh > > Thanks, > Nick