From patchwork Fri Aug 19 14:02:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 12948835 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 7C826C32772 for ; Fri, 19 Aug 2022 14:03:16 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=naOYZhrmc0Y6lm4RkkgBddvnYPxt+KaMky+W5hpSrFI=; b=015H0gwuL6Gxgz HS8Fbuh/HdmXBHYAtqM9YSlL8B1/fGQF0cr7V2Ma4go9POPmxCow+buBnkUGZnywaCNukig/2l2+U 1BKi5p4d9f8S0GUpbTL7UlfBZMhAAH4fKV0wTijKgJKEGSJ/w9RASFmaWQTxhu7DWMEGDZzP/XoJZ mU5Rwy0SiflVliynDmhxyx0n/9gKuVL51E5ryk8+ZcK03YhZFwQ3N1MeBZOGSj6qdrSlF1AizLdBy b+/EUwb3yr5AtCOrCLL5yn6UiTk5rVt9sesUhMjBvCM9H2OTBJ3Me138XUY5m4vDQ+rrN0oOiRSc6 tX1atWd2AuhGNIysS6Sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2aW-009KfN-Eq; Fri, 19 Aug 2022 14:03:04 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2aQ-009KXB-Rh for linux-riscv@lists.infradead.org; Fri, 19 Aug 2022 14:03:00 +0000 Received: by mail-ed1-x52f.google.com with SMTP id e21so943175edc.7 for ; Fri, 19 Aug 2022 07:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=gWpCeboSTd362c81JJRbfvlhocgLTAM7tdDbcBSzWLo=; b=nAbT1+smFaqdX4qfGI5TykDxMyIbjzhqPcHArokTkIhBwchex3uvH78ENi3Bnt4BX0 7w5W23B0DjDiFlHt0tvmIR7ZBNYQXCvUgD8pwYp8qlP3gFqj6NxL89vjWHt8T25TT1Wy UrKpuERmkAa5DCCZ1tOsYOxShaMrJ1Purq4AJ0OlUWJZnLKm9oeL6UTGZSl4ncJ7MzFr 82RvD6l56TIYCeypl3BK4Mgyzwq3H8JprBrW79AqcMzodyc7wGF4QoM8pQgA9htThGnF pqTJ9f/BsE6PliI6Iwsc5feBsinOW5WQUQkxw0puSHoOgvWPFWikY5bEgkDHA8tOF5ra LK2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=gWpCeboSTd362c81JJRbfvlhocgLTAM7tdDbcBSzWLo=; b=ZTc6gl9Eg8jb/y5uBTt6qBPU7kFGvxHp6Dkv8I+FlKdizTAFyFCWOBqafNcUsJi7pR Zw1UWaeWAkmaAfTjZHkR+TKpLjNOKvb6U4vYWahjJzvZ+fw32MOpaawI615bK1Q9Qsp2 WNhRqK8g1PH+yMXfKTr7pfSCmBw0hN8Hxixgsjc+WZZFx5mEGGVirWzTpPr+/O6lVm1F xGjLUAU1B7WXAQrsFHYDmc6vDvLqiteO5JiwP/qLbxO1X8uWu1isATZIeniLIsqaQOHz 2WVUqcF27CTb9T5fyEow+8MVnhU9Tej5PS79dBsLHhwuJYeqzdfXW6+feZM4+3zIJDdE EUuw== X-Gm-Message-State: ACgBeo0z81RSPWEbbT0ngFbXWWHVtaiUioj5eSaRXUwFWA6xEwOc4zVR xEyRGbS+rN4y2u5WB+YAmUD6x+UN6bGArg== X-Google-Smtp-Source: AA6agR6iqHD8BlV5q3t5q+oMfU59Fa2v3ezBpXzZ0BeKOHeC9Vpm41nPJvjiQV3QcFghPode/hRkQw== X-Received: by 2002:a05:6402:198:b0:442:da5a:6716 with SMTP id r24-20020a056402019800b00442da5a6716mr6164620edv.5.1660917773621; Fri, 19 Aug 2022 07:02:53 -0700 (PDT) Received: from localhost (cst2-173-67.cust.vodafone.cz. [31.30.173.67]) by smtp.gmail.com with ESMTPSA id q15-20020a170906360f00b00730a73cbe08sm2383101ejb.169.2022.08.19.07.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 07:02:53 -0700 (PDT) From: Andrew Jones To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, anup@brainfault.org, mchitale@ventanamicro.com, heiko@sntech.de Subject: [PATCH 1/4] riscv: Add X register names to gpr-nums Date: Fri, 19 Aug 2022 16:02:47 +0200 Message-Id: <20220819140250.3892995-2-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220819140250.3892995-1-ajones@ventanamicro.com> References: <20220819140250.3892995-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220819_070258_981716_EE1C0187 X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. 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 When encoding instructions it's sometimes necessary to set a register field to a precise number. This is easiest to do using the x naming. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- arch/riscv/include/asm/gpr-num.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/riscv/include/asm/gpr-num.h b/arch/riscv/include/asm/gpr-num.h index dfee2829fc7c..efeb5edf8a3a 100644 --- a/arch/riscv/include/asm/gpr-num.h +++ b/arch/riscv/include/asm/gpr-num.h @@ -3,6 +3,11 @@ #define __ASM_GPR_NUM_H #ifdef __ASSEMBLY__ + + .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 + .equ .L__gpr_num_x\num, \num + .endr + .equ .L__gpr_num_zero, 0 .equ .L__gpr_num_ra, 1 .equ .L__gpr_num_sp, 2 @@ -39,6 +44,9 @@ #else /* __ASSEMBLY__ */ #define __DEFINE_ASM_GPR_NUMS \ +" .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31\n" \ +" .equ .L__gpr_num_x\\num, \\num\n" \ +" .endr\n" \ " .equ .L__gpr_num_zero, 0\n" \ " .equ .L__gpr_num_ra, 1\n" \ " .equ .L__gpr_num_sp, 2\n" \ From patchwork Fri Aug 19 14:02:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 12948836 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 E43E2C32774 for ; Fri, 19 Aug 2022 14:03:16 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hr6PgScgqgDu8t9PoURq5ARhdrXDI+pSrY9i+gkFnig=; b=BjGsIocaETaSCp qsDo80hX01DzknHJEYi2NE69Ui3F4ZYIjHSjWWRjpdgGApD7bUCpHo7001Il22+71s7uoATa0UeZO BoxJct/5txrix2UUYQugiQdyUifP3sy1bl6IXmLqbg14mihb4P/fUuXVKE6IBtXdi4MupRc9gMj2E qZTH1OCqMfXUpWd2yFxD1ONGVaYgIldvelEzbr0BCXIWFLtQmIZ7UlxA/4AWxt6SMOKlVhmmHMKde KHjxUWXH2BGUw/Ytr7Q5uot+piOkQ2Mr0LGTSkkNAldQToWR4ZnxS/rDVUeyCw9YkkW2DVDi3lLpG 1beaeRtUqlSrws4ijMWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2aY-009Kh0-C8; Fri, 19 Aug 2022 14:03:06 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2aR-009KXn-4U for linux-riscv@lists.infradead.org; Fri, 19 Aug 2022 14:03:01 +0000 Received: by mail-ej1-x62c.google.com with SMTP id dc19so8947650ejb.12 for ; Fri, 19 Aug 2022 07:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=CdNbn84TYwncfTBJxPnu/xlRdTtMM/NuV6HASL/Mh8E=; b=lCh+9pdG34gjrDI076GzFZVpx4/E/qseWgm+HgMbNq2MJQd10BIiZcZdGdBHg2oLKZ ISmjzidGOhYrdfOo6qHCZfYXuFcgY6XL2uMjXhIvjRYQY5iPjSyiQjXeGii7ikG5o7ht Z+tDTkMiBnbcfOGQ6iKUSxpBiEenHq0FTDRv3NZmCDv8q8vsrcM4JDnwTemeUHM3KcNi 56JMnKkv5L8w+1zEEjRpK9FEwGf6FmiaNHSG0AWQvK/SVPoGwCRzSbNZoBwVE9ch40IE O9focsaqJKTW1OZ7+nztPgHJMcBAVe516VIg0e+d3kZDVylLrPMggLO0DHkaj7fcbJpk +heQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=CdNbn84TYwncfTBJxPnu/xlRdTtMM/NuV6HASL/Mh8E=; b=zFmpLkjxNrbZSqHKr/eRqUy9pNlsmg4YDiuvXpHPBWmcdXcERfyp5aRPxpyBqz2QGK i8Uzjp+ttmpWQz2mVgXfZAOVYj47zuMChVvyyc9L480MqF+4Rf2vfVWWqAuKgshqdnv7 FTwTuv0emOHWEIDsP+0eGKQVBybT/SKiL+yu3sSdU8H2GhJcnJJqe15hwwo6GsKifk+A U7dddKTiW85YYXoEWfO7keholBwsangdY132mLfHhO+X7T9TZjdJP+y3uDsIISG9MnCZ fpRuNPMTBB5uYeP+EMsKI3j0hNrOqoMJRuPxdZdvWiN2/KG5wPl1XGRKHdFv31knj4tr uZtA== X-Gm-Message-State: ACgBeo3sI0Ie7Ia/VdCcZnsk9Xp4XHNgJP7RNgGXROXkyeCK9Hx7N6HO Rg3DsrpRlcdyiXJOS71ap/2hmWU4T0oAvQ== X-Google-Smtp-Source: AA6agR7kgjM4XbdNJobWB0KnpsIFG/X1o3vSDdu6NBsYc6JLV3lBrWSwPSJXqdHEA4IO0NWpQIhINQ== X-Received: by 2002:a17:906:93e8:b0:730:9e5c:b45a with SMTP id yl8-20020a17090693e800b007309e5cb45amr4819450ejb.530.1660917775017; Fri, 19 Aug 2022 07:02:55 -0700 (PDT) Received: from localhost (cst2-173-67.cust.vodafone.cz. [31.30.173.67]) by smtp.gmail.com with ESMTPSA id r17-20020aa7cfd1000000b0043ba7df7a42sm3147053edy.26.2022.08.19.07.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 07:02:54 -0700 (PDT) From: Andrew Jones To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, anup@brainfault.org, mchitale@ventanamicro.com, heiko@sntech.de Subject: [PATCH 2/4] riscv: Introduce support for defining instructions Date: Fri, 19 Aug 2022 16:02:48 +0200 Message-Id: <20220819140250.3892995-3-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220819140250.3892995-1-ajones@ventanamicro.com> References: <20220819140250.3892995-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220819_070259_219699_491128C2 X-CRM114-Status: GOOD ( 16.20 ) 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 When compiling with toolchains that haven't yet been taught about new instructions we need to encode them ourselves. Create a new file where support for instruction definitions will evolve. We initiate the file with a macro called INSN_R(), which implements the R-type instruction encoding. INSN_R() will use the assembler's .insn directive when available, which should give the assembler a chance to do some validation. When .insn is not available we fall back to manual encoding. Not only should using instruction encoding macros improve readability and maintainability of code over the alternative of inserting instructions directly (e.g. '.word 0xc0de'), but we should also gain potential for more optimized code after compilation because the compiler will have control over the input and output registers used. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- arch/riscv/Kconfig | 3 ++ arch/riscv/include/asm/insn-def.h | 82 +++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 arch/riscv/include/asm/insn-def.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index ed66c31e4655..f8f3b316b838 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -227,6 +227,9 @@ config RISCV_DMA_NONCOHERENT select ARCH_HAS_SETUP_DMA_OPS select DMA_DIRECT_REMAP +config AS_HAS_INSN + def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero) + source "arch/riscv/Kconfig.socs" source "arch/riscv/Kconfig.erratas" diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h new file mode 100644 index 000000000000..4cd0208068dd --- /dev/null +++ b/arch/riscv/include/asm/insn-def.h @@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ASM_INSN_DEF_H +#define __ASM_INSN_DEF_H +#include + +#define INSN_R_FUNC7_SHIFT 25 +#define INSN_R_RS2_SHIFT 20 +#define INSN_R_RS1_SHIFT 15 +#define INSN_R_FUNC3_SHIFT 12 +#define INSN_R_RD_SHIFT 7 +#define INSN_R_OPCODE_SHIFT 0 + +#ifdef __ASSEMBLY__ + +#ifdef CONFIG_AS_HAS_INSN + + .macro insn_r, opcode, func3, func7, rd, rs1, rs2 + .insn r \opcode, \func3, \func7, \rd, \rs1, \rs2 + .endm + +#else + +#include + + .macro insn_r, opcode, func3, func7, rd, rs1, rs2 + .4byte ((\opcode << INSN_R_OPCODE_SHIFT) | \ + (\func3 << INSN_R_FUNC3_SHIFT) | \ + (\func7 << INSN_R_FUNC7_SHIFT) | \ + (.L__gpr_num_\rd << INSN_R_RD_SHIFT) | \ + (.L__gpr_num_\rs1 << INSN_R_RS1_SHIFT) | \ + (.L__gpr_num_\rs2 << INSN_R_RS2_SHIFT)) + .endm + +#endif + +#define INSN_R(...) insn_r __VA_ARGS__ + +#else /* ! __ASSEMBLY__ */ + +#ifdef CONFIG_AS_HAS_INSN + +#define INSN_R(opcode, func3, func7, rd, rs1, rs2) \ + ".insn r " opcode ", " func3 ", " func7 ", " rd ", " rs1 ", " rs2 "\n" + +#else + +#include +#include + +#define DEFINE_INSN_R \ + __DEFINE_ASM_GPR_NUMS \ +" .macro insn_r, opcode, func3, func7, rd, rs1, rs2\n" \ +" .4byte ((\\opcode << " __stringify(INSN_R_OPCODE_SHIFT) ") |" \ +" (\\func3 << " __stringify(INSN_R_FUNC3_SHIFT) ") |" \ +" (\\func7 << " __stringify(INSN_R_FUNC7_SHIFT) ") |" \ +" (.L__gpr_num_\\rd << " __stringify(INSN_R_RD_SHIFT) ") |" \ +" (.L__gpr_num_\\rs1 << " __stringify(INSN_R_RS1_SHIFT) ") |" \ +" (.L__gpr_num_\\rs2 << " __stringify(INSN_R_RS2_SHIFT) "))\n" \ +" .endm\n" + +#define UNDEFINE_INSN_R \ +" .purgem insn_r\n" + +#define INSN_R(opcode, func3, func7, rd, rs1, rs2) \ + DEFINE_INSN_R \ + "insn_r " opcode ", " func3 ", " func7 ", " rd ", " rs1 ", " rs2 "\n" \ + UNDEFINE_INSN_R + +#endif + +#endif /* ! __ASSEMBLY__ */ + +#define OPCODE(v) __ASM_STR(v) +#define FUNC3(v) __ASM_STR(v) +#define FUNC7(v) __ASM_STR(v) +#define __REG(v) __ASM_STR(x ## v) +#define RD(v) __REG(v) +#define RS1(v) __REG(v) +#define RS2(v) __REG(v) + +#endif /* __ASM_INSN_DEF_H */ From patchwork Fri Aug 19 14:02:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 12948838 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 248FCC32771 for ; Fri, 19 Aug 2022 14:03:23 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wn4KryFCRUDUVem9Ph+FxfTM9lS52+xbeZRFcL1kTjw=; b=qnrE+CHV+aj3Qa 4desbvlpfYoREIBz4Tyo/PMiDhKIbVK3RpY9VvszyoeGIr442xUa57NXeGvsGIx8j051AYW35Oavp NHIMONpXB9GEb8gJtDIyMqfopWhcbPJ4lrYfXRif3FwqVIZT5s9nnlUoYTRBRPo/T+sthZGEhkOKo WTRjwQqezsduyt5hKERuCcHmaqFHzx1aFXnjbRylJgl0B2Tsm1kvIkifH6YjZK7eV9wplvjDUgmzc zq0RcAv8n9ewQrOBPt88Y42wVs9tp8lndT2UMBp5buPfulw94/+iWnHErBleRy5oFElWTAOuHDtGJ WeMTYBftvqKC87/Ymj2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2aa-009Kim-Cr; Fri, 19 Aug 2022 14:03:08 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2aS-009KYe-E8 for linux-riscv@lists.infradead.org; Fri, 19 Aug 2022 14:03:02 +0000 Received: by mail-ed1-x535.google.com with SMTP id e21so943360edc.7 for ; Fri, 19 Aug 2022 07:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=eHs+z8DwNs709gkux1J21T7x+ZKZRefKINTUPP0jqqE=; b=MiVkDd4ypsClXPfrJblJPX1o05V2XlMgkABPNa+ANz5bpPHj3bz+KUWKPLbj4eMh2e Rf+Yfig8Yqutna/Gl1ZlvDAYMbONm2a1faNbFHIgth+0jnO5iCoOoiGUO2cdhbMbPcoX NMC2DiHTYwuBlGQ0fm+hNXHeNI+FOZwopJW5bb9kQ/vLNIsHRnM3VsLkUoUfyPkguFPn DdTu45vwCCHA2KHOEW12+Ilk7iklf/ig1tuAmHI2WDQHVgWZwZRBHOq+P9Rx6AdrUeSA /uUw748nFBk8M/HHgh89LcniBs/ZOywQ1MUrAVWqnhGA8R57j5Uu3Etgfl+IUxWQLBCC crfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=eHs+z8DwNs709gkux1J21T7x+ZKZRefKINTUPP0jqqE=; b=fzqkQW5u7kizLv1pXSvvY6ftgrPu1e2ltXW1wUBonEOa0bTtwc0SMCrF34qZwU/MjV O1OJi/0XizBJnLEqqSsaej796kWrbPJlGIWJyPJVgKJmhPS6kocT6I1xKd83PkhmKU30 Q74IchgHvDRVuCPpXK7rizEQx+4bhSv9sG/UxgZyyRn83auWjEIq/Bq5A+K1vCA+VkJH rNGV+HL4wD0eUXryoUhkFvnipYF4WS34lzWVlIg6HKrPodo0VUzMHw8JQoXc5jvYMBlL 24q1E6izFr4FlW+OWM9pjXuWGx59T+NTyaLBPw9BTC/AfXnUCsAsQFnOYD2polRZtJB3 0uVw== X-Gm-Message-State: ACgBeo2PW0i8SE1+nqFiN4cmH+ykVquAhWIrLRwuTCKvbn2cjyQKdag+ MxiEcjtJfLBE0iytXUt8TGTTiwmhTwrz4g== X-Google-Smtp-Source: AA6agR63VI1qC3a/Avg6iK+EkZbCELYZLImNqOEsToeYNls3s6oXmzXpKEmehFYJbdsLBfBuKZi0RQ== X-Received: by 2002:a05:6402:1044:b0:446:27c1:49a4 with SMTP id e4-20020a056402104400b0044627c149a4mr4331991edu.53.1660917776492; Fri, 19 Aug 2022 07:02:56 -0700 (PDT) Received: from localhost (cst2-173-67.cust.vodafone.cz. [31.30.173.67]) by smtp.gmail.com with ESMTPSA id b9-20020a17090630c900b0073c9d68ca0dsm1434287ejb.133.2022.08.19.07.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 07:02:56 -0700 (PDT) From: Andrew Jones To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, anup@brainfault.org, mchitale@ventanamicro.com, heiko@sntech.de Subject: [PATCH 3/4] riscv: KVM: Apply insn-def to hfence encodings Date: Fri, 19 Aug 2022 16:02:49 +0200 Message-Id: <20220819140250.3892995-4-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220819140250.3892995-1-ajones@ventanamicro.com> References: <20220819140250.3892995-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220819_070300_492218_AEC2BB4A X-CRM114-Status: UNSURE ( 9.41 ) X-CRM114-Notice: Please train this message. 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 Introduce hfence instruction encodings and apply them to KVM's use. With the self-documenting nature of the instruction encoding macros, and a spec always within arm's reach, it's safe to remove the comments, so we do that too. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- arch/riscv/include/asm/insn-def.h | 8 ++ arch/riscv/kvm/tlb.c | 117 ++++-------------------------- 2 files changed, 21 insertions(+), 104 deletions(-) diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h index 4cd0208068dd..cd1c0d365f47 100644 --- a/arch/riscv/include/asm/insn-def.h +++ b/arch/riscv/include/asm/insn-def.h @@ -79,4 +79,12 @@ #define RS1(v) __REG(v) #define RS2(v) __REG(v) +#define OPCODE_SYSTEM OPCODE(115) + +#define HFENCE_VVMA(vaddr, asid) \ + INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(17), RD(0), vaddr, asid) + +#define HFENCE_GVMA(gaddr, vmid) \ + INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(49), RD(0), gaddr, vmid) + #endif /* __ASM_INSN_DEF_H */ diff --git a/arch/riscv/kvm/tlb.c b/arch/riscv/kvm/tlb.c index 1a76d0b1907d..f742a0d888e1 100644 --- a/arch/riscv/kvm/tlb.c +++ b/arch/riscv/kvm/tlb.c @@ -12,22 +12,7 @@ #include #include #include - -/* - * Instruction encoding of hfence.gvma is: - * HFENCE.GVMA rs1, rs2 - * HFENCE.GVMA zero, rs2 - * HFENCE.GVMA rs1 - * HFENCE.GVMA - * - * rs1!=zero and rs2!=zero ==> HFENCE.GVMA rs1, rs2 - * rs1==zero and rs2!=zero ==> HFENCE.GVMA zero, rs2 - * rs1!=zero and rs2==zero ==> HFENCE.GVMA rs1 - * rs1==zero and rs2==zero ==> HFENCE.GVMA - * - * Instruction encoding of HFENCE.GVMA is: - * 0110001 rs2(5) rs1(5) 000 00000 1110011 - */ +#include void kvm_riscv_local_hfence_gvma_vmid_gpa(unsigned long vmid, gpa_t gpa, gpa_t gpsz, @@ -41,31 +26,14 @@ void kvm_riscv_local_hfence_gvma_vmid_gpa(unsigned long vmid, } for (pos = gpa; pos < (gpa + gpsz); pos += BIT(order)) { - /* - * rs1 = a0 (GPA >> 2) - * rs2 = a1 (VMID) - * HFENCE.GVMA a0, a1 - * 0110001 01011 01010 000 00000 1110011 - */ - asm volatile ("srli a0, %0, 2\n" - "add a1, %1, zero\n" - ".word 0x62b50073\n" - :: "r" (pos), "r" (vmid) - : "a0", "a1", "memory"); + asm volatile (HFENCE_GVMA("%0", "%1") + : : "r" (pos >> 2), "r" (vmid) : "memory"); } } void kvm_riscv_local_hfence_gvma_vmid_all(unsigned long vmid) { - /* - * rs1 = zero - * rs2 = a0 (VMID) - * HFENCE.GVMA zero, a0 - * 0110001 01010 00000 000 00000 1110011 - */ - asm volatile ("add a0, %0, zero\n" - ".word 0x62a00073\n" - :: "r" (vmid) : "a0", "memory"); + asm volatile(HFENCE_GVMA("zero", "%0") : : "r" (vmid) : "memory"); } void kvm_riscv_local_hfence_gvma_gpa(gpa_t gpa, gpa_t gpsz, @@ -79,45 +47,16 @@ void kvm_riscv_local_hfence_gvma_gpa(gpa_t gpa, gpa_t gpsz, } for (pos = gpa; pos < (gpa + gpsz); pos += BIT(order)) { - /* - * rs1 = a0 (GPA >> 2) - * rs2 = zero - * HFENCE.GVMA a0 - * 0110001 00000 01010 000 00000 1110011 - */ - asm volatile ("srli a0, %0, 2\n" - ".word 0x62050073\n" - :: "r" (pos) : "a0", "memory"); + asm volatile(HFENCE_GVMA("%0", "zero") + : : "r" (pos >> 2) : "memory"); } } void kvm_riscv_local_hfence_gvma_all(void) { - /* - * rs1 = zero - * rs2 = zero - * HFENCE.GVMA - * 0110001 00000 00000 000 00000 1110011 - */ - asm volatile (".word 0x62000073" ::: "memory"); + asm volatile(HFENCE_GVMA("zero", "zero") : : : "memory"); } -/* - * Instruction encoding of hfence.gvma is: - * HFENCE.VVMA rs1, rs2 - * HFENCE.VVMA zero, rs2 - * HFENCE.VVMA rs1 - * HFENCE.VVMA - * - * rs1!=zero and rs2!=zero ==> HFENCE.VVMA rs1, rs2 - * rs1==zero and rs2!=zero ==> HFENCE.VVMA zero, rs2 - * rs1!=zero and rs2==zero ==> HFENCE.VVMA rs1 - * rs1==zero and rs2==zero ==> HFENCE.VVMA - * - * Instruction encoding of HFENCE.VVMA is: - * 0010001 rs2(5) rs1(5) 000 00000 1110011 - */ - void kvm_riscv_local_hfence_vvma_asid_gva(unsigned long vmid, unsigned long asid, unsigned long gva, @@ -134,17 +73,8 @@ void kvm_riscv_local_hfence_vvma_asid_gva(unsigned long vmid, hgatp = csr_swap(CSR_HGATP, vmid << HGATP_VMID_SHIFT); for (pos = gva; pos < (gva + gvsz); pos += BIT(order)) { - /* - * rs1 = a0 (GVA) - * rs2 = a1 (ASID) - * HFENCE.VVMA a0, a1 - * 0010001 01011 01010 000 00000 1110011 - */ - asm volatile ("add a0, %0, zero\n" - "add a1, %1, zero\n" - ".word 0x22b50073\n" - :: "r" (pos), "r" (asid) - : "a0", "a1", "memory"); + asm volatile(HFENCE_VVMA("%0", "%1") + : : "r" (pos), "r" (asid) : "memory"); } csr_write(CSR_HGATP, hgatp); @@ -157,15 +87,7 @@ void kvm_riscv_local_hfence_vvma_asid_all(unsigned long vmid, hgatp = csr_swap(CSR_HGATP, vmid << HGATP_VMID_SHIFT); - /* - * rs1 = zero - * rs2 = a0 (ASID) - * HFENCE.VVMA zero, a0 - * 0010001 01010 00000 000 00000 1110011 - */ - asm volatile ("add a0, %0, zero\n" - ".word 0x22a00073\n" - :: "r" (asid) : "a0", "memory"); + asm volatile(HFENCE_VVMA("zero", "%0") : : "r" (asid) : "memory"); csr_write(CSR_HGATP, hgatp); } @@ -184,15 +106,8 @@ void kvm_riscv_local_hfence_vvma_gva(unsigned long vmid, hgatp = csr_swap(CSR_HGATP, vmid << HGATP_VMID_SHIFT); for (pos = gva; pos < (gva + gvsz); pos += BIT(order)) { - /* - * rs1 = a0 (GVA) - * rs2 = zero - * HFENCE.VVMA a0 - * 0010001 00000 01010 000 00000 1110011 - */ - asm volatile ("add a0, %0, zero\n" - ".word 0x22050073\n" - :: "r" (pos) : "a0", "memory"); + asm volatile(HFENCE_VVMA("%0", "zero") + : : "r" (pos) : "memory"); } csr_write(CSR_HGATP, hgatp); @@ -204,13 +119,7 @@ void kvm_riscv_local_hfence_vvma_all(unsigned long vmid) hgatp = csr_swap(CSR_HGATP, vmid << HGATP_VMID_SHIFT); - /* - * rs1 = zero - * rs2 = zero - * HFENCE.VVMA - * 0010001 00000 00000 000 00000 1110011 - */ - asm volatile (".word 0x22000073" ::: "memory"); + asm volatile(HFENCE_VVMA("zero", "zero") : : : "memory"); csr_write(CSR_HGATP, hgatp); } From patchwork Fri Aug 19 14:02:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 12948837 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 A1EC3C32773 for ; Fri, 19 Aug 2022 14:03:23 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aTLToXMiaQU1/KHm6XOAKOAUa6fWUO868vx1mL+tCbQ=; b=vMtbvJ4hEgCreT exoVJ4mmqvhTXK6S3hXk5xYrSBcrn2Tk9+cXi48cldbeNnZ6QbANUvV9iIfB8H7uc0r/FwhdCc371 dbIrFxWFrXhPXJ5YwdhaFfmjlvkr2qrMqeKuc3B9H7BPDnGTzD+iEfKfWrIx+OZcPasGsYFkSir22 b6b9pHkJ8/ML6Z89m7hDXQx9sSj4Vr8Ybi9luMX/VeI+M2OP9QFlnk5uuIPOysZ9n82iS7VjRo+0T o/NrfRHFSFeSqpu9SSJr0+7ZrBDuWWTj5/aJZMfBMtiRq3LDqbFN4kY8V7DiXFDEpTr9FtYHTyfeA uNM66dP7etrh8KMDOY2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2ac-009Kkx-FM; Fri, 19 Aug 2022 14:03:10 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oP2aU-009KZl-45 for linux-riscv@lists.infradead.org; Fri, 19 Aug 2022 14:03:03 +0000 Received: by mail-ed1-x531.google.com with SMTP id r4so5779303edi.8 for ; Fri, 19 Aug 2022 07:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=LcgnJW6ojeblPsIc6aD4dBYb9kEDQlJtOgpSlsoKicM=; b=F80xmYw+kiDUqtNmrzbNRu3AMt+mM4KWjQ42y9dE39l2VAObAeVzJz7WOy3CaH+xqJ HjQFKbjRP8H95Cvp1amKY4+bgkO+Q8ezZA+n36ktinonyBVDGWqseyAiMkVn3ZjlVSRU OP2ZTa5gEjM4qkWsbUpzVjW7WPsIyZVoo3CpxIG5oJTwBzb5T6HbH9MiPSERJmZ4gJc7 nGydDtHDyOQLS8xuX35EzecVSa5Ps8oRsWygtCnzFyt08+Zft1JWq+rS+91NapwOe8Cb mw+eaxgcOx7tSnsIWtEuxjnhXC+7Mm7R7XTz9ra9Cq/hWcYlAy/buYnqh9byFUMouQ9T a3kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=LcgnJW6ojeblPsIc6aD4dBYb9kEDQlJtOgpSlsoKicM=; b=bSPjvA783C2gu0mqth7UM0i9AH0aNxZBAcqcb9zi/6kYWfRd+mWZWFMDD2Qd3atuOi ROfNAP+POXuoQCRwNlPEgFWxhfTwxtU2QRyafDb0hyLTQUoEDwYB0xzH8B9NHQENwvef 7gsrpMG+R6tCjwVHYZAYG1XE5cRCEsWEi8Q0f8TI4mUCNVgiGXqc4wYdsZSojOtCcvL9 QTFu1Tkh6L1Z7piUAOry8r34aO2mBQP3SCsZkmAf7SzNoe04pAoEy12ihu46P7U2TC8G g99V5EzevulMx6jaN35KUcng2pmHlyGfCT9+/FeM/+Ty1DZuaBwRu/zpo1DTAFhR45NE R5zg== X-Gm-Message-State: ACgBeo23sxoXfID/BwvjZkhKFv6awCVr62eT+X2+ShGhWhxgaMoKoRoB 9b1n8Xu6AmGduP+ly3FqqnxYeRcLvfk3yg== X-Google-Smtp-Source: AA6agR4EFqr57fc4jUDyesvyg8veXZkmFiKZWBlvKiMpyMHLIIftipgiufj4xlvJJhTBKrr1NYctcg== X-Received: by 2002:aa7:d513:0:b0:43d:5c81:4f71 with SMTP id y19-20020aa7d513000000b0043d5c814f71mr6235776edq.308.1660917778037; Fri, 19 Aug 2022 07:02:58 -0700 (PDT) Received: from localhost (cst2-173-67.cust.vodafone.cz. [31.30.173.67]) by smtp.gmail.com with ESMTPSA id p4-20020a17090653c400b0073bdb2f6f28sm2271393ejo.217.2022.08.19.07.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 07:02:57 -0700 (PDT) From: Andrew Jones To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, anup@brainfault.org, mchitale@ventanamicro.com, heiko@sntech.de Subject: [PATCH 4/4] riscv: KVM: Apply insn-def to hlv encodings Date: Fri, 19 Aug 2022 16:02:50 +0200 Message-Id: <20220819140250.3892995-5-ajones@ventanamicro.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220819140250.3892995-1-ajones@ventanamicro.com> References: <20220819140250.3892995-1-ajones@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220819_070302_195287_8BF45F67 X-CRM114-Status: UNSURE ( 8.82 ) X-CRM114-Notice: Please train this message. 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 Introduce hlv instruction encodings and apply them to KVM's use. We're careful not to introduce hlv.d to 32-bit builds. Indeed, we ensure the build fails if someone tries to use it. Signed-off-by: Andrew Jones Reviewed-by: Anup Patel --- arch/riscv/include/asm/insn-def.h | 14 ++++++++++++++ arch/riscv/kvm/vcpu_exit.c | 29 +++++------------------------ 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h index cd1c0d365f47..c66d5745c5b4 100644 --- a/arch/riscv/include/asm/insn-def.h +++ b/arch/riscv/include/asm/insn-def.h @@ -87,4 +87,18 @@ #define HFENCE_GVMA(gaddr, vmid) \ INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(49), RD(0), gaddr, vmid) +#define HLVX_HU(dest, addr) \ + INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(50), dest, addr, RS2(3)) + +#define HLV_W(dest, addr) \ + INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(52), dest, addr, RS2(0)) + +#ifdef CONFIG_64BIT +#define HLV_D(dest, addr) \ + INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(54), dest, addr, RS2(0)) +#else +#define HLV_D(dest, addr) \ + __ASM_STR(.error "hlv.d requires 64-bit support") +#endif + #endif /* __ASM_INSN_DEF_H */ diff --git a/arch/riscv/kvm/vcpu_exit.c b/arch/riscv/kvm/vcpu_exit.c index d5c36386878a..9cb075e72799 100644 --- a/arch/riscv/kvm/vcpu_exit.c +++ b/arch/riscv/kvm/vcpu_exit.c @@ -8,6 +8,7 @@ #include #include +#include static int gstage_page_fault(struct kvm_vcpu *vcpu, struct kvm_run *run, struct kvm_cpu_trap *trap) @@ -82,22 +83,12 @@ unsigned long kvm_riscv_vcpu_unpriv_read(struct kvm_vcpu *vcpu, ".option push\n" ".option norvc\n" "add %[ttmp], %[taddr], 0\n" - /* - * HLVX.HU %[val], (%[addr]) - * HLVX.HU t0, (t2) - * 0110010 00011 00111 100 00101 1110011 - */ - ".word 0x6433c2f3\n" + HLVX_HU("%[val]", "%[addr]") "andi %[tmp], %[val], 3\n" "addi %[tmp], %[tmp], -3\n" "bne %[tmp], zero, 2f\n" "addi %[addr], %[addr], 2\n" - /* - * HLVX.HU %[tmp], (%[addr]) - * HLVX.HU t1, (t2) - * 0110010 00011 00111 100 00110 1110011 - */ - ".word 0x6433c373\n" + HLVX_HU("%[tmp]", "%[addr]") "sll %[tmp], %[tmp], 16\n" "add %[val], %[val], %[tmp]\n" "2:\n" @@ -121,19 +112,9 @@ unsigned long kvm_riscv_vcpu_unpriv_read(struct kvm_vcpu *vcpu, ".option norvc\n" "add %[ttmp], %[taddr], 0\n" #ifdef CONFIG_64BIT - /* - * HLV.D %[val], (%[addr]) - * HLV.D t0, (t2) - * 0110110 00000 00111 100 00101 1110011 - */ - ".word 0x6c03c2f3\n" + HLV_D("%[val]", "%[addr]") #else - /* - * HLV.W %[val], (%[addr]) - * HLV.W t0, (t2) - * 0110100 00000 00111 100 00101 1110011 - */ - ".word 0x6803c2f3\n" + HLV_W("%[val]", "%[addr]") #endif ".option pop" : [val] "=&r" (val),