Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2224729ybh; Mon, 9 Mar 2020 01:25:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsTtSwkS5VzqbkQ1mLuclmoRRZtx1PrLsjbOM+t8+PRlM9eB7KOo0+ODAWijSTZinSu9fWp X-Received: by 2002:aca:d882:: with SMTP id p124mr5790050oig.178.1583742307536; Mon, 09 Mar 2020 01:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583742307; cv=none; d=google.com; s=arc-20160816; b=svVjD9XN2Y+dm8diNU3ZAGAWjYJQxD6qzSwH6kP4HIcKNVcHb0p+qtyj13XRfvjssX CVHRN92Ll4mWJGm3oqw8tmPSpy2OrW+IjWwk0t3Lb7klqY8DkXsNj4aXAgoDb/vpZjK4 ntlTI3SXWJnJii3G0xRBCQRn8Pzk39LUaW9ZJGQuGBCGbArxOWi/xmx5JtGeGOBdelfH 1v4Ikb95m3K0lZ2dPJet6bM4ulQrfowVN2dBrBc4B9GSJc3oTiZO2BEvrl0R7jvMfkvf QNuaDld2uuGPJIjrEGfF1Opi4CLw9Pdv2nTu1mMInv0RWtOoFts5Fs7kcnXTFEisz+ns Kuhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DKBW8Eyy8NVtYJgHutHlswaK8NeRD9IAyJm/+12aBBY=; b=V7omB7LJqHuQln/RiTnVsP9p9hH7alXKjskqBvVTUtHzF7ea5bgwlucTYU533Bn7F3 erAoFdl2hxwGXlU3pJRCAqCTDbra8PuoXGhnRca7Pr/1CIGLDz8adB606g+9iDvQ90Kr to4YawChHPFAFzkRYBFJY0+fgjwSkIBlnbFdUlDgqJaOZ3XLXsYQ7lwBuSJ0EkPxKbXh rq28CS4OScBi7o1oSxlIwTt7kMOxnuoULL1+g9zSKfp6lvW3fvBJOUvnZJbpMylAuOzK XcSzw5ytSYOiaUST5vmtxPnQhlXNu68itYKcirBX62zmFwm3+gQYH78uPGN5MUtlUyJ5 ouzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=PLP0zU9h; 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 h7si6240464otk.84.2020.03.09.01.24.56; Mon, 09 Mar 2020 01:25:07 -0700 (PDT) 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; dkim=pass header.i=@sifive.com header.s=google header.b=PLP0zU9h; 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 S1726680AbgCIIXF (ORCPT + 99 others); Mon, 9 Mar 2020 04:23:05 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38943 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgCIIWx (ORCPT ); Mon, 9 Mar 2020 04:22:53 -0400 Received: by mail-pg1-f195.google.com with SMTP id s2so4372770pgv.6 for ; Mon, 09 Mar 2020 01:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DKBW8Eyy8NVtYJgHutHlswaK8NeRD9IAyJm/+12aBBY=; b=PLP0zU9h4LODazLocgYTaUlefV0n5miYUkqXeQnR2x+qSMUaUylcFG1Z08ma8BbMpw YWNRqxfL2bdhm2EMPL4ti3jf5tyiN7zqHYcUro5PFxsmj+dB/779BE+Vj/tq7Vg1qZ9w ZyTk50s8LgxDr0SXz4Z+rUJswzfZMGLKf2oAn/fuRddJNqIU6YbM2KvTnrGsbz4HQ2Q/ Tt/N35eOUez5OYJDHr1blVvIB1Qatw/SgsHStUqULYs1oyJtl+5YOnTrRMU2auogtEZS PZnFCwBnaGIlIbj6rswYaLXFRTp/aKCMeTw5MLJauUquwJ22T6n+F3q7GGaQVx01i/92 zSdw== 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=DKBW8Eyy8NVtYJgHutHlswaK8NeRD9IAyJm/+12aBBY=; b=hyNnNqJ7Axw6IsKijZmIuo5lpNCi6aKaONctQaU8ZkwaUQX/ykcfnQz/asXYTfTaxa Avvo69pJeCpmZzKbHEjuWLdiDzRX9cqNTGO8o2Gu/n8UljMXWxP5dJHCuoug2nEzuIAE wbfvgSdcFedxt9yBFXvEdVdXyPfxc7vnoFCFIQ41vSjMgKPyPcd0TKOnFPUWhVEGlcrZ c8XecomObdLCGxxVq+gfKUl/MoFYuR/aYBC2YMYWUsGuswXcdVN1iP4ngnWuh8N4bO0f ouGNVC3d8IL28MVEryybCVC+gx7NZKY0PeSrv6EYQEZ/PRmB2pWIMvWFJZ2ml7GJsmCY jn1w== X-Gm-Message-State: ANhLgQ0b3aOzF6aNbUwco4eYmzqXhcJ1r49FqqVo4e6D8W20hgJDeZ7W p8joiSP27HkxnqEnGK4kF5t9qw== X-Received: by 2002:a63:e053:: with SMTP id n19mr15845329pgj.64.1583742171399; Mon, 09 Mar 2020 01:22:51 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id v5sm18364779pfn.64.2020.03.09.01.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 01:22:51 -0700 (PDT) From: Zong Li To: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li Subject: [PATCH v2 7/9] riscv: add macro to get instruction length Date: Mon, 9 Mar 2020 16:22:27 +0800 Message-Id: <59d5cd2e5325893f3cff9420e7e94d5c0f503da1.1583741997.git.zong.li@sifive.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extract the calculation of instruction length for common use. Signed-off-by: Zong Li --- arch/riscv/include/asm/bug.h | 8 ++++++++ arch/riscv/kernel/traps.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/bug.h b/arch/riscv/include/asm/bug.h index 75604fec1b1b..d6f1ec08d97b 100644 --- a/arch/riscv/include/asm/bug.h +++ b/arch/riscv/include/asm/bug.h @@ -19,6 +19,14 @@ #define __BUG_INSN_32 _UL(0x00100073) /* ebreak */ #define __BUG_INSN_16 _UL(0x9002) /* c.ebreak */ +#define GET_INSN_LENGTH(insn) \ +({ \ + unsigned long __len; \ + __len = ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? \ + 4UL : 2UL; \ + __len; \ +}) + typedef u32 bug_insn_t; #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index ffb3d94bf0cc..a4d136355f78 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -118,7 +118,8 @@ static inline unsigned long get_break_insn_length(unsigned long pc) if (probe_kernel_address((bug_insn_t *)pc, insn)) return 0; - return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL); + + return GET_INSN_LENGTH(insn); } asmlinkage __visible void do_trap_break(struct pt_regs *regs) -- 2.25.1