Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1607894rwe; Fri, 2 Sep 2022 00:05:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AZ6BCK0Fip4risepTtQaP5MLVvxDJM2GQTS43IgvEiILvg4E9FNFmM33emmFP0ckgOMtW X-Received: by 2002:aa7:c6d4:0:b0:448:ecc4:ec59 with SMTP id b20-20020aa7c6d4000000b00448ecc4ec59mr11368380eds.197.1662102321649; Fri, 02 Sep 2022 00:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662102321; cv=none; d=google.com; s=arc-20160816; b=cmPge7PFw6DUlnE/4pAm8hjWl5IAIIfLWNY4Vf3USMU85L+LcdZg+9O/xro/30Azii NJZbN0Mw1SXIus8XC5qcSRcPSDFmPrLggV/eXL+gIzjVf6TuH/ow2h4kdEimT+iXcK2r mdBPPUXn5Uc5LMhqqi6RF0p2LAkMQ/jLwNyybkfW5S0nknsWXeJ5e7XlILVM7PZI/R2+ phdpkBJ0Ya80BzLvES0qwkT0DyXOrDz2yT73/Oxz1RKoE0f8euy3BJpKxtB/YEesJE+r pCFSm1Pj3e527BKQktkCntLrhfZu9RRb2c88P0DQDlaVNMvUFl92vAdd5XpgAmZtGquO qRAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wIY3Cp70hOwu5cFFqibpP3VvX84nHcY+aOjHPogHvC8=; b=dDZ3pad9Hv/ewrkWXfrxc7cH718UDu4R2qrAvF0aeDs1M+Hv1yu6OybvvZJ9zo5o5P L2jK1A33qK1bMnSoCKrc9G1fGMt1fLXND0fDmTsKr6A/4bivEPKox6uRk6zThyd93Da8 VFx+EI3OrOgV6VFPtKBF6xGtiMQTI671ja2iMqGlIpqeYuKEba3so6j4c7/VL+6eBZ0y D0jWRGj5V7duM9cofgWdFqbbuS7v09NvI3S3jTrprrtJFZ1nQmOTXOc3GHQFrhP7ogqp 5McKORhe4Sm6kQ9clBQ1vMpFY1dEWK9/javS5OSbpw6sRONg1X87o6E5q6VrVfSH6im1 g68w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=dFiTkme8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a1709064fc300b007306121368esi1314672ejw.668.2022.09.02.00.04.55; Fri, 02 Sep 2022 00:05:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=dFiTkme8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233919AbiIBGxs (ORCPT + 99 others); Fri, 2 Sep 2022 02:53:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235608AbiIBGxl (ORCPT ); Fri, 2 Sep 2022 02:53:41 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0507B6D65 for ; Thu, 1 Sep 2022 23:53:40 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id l196so1834694ybl.12 for ; Thu, 01 Sep 2022 23:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=wIY3Cp70hOwu5cFFqibpP3VvX84nHcY+aOjHPogHvC8=; b=dFiTkme8yhUBNTEDn/G5bfjKQV3zaMBemnKrGUidQPKV73pDDm0/O3rJikO7OmNcNC CeyZyBAPE6BNDl84ueflTzvDXws9uQTiHGpC6U7SCxiQTzHS2x/K1hHERhe66PPfCJyI Un61ZDQS0+93PiwFOIHD8Y2h0Kye6B0H7KZnEJzwx6MSPMfjybPR0bKEj88gbK2GhCua z+WsdwqScNbnpT6r20Mp1aiyHVYdN5Pje/2wplBqCKg9w9ygdDLhNdIaHwlV3Bwm2l01 qcZDo7tCyFT4KSll1wtj3WiScdDPj1Pwx3D5G5V3VC84M+2kc1igW61TifKII3lrDeW2 3Gaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=wIY3Cp70hOwu5cFFqibpP3VvX84nHcY+aOjHPogHvC8=; b=lDNS7zO1/YOr1sb0K4u8Mc+WQV/ISN0pXqBgNFcF++e0k/ZcIyUxNcKTqZfT3R3gZW X08wYiWcb+yvaqZGRlG3mE4qxutAF8rjNUWs9cqwJKFtWrKr9x8JtYBA+QjnpEE3yK5N HIH7TsrJVWTawhzN8Q2KFXVOZHhjFXFFRtCKp0uFw4J5sqJecD7ajlBf1FWKPKARqSq7 ANGFU0vsd8ZsWrsYTb7rh2rtUxMC30Od5FCHZMiJBKpeSy9rWp30jUGWaakVaW+iv2sC EJcRfcTgatPkE03nP2/7daOCBOO/9XsgyuFwXkd/hONoSULaRzjtZamSl2sMMAt6Wf4n s1iA== X-Gm-Message-State: ACgBeo2MtSZ5lYNizAoC5bMvjM9yXlpMX/oSup9BITss/pn/VXIbPKhe WhOzPsjZ/zIWerE2/NhjXXXxBf63y8Qxyyt16jhBPg== X-Received: by 2002:a25:234a:0:b0:696:435f:df06 with SMTP id j71-20020a25234a000000b00696435fdf06mr21650473ybj.180.1662101619673; Thu, 01 Sep 2022 23:53:39 -0700 (PDT) MIME-Version: 1.0 References: <20220831172500.752195-1-ajones@ventanamicro.com> <20220831172500.752195-5-ajones@ventanamicro.com> In-Reply-To: <20220831172500.752195-5-ajones@ventanamicro.com> From: Anup Patel Date: Fri, 2 Sep 2022 12:23:27 +0530 Message-ID: Subject: Re: [PATCH v2 4/4] riscv: KVM: Apply insn-def to hlv encodings To: Andrew Jones Cc: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, mchitale@ventanamicro.com, heiko@sntech.de Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 31, 2022 at 10:55 PM Andrew Jones wrote: > > 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 I have queued this patch for Linux-6.1 Thanks, Anup > --- > arch/riscv/include/asm/insn-def.h | 17 +++++++++++++++++ > arch/riscv/kvm/vcpu_exit.c | 29 +++++------------------------ > 2 files changed, 22 insertions(+), 24 deletions(-) > > diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h > index 86c1f602413b..8fe9036efb68 100644 > --- a/arch/riscv/include/asm/insn-def.h > +++ b/arch/riscv/include/asm/insn-def.h > @@ -93,4 +93,21 @@ > INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(49), \ > __RD(0), RS1(gaddr), RS2(vmid)) > > +#define HLVX_HU(dest, addr) \ > + INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(50), \ > + RD(dest), RS1(addr), __RS2(3)) > + > +#define HLV_W(dest, addr) \ > + INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(52), \ > + RD(dest), RS1(addr), __RS2(0)) > + > +#ifdef CONFIG_64BIT > +#define HLV_D(dest, addr) \ > + INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(54), \ > + RD(dest), RS1(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..da793f113a72 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), > -- > 2.37.2 >