Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2951566imb; Mon, 4 Mar 2019 19:27:05 -0800 (PST) X-Google-Smtp-Source: APXvYqxbQI1Q1o9t01iTaFExeawnI8G4hmm7vcCBysshKsTUSPfCiGrKVr9cbIy1BPexmvZFqNjQ X-Received: by 2002:a17:902:1e6:: with SMTP id b93mr23719921plb.325.1551756425238; Mon, 04 Mar 2019 19:27:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551756425; cv=none; d=google.com; s=arc-20160816; b=nR07SZ3bVRZVIrWG274AuWofgba9fQlSbRqfqgUyza95jbzJgVT0jQAF7uhpwOD1uj qEQR9mhr/ixDW8S6/pQiOBqUS8ZVS0AQKI6rAyorNnL95G3tHLe8BdGmQxkEYu11ijFn GiVjENKS11yp9B5uXu+qcAJ3kuqPn1IdDh4a7sM05i7580deMpTI7Bh9mEL642sTo+xT jI8cOSvKgcNz/jURWyZbitBCo2xluex+8yVkw9UjyxlSrKazNBD4tOccM1wOsOX0Ks2L j1P99TnHZbjpa4nqITizhETzIMkBUXE3G2JiurhLgMeIalejobhsexPcBFcDofzBjln/ QT4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=4e/6Ou+aESekUCpDmM+0HaK0YyYptnq8KKIjtyicU/U=; b=uCkESsqjp+aa6eriTfwyfYV6GGBfCK/Yt7kAQIBY3O+UJlqPMrqLePRmT38zTS9Bg1 QKAMcfWEpkM8mN4anPDVzynBvKaDSE2faFctqk9BiJ9sldz6DXvXm6M8xxuukQAQYpsw lEP6GKIs+RsONO47hkirHmTcYkNQMN3SzmHyV8TwE6iigw8uL1Jih7Kj7L9KJXRJyK4y 0hsp29u4ndM0gVzPriWURfJrobnExsAgCKm3swWPcdIWRUbBU2BTsOQcnhG1wbPdhI4/ XfySZMvwXJ2IcBy5RgSKTxaSk/CF980CFRwgB0d7r4eG7rX99LBnEKFTD/RHIDDDbdBT aSNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c24si6459247pgw.46.2019.03.04.19.26.50; Mon, 04 Mar 2019 19:27:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727049AbfCEDY0 (ORCPT + 99 others); Mon, 4 Mar 2019 22:24:26 -0500 Received: from 59-120-53-16.HINET-IP.hinet.net ([59.120.53.16]:42061 "EHLO ATCSQR.andestech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726993AbfCEDYZ (ORCPT ); Mon, 4 Mar 2019 22:24:25 -0500 Received: from mail.andestech.com (atcpcs16.andestech.com [10.0.1.222]) by ATCSQR.andestech.com with ESMTP id x253MwJ7044096; Tue, 5 Mar 2019 11:22:58 +0800 (GMT-8) (envelope-from vincentc@andestech.com) Received: from atcsqa06.andestech.com (10.0.15.65) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.123.3; Tue, 5 Mar 2019 11:23:58 +0800 From: Vincent Chen To: , , , , , CC: , Subject: [PATCH v2 3/3] riscv: Support BUG() in kernel module Date: Tue, 5 Mar 2019 11:23:35 +0800 Message-ID: <1551756215-22299-4-git-send-email-vincentc@andestech.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551756215-22299-1-git-send-email-vincentc@andestech.com> References: <1551756215-22299-1-git-send-email-vincentc@andestech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.15.65] X-DNSRBL: X-MAIL: ATCSQR.andestech.com x253MwJ7044096 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel module is loaded into vmalloc region which is located below to the PAGE_OFFSET. Hence the condition, pc < PAGE_OFFSET, in the is_valid_bugaddr() will filter out all trap exceptions triggered by kernel module. To support BUG() in kernel module, the condition is changed to pc < VMALLOC_START. Signed-off-by: Vincent Chen --- arch/riscv/kernel/traps.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 0cd0137..9551388 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -156,7 +156,7 @@ int is_valid_bugaddr(unsigned long pc) { bug_insn_t insn; - if (pc < PAGE_OFFSET) + if (pc < VMALLOC_START) return 0; if (probe_kernel_address((bug_insn_t *)pc, insn)) return 0; -- 1.7.1