From patchwork Tue Jul 2 05:19:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125940 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCK41GLsz9sLt for ; Tue, 2 Jul 2019 15:21:44 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="nhdS0KN6"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCK36sftzDqTn for ; Tue, 2 Jul 2019 15:21:43 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="nhdS0KN6"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCGq6FYlzDqSq for ; Tue, 2 Jul 2019 15:19:47 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id w24so8508435plp.2 for ; Mon, 01 Jul 2019 22:19:47 -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=h+d/dQulSsirIOKPqYl4FAJMvNn/8ZD+HSg3OI8Zr9U=; b=nhdS0KN6t7UeKEx07/tvhS5TN5HJYAjclysXa2xPwbXdb+j2HKfICd4zUHIOCP5uJg K/qPNhrk3xQg862DQqnqNBBUXY55U4LUzbPO3U7D9inNSujwXVVF9w1M2rHMVxR0rllV vuNH7g91R92bTAmDCJzGNowD48qhjpt0dOkIFBn8w9KHMsQ+ashmolOpGzeOBlVjHoHy 6RK57+MISandUTSsedNqlVzZ2BpEN7i47MHXTQb+nhpjj7ELqlxVkEfU96r9JyHnXBT/ Xrlnq/N4IfED5eKlt9Zhk5dNla6J0Dy4Xauebmd8mO16iNTzUy0PGF165l9+IEgu1koW oTXg== 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=h+d/dQulSsirIOKPqYl4FAJMvNn/8ZD+HSg3OI8Zr9U=; b=sEENUsAoQevkstJsWUmDRUT7oQeNwXN6cuMWXnCfeEDZ2j9psUkgrTQLPbgOSTvTQo doezIGma5rgYFHYXJlHft18gaIqN7bNzEZNhrwvyb7sT+DAvWDNtFKrgdP4uY2dujhPO 876O6k551kFhNYGK4+PWLHluNdtagVAcNeUGNbnJZ+RXqLOC9vqs/sEO3EJzUsOajMgy TcjbFNkGq21pmPgPyelGA4me3AKpPr8qSQjG6HBmp6jZ+DOcKQGYYdcaPPZcQnLG+Sos ulK2ZsP3T8ILe/kXJe652dN7TRHOXQ4VOqpipAwUKcL2odLdYTAyoLmMwUdbmn+Qz3Ob UhOw== X-Gm-Message-State: APjAAAWHil0w0qxzwfGN+FEPcnmw7kRUlh7B34sa/nVl42/ORW/6smMz n+5S+I8TCefKZIfyHDXvyen6pzrxCEDKKA== X-Google-Smtp-Source: APXvYqwu53hhrwJ1/YfXfyXjY5fijnNg2Px0Ayjq9tqtt2dCf0MFBdWQBi94btLTHlBo/yiK3bfOrQ== X-Received: by 2002:a17:902:4e25:: with SMTP id f34mr32889807ple.305.1562044785853; Mon, 01 Jul 2019 22:19:45 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.19.42 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:19:45 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 01/12] powerpc/mce: Make machine_check_ue_event() static Date: Tue, 2 Jul 2019 10:49:21 +0530 Message-Id: <20190702051932.511-2-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab The function doesn't get used outside this file, so make it static. Signed-off-by: Reza Arbab --- arch/powerpc/kernel/mce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index b18df633eae9..e78c4f18ea0a 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -33,7 +33,7 @@ static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT], mce_ue_event_queue); static void machine_check_process_queued_event(struct irq_work *work); -void machine_check_ue_event(struct machine_check_event *evt); +static void machine_check_ue_event(struct machine_check_event *evt); static void machine_process_ue_event(struct work_struct *work); static struct irq_work mce_event_process_work = { @@ -203,7 +203,7 @@ void release_mce_event(void) /* * Queue up the MCE event which then can be handled later. */ -void machine_check_ue_event(struct machine_check_event *evt) +static void machine_check_ue_event(struct machine_check_event *evt) { int index; From patchwork Tue Jul 2 05:19:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125990 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dDyT5SDFz9sNC for ; Tue, 2 Jul 2019 16:35:45 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="zaA80uur"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dDyT3dQRzDqSr for ; Tue, 2 Jul 2019 16:35:45 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="zaA80uur"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCGw1c6czDqSn for ; Tue, 2 Jul 2019 15:19:51 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id m4so7097535pgk.0 for ; Mon, 01 Jul 2019 22:19:51 -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=Nqm1MiOeZebJXjq+40rQkia+J1ym1ayfkTrPWZH8MuU=; b=zaA80uurEM6pYLRnL3n9l5DfTNvE5Jv2DvKZ42vnKf/je+7UWZ62Igg0nI6Vzo72Bj I62Rq6VE82rjbCoqHdsENnt3vTG82bdssAW80tJvTaLSoTF6cJETdF+RsoneifPjKSOV EK2YLIiKg5U5W9VGdIUE5m+4/JTDwdJzgLou0K4oSBNxbAjS1U1RrpS5gDOeJpBNJe/S Obw4xya1DfuB/X6WZo08DxvEs6F0BHWhTgTWb5U4xYk3hx4ZfxtTVxuefclCL7whV5YW 0II7mu5ukymeY5U4c+ywWwq3YCx6OsvnzTLFvin3M1/3ULsptB0l33YhcmjF/TJUdPfQ k0Yw== 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=Nqm1MiOeZebJXjq+40rQkia+J1ym1ayfkTrPWZH8MuU=; b=NNDRPO0NFItSoqUu2D3rPUHPQwqPCEvZwPX40smnIZLw++Ab2CYf8CkAghfeDj2e32 g7gMWPg3jCwjJdGBRNdz6cWZgKz7RTt6N2Cxz3ryBAh4Xbri6Yi/Ik/H66npxip+9/cC byOOzPFCx9XvpPjTHJzqOeCYJBmJRFKdQlcWjT/jCH8UG2FJU86C0aOz4Y3j3CQpfIti Do9D6g9yJFK1uWCeT6UI3aHXOCddKpS4ck2m7qHGnlI/j5GT+JNxI/4mEckWV1Lj6+Bt oFurqHWaKNafQuHRzJGuG2mqwAusNHf2EiQuNyM+cNKMAHx54NiuDApZSCJtRvFP+MnF Z4Rg== X-Gm-Message-State: APjAAAVBYNKkB+NjOIIhCgM0LPq73vU93wcPitlqdFVnANT0EGnf5bBu 5p/xxw10eIxSmdm8m4ZpITUHBIB7R/jpow== X-Google-Smtp-Source: APXvYqyd3AY2n6NsKvldI34RT54wi9zVhhzYtNPesZPcQAoO+IjY5NI9QDIBo8/iQtlSe+VKk1/rQw== X-Received: by 2002:a17:90a:fa12:: with SMTP id cm18mr3375511pjb.137.1562044789286; Mon, 01 Jul 2019 22:19:49 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.19.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:19:48 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 02/12] powerpc/mce: Bug fixes for MCE handling in kernel space Date: Tue, 2 Jul 2019 10:49:22 +0530 Message-Id: <20190702051932.511-3-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Balbir Singh The code currently assumes PAGE_SHIFT as the shift value of the pfn, this works correctly (mostly) for user space pages, but the correct thing to do is 1. Extract the shift value returned via the pte-walk API's 2. Use the shift value to access the instruction address. Note, the final physical address still use PAGE_SHIFT for computation. handle_ierror() is not modified and handle_derror() is modified just for extracting the correct instruction address. This is largely due to __find_linux_pte() returning pfn's shifted by pdshift. The code is much more generic and can handle shift values returned. Fixes: ba41e1e1ccb9 ("powerpc/mce: Hookup derror (load/store) UE errors") Signed-off-by: Balbir Singh [arbab@linux.ibm.com: Fixup pseries_do_memory_failure()] --- arch/powerpc/include/asm/mce.h | 3 ++- arch/powerpc/kernel/mce_power.c | 26 ++++++++++++++++---------- arch/powerpc/platforms/pseries/ras.c | 6 ++++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h index a4c6a74ad2fb..94888a7025b3 100644 --- a/arch/powerpc/include/asm/mce.h +++ b/arch/powerpc/include/asm/mce.h @@ -209,7 +209,8 @@ 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_pfn(struct pt_regs *regs, unsigned long addr, + unsigned int *shift); #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 e39536aad30d..04666c0b40a8 100644 --- a/arch/powerpc/kernel/mce_power.c +++ b/arch/powerpc/kernel/mce_power.c @@ -23,7 +23,8 @@ * Convert an address related to an mm to a PFN. 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_pfn(struct pt_regs *regs, unsigned long addr, + unsigned int *shift) { pte_t *ptep; unsigned long flags; @@ -36,13 +37,15 @@ unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr) local_irq_save(flags); if (mm == current->mm) - ptep = find_current_mm_pte(mm->pgd, addr, NULL, NULL); + ptep = find_current_mm_pte(mm->pgd, addr, NULL, shift); else - ptep = find_init_mm_pte(addr, NULL); + ptep = find_init_mm_pte(addr, shift); local_irq_restore(flags); if (!ptep || pte_special(*ptep)) return ULONG_MAX; - return pte_pfn(*ptep); + if (!*shift) + *shift = PAGE_SHIFT; + return (pte_val(*ptep) & PTE_RPN_MASK) >> *shift; } /* flush SLBs and reload */ @@ -358,15 +361,16 @@ static int mce_find_instr_ea_and_pfn(struct pt_regs *regs, uint64_t *addr, unsigned long pfn, instr_addr; struct instruction_op op; struct pt_regs tmp = *regs; + unsigned int shift; - pfn = addr_to_pfn(regs, regs->nip); + pfn = addr_to_pfn(regs, regs->nip, &shift); if (pfn != ULONG_MAX) { - instr_addr = (pfn << PAGE_SHIFT) + (regs->nip & ~PAGE_MASK); + instr_addr = (pfn << shift) + (regs->nip & ((1 << shift) - 1)); instr = *(unsigned int *)(instr_addr); if (!analyse_instr(&op, &tmp, instr)) { - pfn = addr_to_pfn(regs, op.ea); + pfn = addr_to_pfn(regs, op.ea, &shift); *addr = op.ea; - *phys_addr = (pfn << PAGE_SHIFT); + *phys_addr = (pfn << shift); return 0; } /* @@ -442,12 +446,14 @@ static int mce_handle_ierror(struct pt_regs *regs, if (mce_err->sync_error && table[i].error_type == MCE_ERROR_TYPE_UE) { unsigned long pfn; + unsigned int shift; if (get_paca()->in_mce < MAX_MCE_DEPTH) { - pfn = addr_to_pfn(regs, regs->nip); + pfn = addr_to_pfn(regs, regs->nip, + &shift); if (pfn != ULONG_MAX) { *phys_addr = - (pfn << PAGE_SHIFT); + (pfn << shift); } } } diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c index f16fdd0f71f7..5e43283d3300 100644 --- a/arch/powerpc/platforms/pseries/ras.c +++ b/arch/powerpc/platforms/pseries/ras.c @@ -740,12 +740,14 @@ static void pseries_do_memory_failure(struct pt_regs *regs, paddr = be64_to_cpu(mce_log->logical_address); } else if (mce_log->sub_err_type & UE_EFFECTIVE_ADDR_PROVIDED) { unsigned long pfn; + unsigned int shift; pfn = addr_to_pfn(regs, - be64_to_cpu(mce_log->effective_address)); + be64_to_cpu(mce_log->effective_address), + &shift); if (pfn == ULONG_MAX) return; - paddr = pfn << PAGE_SHIFT; + paddr = pfn << shift; } else { return; } From patchwork Tue Jul 2 05:19:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125991 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dF0n1vKmz9sNC for ; Tue, 2 Jul 2019 16:37:45 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="NJweHnYS"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dF0n0ZZRzDqYj for ; Tue, 2 Jul 2019 16:37:45 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::643; helo=mail-pl1-x643.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="NJweHnYS"; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCGy3vprzDqSn for ; Tue, 2 Jul 2019 15:19:54 +1000 (AEST) Received: by mail-pl1-x643.google.com with SMTP id b7so8515780pls.6 for ; Mon, 01 Jul 2019 22:19:54 -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=VGnUeOD9q4vdMF4DDLffBmI8X+bOtxV4zPtktuX2RWM=; b=NJweHnYSIJq0SALdEp1MHA7qgiorGjdQflvjVrvtUcDvTzBx7EGXprCrdujLBdNM70 cPUyXs3lVbcrk8q+gYgTfvq+TH+0jZrI2A0OAUmkN5hJDllmWF9d04XuQ+0oyddEBnbP zIcJ8o5aJ7MiOG9Oh+71CeF/cDRoh6EkD7d09cp+oNH5tn5ckM9v7hOGDXeg23vizJiN oekYkcAfFseqtoiqLkcZvhqQ5QPV8ITJDqCq2B7AJ8mfm4mucjQLBOmfjync+HER94Nm s0eJLU4fs5b4kYO2g8UAh/11hFFV5V2MtAy7qSLRUiPzujBEDG6hoAG3yYdcTj8JvNgn 0nhg== 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=VGnUeOD9q4vdMF4DDLffBmI8X+bOtxV4zPtktuX2RWM=; b=YRtug/fHBV2EC1vtae8AinCxtmbedmpFjC5nReupwRgTUbGXCVX+Pg8zpVU5BYCHak n+nH872s+6KT5cbkOY9j10T4S3s4fCT0hXCDw/F13/9hzq4bxUa4C/4SrivCggMBsM06 OM/rjYpw8qNVwPdEpmZGUM2IfIwk8yLIeecB9ptQHJOQRsXAeg4FRV22O4u0ZNgtRY1F 6eUzr0r6e4wPyieYp07yM6Y/DzjIilmyPEd6dyQNryAgUA5hB4VZYMUp1bHhvqTFS5+F WDi4O0G0+VZSN5jsd9+1A8CR+rpB+ZwGLivilqZMJi8GwSOnkQcWLnPX+ySa5bZ5ty3K jolw== X-Gm-Message-State: APjAAAXgb0PyPr+rZudr/R8a4YwPaDXRtAw+ckxQXQ9tRmEP1Qt0VRCb kbeU87Z6JAZUPXBdPzslKSH7e4wN2Nr7lg== X-Google-Smtp-Source: APXvYqwQtc+D6UgmbzkRLzocEyL+HaYjS/NpkAZcsImE375e5hZz0yWqyiL4k8b0kzbzJqGkSaZqOw== X-Received: by 2002:a17:902:29a7:: with SMTP id h36mr33957559plb.158.1562044792613; Mon, 01 Jul 2019 22:19:52 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.19.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:19:52 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 03/12] powerpc/mce: Add MCE notification chain Date: Tue, 2 Jul 2019 10:49:23 +0530 Message-Id: <20190702051932.511-4-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab Signed-off-by: Reza Arbab --- arch/powerpc/include/asm/asm-prototypes.h | 1 + arch/powerpc/include/asm/mce.h | 4 ++++ arch/powerpc/kernel/exceptions-64s.S | 4 ++++ arch/powerpc/kernel/mce.c | 22 ++++++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h index ec1c97a8e8cb..f66f26ef3ce0 100644 --- a/arch/powerpc/include/asm/asm-prototypes.h +++ b/arch/powerpc/include/asm/asm-prototypes.h @@ -72,6 +72,7 @@ void machine_check_exception(struct pt_regs *regs); void emulation_assist_interrupt(struct pt_regs *regs); long do_slb_fault(struct pt_regs *regs, unsigned long ea); void do_bad_slb_fault(struct pt_regs *regs, unsigned long ea, long err); +void machine_check_notify(struct pt_regs *regs); /* signals, syscalls and interrupts */ long sys_swapcontext(struct ucontext __user *old_ctx, diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h index 94888a7025b3..948bef579086 100644 --- a/arch/powerpc/include/asm/mce.h +++ b/arch/powerpc/include/asm/mce.h @@ -214,4 +214,8 @@ unsigned long addr_to_pfn(struct pt_regs *regs, unsigned long addr, #ifdef CONFIG_PPC_BOOK3S_64 void flush_and_reload_slb(void); #endif /* CONFIG_PPC_BOOK3S_64 */ + +int mce_register_notifier(struct notifier_block *nb); +int mce_unregister_notifier(struct notifier_block *nb); + #endif /* __ASM_PPC64_MCE_H__ */ diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 6b86055e5251..2e56014fca21 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -457,6 +457,10 @@ EXC_COMMON_BEGIN(machine_check_handle_early) addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_early std r3,RESULT(r1) /* Save result */ + + addi r3,r1,STACK_FRAME_OVERHEAD + bl machine_check_notify + ld r12,_MSR(r1) BEGIN_FTR_SECTION b 4f diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index e78c4f18ea0a..24d350a934e4 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -42,6 +42,18 @@ static struct irq_work mce_event_process_work = { DECLARE_WORK(mce_ue_event_work, machine_process_ue_event); +static BLOCKING_NOTIFIER_HEAD(mce_notifier_list); + +int mce_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&mce_notifier_list, nb); +} + +int mce_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&mce_notifier_list, nb); +} + static void mce_set_error_info(struct machine_check_event *mce, struct mce_error_info *mce_err) { @@ -635,3 +647,13 @@ long hmi_exception_realmode(struct pt_regs *regs) return 1; } + +void machine_check_notify(struct pt_regs *regs) +{ + struct machine_check_event evt; + + if (!get_mce_event(&evt, MCE_EVENT_DONTRELEASE)) + return; + + blocking_notifier_call_chain(&mce_notifier_list, 0, &evt); +} From patchwork Tue Jul 2 05:19:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125997 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dF2q1n0Jz9sNC for ; Tue, 2 Jul 2019 16:39:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="uLwrvlss"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dF2q0WSCzDqZj for ; Tue, 2 Jul 2019 16:39:31 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="uLwrvlss"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCH224n5zDqVP for ; Tue, 2 Jul 2019 15:19:58 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id m4so7097646pgk.0 for ; Mon, 01 Jul 2019 22:19:58 -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=XB8JDWrvxOU6U9PteJneZ99ibbyNeJLhwtOQI5zxxaE=; b=uLwrvlssgRZUCY1wQG4PVSd/VBD/UwP2wv6Ug5qyOaZW4qipGf6CQU9n6s5+kRzh/W LqxWTUIwTNTB3jZN2oI8grq23pisVKzcxRYvojdE+jtfdZmDKKhkXDjS93FMJOeJYrwb 1ej4gUnWk2uXfBUihQxS5+hPhZa4eUFYtcB8dsxFjSpGskob/ARWnA/jJOiWTV+JKIw4 5p70GXH4mZPUkhdIR5ZhydaemcnrEPSKqG87UUfi1KpGBhEw3wFH5bizg9rIeuAV+DZS 9DiwPf251WGQizLdexk7Rv5M9GklUS3iRjqGM0wo6m4VRmks/4hGFLHZOinHv7y6Pbth ZHgA== 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=XB8JDWrvxOU6U9PteJneZ99ibbyNeJLhwtOQI5zxxaE=; b=ObPY/XeMyKCXZtjHm7UuANMR5Gf7n7sqEy+5Gd5NRxTt7n3gew2TAzdHblVZkswLRo WTHmnU8adyp4kWzxxK/odosyJzUmq+Up40kWbrnRWbwSvHUkiMgp5/rXzDr3wNMFcOkN Y3YwnJYQGqZAXyQylyQWIHJJ7Vhwqt7sLkxeEDq9i4G/JbS6kUGyNgH1p02q8RJvmWtZ +3Iop/ngxQ0yAN8P5hWRrnl+xgPOwl0Hovjk5gkOMY1AZgdbw5tBVCztCOEk5ts9KeaK s5YBJQSYk3bDCMRiQjx4VF4GMKOlX1zy3zz4IZyABPGYW41xQuhMW1QqOG+bnLwSdgCo J0Kg== X-Gm-Message-State: APjAAAWX2UUYK27dJZZSXSqUi/hB8P6H12OLL297ItUAljOSdX+WF3Ts doIhI+bkcCuvZJ12wQRM3KBXeCTQWJ8lIw== X-Google-Smtp-Source: APXvYqxDXxLz5GXJiALnMOWknaYdHpPL80OSU5ZijvTCgheKQnHqmIaqACP4QagdQLIxY40gWghH3g== X-Received: by 2002:a63:18d:: with SMTP id 135mr28749774pgb.62.1562044796233; Mon, 01 Jul 2019 22:19:56 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.19.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:19:55 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 04/12] powerpc/mce: Move machine_check_ue_event() call Date: Tue, 2 Jul 2019 10:49:24 +0530 Message-Id: <20190702051932.511-5-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab Move the call site of machine_check_ue_event() slightly later in the MCE codepath. No functional change intended--this is prep for a later patch to conditionally skip the call. Signed-off-by: Reza Arbab --- arch/powerpc/kernel/mce.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index 24d350a934e4..0ab171b41ede 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -156,7 +156,6 @@ void save_mce_event(struct pt_regs *regs, long handled, if (phys_addr != ULONG_MAX) { mce->u.ue_error.physical_address_provided = true; mce->u.ue_error.physical_address = phys_addr; - machine_check_ue_event(mce); } } return; @@ -656,4 +655,8 @@ void machine_check_notify(struct pt_regs *regs) return; blocking_notifier_call_chain(&mce_notifier_list, 0, &evt); + + if (evt.error_type == MCE_ERROR_TYPE_UE && + evt.u.ue_error.physical_address_provided) + machine_check_ue_event(&evt); } From patchwork Tue Jul 2 05:19:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125941 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCLt0tP9z9sLt for ; Tue, 2 Jul 2019 15:23:18 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="PlNjRfhR"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCLs6KWvzDqM7 for ; Tue, 2 Jul 2019 15:23:17 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="PlNjRfhR"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCH54fVNzDqJ7 for ; Tue, 2 Jul 2019 15:20:01 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id i8so3878921pgm.13 for ; Mon, 01 Jul 2019 22:20:01 -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=eTxRJjN3pTPMOz/LuyvMrNd6bnn7wmfAl4QIN2ZzQNE=; b=PlNjRfhR61wr/pBxo3O490uasub6KA8gK3idricPfUia6mCBtttURrhky0PAAQIQcd yMZLgmbmc8eVw4PcSoE0HUX080zoxiR6H8Ita3pmERdH8sqeNCjDSxUh8UECDVCOTaX+ V60hZ1LcntSuw8UKo5lbTBAgHtVzDGscvmlAX+NVSAG4zgsRdcu7hvbZMAd1Swfa2LtT bzDEIdTPyrNYdvj37tAnJb7Fh4FNT92+kGRWWxOhNY+D+akrZze9xFEk7YttjTZf9g0E +jWZ/n87YSyK79NK5Edk0VYP1dUYIX95pkaH+oDZWGRaQnNS2gEZk0bDyAwGTTsygdDx yanA== 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=eTxRJjN3pTPMOz/LuyvMrNd6bnn7wmfAl4QIN2ZzQNE=; b=gBQ6vK102KeDK9AEHsZ7jxm19+SrWrsF/2N74TWKzHxKpo9NqnIeUGo+koYh+9Rd0o iQxAAq1jdGlaCFkfawNOi3VS2GJfFMVNlVvLvo/F3MVhkv2wvSe1ODbGOad5VB+7XWDd KP+8WuDACmFS0gIN1+QJEBGQnste7RANvmFURJF1l/L7MHTvd1nR/DwJRz9Lqyc4cGTH UeVOBwFHfnFtOifhs113VcEviXhW21WML9PQ/3UxvCArn0+Z8C1/hNcnbejsG4GJ5Xm7 DI2nf9bGXT9mz1sZZ1QY4eNpyR475jrVEX93FqQx8OvJK8xA/avgNZ01lNFRlvOASAF3 HgGw== X-Gm-Message-State: APjAAAUzdOJBKMm4nNJtpzbAdkM2n7KEeZd/oL9Qu58/zYzTPRmH/YCY wFlTmGFeknKaN0k+1Z1K7z77FHafMjJ2Ow== X-Google-Smtp-Source: APXvYqzGWOI8L6L9hiZ0MjSD4G2DuIe7MS9vmoLpBc8Ya17KaPdFSSH7+7s0T8dLU9/Am4/Wi75e1g== X-Received: by 2002:a63:2a83:: with SMTP id q125mr28233038pgq.102.1562044799561; Mon, 01 Jul 2019 22:19:59 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.19.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:19:59 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 05/12] powerpc/mce: Allow notifier callback to handle MCE Date: Tue, 2 Jul 2019 10:49:25 +0530 Message-Id: <20190702051932.511-6-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab If a notifier returns NOTIFY_STOP, consider the MCE handled, just as we do when machine_check_early() returns 1. Signed-off-by: Reza Arbab --- arch/powerpc/include/asm/asm-prototypes.h | 2 +- arch/powerpc/include/asm/mce.h | 3 +- arch/powerpc/kernel/exceptions-64s.S | 3 ++ arch/powerpc/kernel/mce.c | 37 ++++++++++++++++++----- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h index f66f26ef3ce0..49ee8f08de2a 100644 --- a/arch/powerpc/include/asm/asm-prototypes.h +++ b/arch/powerpc/include/asm/asm-prototypes.h @@ -72,7 +72,7 @@ void machine_check_exception(struct pt_regs *regs); void emulation_assist_interrupt(struct pt_regs *regs); long do_slb_fault(struct pt_regs *regs, unsigned long ea); void do_bad_slb_fault(struct pt_regs *regs, unsigned long ea, long err); -void machine_check_notify(struct pt_regs *regs); +long machine_check_notify(struct pt_regs *regs); /* signals, syscalls and interrupts */ long sys_swapcontext(struct ucontext __user *old_ctx, diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h index 948bef579086..240dd1fdfe35 100644 --- a/arch/powerpc/include/asm/mce.h +++ b/arch/powerpc/include/asm/mce.h @@ -122,7 +122,8 @@ struct machine_check_event { enum MCE_UeErrorType ue_error_type:8; u8 effective_address_provided; u8 physical_address_provided; - u8 reserved_1[5]; + u8 process_event; + u8 reserved_1[4]; u64 effective_address; u64 physical_address; u8 reserved_2[8]; diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 2e56014fca21..c83e38a403fd 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -460,6 +460,9 @@ EXC_COMMON_BEGIN(machine_check_handle_early) addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_notify + ld r11,RESULT(r1) + or r3,r3,r11 + std r3,RESULT(r1) ld r12,_MSR(r1) BEGIN_FTR_SECTION diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index 0ab171b41ede..4a37928ab30e 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -157,6 +157,8 @@ void save_mce_event(struct pt_regs *regs, long handled, mce->u.ue_error.physical_address_provided = true; mce->u.ue_error.physical_address = phys_addr; } + + mce->u.ue_error.process_event = true; } return; } @@ -241,6 +243,10 @@ void machine_check_queue_event(void) if (!get_mce_event(&evt, MCE_EVENT_RELEASE)) return; + if (evt.error_type == MCE_ERROR_TYPE_UE && + !evt.u.ue_error.process_event) + return; + index = __this_cpu_inc_return(mce_queue_count) - 1; /* If queue is full, just return for now. */ if (index >= MAX_MC_EVT) { @@ -647,16 +653,31 @@ long hmi_exception_realmode(struct pt_regs *regs) return 1; } -void machine_check_notify(struct pt_regs *regs) +long machine_check_notify(struct pt_regs *regs) { - struct machine_check_event evt; + int index = __this_cpu_read(mce_nest_count) - 1; + struct machine_check_event *evt; + int rc; - if (!get_mce_event(&evt, MCE_EVENT_DONTRELEASE)) - return; + if (index < 0 || index >= MAX_MC_EVT) + return 0; - blocking_notifier_call_chain(&mce_notifier_list, 0, &evt); + evt = this_cpu_ptr(&mce_event[index]); - if (evt.error_type == MCE_ERROR_TYPE_UE && - evt.u.ue_error.physical_address_provided) - machine_check_ue_event(&evt); + rc = blocking_notifier_call_chain(&mce_notifier_list, 0, evt); + if (rc & NOTIFY_STOP_MASK) { + if (evt->error_type == MCE_ERROR_TYPE_UE) + evt->u.ue_error.process_event = false; + + if ((rc & NOTIFY_STOP_MASK) && (regs->msr & MSR_RI)) + evt->disposition = MCE_DISPOSITION_RECOVERED; + + return 1; + } + + if (evt->error_type == MCE_ERROR_TYPE_UE && + evt->u.ue_error.physical_address_provided) + machine_check_ue_event(evt); + + return 0; } From patchwork Tue Jul 2 05:19:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125942 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCP535Wrz9sNC for ; Tue, 2 Jul 2019 15:25:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="dRzJgqeU"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCP52BJTzDqM7 for ; Tue, 2 Jul 2019 15:25:13 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="dRzJgqeU"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCH85PwZzDqGq for ; Tue, 2 Jul 2019 15:20:04 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id b7so8515970pls.6 for ; Mon, 01 Jul 2019 22:20:04 -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=GxNeZ5n8GD9oBiBsiXo4KrAZsRCItyrNkSZWmT1qLSc=; b=dRzJgqeUSMNPMlr5D/Zz85r4eHzuFvVMzeopJbFrKQREHlXF9dNLLLfvkdDMRnSj6B pp5PfChXdaJV1HeyN10sM3+zndZavkGHRRSeGXl2y5qP53Z7oBPant4l746zekZpwZjd lNwl+uei8Y2LvzuipkTlkfU+peqGP/FKXx85CAVppX4etAorKrKnYDJgipZG8tfuiWgY MhFCsRVbgAPgsSd3llvHdgoSpC1Jypie9BwBraOmC0tYIMYAOvozlMmZwtgTvUj4F46O lnr3z/n22UrYnboZFpbcd2OogRv5gvByLd3iSMcE+1GniqoS/GNO/gypYOR2rnfBO2Ow TdEw== 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=GxNeZ5n8GD9oBiBsiXo4KrAZsRCItyrNkSZWmT1qLSc=; b=Fo3zsmyXTk+9SCbVojIjSZ5wFQX6c2YM48PWep9TpI93nrBdCgS6O8IjgJv2eJQjHD 2JT72HusTo2czCWOImXcfo3JPtrpDiCJFUhrYaLpGFicET6M0QED8X2LvbIk6gB3o+x+ 43GgJDW0isfcGThWA5AtKstMQRf80F2bO+UigUg2p/JPlHXhIShxSXdCKRRzZdYEZwUb p4GDAXM0s25SfHjjmNC55408IQil9tUr5Fcw6xAKKJUC3cYvktWYIBl18rOuwm4nRvbT upzhA4pY9/xOu+u53hF9rUjzhQBMm+0zBmRwGOU2TaKV3iRvlP0Oq7jDwsDFcacP3yzC 2M+Q== X-Gm-Message-State: APjAAAVwoDtFni6sQZKqdwNOYuaGPRPSPHhpZG+hMaAyS9jF7SWsq1k2 rWazCe3lzoe+WGcl3LfqlFYjkIdMtuQBVQ== X-Google-Smtp-Source: APXvYqyU+UqIeiEjw8iDrepg3r2P6SsQ5Y5aV8VD9W8jCiNFQkO/f6JBRE0HCjqS0bysEZGubQg2Uw== X-Received: by 2002:a17:902:6b86:: with SMTP id p6mr33981548plk.14.1562044802733; Mon, 01 Jul 2019 22:20:02 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.19.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:20:02 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 06/12] powerpc/mce: Add fixup address to UE events Date: Tue, 2 Jul 2019 10:49:26 +0530 Message-Id: <20190702051932.511-7-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab If the instruction causing a UE has an exception table entry with fixup address, save it in the machine_check_event struct. If a machine check notifier callback returns NOTIFY_STOP to indicate it has handled the error, set nip to continue execution from the fixup address. Signed-off-by: Reza Arbab --- arch/powerpc/include/asm/mce.h | 5 +++-- arch/powerpc/kernel/mce.c | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h index 240dd1fdfe35..9d9661747adf 100644 --- a/arch/powerpc/include/asm/mce.h +++ b/arch/powerpc/include/asm/mce.h @@ -122,11 +122,12 @@ struct machine_check_event { enum MCE_UeErrorType ue_error_type:8; u8 effective_address_provided; u8 physical_address_provided; + u8 fixup_address_provided; u8 process_event; - u8 reserved_1[4]; + u8 reserved_1[3]; u64 effective_address; u64 physical_address; - u8 reserved_2[8]; + u64 fixup_address; } ue_error; struct { diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index 4a37928ab30e..0233c0ee45ab 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -15,10 +15,12 @@ #include #include #include +#include #include #include #include +#include static DEFINE_PER_CPU(int, mce_nest_count); static DEFINE_PER_CPU(struct machine_check_event[MAX_MC_EVT], mce_event); @@ -151,6 +153,8 @@ void save_mce_event(struct pt_regs *regs, long handled, mce->u.link_error.effective_address_provided = true; mce->u.link_error.effective_address = addr; } else if (mce->error_type == MCE_ERROR_TYPE_UE) { + const struct exception_table_entry *entry; + mce->u.ue_error.effective_address_provided = true; mce->u.ue_error.effective_address = addr; if (phys_addr != ULONG_MAX) { @@ -158,6 +162,12 @@ void save_mce_event(struct pt_regs *regs, long handled, mce->u.ue_error.physical_address = phys_addr; } + entry = search_exception_tables(regs->nip); + if (entry) { + mce->u.ue_error.fixup_address_provided = true; + mce->u.ue_error.fixup_address = extable_fixup(entry); + } + mce->u.ue_error.process_event = true; } return; @@ -666,8 +676,12 @@ long machine_check_notify(struct pt_regs *regs) rc = blocking_notifier_call_chain(&mce_notifier_list, 0, evt); if (rc & NOTIFY_STOP_MASK) { - if (evt->error_type == MCE_ERROR_TYPE_UE) + if (evt->error_type == MCE_ERROR_TYPE_UE) { + if (evt->u.ue_error.fixup_address_provided) + regs->nip = evt->u.ue_error.fixup_address; + evt->u.ue_error.process_event = false; + } if ((rc & NOTIFY_STOP_MASK) && (regs->msr & MSR_RI)) evt->disposition = MCE_DISPOSITION_RECOVERED; From patchwork Tue Jul 2 05:19:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125943 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCRD2GLTz9sLt for ; Tue, 2 Jul 2019 15:27:04 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="OWcSxHH4"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCRD1B0czDqVB for ; Tue, 2 Jul 2019 15:27:04 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="OWcSxHH4"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCHD5bYRzDqHl for ; Tue, 2 Jul 2019 15:20:08 +1000 (AEST) Received: by mail-pf1-x442.google.com with SMTP id 81so7644865pfy.13 for ; Mon, 01 Jul 2019 22:20:08 -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=MnkWk4le4KlHZEUfmObvitjZmv4uk16SlGh4Ik74juA=; b=OWcSxHH4M2etIQpz1I28atBHYVFTQdfm8HDGGgoGRGnyBrtxbDbHXcVV4jl73p7KS6 VuaUlOUou6iWJHj7P0YGmoLxrjIBdOd0bPzd4W7VumSierGCJ4M6rU6bPswHrOa2f303 lSsHWf6/VF9FhwJfqcxWiUhhk7pkSgTn7FE9JON264UjbS/yoAEDcO+Mxmjarw+v/KSm /QbSB81/r6Q1ofEoJ+yBVLNmwl18p9eOIxSEtwVtsHrDghf0hKgriPeDhm+/TiJHjAJZ 0WI6boe3E9UxwUEpLVEiHx/u2SfhwEX+eTeC6jVwJeb/qCXoq198LN0t1P7pf6V3e5HR enxA== 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=MnkWk4le4KlHZEUfmObvitjZmv4uk16SlGh4Ik74juA=; b=rnpj733ccZIQqNtxgkadfowVqjfkp7ih9E9jxNlK3v4ELRkcqwIMgh+H8yrhLgNZx4 /EAnU9wSdrf/VaxYx0OEl8k7Xp2PjWDeQT3NfzYS3uEBqFKYiEOPrUd297WdJkowGLED D5XsoK3oimVNzTZsLuxNEqXBXJmW6WyOjUpIv8dnc4T8kuVScl6dTavea4ewtXQzkXyR B2g4tcfsJ4sfJREq2C6tuAU8Ddg/rXIb+N407ZSS3r5xQte9YCmdeooXWvKFArlDF9Rc yFIQmcv/FljO6cy7w3rc8YMBS8/8iY6sjn1o8wrFZ24wQyabIl4VlG4FFaLMaQpWjou7 YJcw== X-Gm-Message-State: APjAAAXSSDxd+fSBENA/1LY78N7AVRaBYvhEDyvHhK7O8nLFJVqSK1Ma H1sl5V0vMWNujCPVjyv2P5WuLddvh7IXpg== X-Google-Smtp-Source: APXvYqx9HW0pezDrBZqGevz7xf+aa4KLXCiTlVu2YZ9tNzMgPh9Y4cIFKapFSmp+gqSObr6QwXWCIQ== X-Received: by 2002:a17:90a:8d0c:: with SMTP id c12mr3324473pjo.140.1562044805940; Mon, 01 Jul 2019 22:20:05 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.20.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:20:05 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 07/12] powerpc/memcpy: Add memcpy_mcsafe for pmem Date: Tue, 2 Jul 2019 10:49:27 +0530 Message-Id: <20190702051932.511-8-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Balbir Singh The pmem infrastructure uses memcpy_mcsafe in the pmem layer so as to convert machine check exceptions into a return value on failure in case a machine check exception is encountered during the memcpy. This patch largely borrows from the copyuser_power7 logic and does not add the VMX optimizations, largely to keep the patch simple. If needed those optimizations can be folded in. Signed-off-by: Balbir Singh Acked-by: Nicholas Piggin [arbab@linux.ibm.com: Added symbol export] --- arch/powerpc/include/asm/string.h | 2 + arch/powerpc/lib/Makefile | 2 +- arch/powerpc/lib/memcpy_mcsafe_64.S | 215 ++++++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/lib/memcpy_mcsafe_64.S diff --git a/arch/powerpc/include/asm/string.h b/arch/powerpc/include/asm/string.h index 9bf6dffb4090..b72692702f35 100644 --- a/arch/powerpc/include/asm/string.h +++ b/arch/powerpc/include/asm/string.h @@ -53,7 +53,9 @@ void *__memmove(void *to, const void *from, __kernel_size_t n); #ifndef CONFIG_KASAN #define __HAVE_ARCH_MEMSET32 #define __HAVE_ARCH_MEMSET64 +#define __HAVE_ARCH_MEMCPY_MCSAFE +extern int memcpy_mcsafe(void *dst, const void *src, __kernel_size_t sz); extern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t); extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t); extern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t); diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index c55f9c27bf79..529d6536eb4a 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile @@ -39,7 +39,7 @@ obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o copypage_power7.o \ memcpy_power7.o obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \ - memcpy_64.o pmem.o + memcpy_64.o pmem.o memcpy_mcsafe_64.o obj64-$(CONFIG_SMP) += locks.o obj64-$(CONFIG_ALTIVEC) += vmx-helper.o diff --git a/arch/powerpc/lib/memcpy_mcsafe_64.S b/arch/powerpc/lib/memcpy_mcsafe_64.S new file mode 100644 index 000000000000..50f865db0338 --- /dev/null +++ b/arch/powerpc/lib/memcpy_mcsafe_64.S @@ -0,0 +1,215 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) IBM Corporation, 2011 + * Derived from copyuser_power7.s by Anton Blanchard + * Author - Balbir Singh + */ +#include +#include +#include + + .macro err1 +100: + EX_TABLE(100b,.Ldo_err1) + .endm + + .macro err2 +200: + EX_TABLE(200b,.Ldo_err2) + .endm + +.Ldo_err2: + ld r22,STK_REG(R22)(r1) + ld r21,STK_REG(R21)(r1) + ld r20,STK_REG(R20)(r1) + ld r19,STK_REG(R19)(r1) + ld r18,STK_REG(R18)(r1) + ld r17,STK_REG(R17)(r1) + ld r16,STK_REG(R16)(r1) + ld r15,STK_REG(R15)(r1) + ld r14,STK_REG(R14)(r1) + addi r1,r1,STACKFRAMESIZE +.Ldo_err1: + li r3,-EFAULT + blr + + +_GLOBAL(memcpy_mcsafe) + cmpldi r5,16 + blt .Lshort_copy + +.Lcopy: + /* Get the source 8B aligned */ + neg r6,r4 + mtocrf 0x01,r6 + clrldi r6,r6,(64-3) + + bf cr7*4+3,1f +err1; lbz r0,0(r4) + addi r4,r4,1 +err1; stb r0,0(r3) + addi r3,r3,1 + +1: bf cr7*4+2,2f +err1; lhz r0,0(r4) + addi r4,r4,2 +err1; sth r0,0(r3) + addi r3,r3,2 + +2: bf cr7*4+1,3f +err1; lwz r0,0(r4) + addi r4,r4,4 +err1; stw r0,0(r3) + addi r3,r3,4 + +3: sub r5,r5,r6 + cmpldi r5,128 + blt 5f + + mflr r0 + stdu r1,-STACKFRAMESIZE(r1) + std r14,STK_REG(R14)(r1) + std r15,STK_REG(R15)(r1) + std r16,STK_REG(R16)(r1) + std r17,STK_REG(R17)(r1) + std r18,STK_REG(R18)(r1) + std r19,STK_REG(R19)(r1) + std r20,STK_REG(R20)(r1) + std r21,STK_REG(R21)(r1) + std r22,STK_REG(R22)(r1) + std r0,STACKFRAMESIZE+16(r1) + + srdi r6,r5,7 + mtctr r6 + + /* Now do cacheline (128B) sized loads and stores. */ + .align 5 +4: +err2; ld r0,0(r4) +err2; ld r6,8(r4) +err2; ld r7,16(r4) +err2; ld r8,24(r4) +err2; ld r9,32(r4) +err2; ld r10,40(r4) +err2; ld r11,48(r4) +err2; ld r12,56(r4) +err2; ld r14,64(r4) +err2; ld r15,72(r4) +err2; ld r16,80(r4) +err2; ld r17,88(r4) +err2; ld r18,96(r4) +err2; ld r19,104(r4) +err2; ld r20,112(r4) +err2; ld r21,120(r4) + addi r4,r4,128 +err2; std r0,0(r3) +err2; std r6,8(r3) +err2; std r7,16(r3) +err2; std r8,24(r3) +err2; std r9,32(r3) +err2; std r10,40(r3) +err2; std r11,48(r3) +err2; std r12,56(r3) +err2; std r14,64(r3) +err2; std r15,72(r3) +err2; std r16,80(r3) +err2; std r17,88(r3) +err2; std r18,96(r3) +err2; std r19,104(r3) +err2; std r20,112(r3) +err2; std r21,120(r3) + addi r3,r3,128 + bdnz 4b + + clrldi r5,r5,(64-7) + + ld r14,STK_REG(R14)(r1) + ld r15,STK_REG(R15)(r1) + ld r16,STK_REG(R16)(r1) + ld r17,STK_REG(R17)(r1) + ld r18,STK_REG(R18)(r1) + ld r19,STK_REG(R19)(r1) + ld r20,STK_REG(R20)(r1) + ld r21,STK_REG(R21)(r1) + ld r22,STK_REG(R22)(r1) + addi r1,r1,STACKFRAMESIZE + + /* Up to 127B to go */ +5: srdi r6,r5,4 + mtocrf 0x01,r6 + +6: bf cr7*4+1,7f +err1; ld r0,0(r4) +err1; ld r6,8(r4) +err1; ld r7,16(r4) +err1; ld r8,24(r4) +err1; ld r9,32(r4) +err1; ld r10,40(r4) +err1; ld r11,48(r4) +err1; ld r12,56(r4) + addi r4,r4,64 +err1; std r0,0(r3) +err1; std r6,8(r3) +err1; std r7,16(r3) +err1; std r8,24(r3) +err1; std r9,32(r3) +err1; std r10,40(r3) +err1; std r11,48(r3) +err1; std r12,56(r3) + addi r3,r3,64 + + /* Up to 63B to go */ +7: bf cr7*4+2,8f +err1; ld r0,0(r4) +err1; ld r6,8(r4) +err1; ld r7,16(r4) +err1; ld r8,24(r4) + addi r4,r4,32 +err1; std r0,0(r3) +err1; std r6,8(r3) +err1; std r7,16(r3) +err1; std r8,24(r3) + addi r3,r3,32 + + /* Up to 31B to go */ +8: bf cr7*4+3,9f +err1; ld r0,0(r4) +err1; ld r6,8(r4) + addi r4,r4,16 +err1; std r0,0(r3) +err1; std r6,8(r3) + addi r3,r3,16 + +9: clrldi r5,r5,(64-4) + + /* Up to 15B to go */ +.Lshort_copy: + mtocrf 0x01,r5 + bf cr7*4+0,12f +err1; lwz r0,0(r4) /* Less chance of a reject with word ops */ +err1; lwz r6,4(r4) + addi r4,r4,8 +err1; stw r0,0(r3) +err1; stw r6,4(r3) + addi r3,r3,8 + +12: bf cr7*4+1,13f +err1; lwz r0,0(r4) + addi r4,r4,4 +err1; stw r0,0(r3) + addi r3,r3,4 + +13: bf cr7*4+2,14f +err1; lhz r0,0(r4) + addi r4,r4,2 +err1; sth r0,0(r3) + addi r3,r3,2 + +14: bf cr7*4+3,15f +err1; lbz r0,0(r4) +err1; stb r0,0(r3) + +15: li r3,0 + blr + +EXPORT_SYMBOL_GPL(memcpy_mcsafe); From patchwork Tue Jul 2 05:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125944 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCTD704Sz9sLt for ; Tue, 2 Jul 2019 15:28:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="ioFuKzOg"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCTD68MzzDqJs for ; Tue, 2 Jul 2019 15:28:48 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="ioFuKzOg"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCHH4XfBzDq62 for ; Tue, 2 Jul 2019 15:20:11 +1000 (AEST) Received: by mail-pf1-x443.google.com with SMTP id j2so7656877pfe.6 for ; Mon, 01 Jul 2019 22:20:11 -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=mCkd72MD7RytSXHmQTG+BJmdV+ujuMt041RZ+wphY4U=; b=ioFuKzOgaVjoTIhAoYS6/aGh1BN++JfYYIy0iANwC1pFnO/dTfdRd31WhsRFOG4CJN ySN5ZaFPQG8CClw61nMuSTzoh1FUAUaaeaNTF4ulNfmz9BGhtaiXZ7m26Ktw7/PcgUDP IwJUJHyROmyTVeFCpr+/4edeM0YYYA9EXaAU0XVgbSFwQWDIz722TdbObdb/+GMpwBIz DmLoySUi9hYqCJxZtFgAnoAonjT8wu05tAXoup85pJ/oKtiIXk+MUnWlVAwSWoqlufKd Z/Pp5lRlzywHSqg4ULf+AVlBrjMWuGAnD7cl7HIJfVkeJ9L8lv0QBfPSZd5ly27utkph ZtAQ== 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=mCkd72MD7RytSXHmQTG+BJmdV+ujuMt041RZ+wphY4U=; b=aZ/V2e19i1Vl69wDtrmr0US7MrdV5soXvkEFGmwwK5z8Nv1qRwQmbgnxauMp67rRq8 Ps9DhOJU5bIo2mYSnK+kZToNbDrGpsGQcbRfTvmgVPtZwAVveu2ZOpvSqWpi186Bdhz8 cjtmRExJbA1iniiI5epyeo0Z7SSsB50jO6fIdhNy+FvXKTk314G48BhEbTyLP4GQ3BFC YFG5Rrk7hkeTlJ2dcR8lBJfQhrBPL4/7gxuY+GT/OlLgFJKWlCkozBYxRS52SUweT080 HGkpYwSUknWa9bIihwn1hD74WO7Ms4JXf2mG8CKCiHdmeLGO2y+Y0Y0qJTDNexTBbqtj 583g== X-Gm-Message-State: APjAAAVtfwmEVqvEkXFsQRXqxqdAtnHMb7DMazF83EsLW5n6y+Iye2tN 2gZ5roMReos9NDZOMFQQTtcsbwi+CTc9WQ== X-Google-Smtp-Source: APXvYqzjRFZR4nlLY9fbLiLnsoq3Z/EGF8m38NURTQD9IKHvziQR502z0muCydGSfqHyPxMgsEb3DA== X-Received: by 2002:a63:224a:: with SMTP id t10mr28515088pgm.289.1562044809104; Mon, 01 Jul 2019 22:20:09 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.20.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:20:08 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 08/12] powerpc/mce: Handle memcpy_mcsafe() Date: Tue, 2 Jul 2019 10:49:28 +0530 Message-Id: <20190702051932.511-9-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab Add an mce notifier intended to service memcpy_mcsafe(). The notifier uses this heuristic; if a UE occurs when accessing device memory, and the faulting instruction had a fixup entry, the callback will return NOTIFY_STOP. This causes the notification mechanism to consider the MCE handled and continue execution at the fixup address, which returns -EFAULT from the memcpy_mcsafe() call. Signed-off-by: Reza Arbab --- arch/powerpc/kernel/mce.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index 0233c0ee45ab..a8348a9bea5b 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -56,6 +56,40 @@ int mce_unregister_notifier(struct notifier_block *nb) return blocking_notifier_chain_unregister(&mce_notifier_list, nb); } +static int check_memcpy_mcsafe(struct notifier_block *nb, unsigned long val, + void *data) +{ + struct machine_check_event *evt = data; + unsigned long pfn; + struct page *page; + + if (evt->error_type != MCE_ERROR_TYPE_UE || + !evt->u.ue_error.physical_address_provided) + return NOTIFY_DONE; + + pfn = evt->u.ue_error.physical_address >> PAGE_SHIFT; + page = pfn_to_page(pfn); + if (!page) + return NOTIFY_DONE; + + /* HMM and PMEM */ + if (is_zone_device_page(page) && evt->u.ue_error.fixup_address_provided) + return NOTIFY_STOP; + + return NOTIFY_DONE; +} + +static struct notifier_block memcpy_mcsafe_nb = { + .notifier_call = check_memcpy_mcsafe +}; + +static int __init mce_mcsafe_register(void) +{ + mce_register_notifier(&memcpy_mcsafe_nb); + return 0; +} +arch_initcall(mce_mcsafe_register); + static void mce_set_error_info(struct machine_check_event *mce, struct mce_error_info *mce_err) { From patchwork Tue Jul 2 05:19:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125945 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCWj4242z9sLt for ; Tue, 2 Jul 2019 15:30:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="sdVj0eAf"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCWj0YJKzDqLc for ; Tue, 2 Jul 2019 15:30:57 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="sdVj0eAf"; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCHL29QVzDq5b for ; Tue, 2 Jul 2019 15:20:14 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id ay6so8462417plb.9 for ; Mon, 01 Jul 2019 22:20:14 -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=FCcMOSA1W9ejLFHOo0LYIVGLCDzvV9wbPlNYjs5O9hk=; b=sdVj0eAfVKWAD1kIC38Y7C0eUOy2gEIHlkGgpEQmALTS3WGhU4vXtT0HL8qlIU1kwB qMWcsfQMaFlWnSS8DpMgAheOiFqDzKvwfwvnT3hkUGyJr96VQ0N4zUopPUGRkTWRsUfr qEIBIMKNV7FO5x866Y/NUWLrdYV1Fz6jyE2kTeixnE1Q9VOKD+wav21Zz11R3advj4la Sx2SlJ4ibk4d5KS8Q96NuO3pujuP/dvOgXLC1iG7T9VmGnDvek/D4QmADMtYlLJGR2XE rFkCDUWt/Vi5XlWtfnpMj17u7QMCZgYDMdd6doHHvwu4cvQtdgTpdIZvWPDwOHNv8RQO FqCQ== 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=FCcMOSA1W9ejLFHOo0LYIVGLCDzvV9wbPlNYjs5O9hk=; b=Xsd4iipQzGMkG481+UEcfMoPS3QFk6F+gObSv8q/NX2tdWn70YaAXgnklSD8FBrMxP y3EiYnLpNc21T5OZS2Ser+5xmopsufK0ydqsinxq6QyaZLVFI95TjcgkES6TeUs8YbGi /SQtL3CwyFJ/+dC0fAabOICszWh6rdh8eItvx615PpFRztsn+7if+yfKk+Ct/Bxdjj1z CxH9Y3LoOcaPrsfYYiT9Ie5o5WtxTc+05dzGGTvpdxfa306+NByqtKcaciDwEf5SoTRu HV5/avo78EMFeKqXpAj6/uIMRrbylFUwp0XxSOwrUwyd/F8Wt5oGiJv4mtarGbzZL+wO 0VMA== X-Gm-Message-State: APjAAAUufNAB4r4jLWTovB6xZPGAhPwiosBc3J/sknPD1XU1LdZXEuxT JIxN+/h6ShR6zQUPf1eWmLIMhp2DljWQww== X-Google-Smtp-Source: APXvYqxnqKafTJespSqfVY2qOrOnHM774v6y59+0drWqz/5t/Wdszynw9oy0ZAUSFjqokX+JCPTy6Q== X-Received: by 2002:a17:902:2884:: with SMTP id f4mr32469631plb.286.1562044812353; Mon, 01 Jul 2019 22:20:12 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.20.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:20:11 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 09/12] powerpc/mce: Enable MCE notifiers in external modules Date: Tue, 2 Jul 2019 10:49:29 +0530 Message-Id: <20190702051932.511-10-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab Signed-off-by: Reza Arbab --- arch/powerpc/kernel/exceptions-64s.S | 6 ++++++ arch/powerpc/kernel/mce.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index c83e38a403fd..311f1392a2ec 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -458,6 +458,12 @@ EXC_COMMON_BEGIN(machine_check_handle_early) bl machine_check_early std r3,RESULT(r1) /* Save result */ + /* Notifiers may be in a module, so enable virtual addressing. */ + mfmsr r11 + ori r11,r11,MSR_IR + ori r11,r11,MSR_DR + mtmsr r11 + addi r3,r1,STACK_FRAME_OVERHEAD bl machine_check_notify ld r11,RESULT(r1) diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c index a8348a9bea5b..9e4d497837d8 100644 --- a/arch/powerpc/kernel/mce.c +++ b/arch/powerpc/kernel/mce.c @@ -50,11 +50,13 @@ int mce_register_notifier(struct notifier_block *nb) { return blocking_notifier_chain_register(&mce_notifier_list, nb); } +EXPORT_SYMBOL_GPL(mce_register_notifier); int mce_unregister_notifier(struct notifier_block *nb) { return blocking_notifier_chain_unregister(&mce_notifier_list, nb); } +EXPORT_SYMBOL_GPL(mce_unregister_notifier); static int check_memcpy_mcsafe(struct notifier_block *nb, unsigned long val, void *data) From patchwork Tue Jul 2 05:19:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125946 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCZX5vfwz9sLt for ; Tue, 2 Jul 2019 15:33:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="YeDpXFu4"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCZX25YfzDqHk for ; Tue, 2 Jul 2019 15:33:24 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="YeDpXFu4"; dkim-atps=neutral Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCHP4Pq8zDqLL for ; Tue, 2 Jul 2019 15:20:17 +1000 (AEST) Received: by mail-pg1-x542.google.com with SMTP id f25so7084754pgv.10 for ; Mon, 01 Jul 2019 22:20:17 -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=2eKySy+ofP39yUhvXO65KjBrDTXu6io+eKrLabYiJKM=; b=YeDpXFu4gedkfulYzdQ5LLfnlppsJe6PNZ+30EPI+ryRaQmIfE3bVkJNtUrvSlsnLE jSc2b/Uqi2YBCDtfNtOpi5llQHmUeFkdDKieIDjYFjgGxolDrPztwBv2tFN7W6gO6dcj 9G0ln6bLHdqQ1mI+DD40OeSb6tDkvAXYsH3zV0J3nZkBfTQ5s6gI0VhKfurjCj/WCORn 2A4NHnTJFe7XlHegrUvCd9lqEyYFMepMq4HYG8OF2pxeeB+ixNeuKlUiunNY12sQtNlU Ecwj+1K/Of0xj9cLgm3OWNG2gEaMoZ2I/YgCFi/ZIBejcibUI58f4q5kzYAQKPQzBR15 f5Ag== 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=2eKySy+ofP39yUhvXO65KjBrDTXu6io+eKrLabYiJKM=; b=OsW1p4wQP1tTdeUIbKSjU+GQrJG+pVnF4XCHXrNBDFOyw1uknEqBHKQ+xfV9/gGtK6 rq+pBJLu5XCskEMedeC+XH7bCAY2dbt6+R02J5bfOOeqmyjgxBtwvYba388DMEyuhPZK R6gi/0qjdXEXQZLPPtrXXcNeoyBdlPuke2XfDryKYytKmks94xKMg/88hquiYUmsP4Zf IaWFdn1hD2eMu9SnQUwkChZ38LDm3uwJVTIojkgwWTZotp4kW3KDUWWWGKogSjzw425R x+RHJCHTIBukYxMPHkWNKq8dnAIJofjiC9i1+AJ+kua9Tyu7BgA4v6BeJcz0qsG9fjEs JgLg== X-Gm-Message-State: APjAAAUSkpZyQ0FZy5qA4nEzEae3MjRcJ4CzdHxD+2Od/gbbqhpG8BQv r8v662xxo5nzi37nFYJPBr4lBMltT9c= X-Google-Smtp-Source: APXvYqyZ4sJCBnDW6zCtn4sDgkiROnog1cNShryXOCEum41LkpwqnS/iJ8+MkzcT6hrEtIfSV/y6uQ== X-Received: by 2002:a17:90a:2385:: with SMTP id g5mr3571804pje.12.1562044815682; Mon, 01 Jul 2019 22:20:15 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.20.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:20:15 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 10/12] powerpc/memcpy_mcsafe: return remaining bytes Date: Tue, 2 Jul 2019 10:49:30 +0530 Message-Id: <20190702051932.511-11-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" memcpy_mcsafe currently return -EFAULT on a machine check exception, change it to return the remaining bytes that needs to be copied, so that machine check safe copy_to_user can maintain the same behavior as copy_to_user. Signed-off-by: Santosh Sivaraj --- arch/powerpc/lib/memcpy_mcsafe_64.S | 129 +++++++++++++++------------- 1 file changed, 70 insertions(+), 59 deletions(-) diff --git a/arch/powerpc/lib/memcpy_mcsafe_64.S b/arch/powerpc/lib/memcpy_mcsafe_64.S index 50f865db0338..566c664aa640 100644 --- a/arch/powerpc/lib/memcpy_mcsafe_64.S +++ b/arch/powerpc/lib/memcpy_mcsafe_64.S @@ -30,11 +30,12 @@ ld r14,STK_REG(R14)(r1) addi r1,r1,STACKFRAMESIZE .Ldo_err1: - li r3,-EFAULT + mr r3,r7 blr _GLOBAL(memcpy_mcsafe) + mr r7,r5 cmpldi r5,16 blt .Lshort_copy @@ -49,18 +50,21 @@ err1; lbz r0,0(r4) addi r4,r4,1 err1; stb r0,0(r3) addi r3,r3,1 + subi r7,r7,1 1: bf cr7*4+2,2f err1; lhz r0,0(r4) addi r4,r4,2 err1; sth r0,0(r3) addi r3,r3,2 + subi r7,r7,2 2: bf cr7*4+1,3f err1; lwz r0,0(r4) addi r4,r4,4 err1; stw r0,0(r3) addi r3,r3,4 + subi r7,r7,4 3: sub r5,r5,r6 cmpldi r5,128 @@ -87,43 +91,69 @@ err1; stw r0,0(r3) 4: err2; ld r0,0(r4) err2; ld r6,8(r4) -err2; ld r7,16(r4) -err2; ld r8,24(r4) -err2; ld r9,32(r4) -err2; ld r10,40(r4) -err2; ld r11,48(r4) -err2; ld r12,56(r4) -err2; ld r14,64(r4) -err2; ld r15,72(r4) -err2; ld r16,80(r4) -err2; ld r17,88(r4) -err2; ld r18,96(r4) -err2; ld r19,104(r4) -err2; ld r20,112(r4) -err2; ld r21,120(r4) +err2; ld r8,16(r4) +err2; ld r9,24(r4) +err2; ld r10,32(r4) +err2; ld r11,40(r4) +err2; ld r12,48(r4) +err2; ld r14,56(r4) +err2; ld r15,64(r4) +err2; ld r16,72(r4) +err2; ld r17,80(r4) +err2; ld r18,88(r4) +err2; ld r19,96(r4) +err2; ld r20,104(r4) +err2; ld r21,112(r4) +err2; ld r22,120(r4) addi r4,r4,128 err2; std r0,0(r3) err2; std r6,8(r3) -err2; std r7,16(r3) -err2; std r8,24(r3) -err2; std r9,32(r3) -err2; std r10,40(r3) -err2; std r11,48(r3) -err2; std r12,56(r3) -err2; std r14,64(r3) -err2; std r15,72(r3) -err2; std r16,80(r3) -err2; std r17,88(r3) -err2; std r18,96(r3) -err2; std r19,104(r3) -err2; std r20,112(r3) -err2; std r21,120(r3) +err2; std r8,16(r3) +err2; std r9,24(r3) +err2; std r10,32(r3) +err2; std r11,40(r3) +err2; std r12,48(r3) +err2; std r14,56(r3) +err2; std r15,64(r3) +err2; std r16,72(r3) +err2; std r17,80(r3) +err2; std r18,88(r3) +err2; std r19,96(r3) +err2; std r20,104(r3) +err2; std r21,112(r3) +err2; std r22,120(r3) addi r3,r3,128 + subi r7,r7,128 bdnz 4b clrldi r5,r5,(64-7) - ld r14,STK_REG(R14)(r1) + /* Up to 127B to go */ +5: srdi r6,r5,4 + mtocrf 0x01,r6 + +6: bf cr7*4+1,7f +err2; ld r0,0(r4) +err2; ld r6,8(r4) +err2; ld r8,16(r4) +err2; ld r9,24(r4) +err2; ld r10,32(r4) +err2; ld r11,40(r4) +err2; ld r12,48(r4) +err2; ld r14,56(r4) + addi r4,r4,64 +err2; std r0,0(r3) +err2; std r6,8(r3) +err2; std r8,16(r3) +err2; std r9,24(r3) +err2; std r10,32(r3) +err2; std r11,40(r3) +err2; std r12,48(r3) +err2; std r14,56(r3) + addi r3,r3,64 + subi r7,r7,64 + +7: ld r14,STK_REG(R14)(r1) ld r15,STK_REG(R15)(r1) ld r16,STK_REG(R16)(r1) ld r17,STK_REG(R17)(r1) @@ -134,42 +164,19 @@ err2; std r21,120(r3) ld r22,STK_REG(R22)(r1) addi r1,r1,STACKFRAMESIZE - /* Up to 127B to go */ -5: srdi r6,r5,4 - mtocrf 0x01,r6 - -6: bf cr7*4+1,7f -err1; ld r0,0(r4) -err1; ld r6,8(r4) -err1; ld r7,16(r4) -err1; ld r8,24(r4) -err1; ld r9,32(r4) -err1; ld r10,40(r4) -err1; ld r11,48(r4) -err1; ld r12,56(r4) - addi r4,r4,64 -err1; std r0,0(r3) -err1; std r6,8(r3) -err1; std r7,16(r3) -err1; std r8,24(r3) -err1; std r9,32(r3) -err1; std r10,40(r3) -err1; std r11,48(r3) -err1; std r12,56(r3) - addi r3,r3,64 - /* Up to 63B to go */ -7: bf cr7*4+2,8f + bf cr7*4+2,8f err1; ld r0,0(r4) err1; ld r6,8(r4) -err1; ld r7,16(r4) -err1; ld r8,24(r4) +err1; ld r8,16(r4) +err1; ld r9,24(r4) addi r4,r4,32 err1; std r0,0(r3) err1; std r6,8(r3) -err1; std r7,16(r3) -err1; std r8,24(r3) +err1; std r8,16(r3) +err1; std r9,24(r3) addi r3,r3,32 + subi r7,r7,32 /* Up to 31B to go */ 8: bf cr7*4+3,9f @@ -179,6 +186,7 @@ err1; ld r6,8(r4) err1; std r0,0(r3) err1; std r6,8(r3) addi r3,r3,16 + subi r7,r7,16 9: clrldi r5,r5,(64-4) @@ -192,18 +200,21 @@ err1; lwz r6,4(r4) err1; stw r0,0(r3) err1; stw r6,4(r3) addi r3,r3,8 + subi r7,r7,8 12: bf cr7*4+1,13f err1; lwz r0,0(r4) addi r4,r4,4 err1; stw r0,0(r3) addi r3,r3,4 + subi r7,r7,4 13: bf cr7*4+2,14f err1; lhz r0,0(r4) addi r4,r4,2 err1; sth r0,0(r3) addi r3,r3,2 + subi r7,r7,2 14: bf cr7*4+3,15f err1; lbz r0,0(r4) From patchwork Tue Jul 2 05:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125947 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCcy1ls7z9sLt for ; Tue, 2 Jul 2019 15:35:30 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="nDrzgl7A"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCcx5sd9zDqCH for ; Tue, 2 Jul 2019 15:35:29 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="nDrzgl7A"; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCHS5cpGzDqGq for ; Tue, 2 Jul 2019 15:20:20 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id t16so7644506pfe.11 for ; Mon, 01 Jul 2019 22:20:20 -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=O0RpxuR45dwfhoqht7ZB55QWMjctg/I39pbBZLVMTYI=; b=nDrzgl7Ac58CidsaQ6PIuy197jcO/z/YiU0EKRLMa7gawFXcHfSPFVjyFV8bA8fzfX kbLVE7fihyQybCu62Pav6Ya5wh6zD01MAR/KID6uPmcS9VRuCMfYWLAjFKhIvcR3CcG/ riARMXG16twAGfsI3P74kuVEFzLiu/+6KfT/EBoJe/6Bl2nB+2+f/7o+ZXdXeh4h5iWo 0N9O1l0gl2/jdhYmL5PGJXKF6YqSbUuAUPlxjZ0c3wXXDGHgR0j5oAvFl98EadkrS2BS h3qC+JJeGjH9kr/4fdbCXqA/rbgrbm+7z/3/2ctHY5yimPi5TSqzbyJHPIq1Vd94mcvY +jEQ== 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=O0RpxuR45dwfhoqht7ZB55QWMjctg/I39pbBZLVMTYI=; b=hIgv70E29RE5Fks0GjIRBARro610rUu3JMUazCou+tW0zFnyiyAgXCV6rHWZBoMckM WJocJIdLYkU8XYie5RMYuM5YklWfN6AnIbDzqFhTep1Y2HTt+eVybDBjnkHZvIx2sgOt a724bLC5Q4CtkwmKGVSDuQr6+IKCendJKHCo1zNbg4NHjnIpwf7yRNLLa6hZ9pM+kkM1 ZumoqQYJgyMnO1GxwieEAt5vFU4UnUdszsfwwYvxmgOhHp2udo3BySHk/jEGocu8I/LV YjsYsnh2m4STecbWIqJkU4Dy3DbIzAM6Xu/fAaDeypDwGjHzbrVwR3DHhp18az8PXWFY zb2Q== X-Gm-Message-State: APjAAAVdhWBbHJKCKoiyXdMibCFuY24DY1+UcH6mxnpjuD14iVu+aVwC apIzafVhzTE8e6cdZnhtK0LLt9Vn3theHg== X-Google-Smtp-Source: APXvYqx+WjAPSmdYr9tmqlIfaV8PP52y742alvV7T95gT3Ie/XgUFvMPPYbYDWTUWvnNcfaOhxiuIQ== X-Received: by 2002:a65:6541:: with SMTP id a1mr28266774pgw.409.1562044818857; Mon, 01 Jul 2019 22:20:18 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.20.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:20:18 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 11/12] powerpc: add machine check safe copy_to_user Date: Tue, 2 Jul 2019 10:49:31 +0530 Message-Id: <20190702051932.511-12-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Use memcpy_mcsafe() implementation to define copy_to_user_mcsafe() Signed-off-by: Santosh Sivaraj --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/uaccess.h | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 8c1c636308c8..a173b392c272 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -134,6 +134,7 @@ config PPC select ARCH_HAS_STRICT_KERNEL_RWX if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION) select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 + select ARCH_HAS_UACCESS_MCSAFE if PPC64 select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index 76f34346b642..f8fcaab4c5bc 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -386,6 +386,18 @@ static inline unsigned long raw_copy_to_user(void __user *to, return ret; } +static __always_inline unsigned long __must_check +copy_to_user_mcsafe(void __user *to, const void *from, unsigned long n) +{ + if (likely(check_copy_size(from, n, true))) { + allow_write_to_user(to, n); + n = memcpy_mcsafe(to, from, n); + prevent_write_to_user(to, n); + } + + return n; +} + extern unsigned long __clear_user(void __user *addr, unsigned long size); static inline unsigned long clear_user(void __user *addr, unsigned long size) From patchwork Tue Jul 2 05:19:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 1125948 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45dCg31tYpz9sLt for ; Tue, 2 Jul 2019 15:37:19 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="EmpbRWay"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45dCg30TWwzDq9d for ; Tue, 2 Jul 2019 15:37:19 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=fossix.org (client-ip=2607:f8b0:4864:20::443; helo=mail-pf1-x443.google.com; envelope-from=santosh@fossix.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=fossix.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=fossix-org.20150623.gappssmtp.com header.i=@fossix-org.20150623.gappssmtp.com header.b="EmpbRWay"; dkim-atps=neutral Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45dCHY2QnHzDqJ7 for ; Tue, 2 Jul 2019 15:20:25 +1000 (AEST) Received: by mail-pf1-x443.google.com with SMTP id 19so7671053pfa.4 for ; Mon, 01 Jul 2019 22:20:25 -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=Yzt9XRFLbxP/LrXAtCfoTzO098TseTzVOH+EfWjGDpI=; b=EmpbRWayGZDos32dyS/J+VEpgt5Q8jrsvkOQuD9wC5a9ITo8nJw9DGn6sAxSlECCQ6 ZfEMXfonP1ABNDolQkIHsHDzeog80hw6r8clIG/+BzUanhCfRrAVMOPmHvxEyrGMKWm4 TfGXtueZgCNX4r6d60Pnwi7hjluNBNfBb+69r6rHSY2l2PjMzvwW7IbPCoey2lW4RJCk vRGUHviEPHazgo5FFNzIcoE5CZbcV+Uwi7Y727IJxYG+zzz5cz3SSZAFfOJA+C2sW/GB pbtYRCv9VGavmW3eJR+JuQqY3kotDakmmbmsagXkVCNrDqapoAfitD97q4GS2xGt5tdn rcPg== 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=Yzt9XRFLbxP/LrXAtCfoTzO098TseTzVOH+EfWjGDpI=; b=NnqGQOAXJdDL13k870usYcoPMSWgQZCd6blthHYl3typif8ZLR+qK536TMT9HcB4zl iao5sbjBqG3wpW/nvkcaJKWQ/mR5TGN5SGTtYOVFjfD0Sm6qdu6LgSJ1FAVSocpjPMKT xsI4BZ7lvSQbcv4sK0hZpGahvy4Hpx17OfDCjcXPG8BKSCIqhfix6qEI0F0ITYP9C1j1 603kzFGDPocHp8o2D2lTQRuTKBFAeLQeWeqYLYZM0vyJ0iLoDkihTB9qfdOTNNTQw2yC t1HIAONMlTBkmYvUD553rX3kNtD8GnNvSU0r+uzEIvGQ/3ZD3W/kyrRNIhSrLNWOIOsl jP/Q== X-Gm-Message-State: APjAAAUpiqN4xWGtO1uiRs39p11GdhQ0iQPXMYwm8n0t7Xabs2ZraP4o bLjjE6gi0eVM3aBsWEPm8OCXjnPWd+bzZw== X-Google-Smtp-Source: APXvYqysBgsXbPVHa9yJjCloh7fWyfD+Tmodc3S42n4y9VA3+kryJ2T9XjyJs6jEGHViZN7zoE3L5Q== X-Received: by 2002:a63:6cc3:: with SMTP id h186mr28212296pgc.292.1562044822498; Mon, 01 Jul 2019 22:20:22 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.67]) by smtp.gmail.com with ESMTPSA id t9sm1106898pji.18.2019.07.01.22.20.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 22:20:21 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev Subject: [v2 12/12] powerpc/64s: Save r13 in machine_check_common_early Date: Tue, 2 Jul 2019 10:49:32 +0530 Message-Id: <20190702051932.511-13-santosh@fossix.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702051932.511-1-santosh@fossix.org> References: <20190702051932.511-1-santosh@fossix.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Nicholas Piggin , Chandan Rajendra , Reza Arbab Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Reza Arbab Testing my memcpy_mcsafe() work in progress with an injected UE, I get an error like this immediately after the function returns: BUG: Unable to handle kernel data access at 0x7fff84dec8f8 Faulting instruction address: 0xc0080000009c00b0 Oops: Kernel access of bad area, sig: 11 [#1] LE PAGE_SIZE=64K MMU=Radix MMU=Hash SMP NR_CPUS=2048 NUMA PowerNV Modules linked in: mce(O+) vmx_crypto crc32c_vpmsum CPU: 0 PID: 1375 Comm: modprobe Tainted: G O 5.1.0-rc6 #267 NIP: c0080000009c00b0 LR: c0080000009c00a8 CTR: c000000000095f90 REGS: c0000000ee197790 TRAP: 0300 Tainted: G O (5.1.0-rc6) MSR: 900000000280b033 CR: 88002826 XER: 00040000 CFAR: c000000000095f8c DAR: 00007fff84dec8f8 DSISR: 40000000 IRQMASK: 0 GPR00: 000000006c6c6568 c0000000ee197a20 c0080000009c8400 fffffffffffffff2 GPR04: c0080000009c02e0 0000000000000006 0000000000000000 c000000003c834c8 GPR08: 0080000000000000 776a6681b7fb5100 0000000000000000 c0080000009c01c8 GPR12: c000000000095f90 00007fff84debc00 000000004d071440 0000000000000000 GPR16: 0000000100000601 c0080000009e0000 c000000000c98dd8 c000000000c98d98 GPR20: c000000003bba970 c0080000009c04d0 c0080000009c0618 c0000000001e5820 GPR24: 0000000000000000 0000000000000100 0000000000000001 c000000003bba958 GPR28: c0080000009c02e8 c0080000009c0318 c0080000009c02e0 0000000000000000 NIP [c0080000009c00b0] cause_ue+0xa8/0xe8 [mce] LR [c0080000009c00a8] cause_ue+0xa0/0xe8 [mce] To fix, ensure that r13 is properly restored after an MCE. This commit is needed for testing this series, this is a possible simulator bug. --- arch/powerpc/kernel/exceptions-64s.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 311f1392a2ec..932d8d05892c 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -265,6 +265,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE) EXC_REAL_END(machine_check, 0x200, 0x100) EXC_VIRT_NONE(0x4200, 0x100) TRAMP_REAL_BEGIN(machine_check_common_early) + SET_SCRATCH0(r13) /* save r13 */ EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200) /* * Register contents: