Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1390628ybt; Sat, 27 Jun 2020 06:59:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxucAxjllAybmdpD0/VV3nFEyuLSqbbpkBAqJsiye7xBhWTFGpWBWwS+/qhzPKG2uGoSPnm X-Received: by 2002:a17:906:b813:: with SMTP id dv19mr6590166ejb.119.1593266388082; Sat, 27 Jun 2020 06:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593266388; cv=none; d=google.com; s=arc-20160816; b=E1qELq6wVTvh7hFdKzvDRzTm1jTDQyzVg62iSQwjKsAxzTCbtd0UOhV7XYvIflhjfH sQMCV69VpA5lcT9aucwichYlnbja+yQTkt4A5QoZ2c6ozV7Btl/o22ttWswmmAgQT7VD VXqQPKHcZ/CLUhd4xbBbz+KlbXlPLZapO6tpl922kW2yfM09NETo+8UNcOC2j8jeRleK c8Ou2E5FSAkbiLlRtbzPOTrxdBUzaiBkuLeNfYWM+SI8AKUOwqGIc3jdWneItqshxgrY QshcmBpMS0toIMIeZrUI4mi5OI2G1u75zSVOzHzxMxBOHuXMnXLEpG5mmU7ST4y3MWhY 0B7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=V3wszR6JX4d4FhbWZ6VV7fH2yBNLsp2oGGRsgdcM0a0=; b=H6DhlBZKGinDR1KrhANqIEx8VlgMh/Sw8n+hi7w0Wro8q32maZecSS4FVRUbdBkuUJ LflKWixS4ZbQe073Z8ShSjqv4FbLrxTyeDmkJn752tA9QBKHB9BmuWHJoxnRqC+Nvhh2 WbSkkTci7mqVW/CZoZfOsy+EYG7/RvXQTi0J5vrgYNWBhXJNmW6vNm7xQma3ExV6Wm7E fVSqynLF9NbQFY4++lHJljIDAxSCN1PHsJR+NW+9mR8vNT5cQH/h+V6j4bJ5HtLYbstO Gfz2Z9wL7ipXRGBFEO+1aHcuMg6l2uVHRtfqPb43iPkEj7/EyJDWOXsW8b1uc4RR8UoH kyCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RLKMu16Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k19si13586358ejc.167.2020.06.27.06.59.24; Sat, 27 Jun 2020 06:59:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RLKMu16Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgF0N62 (ORCPT + 99 others); Sat, 27 Jun 2020 09:58:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:57744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbgF0N6Z (ORCPT ); Sat, 27 Jun 2020 09:58:25 -0400 Received: from localhost.localdomain (unknown [89.208.247.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 25B5421707; Sat, 27 Jun 2020 13:58:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593266304; bh=IWnZVZFkP2osi1vJUSnyhYIHj1OQga5bCNzMBDr1xHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RLKMu16Z74LgpMSKnH2oMSg25TX2zeB4DVr3S/jJCyz7ByG4MEHzfIW3WU6ytk09X FfZR9JoAkJ6g981qLceTuj9MDewy4ZWu5GVSwkXbWI9zNcjvpjMboo2KAhuSXRhHWX Mnt0o80odJgEe+Y7DeRcQV/6zY/cXRvA/CSf54ew= From: guoren@kernel.org To: palmerdabbelt@google.com, paul.walmsley@sifive.com, anup@brainfault.org, greentime.hu@sifive.com, zong.li@sifive.com, aou@eecs.berkeley.edu, tglx@linutronix.de, tycho@tycho.ws, nickhu@andestech.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, Guo Ren Subject: [PATCH V2 3/3] riscv: Enable LOCKDEP_SUPPORT & fixup TRACE_IRQFLAGS_SUPPORT Date: Sat, 27 Jun 2020 13:57:08 +0000 Message-Id: <1593266228-61125-4-git-send-email-guoren@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593266228-61125-1-git-send-email-guoren@kernel.org> References: <1593266228-61125-1-git-send-email-guoren@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren Lockdep is needed by proving the spinlocks and rwlocks. To suupport it, we need fixup TRACE_IRQFLAGS_SUPPORT in kernel/entry.S. This patch follow Documentation/irqflags-tracing.txt. Signed-off-by: Guo Ren Cc: Greentime Hu --- arch/riscv/Kconfig | 3 +++ arch/riscv/kernel/entry.S | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 58d6f66..d5d5100 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -179,6 +179,9 @@ config PGTABLE_LEVELS default 3 if 64BIT default 2 +config LOCKDEP_SUPPORT + def_bool y + source "arch/riscv/Kconfig.socs" menu "Platform type" diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S index cae7e6d..45c81e4 100644 --- a/arch/riscv/kernel/entry.S +++ b/arch/riscv/kernel/entry.S @@ -97,19 +97,26 @@ _save_context: la gp, __global_pointer$ .option pop - la ra, ret_from_exception +#ifdef CONFIG_TRACE_IRQFLAGS + call trace_hardirqs_off +#endif /* * MSB of cause differentiates between * interrupts and exceptions */ bge s4, zero, 1f + la ra, ret_from_exception + /* Handle interrupts */ move a0, sp /* pt_regs */ la a1, handle_arch_irq REG_L a1, (a1) jr a1 1: +#ifdef CONFIG_TRACE_IRQFLAGS + call trace_hardirqs_on +#endif /* * Exceptions run with interrupts enabled or disabled depending on the * state of SR_PIE in m/sstatus. @@ -119,6 +126,7 @@ _save_context: csrs CSR_STATUS, SR_IE 1: + la ra, ret_from_exception /* Handle syscalls */ li t0, EXC_SYSCALL beq s4, t0, handle_syscall @@ -137,6 +145,17 @@ _save_context: tail do_trap_unknown handle_syscall: +#ifdef CONFIG_TRACE_IRQFLAGS + /* Recover a0 - a7 for system calls */ + REG_L a0, PT_A0(sp) + REG_L a1, PT_A1(sp) + REG_L a2, PT_A2(sp) + REG_L a3, PT_A3(sp) + REG_L a4, PT_A4(sp) + REG_L a5, PT_A5(sp) + REG_L a6, PT_A6(sp) + REG_L a7, PT_A7(sp) +#endif /* save the initial A0 value (needed in signal handlers) */ REG_S a0, PT_ORIG_A0(sp) /* @@ -190,6 +209,9 @@ ret_from_syscall_rejected: ret_from_exception: REG_L s0, PT_STATUS(sp) csrc CSR_STATUS, SR_IE +#ifdef CONFIG_TRACE_IRQFLAGS + call trace_hardirqs_off +#endif #ifdef CONFIG_RISCV_M_MODE /* the MPP value is too large to be used as an immediate arg for addi */ li t0, SR_MPP @@ -216,6 +238,16 @@ resume_userspace: csrw CSR_SCRATCH, tp restore_all: +#ifdef CONFIG_TRACE_IRQFLAGS + REG_L s1, PT_STATUS(sp) + andi t0, s1, SR_PIE + beqz t0, 1f + call trace_hardirqs_on + j 2f +1: + call trace_hardirqs_off +2: +#endif REG_L a0, PT_STATUS(sp) /* * The current load reservation is effectively part of the processor's -- 2.7.4