[-fixes,1/2] riscv: Handle VM_FAULT_[HWPOISON|HWPOISON_LARGE] faults instead of panicking
Message ID | 20230928151846.8229-2-alexghiti@rivosinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3432163vqu; Thu, 28 Sep 2023 09:21:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIw7rG4YXsTjBrgYcEgXYk/5/D+X8fZtIKnNEAAyRgSpBTXVCHYBjqL/su9h8c3tBFvORN X-Received: by 2002:a05:6358:9496:b0:141:10f4:1cbc with SMTP id i22-20020a056358949600b0014110f41cbcmr1574195rwb.14.1695918073345; Thu, 28 Sep 2023 09:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695918073; cv=none; d=google.com; s=arc-20160816; b=fpUm1Ep4NTH67mL/p23Gx3vZAOzw5AxwchRG+hLeMmVzl72tjibYG+ZtmjBsDfqujy fXuWjnyheOzTezuVwOFluEDpNbDNdu1aMP1/ll4042URpYRFBO/lreM3OaUiFz8REcg7 HOILJKsm+rqjVJoroc8uIKUE8hBy4hTBN2GqxTM44gxVbhvJj/xJlQabGM7uhWN3XMdi 6ia9xYj0d73cWOQ316urdco9iSID+eTw1pKoRGKnyMBguSeJVoeRIfhZMg1eL1CoFPAK 0/49Rb+RDT9FQS7J5iPmv5XcsnUFCpWZML78FqkojIC1aQtb0Gxhm3eNZQ6iJeiKnFxG d5+A== 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 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id eb17-20020a056a004c9100b00690158afc78si19136332pfb.284.2023.09.28.09.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 09:21:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; 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 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id E9B9E8235769; Thu, 28 Sep 2023 08:20:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjI1PUA (ORCPT <rfc822;pwkd43@gmail.com> + 21 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Thu, 28 Sep 2023 08:19:57 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4064867903cso27979205e9.2 for <linux-kernel@vger.kernel.org>; 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 <alexghiti@rivosinc.com> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Andrew Jones <ajones@ventanamicro.com>, Qinglin Pan <panqinglin2020@iscas.ac.cn>, Ryan Roberts <ryan.roberts@arm.com>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti <alexghiti@rivosinc.com> 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 agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 28 Sep 2023 08:20:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778298989644510862 X-GMAIL-MSGID: 1778298989644510862 |
Series |
Fix set_huge_pte_at()
|
|
Commit Message
Alexandre Ghiti
Sept. 28, 2023, 3:18 p.m. UTC
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 <alexghiti@rivosinc.com>
---
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);