Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3402034rdh; Thu, 28 Sep 2023 10:29:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDS6HD+OEe3pZtKlmqxPmr8kj25iSyWr9KMN17OrIo3MveVa18PCTcf5wk9UPMqWLj9qXe X-Received: by 2002:a05:6870:7023:b0:1dc:884a:95c1 with SMTP id u35-20020a056870702300b001dc884a95c1mr2103445oae.44.1695922158853; Thu, 28 Sep 2023 10:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695922158; cv=none; d=google.com; s=arc-20160816; b=WExL2H/nkhpLDLjzxgRO2s91H2/pr2qMezpVRjRaSznoBPXCOl+dT/RAQWcnP9NRR7 eeOhefdcA44hf9oaS4+BdWjJBPqsRbQwdNcteZu1mXXoxmvTnViO5tu82Z2iBl0iWWBA ZXzkytSldeYVBcyAeTjz5s+jHL+Qjbun4QmQVUMo5QQjfgDd8svOmXasQInuclnvjikS GqG/NrwLSom10RjuTIICsSGNG7mOqmKLIz6NM/NLjxnfv26XeHyKStWOZgdA+asYZGXz 4YYfjLVmNAK0smc62Zqmm91fWaQ4hnRFHqFs/vCf18h2RZ/fgI8cJNUwb/qUcATRr4Pt UJPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HQIW28iugADvBEABL7y0pWJwukdro8ctMwfbqsan8LM=; fh=70E37CH7MQytXhmqGdiWg7mOO5+EDfbVj5MS5OXKWoU=; b=AG3jlIowfDh+ajSrwiZoOK1gSU93571NNlWguCTtsOj0v9OoyDJQn2wmysNGfM/g2p BYhBNiWObvQR6l5HdHPO7cG+0Ys+mJZmsjoiK0bTT07b8AqVmEyAfXknwRv1OHophQQu kqY259qbJ+jqhZNkMEVWnGrVv/dctGO3ghG3CEs4ON6jNEe/60uMsVZZb6y1WwAlp1ib zcRTfUbiwvNyCgXIZKl3e+GBJsMrfb4YWl8ubbKk0phYhJQ43v0PN9YsFw4WauyNQh5E bR1qZiVv+yR/SU9uwx/Kq50kTD3OB5YGdg6LD12aIk4umk0o6Hz0LHIiRB0QTA1AkLNa hlvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=OKkplhDh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id be3-20020a656e43000000b00578a30162c8si15771758pgb.537.2023.09.28.10.29.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:29:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=OKkplhDh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9B6578072350; Thu, 28 Sep 2023 08:20:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbjI1PUA (ORCPT + 99 others); Thu, 28 Sep 2023 11:20:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231593AbjI1PT6 (ORCPT ); Thu, 28 Sep 2023 11:19:58 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C39DAC for ; Thu, 28 Sep 2023 08:19:57 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4064867903cso27979205e9.2 for ; Thu, 28 Sep 2023 08:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1695914395; x=1696519195; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HQIW28iugADvBEABL7y0pWJwukdro8ctMwfbqsan8LM=; b=OKkplhDhN8+0b9zz2wH9gA9M1LL2sK+ZFr0mvDSW4b+u7LAey9X1r7UNwMDQO29qLt EPCu1ZCNB4fdJ3spwaDGKhe6PmpkTZ2mUVNh+4YsaFPsuGXduwSbsvlFtQ7Ugw4Z8fRK ydPOB/PzdreN1WNuDLMfinPqOI4x4cVMw5RHZX7R9vP42Hq9/GfjmnRsloHlIk4W15Mm F6rPm3ZEC6acAsAsRzDps1bEA/S34D/bRkRTwLzI2aRtPRUl7FGFOCX51n+h7WfT2bpg oeLFMBBUFZUWbQvM4eYNPFz/46HZQl27nPvhuNuKKr6gCXO1JG3JabvVP9rmy07tJQL/ uzTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695914395; x=1696519195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HQIW28iugADvBEABL7y0pWJwukdro8ctMwfbqsan8LM=; b=aIUGNcro6NFeltmfdPahuET+yAFf1FpwgFE/n6gsUKodTYkacyuxiz5CrbT/IOq8FH rUGl5jg7N6Hd2AvUVt/IT86RYxpxY1tyZjxdvBhBdqFEkmBJ5EndwRHtWlsBUx1SEZD3 ZxVew4LeaNS5qTjKKJ3LcPtB3sjCF/f1ZI5wpRhIAVcyZUUcxd2Ysbh9168Z0FSPidLm +RA32Pddz4r3injASvstQICddEOxnKipa14MSCrBk0RuQkpezdnahiW8ltCRU/9TB7yj RsDG0bl+7rTlpPEvS96SeoHOFaQMDcomSH54p9Xg/GK9gKB56k33uQ2bEIcktV1In0Lu iz6Q== X-Gm-Message-State: AOJu0YxySfnqfHaE9Ru+FFx37k8kwa7ObrmxxtXiFBFGxKVk/K6KeOyb MMwHjU9Zi0c1hIiNwL88RRL1Mw== X-Received: by 2002:adf:eb47:0:b0:31f:e2b9:de1f with SMTP id u7-20020adfeb47000000b0031fe2b9de1fmr1247149wrn.24.1695914395323; Thu, 28 Sep 2023 08:19:55 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com ([2a02:8440:4541:1a11:c4e7:d9ee:586b:e201]) by smtp.gmail.com with ESMTPSA id t6-20020a5d6906000000b00321773bb933sm950874wru.77.2023.09.28.08.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 08:19:54 -0700 (PDT) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Jones , Qinglin Pan , Ryan Roberts , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH -fixes 1/2] riscv: Handle VM_FAULT_[HWPOISON|HWPOISON_LARGE] faults instead of panicking Date: Thu, 28 Sep 2023 17:18:45 +0200 Message-Id: <20230928151846.8229-2-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230928151846.8229-1-alexghiti@rivosinc.com> References: <20230928151846.8229-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 08:20:10 -0700 (PDT) We used to panic when such faults were encountered but we should handle those faults gracefully for userspace by sending a SIGBUS to the process, like most architectures do. Signed-off-by: Alexandre Ghiti --- arch/riscv/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c index 6115d7514972..90d4ba36d1d0 100644 --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -72,7 +72,7 @@ static inline void mm_fault_error(struct pt_regs *regs, unsigned long addr, vm_f } pagefault_out_of_memory(); return; - } else if (fault & VM_FAULT_SIGBUS) { + } else if (fault & (VM_FAULT_SIGBUS | VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) { /* Kernel mode? Handle exceptions or die */ if (!user_mode(regs)) { no_context(regs, addr); -- 2.39.2