From patchwork Sat Apr 1 11:27:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 78115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1161264vqo; Sat, 1 Apr 2023 04:28:50 -0700 (PDT) X-Google-Smtp-Source: AKy350Z2i8/rt1uJ3ygIfRusdniNsU2w7IjXi2Cb5pMiX3FO6Rb9SNCQOp9uyFXW2wxUyhM5Fbfk X-Received: by 2002:a17:90b:4c4d:b0:240:7f0d:9235 with SMTP id np13-20020a17090b4c4d00b002407f0d9235mr25426743pjb.22.1680348530506; Sat, 01 Apr 2023 04:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680348530; cv=none; d=google.com; s=arc-20160816; b=quC70UKJi9mWsHvSrU0Spd0wROK0S0hoI68LpXniYotS0jh9cuP/c2CKJPWi+q2cZH pkFlVJqOcmzRz7Y8lfFGSUeF8dauii7OeQ56t7trm0LKYM7KOg0ZeB1V2XtXTgkWSkI4 oeJ6pf0K1BBUdYt8lmf6kzVBCFRAYDDAEAPLS2QUkUllpi/+6sL+LfR/mpnjB0MMMYaS DxZqrHu+KBXxq85jhmiwbvUNXbaHukGk7OFDigD30KqALmOYy8WtGIQl9U3BsgnC1cLd 7Fe913j1JoazX8V/lqHYFxD4LzUTl6LhyqBo6OLXeaIVE1gAYC4zmhsnoG+JQc6I/BAf fTAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=V9h16YuAEUK1wvL2RNBHCcwpte7Y1FwWRsmABLjps+c=; b=bTjnWR9S+3IFpyf/uK4YyyNAtRGV4gAG6hQg+wk5N/zLS4i/z0nB3tsreUILb9WJlU Oa43wzzEKIuzpG0z3us/jBvsGuKCwgqCuhK0EGrEJlh7H4ugE0bcFSzphOXjuAK1qeXS LuckMBEHiOY+moHM0UuEXgytkKXeGZA3t/l8/NX2rRgI8OJH+sR80VXWslmfJOaAETKC USn2tQnr5OQBvm3NpcmuIlFKy6ARDs/h3ywq4cp0Z0dQqK4KXKH1rCu1SqGjHQImbqbn umNP3cWPN4F0iYtJc8HS3IOgpVgCqed7xOCSM7Ehkd2Zy3MxFlwV1i1HxSD/QCBRAjCu bqlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=PGIwXlXr; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q31-20020a17090a1b2200b0021918bc9a47si4159686pjq.174.2023.04.01.04.28.38; Sat, 01 Apr 2023 04:28:50 -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=@ventanamicro.com header.s=google header.b=PGIwXlXr; 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 S229740AbjDAL2V (ORCPT + 99 others); Sat, 1 Apr 2023 07:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbjDAL2H (ORCPT ); Sat, 1 Apr 2023 07:28:07 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2859227006 for ; Sat, 1 Apr 2023 04:27:50 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id lr16-20020a17090b4b9000b0023f187954acso26143038pjb.2 for ; Sat, 01 Apr 2023 04:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1680348462; x=1682940462; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=V9h16YuAEUK1wvL2RNBHCcwpte7Y1FwWRsmABLjps+c=; b=PGIwXlXrzX91EGrukJM1qAYYCcMIfBb3wXtKHu6+fISpFF6RjKrQ20HM+dKW28CSkX iKmubwFsJtVjc82a3/yKsT7EJI6YSkEby9CR1Gu/wr5/xSQLvTCve1Df6Xk1DTqfyL3S q7EubEeoKYuNmwpXskbDU6gG4ohF+9a5SmUnR8zH1YXpCFEI4u/tBEivbogaFZvwvOL7 4UY5jBvhaMx3l1VaZM+KeSLuVzCEIRwFpAdVKKoyNY6viYAmZNOzyyydDuuJds592QI5 liA3f/uCd48q2H5oWJzBmjcpiYiTK8JH8C7Uq6N0ewf2yNUPWhM39VWhKmvgFSW6U+ju x1AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680348462; x=1682940462; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=V9h16YuAEUK1wvL2RNBHCcwpte7Y1FwWRsmABLjps+c=; b=CM7R4ki8jxsP3juM5yzv35IQgYeFT90L3WPeKGEfb8f3M6mxWtP66MqqqMfXOOdal3 XecoIVP2ZkhRaFA49LpglVew+Q1EqzBhv+oYdhWFOLJq7Ifkipe7NJzSiZgYZkOo9RFy 4zwWaLQPhgTXQ8guX1TedR6JOfyhNg8XfSiIUNfBGoQkdF0gCumqUbOkKjMqfkfn41Fc JYtWp05S75V75raEWu06vEf4R4Qz9rZmUT2lzkGYFDj8yYduybh4S30saoEzCmU6oIVa bnM56BQF3LEeoVH0OzeXkMkNnpkTjbv6SbYN3Jix71Y+emGCImBFsBNqz1gkuyt8QdWU KN3A== X-Gm-Message-State: AO0yUKVsswA4zN7I/nUDDm44V2OmB8BmiU2gKsmAqN1mNb92fIuoByI8 99LxKwVHXCIu0lTy/xUYz3RR5g== X-Received: by 2002:a17:90b:2243:b0:23f:7176:df32 with SMTP id hk3-20020a17090b224300b0023f7176df32mr32788883pjb.40.1680348462342; Sat, 01 Apr 2023 04:27:42 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id j8-20020a17090a738800b0023b4d4ca3a9sm2915991pjg.50.2023.04.01.04.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Apr 2023 04:27:41 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH] RISC-V: KVM: Allow Zbb extension for Guest/VM Date: Sat, 1 Apr 2023 16:57:30 +0530 Message-Id: <20230401112730.2105240-1-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761973140825730583?= X-GMAIL-MSGID: =?utf-8?q?1761973140825730583?= We extend the KVM ISA extension ONE_REG interface to allow KVM user space to detect and enable Zbb extension for Guest/VM. Signed-off-by: Anup Patel Reviewed-by: Atish Patra Reviewed-by: Andrew Jones --- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h index d8ead5952ed9..47a7c3958229 100644 --- a/arch/riscv/include/uapi/asm/kvm.h +++ b/arch/riscv/include/uapi/asm/kvm.h @@ -106,6 +106,7 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_SVINVAL, KVM_RISCV_ISA_EXT_ZIHINTPAUSE, KVM_RISCV_ISA_EXT_ZICBOM, + KVM_RISCV_ISA_EXT_ZBB, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 3112697cb12d..02b49cb94561 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -61,6 +61,7 @@ static const unsigned long kvm_isa_ext_arr[] = { KVM_ISA_EXT_ARR(SSTC), KVM_ISA_EXT_ARR(SVINVAL), KVM_ISA_EXT_ARR(SVPBMT), + KVM_ISA_EXT_ARR(ZBB), KVM_ISA_EXT_ARR(ZIHINTPAUSE), KVM_ISA_EXT_ARR(ZICBOM), }; @@ -99,6 +100,7 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext) case KVM_RISCV_ISA_EXT_SSTC: case KVM_RISCV_ISA_EXT_SVINVAL: case KVM_RISCV_ISA_EXT_ZIHINTPAUSE: + case KVM_RISCV_ISA_EXT_ZBB: return false; default: break;