From patchwork Mon Sep 18 18:06:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 141507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2863750vqi; Mon, 18 Sep 2023 11:23:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx8Ww1dAT6K3YDKj5BrIFpDDzQ4yoRbs+GoBjWbJTI7s1nc6o4lmujds30CLehWusP/lRf X-Received: by 2002:a17:902:d504:b0:1bc:2fe1:1821 with SMTP id b4-20020a170902d50400b001bc2fe11821mr573188plg.17.1695061429651; Mon, 18 Sep 2023 11:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695061429; cv=none; d=google.com; s=arc-20160816; b=GgEdFlwgXpHtQIJnx0X+Cl8vGnnSItLfXyoLFcDBThHBJEDVZhlDoatlHBN+9NPXHY R0n2rqL42J4exb4q7XLe9qxOr43pyOUouAUR0EEwUpgcuVqAHtYgESVwVinrfdroRYaT HF5EyMj4VvDnK4mSJJKvGp/+QqO5cdI+Bwi15tLrjYm1YrtYYuTYaE+y5KPcsAaEynWi zosbR4tCxG1TF6FlJ2oA2qIQFQh3IsG7IquKswcsTazm+UVb3uN2Y6W7Px8HcAsaBBkE ZM1rsl5PeF6KiUKF8afVt/Qubc1fkOqURk6/Bz/a3Hgmkr4Mk85xeT32UY+qAl5s2CJg /+Sg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5i1eIcDaE0yWa5Js2PwK7z4plrujub6N9pwbwUycwvI=; fh=2S+54NKBCousR9yNCeiEbYlRCvnfU9LmKXxbaD6jKe8=; b=qn1gGJwQ2MLl3vNbhjP0umqWOmGfbLAP0CGTioqlQqw/I4lVsO9sieAyhWr0tLYG1A sSJGYygv6twtGs68Nfktvo4RDpiUGj3NrFUCbA6tAej9BnYz3DFrTi59cJm0BElNhJcV wm6+D3KeBhPoFdxPNI8WsWoe3fUOYT5BUKhfF9ZADmUufMJHYYNWBLra4ToKoDyPTiqz sM9TlsU/rvoIi/5f89Juw7EPDhFgM6VW5X2dSnuTA2IfAORYX8KIFygwR9qawOLX1GoE tMt++86HBWE2urkD3v/bzjqDB+PRT6Q2//CKQQPswpeaUEac5k3VrIvaASH2eGJyn1Fi fB8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=n5WgOqxC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l6-20020a170903120600b001bdd0d0530dsi8685468plh.129.2023.09.18.11.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 11:23:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=n5WgOqxC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 5B3B0823352A; Mon, 18 Sep 2023 11:07:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbjIRSHX (ORCPT + 25 others); Mon, 18 Sep 2023 14:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbjIRSHM (ORCPT ); Mon, 18 Sep 2023 14:07:12 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3010116 for ; Mon, 18 Sep 2023 11:07:06 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bf1935f6c2so34303925ad.1 for ; Mon, 18 Sep 2023 11:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1695060426; x=1695665226; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5i1eIcDaE0yWa5Js2PwK7z4plrujub6N9pwbwUycwvI=; b=n5WgOqxC/sD9AIOObnUBwHjxeweIK+5IApTUFl+PM6jHKTprvdAK++E38m4gimmR7f HZb9ECsoUHD4pu/JKmGM4tQr6ZyuJ23ZjhC/yVmgavAG+g11RqPcOxFBkFgmak+kNrzo JMaPejqa12loIEdKrjzGqSFXyEzYzEvkzR0f/WUcB0RgaE7iXYBxggQK1XeoL2hHMQwE VsXJ4mvPkxFNNfRLeByXWT+lhPeErl+B1gecBeQLlABs4Bc6jbxYpZ1n6tgpnlxusJCP FZAguQ7fgN9ewS96fIBHgUPwjL9xxaWtFXS4JSRXmUBqgwDIJZvFXiuD9mUUcpQCaC09 aOtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695060426; x=1695665226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5i1eIcDaE0yWa5Js2PwK7z4plrujub6N9pwbwUycwvI=; b=Bnlo/QJ187XZhsvDNH2NZuQl8qnD+QaoyU0QHEeKWWVVgcVmE3MRxjhuKA/PZrtNaj M/eaEtYffU2AEz2Zo4fAkDKYkQcuukOmgxsEtv8RdwMVKJEvR//kDfBO5EIKIlr0Ohkk HXyzUBssfLtKmyfbVXrP/6V+FMvyYv1blnrbj8Vn69q/qdjIcHsBZtF4xOIRD2rzXdCc xQJGA1TJPvuiEfaa1t6pugk9nC65W+5kptr3l4rINtPPSit5E+q7LFg3eQV05Aya0qdo aYZkWbxRbhUVb7PXqWKi9YdjeWI6qbd++v1fDkG4zW1TscL4eLoaStx/IgLTBBlqkjFO RPmQ== X-Gm-Message-State: AOJu0YyLOQjEb2V/SbbyADRFaIvtFZifT1kAUio0Wp8Wo3SE2MoQpBDN NMndbHd2dMVvtn9NZfwrckQUrw== X-Received: by 2002:a17:903:41cb:b0:1bd:d510:78fb with SMTP id u11-20020a17090341cb00b001bdd51078fbmr529431ple.3.1695060426120; Mon, 18 Sep 2023 11:07:06 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id h7-20020a170902704700b001aaf2e8b1eesm8556720plt.248.2023.09.18.11.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 11:07:05 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra , Shuah Khan Cc: Palmer Dabbelt , Paul Walmsley , Andrew Jones , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Anup Patel Subject: [PATCH 2/4] RISC-V: KVM: Fix riscv_vcpu_get_isa_ext_single() for missing extensions Date: Mon, 18 Sep 2023 23:36:44 +0530 Message-Id: <20230918180646.1398384-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230918180646.1398384-1-apatel@ventanamicro.com> References: <20230918180646.1398384-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 11:07:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777400733415014982 X-GMAIL-MSGID: 1777400733415014982 The riscv_vcpu_get_isa_ext_single() should fail with -ENOENT error when corresponding ISA extension is not available on the host. Fixes: e98b1085be79 ("RISC-V: KVM: Factor-out ONE_REG related code to its own source file") Signed-off-by: Anup Patel Reviewed-by: Atish Patra Reviewed-by: Andrew Jones --- arch/riscv/kvm/vcpu_onereg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kvm/vcpu_onereg.c b/arch/riscv/kvm/vcpu_onereg.c index e7e833ced91b..b7e0e03c69b1 100644 --- a/arch/riscv/kvm/vcpu_onereg.c +++ b/arch/riscv/kvm/vcpu_onereg.c @@ -460,8 +460,11 @@ static int riscv_vcpu_get_isa_ext_single(struct kvm_vcpu *vcpu, reg_num >= ARRAY_SIZE(kvm_isa_ext_arr)) return -ENOENT; - *reg_val = 0; host_isa_ext = kvm_isa_ext_arr[reg_num]; + if (!__riscv_isa_extension_available(NULL, host_isa_ext)) + return -ENOENT; + + *reg_val = 0; if (__riscv_isa_extension_available(vcpu->arch.isa, host_isa_ext)) *reg_val = 1; /* Mark the given extension as available */