From patchwork Fri Aug 4 02:10:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13341122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E6E5EB64DD for ; Fri, 4 Aug 2023 02:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xJrc+TzGzUKlEMmmf3xWBQOb+r/3yoG58eKGy8f8ZgY=; b=HzUA4r6ZQq+JZD kjjzizjie7ohyGZct245UfQSAW6LJx7/Uxud8RUf7sUJUilx265yuQQNHTS+ngl6b18aBXhNkRz8q kPkTk12n3wSIudH8S/aBW1SviRX6xMHcx+WmVe8wtf64/eUx99VIUP/aTSwmiHbDkWqDTDBCW7Njm 3qeZtpjyW1qIQdOgjwiDFY8DMqiuyiHoeKuZ6iGOXXtIlZChAGPeiMWFD4YMT3zPP9NbxcOmgN7Cb aPx8e7Jhu7Uts0Hjxe4lcCepSvMnTBgGJTSY6KS+oN9x/0+sRPXBVL3nwX4bRP1DGoVtjhg3KIKoY VzBUlYxFuB7FzXg/zAkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRkHR-00BL1Q-0v; Fri, 04 Aug 2023 02:11:05 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRkHM-00BKw4-2M for linux-riscv@lists.infradead.org; Fri, 04 Aug 2023 02:11:03 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bc3bec2c95so11704525ad.0 for ; Thu, 03 Aug 2023 19:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1691115058; x=1691719858; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=k6HgGLGtG7M3LESpN5nTWoHfsSRrv8ioEMKugiOnOTw=; b=tu7avlotyozMV/l8NRFA0DJ9nnNC6Iq43LymSGWeqaIFo+4SOLemWteCRxuxVqX1vN v5bb3l0plvTmmo2yGXB6uIC1F/QI4lTwiO69NqjpKxuMRfL+xYAnS4u+tegfJm0NuEKP 0kChJuxf5ozsMipWf8xNnVMnHYeK7CIXvxUiE3DuPC17GkDDWyzdDHCq7v8KNNMZN3aR E+nUQYwRE0MLaL/LwTWHQGSQHIoxQ1RLPR4iRDtmnbokti7RepO5Ri/GxUt3bdFA6/dP pyxnjsEJpHF1MQS3xf8YsV6SjjvC5Eyd4tgBsMQxdwZBNR6xOFws8g38Zn3skjbBCBfO Im3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691115059; x=1691719859; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k6HgGLGtG7M3LESpN5nTWoHfsSRrv8ioEMKugiOnOTw=; b=aNM0fypLHrpI2ieLndU1FQOtOJ1U4BGqcds+wwpPwOJfxbikkn5RRkfa0UbkypY12/ DBOFTfZhwHVSnC+22sInDqMLkLKILZucY2GZ9JRpVx4GQjAQ4P5Iqi2kZam/endGubOU pPJ7FDcuRvnfkZ4Y7Hga4L7dfHkedNkkTahaovNLoqhNcis5SJWdhBBRfgzkItfGHDhZ pqMdv7ueNHqBTqMhwLsKF5jpCa6tMiRogdrf8Y/kqLOrXoZj25jUYcw47tmVxvWEH+D9 c52/ZRF0nSayqNfF5bRePIfNmHqa+kvG14OzC8niwlXcwn9RYs8Qkc5ZAvRMjELBcu4w 1XqQ== X-Gm-Message-State: AOJu0Yxkm0nfzStt892Bm1HdFig2oWQcWRteJfHpPKBDpfKu+HiqTL94 BK2Ay7CiKpbR8j8kovcgNhgqEw== X-Google-Smtp-Source: AGHT+IEN0Jt5wwNuskL0qGGhhGkOeUg3t8WkQm4o7XfOAfqqqzUJqOVX9dt6wxX88cfzTtEYQSuJcg== X-Received: by 2002:a17:902:ab48:b0:1bc:e37:aa76 with SMTP id ij8-20020a170902ab4800b001bc0e37aa76mr516147plb.6.1691115058660; Thu, 03 Aug 2023 19:10:58 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id g6-20020a655806000000b0055c558ac4edsm369499pgr.46.2023.08.03.19.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 19:10:58 -0700 (PDT) From: Charlie Jenkins Date: Thu, 03 Aug 2023 19:10:29 -0700 Subject: [PATCH 04/10] RISC-V: KGDB: Refactor instructions MIME-Version: 1.0 Message-Id: <20230803-master-refactor-instructions-v4-v1-4-2128e61fa4ff@rivosinc.com> References: <20230803-master-refactor-instructions-v4-v1-0-2128e61fa4ff@rivosinc.com> In-Reply-To: <20230803-master-refactor-instructions-v4-v1-0-2128e61fa4ff@rivosinc.com> To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, bpf@vger.kernel.org Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Peter Zijlstra , Josh Poimboeuf , Jason Baron , Steven Rostedt , Ard Biesheuvel , Anup Patel , Atish Patra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , =?utf-8?b?Qmo=?= =?utf-8?b?w7ZybiBUw7ZwZWw=?= , Luke Nelson , Xi Wang , Nam Cao , Charlie Jenkins X-Mailer: b4 0.12.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230803_191100_771354_1474BF71 X-CRM114-Status: GOOD ( 12.55 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Use shared instruction definitions in insn.h. Signed-off-by: Charlie Jenkins --- arch/riscv/kernel/kgdb.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/riscv/kernel/kgdb.c b/arch/riscv/kernel/kgdb.c index 2393342ab362..e1305706120e 100644 --- a/arch/riscv/kernel/kgdb.c +++ b/arch/riscv/kernel/kgdb.c @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -25,12 +24,12 @@ static unsigned int stepped_opcode; static int decode_register_index(unsigned long opcode, int offset) { - return (opcode >> offset) & 0x1F; + return (opcode >> offset) & RV_STANDARD_REG_MASK; } static int decode_register_index_short(unsigned long opcode, int offset) { - return ((opcode >> offset) & 0x7) + 8; + return ((opcode >> offset) & RV_COMPRESSED_REG_MASK) + 8; } /* Calculate the new address for after a step */ @@ -43,7 +42,7 @@ static int get_step_address(struct pt_regs *regs, unsigned long *next_addr) if (get_kernel_nofault(op_code, (void *)pc)) return -EINVAL; - if ((op_code & __INSN_LENGTH_MASK) != INSN_C_MASK) { + if (INSN_IS_C(op_code)) { if (riscv_insn_is_c_jalr(op_code) || riscv_insn_is_c_jr(op_code)) { rs1_num = decode_register_index(op_code, RVC_C2_RS1_OPOFF); @@ -55,14 +54,14 @@ static int get_step_address(struct pt_regs *regs, unsigned long *next_addr) rs1_num = decode_register_index_short(op_code, RVC_C1_RS1_OPOFF); if (!rs1_num || regs_ptr[rs1_num] == 0) - *next_addr = RVC_EXTRACT_BTYPE_IMM(op_code) + pc; + *next_addr = RVC_EXTRACT_BZ_IMM(op_code) + pc; else *next_addr = pc + 2; } else if (riscv_insn_is_c_bnez(op_code)) { rs1_num = decode_register_index_short(op_code, RVC_C1_RS1_OPOFF); if (rs1_num && regs_ptr[rs1_num] != 0) - *next_addr = RVC_EXTRACT_BTYPE_IMM(op_code) + pc; + *next_addr = RVC_EXTRACT_BZ_IMM(op_code) + pc; else *next_addr = pc + 2; } else {