Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp647821pxb; Thu, 21 Apr 2022 07:31:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSslywNAvottCw2n/Z8mpRxnwTtiNCC0wUinI7o1HT/Cx51MoGaqChw774kAPzl5O/hQxD X-Received: by 2002:a17:907:7d8e:b0:6e8:c95a:525e with SMTP id oz14-20020a1709077d8e00b006e8c95a525emr22597357ejc.312.1650551511940; Thu, 21 Apr 2022 07:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650551511; cv=none; d=google.com; s=arc-20160816; b=nr/uxeLLtDPWL/AKHLxYnGVLAL7yAcHLFf9bbuUhks/CUqEt1OUGJSlMMKATqESoSc 05q+91SM+8BO9h2FmeRSiZfXDS94Z2IvATWWAPLpufQlzc1kPuj6Mq4E4h0+5v3JS5Pt X93niOv6ts4f7+S5SEvM9loBhQ8WtwW88NLFYXAF+zuQTrlZtk5ANYNWNHt70NatC1Ip 54m5+AG0dK33bI0jMchveke3Yam7EbfyM6m1PPNUm3ZKiZrlK07wRh16E/SLjvajE+Me 8JUbnIY3HrcRkrLbQSISSGXapW/btor6ZCgVfHnBWXRzdi529AnYyJW8vcxZbjegW8LQ PvNg== 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=tAe7ocOZ0bBrreHF0RxD9R0oEMScj7O80nn6Z0+6mKk=; b=Rm4myZv8IP/3RVeyyh+wh1OTBsslyCpwV9G995khJR3yYcG8iAJLL2LhqBPjILl/rx f3MuJB0ALcWpHVfOdX0QSObqy/gbM9SE4LHPf1pcGXdbRiLnKLVTZi32FEBmTonPqS61 KJ7Lopl8mZFx2uLO4HB09IrrEYP+hcPIozTH4Lo2+efJClWGPsY+Y7Sm1k4CsbMQqbxK ZqwNQtfQ4FGMcaYIg0FEizDdMfOmNQPGOfqRTe0p+7vWTgVHS/graRB0aUgOiQB7hCG8 5ciFOhhYY2MzXKwG8SkUBkk46W1LUTKbyiZTVU50M8hVYhC7RnVdmoxKxGGTRY2oA5fC +sgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=l7aPeWem; 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 i21-20020a1709061cd500b006df76385ebfsi4230979ejh.863.2022.04.21.07.31.27; Thu, 21 Apr 2022 07:31:51 -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=l7aPeWem; 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 S1376915AbiDTIuN (ORCPT + 99 others); Wed, 20 Apr 2022 04:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376904AbiDTIuK (ORCPT ); Wed, 20 Apr 2022 04:50:10 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A43E21900F for ; Wed, 20 Apr 2022 01:47:24 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id r18so1149993ljp.0 for ; Wed, 20 Apr 2022 01:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tAe7ocOZ0bBrreHF0RxD9R0oEMScj7O80nn6Z0+6mKk=; b=l7aPeWemyn/R90hcDdIeAm1ynIy9VHgrdD+aB5XMWSttSYjB3m3nf82oOQL5BO70pf yKt3cTG/Y5uxBT8/EdawX4RKgVRideaRv/5Y7f97MbkHjGBbHi0TTrcVApE+ETXXOupq dx7KHF8KZaGgXBfzM/A9wSl1a3draGgOOuk7qRps+NYoWW+Mr801M1qRdrSpZXYnojrq l+bZqHL70oDSYG7GZTP9rmWgoRJZLsZtCTHdM9k57/gikiSWCDq85aPUMQdI7hCkl3mi 0k26ZysqwMsgqb8+2Xw+u3S7eUxUwzzJO5pz7PPrlzgKaqvBLXtAs0iQpZ+ktMuhrq00 cczQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tAe7ocOZ0bBrreHF0RxD9R0oEMScj7O80nn6Z0+6mKk=; b=kkhzTG7NaPcvQO+mQzWk+YiIC/SmkSvaMayBAn4/Et70VH6GoE9JQBBl5sRNOY3gt4 47aHGYMEG8vNUkshMu+yXJgJTnoY02mOg3CKxydCLaB27KAbyA4oXekzpLr/XjaoJUyY 4L45H2w33pCsO8Df5SCRJUTyQv8JWdVjhKBho02JaRF96dlhvfEpBDpAtGRy3t6R59mE bJWvY1q0uInfNQvqHJ6u5D61LpTq0OQ0zsSMntZvJH5LP6k5U5F9w7KumBttChEhS6nO mA9z3aIXmuRsfBQ4JPDh74Jnjzmf620K6e+jtwBPjNXtKjThvnAWCyhbB61XNJxAPEDL yxDQ== X-Gm-Message-State: AOAM5313oAwfeZVJZLgZFuj+wIY2MHqu1r3cj6YPyR8s1FjcNX7IkpQi 8QBkqaVq6iXslQvZMNKCQYsqppfbB8nP0Qx+pUgaBQ== X-Received: by 2002:a2e:6a08:0:b0:24d:14af:4be4 with SMTP id f8-20020a2e6a08000000b0024d14af4be4mr12846312ljc.24.1650444442933; Wed, 20 Apr 2022 01:47:22 -0700 (PDT) MIME-Version: 1.0 References: <20220420013258.3639264-1-atishp@rivosinc.com> <20220420013258.3639264-3-atishp@rivosinc.com> In-Reply-To: From: Anup Patel Date: Wed, 20 Apr 2022 14:17:10 +0530 Message-ID: Subject: Re: [PATCH 2/2] RISC-V: KVM: Restrict the extensions that can be disabled To: Atish Patra Cc: Atish Patra , KVM General , Anup Patel , Damien Le Moal , devicetree , Jisheng Zhang , Krzysztof Kozlowski , "linux-kernel@vger.kernel.org List" , linux-riscv , Palmer Dabbelt , Paul Walmsley , Rob Herring , kvm-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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, Apr 20, 2022 at 1:13 PM Atish Patra wrote: > > On Tue, Apr 19, 2022 at 6:33 PM Atish Patra wrote: > > > > Currently, the config reg register allows to disable all allowed > > single letter ISA extensions. It shouldn't be the case as vmm > > shouldn't be able disable base extensions (imac). > > /s/able/able to/ > > > These extensions should always be enabled as long as they are enabled > > in the host ISA. > > > > Signed-off-by: Atish Patra > > --- > > arch/riscv/kvm/vcpu.c | 21 +++++++++++++-------- > > 1 file changed, 13 insertions(+), 8 deletions(-) > > > > diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c > > index 2e25a7b83a1b..14dd801651e5 100644 > > --- a/arch/riscv/kvm/vcpu.c > > +++ b/arch/riscv/kvm/vcpu.c > > @@ -38,12 +38,16 @@ const struct kvm_stats_header kvm_vcpu_stats_header = { > > sizeof(kvm_vcpu_stats_desc), > > }; > > > > -#define KVM_RISCV_ISA_ALLOWED (riscv_isa_extension_mask(a) | \ > > - riscv_isa_extension_mask(c) | \ > > - riscv_isa_extension_mask(d) | \ > > - riscv_isa_extension_mask(f) | \ > > - riscv_isa_extension_mask(i) | \ > > - riscv_isa_extension_mask(m)) > > +#define KVM_RISCV_ISA_DISABLE_ALLOWED (riscv_isa_extension_mask(d) | \ > > + riscv_isa_extension_mask(f)) > > + > > +#define KVM_RISCV_ISA_DISABLE_NOT_ALLOWED (riscv_isa_extension_mask(a) | \ > > + riscv_isa_extension_mask(c) | \ > > + riscv_isa_extension_mask(i) | \ > > + riscv_isa_extension_mask(m)) > > + > > +#define KVM_RISCV_ISA_ALLOWED (KVM_RISCV_ISA_DISABLE_ALLOWED | \ > > + KVM_RISCV_ISA_DISABLE_NOT_ALLOWED) > > > > static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu) > > { > > @@ -217,9 +221,10 @@ static int kvm_riscv_vcpu_set_reg_config(struct kvm_vcpu *vcpu, > > switch (reg_num) { > > case KVM_REG_RISCV_CONFIG_REG(isa): > > if (!vcpu->arch.ran_atleast_once) { > > - vcpu->arch.isa = reg_val; > > + /* Ignore the disable request for these extensions */ > > + vcpu->arch.isa = reg_val | KVM_RISCV_ISA_DISABLE_NOT_ALLOWED; > > vcpu->arch.isa &= riscv_isa_extension_base(NULL); > > - vcpu->arch.isa &= KVM_RISCV_ISA_ALLOWED; > > + vcpu->arch.isa &= KVM_RISCV_ISA_DISABLE_ALLOWED; > > kvm_riscv_vcpu_fp_reset(vcpu); > > } else { > > return -EOPNOTSUPP; > > -- > > 2.25.1 > > > > Sorry. I forgot to add the fixes tag. > > Fixes: 92ad82002c39 (RISC-V: KVM: Implement > KVM_GET_ONE_REG/KVM_SET_ONE_REG ioctls) I have queued this for fixes. Thanks, Anup > > -- > Regards, > Atish > > -- > kvm-riscv mailing list > kvm-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kvm-riscv