From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69508C7EE2E for ; Thu, 25 May 2023 16:40:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236065AbjEYQkQ (ORCPT ); Thu, 25 May 2023 12:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233816AbjEYQkM (ORCPT ); Thu, 25 May 2023 12:40:12 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388BB19C for ; Thu, 25 May 2023 09:40:10 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f6e1394060so4248755e9.3 for ; Thu, 25 May 2023 09:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685032808; x=1687624808; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AR0TcRh5E3uNMVlwV4MX3XAnDWVMVCj/HBAPlYOkb4Q=; b=SMOO/RHoH9sCbPbHZOhilUrB2bJNfvDLCzNO5ccrVnl5YTsggfxCAGw2enOsIJsw3S muOPMMbM8OB9rpMjOPTcLN0styrxHRbccc9yTmXWbgcevJUP1pwqZXi98iwgUX4Pfv55 os7jsjCiXCLLhdD3CTPGSThlSx7rRpRDglbQkL4uhDoPpGndSA0UT7be/09Y3qB4sCTU 9Jj2LjqrHnXVoyAXUQEyeCSGlSCPNGIKyvU2Ar0ZXlrITl5RpUUhEMrIW9rij7AQisZh pS4SfprjWAgXcStQyvo0bOqre47fTQRcCig3TUxi2T6iUTtbEYJBhRLX2YVECM6VJ7Ni /zsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685032808; x=1687624808; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AR0TcRh5E3uNMVlwV4MX3XAnDWVMVCj/HBAPlYOkb4Q=; b=CnyzNN5Neo1Z9hVMvhyN1NEEyrVlF0DQxs3uLYTm5HBrH+YpPJVzpUFn5sX0wNKfLN nan3Gm/A5EWKYMQ/zMqLI9w9WhDux/FQKkGRhCDbcBTXvmv3sPenjSB6MK/U8yUtAunZ 4C55R5AUTj+amTvqWvl6Wuxgo/UR4WPqe21HutFk2OD62QC1GFYcXxdWmR1MEGupQZ99 p98wjdJz0G4bmtuOLVUM0hNDjUgNl1+qS97AybOdPj3kQRluD9RDpwmdskbd5ViPIDWY WTZmSk00ZIsKCn8zBPCmb8Myfi2TCeZZM2V79RxA+UXgLL+C5umDdyxqbq1YjeKcN/8r Flog== X-Gm-Message-State: AC+VfDyoA2KHYLFLHXsrOO0jzWVxmeQ4x0Rq4reWlOdYhMblYF7NGrGt PshfRUeII6IDCEPwgqkTAqZrow== X-Google-Smtp-Source: ACHHUZ4E3vZaFea6aEdcJxuXhPYk5shRp2rDROSu38VNjlX+Zz36M4ciiQeNekDxjPytu3ey3fhDvg== X-Received: by 2002:a7b:cbd6:0:b0:3f4:2452:9669 with SMTP id n22-20020a7bcbd6000000b003f424529669mr3090300wmi.0.1685032808575; Thu, 25 May 2023 09:40:08 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id c2-20020adfed82000000b003078a3f3a24sm2311517wro.114.2023.05.25.09.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 09:40:07 -0700 (PDT) Date: Thu, 25 May 2023 18:40:07 +0200 From: Andrew Jones To: Haibo Xu Cc: xiaobo55x@gmail.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini , Jonathan Corbet , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , James Morse , Suzuki K Poulose , Zenghui Yu , David Matlack , Ben Gardon , Vipin Sharma , Colton Lewis , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v2 09/11] KVM: riscv: selftests: Make check_supported arch specific Message-ID: <20230525-705ddcbcd43aa63e3fd356c8@orel> References: <26dea518fc5e8da51e61db279d175364bfecd009.1684999824.git.haibo1.xu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26dea518fc5e8da51e61db279d175364bfecd009.1684999824.git.haibo1.xu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 25, 2023 at 03:38:33PM +0800, Haibo Xu wrote: > check_supported() was used to verify whether a feature/extension was > supported in a guest in the get-reg-list test. Currently this info > can be retrieved through the KVM_CAP_ARM_* API in aarch64, but in > riscv, this info was only exposed through the KVM_GET_ONE_REG on > KVM_REG_RISCV_ISA_EXT pseudo registers. > > Signed-off-by: Haibo Xu > --- > tools/testing/selftests/kvm/get-reg-list.c | 32 +++++++++++----------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index f6ad7991a812..f1fc113e9719 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -99,6 +99,20 @@ void __weak print_reg(const char *prefix, __u64 id) > } > > #ifdef __aarch64__ > +static void check_supported(struct vcpu_reg_list *c) > +{ > + struct vcpu_reg_sublist *s; > + > + for_each_sublist(c, s) { > + if (!s->capability) > + continue; I was going to say that making this function aarch64 shouldn't be necessary, since riscv leaves capability set to zero and this function doesn't do anything, but then looking ahead I see riscv is abusing capability by putting isa extensions in it. IMO, capability should only be set to KVM_CAP_* values. Since riscv doesn't use it, then it should be left zero. If we're going to abuse something, then I'd rather abuse the 'feature' member, but since it's only an int (not an unsigned long), then let's just add an 'unsigned long extension' member. Then, the finalize_vcpu() call can be moved back to run_test(), from aarch64's vcpu_config_get_vcpu(). Both aarch64 and riscv will call it right after vcpu_config_get_vcpu() and the riscv version of it will do what your current riscv check_supported() is doing, using the new 'extension' member instead of 'capability'. And this patch gets dropped. Thanks, drew > + > + __TEST_REQUIRE(kvm_has_cap(s->capability), > + "%s: %s not available, skipping tests\n", > + config_name(c), s->name); > + } > +} > + > static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) > { > struct vcpu_reg_sublist *s; > @@ -126,6 +140,8 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm > struct kvm_vcpu_init init = { .target = -1, }; > struct kvm_vcpu *vcpu; > > + check_supported(c); > + > prepare_vcpu_init(c, &init); > vcpu = __vm_vcpu_add(vm, 0); > aarch64_vcpu_setup(vcpu, &init); > @@ -140,20 +156,6 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm > } > #endif > > -static void check_supported(struct vcpu_reg_list *c) > -{ > - struct vcpu_reg_sublist *s; > - > - for_each_sublist(c, s) { > - if (!s->capability) > - continue; > - > - __TEST_REQUIRE(kvm_has_cap(s->capability), > - "%s: %s not available, skipping tests\n", > - config_name(c), s->name); > - } > -} > - > static bool print_list; > static bool print_filtered; > > @@ -165,8 +167,6 @@ static void run_test(struct vcpu_reg_list *c) > struct kvm_vm *vm; > struct vcpu_reg_sublist *s; > > - check_supported(c); > - > vm = vm_create_barebones(); > vcpu = vcpu_config_get_vcpu(c, vm); > > -- > 2.34.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 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 23038C7EE2F for ; Thu, 25 May 2023 16:40:19 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KL14nDTuuaTOKv4vBD5ovmZutFqc7Vtk/njM8aA5FJU=; b=ImCJFKHevlLXRC M9bBWax48JO3rHxmzj5gefJwbZIVjme/ICFEXDBHdkm2XLjY73nVEsDCx/vlH+ta4FiV1AimeAp49 l7L6IvF6k7JWDoErvruRyqCQAMtL0Q41ydZuUypY2LFME5nlYA6xrppwAiBx3R8oJ1XurT4ZEv3MD 9jN1X+oOUhwDqXRrOZCrCmR+2QpVF0VKBZobLsbLy9xJ7hJUt1b7Y/Ryq83WWWs7lWkqSSlFPrLDA Z8LeE2AkMOurAmExBQTX0M/cfaglRMr/fPHvsPihQIh7MmD6fvt+E/q6KhTpZnXFx57/s11DrvCrU rbTW0JQzzfCELEqKG/0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2E0c-00H79i-2m; Thu, 25 May 2023 16:40:14 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2E0a-00H78E-0c for linux-riscv@lists.infradead.org; Thu, 25 May 2023 16:40:13 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f6e1394060so4248745e9.3 for ; Thu, 25 May 2023 09:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685032808; x=1687624808; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AR0TcRh5E3uNMVlwV4MX3XAnDWVMVCj/HBAPlYOkb4Q=; b=SMOO/RHoH9sCbPbHZOhilUrB2bJNfvDLCzNO5ccrVnl5YTsggfxCAGw2enOsIJsw3S muOPMMbM8OB9rpMjOPTcLN0styrxHRbccc9yTmXWbgcevJUP1pwqZXi98iwgUX4Pfv55 os7jsjCiXCLLhdD3CTPGSThlSx7rRpRDglbQkL4uhDoPpGndSA0UT7be/09Y3qB4sCTU 9Jj2LjqrHnXVoyAXUQEyeCSGlSCPNGIKyvU2Ar0ZXlrITl5RpUUhEMrIW9rij7AQisZh pS4SfprjWAgXcStQyvo0bOqre47fTQRcCig3TUxi2T6iUTtbEYJBhRLX2YVECM6VJ7Ni /zsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685032808; x=1687624808; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AR0TcRh5E3uNMVlwV4MX3XAnDWVMVCj/HBAPlYOkb4Q=; b=gdr/KnfJxjkb+kVNiuseqYpXX+UdkKXGdFHLJOQlLG1Kyp/Gt5HlxD35TVoYyjkUMG D8NIa2SxzcOZDDW1pn3rfgyJBPpifpKckjl7yBfQCYsb+o9snQ4hCOrrz9yBBDcIDuws Od/zft2mObb5eFSC6THGb85p7nMBuf6MM+sEKooBpDXYS5f2D6r/UewO5D+qyQxRt622 m31n06pA1NCI1MKOUa2AWRxmT8YMCxi9H22OXp9UvHk9GKQ07udIjp7bGunJ1X8A28ub HmNA5nFtv3b6zby+WGxJTyrl/OfuZTs6ug+agAvTSzVT5OsLcvesGri+kDPa7qxGRswH kt4Q== X-Gm-Message-State: AC+VfDxL2NFCiM1nyQu+OMvTkBhHck5bD8xTV0+aiHvpATCjZxpFZqPk Ac1X36BPaY5n8H97QxXarqghAA== X-Google-Smtp-Source: ACHHUZ4E3vZaFea6aEdcJxuXhPYk5shRp2rDROSu38VNjlX+Zz36M4ciiQeNekDxjPytu3ey3fhDvg== X-Received: by 2002:a7b:cbd6:0:b0:3f4:2452:9669 with SMTP id n22-20020a7bcbd6000000b003f424529669mr3090300wmi.0.1685032808575; Thu, 25 May 2023 09:40:08 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id c2-20020adfed82000000b003078a3f3a24sm2311517wro.114.2023.05.25.09.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 09:40:07 -0700 (PDT) Date: Thu, 25 May 2023 18:40:07 +0200 From: Andrew Jones To: Haibo Xu Cc: xiaobo55x@gmail.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini , Jonathan Corbet , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , James Morse , Suzuki K Poulose , Zenghui Yu , David Matlack , Ben Gardon , Vipin Sharma , Colton Lewis , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v2 09/11] KVM: riscv: selftests: Make check_supported arch specific Message-ID: <20230525-705ddcbcd43aa63e3fd356c8@orel> References: <26dea518fc5e8da51e61db279d175364bfecd009.1684999824.git.haibo1.xu@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <26dea518fc5e8da51e61db279d175364bfecd009.1684999824.git.haibo1.xu@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230525_094012_239591_8221FE09 X-CRM114-Status: GOOD ( 23.55 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Thu, May 25, 2023 at 03:38:33PM +0800, Haibo Xu wrote: > check_supported() was used to verify whether a feature/extension was > supported in a guest in the get-reg-list test. Currently this info > can be retrieved through the KVM_CAP_ARM_* API in aarch64, but in > riscv, this info was only exposed through the KVM_GET_ONE_REG on > KVM_REG_RISCV_ISA_EXT pseudo registers. > > Signed-off-by: Haibo Xu > --- > tools/testing/selftests/kvm/get-reg-list.c | 32 +++++++++++----------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index f6ad7991a812..f1fc113e9719 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -99,6 +99,20 @@ void __weak print_reg(const char *prefix, __u64 id) > } > > #ifdef __aarch64__ > +static void check_supported(struct vcpu_reg_list *c) > +{ > + struct vcpu_reg_sublist *s; > + > + for_each_sublist(c, s) { > + if (!s->capability) > + continue; I was going to say that making this function aarch64 shouldn't be necessary, since riscv leaves capability set to zero and this function doesn't do anything, but then looking ahead I see riscv is abusing capability by putting isa extensions in it. IMO, capability should only be set to KVM_CAP_* values. Since riscv doesn't use it, then it should be left zero. If we're going to abuse something, then I'd rather abuse the 'feature' member, but since it's only an int (not an unsigned long), then let's just add an 'unsigned long extension' member. Then, the finalize_vcpu() call can be moved back to run_test(), from aarch64's vcpu_config_get_vcpu(). Both aarch64 and riscv will call it right after vcpu_config_get_vcpu() and the riscv version of it will do what your current riscv check_supported() is doing, using the new 'extension' member instead of 'capability'. And this patch gets dropped. Thanks, drew > + > + __TEST_REQUIRE(kvm_has_cap(s->capability), > + "%s: %s not available, skipping tests\n", > + config_name(c), s->name); > + } > +} > + > static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) > { > struct vcpu_reg_sublist *s; > @@ -126,6 +140,8 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm > struct kvm_vcpu_init init = { .target = -1, }; > struct kvm_vcpu *vcpu; > > + check_supported(c); > + > prepare_vcpu_init(c, &init); > vcpu = __vm_vcpu_add(vm, 0); > aarch64_vcpu_setup(vcpu, &init); > @@ -140,20 +156,6 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm > } > #endif > > -static void check_supported(struct vcpu_reg_list *c) > -{ > - struct vcpu_reg_sublist *s; > - > - for_each_sublist(c, s) { > - if (!s->capability) > - continue; > - > - __TEST_REQUIRE(kvm_has_cap(s->capability), > - "%s: %s not available, skipping tests\n", > - config_name(c), s->name); > - } > -} > - > static bool print_list; > static bool print_filtered; > > @@ -165,8 +167,6 @@ static void run_test(struct vcpu_reg_list *c) > struct kvm_vm *vm; > struct vcpu_reg_sublist *s; > > - check_supported(c); > - > vm = vm_create_barebones(); > vcpu = vcpu_config_get_vcpu(c, vm); > > -- > 2.34.1 > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 45CD5C77B7A for ; Thu, 25 May 2023 16:40:41 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SFomy6sb2nAQN2YOGgImYhZ++YsH80jsS/cCdrp5aFY=; b=llrYhTodEJ43Np CtYozM9eTYTyiA1842rseQRxlNqSevO6JDIUfXHSChv3oO5cyHPYUQ1N7ib+pr1wn/UnAGe4SDkem sXfRR+ilhJTmIpDW1UoBjSaI6h7WYQzPvpYOYiyQrf7TBMlSroprLCVF+fUEnkq/ztpiNyk00b3W0 3aNCf1v6hEliFpx36gz9P5ERQy6lezdDZ4mzhHlZZ6iML4nR16j5q7CI0vSn+MjWbFj3oHEMn5B46 zGLzX/stHjV0OxJEkFqQ21Zq0sg/0hqlpBrw02vTK665Eyyh0g02GT+ZbzPRApcidYJV3b4TLBwXJ UFSTeahjBlcPyF9wS9pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q2E0e-00H7Ao-2p; Thu, 25 May 2023 16:40:16 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q2E0a-00H78C-19 for linux-arm-kernel@lists.infradead.org; Thu, 25 May 2023 16:40:15 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f611ccd06eso6345745e9.0 for ; Thu, 25 May 2023 09:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1685032808; x=1687624808; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AR0TcRh5E3uNMVlwV4MX3XAnDWVMVCj/HBAPlYOkb4Q=; b=SMOO/RHoH9sCbPbHZOhilUrB2bJNfvDLCzNO5ccrVnl5YTsggfxCAGw2enOsIJsw3S muOPMMbM8OB9rpMjOPTcLN0styrxHRbccc9yTmXWbgcevJUP1pwqZXi98iwgUX4Pfv55 os7jsjCiXCLLhdD3CTPGSThlSx7rRpRDglbQkL4uhDoPpGndSA0UT7be/09Y3qB4sCTU 9Jj2LjqrHnXVoyAXUQEyeCSGlSCPNGIKyvU2Ar0ZXlrITl5RpUUhEMrIW9rij7AQisZh pS4SfprjWAgXcStQyvo0bOqre47fTQRcCig3TUxi2T6iUTtbEYJBhRLX2YVECM6VJ7Ni /zsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685032808; x=1687624808; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AR0TcRh5E3uNMVlwV4MX3XAnDWVMVCj/HBAPlYOkb4Q=; b=h0WGb1assayZGbtRLDufCOtHJyUhNMqbWt9yCcOIdoCDhWcj/z0WOIlUCE9X2Xg5Va QEbei+o833Li0QOq5UlC+5SsQ7m5ArpRjGjmvgsG9yWkE/nzXHckmtSp7UF4D76UO12u pIWyBOV7DGPL+YShfgZDNlzeq18/BgrVQbyA/w+W3/DcNgt/Uy9/F7iM7DIdUl3kIoDa Z95rnCZ/tG9XMbAwbUCq1yr35iN8BlPzUhPY0vPuWhEMxvNSwLOBp5QaKXeqLyZ7rovz vIAlNx4op1Qh2ujBjfBdXKotQ/by2sgWUbj3pf046TqVcvBk6bqNBJUG1DWUZVA5i3Nb So4Q== X-Gm-Message-State: AC+VfDwyXvWSXUya4MVPrJ1V6JCa0VTUanE17Xt2UVD5JW8vI+AdsE0z 9KGKK6ZLrXZmsY9A1uMejFiDBg== X-Google-Smtp-Source: ACHHUZ4E3vZaFea6aEdcJxuXhPYk5shRp2rDROSu38VNjlX+Zz36M4ciiQeNekDxjPytu3ey3fhDvg== X-Received: by 2002:a7b:cbd6:0:b0:3f4:2452:9669 with SMTP id n22-20020a7bcbd6000000b003f424529669mr3090300wmi.0.1685032808575; Thu, 25 May 2023 09:40:08 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id c2-20020adfed82000000b003078a3f3a24sm2311517wro.114.2023.05.25.09.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 09:40:07 -0700 (PDT) Date: Thu, 25 May 2023 18:40:07 +0200 From: Andrew Jones To: Haibo Xu Cc: xiaobo55x@gmail.com, maz@kernel.org, oliver.upton@linux.dev, seanjc@google.com, Paolo Bonzini , Jonathan Corbet , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Shuah Khan , James Morse , Suzuki K Poulose , Zenghui Yu , David Matlack , Ben Gardon , Vipin Sharma , Colton Lewis , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v2 09/11] KVM: riscv: selftests: Make check_supported arch specific Message-ID: <20230525-705ddcbcd43aa63e3fd356c8@orel> References: <26dea518fc5e8da51e61db279d175364bfecd009.1684999824.git.haibo1.xu@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <26dea518fc5e8da51e61db279d175364bfecd009.1684999824.git.haibo1.xu@intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230525_094012_397262_4BDC478E X-CRM114-Status: GOOD ( 25.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 25, 2023 at 03:38:33PM +0800, Haibo Xu wrote: > check_supported() was used to verify whether a feature/extension was > supported in a guest in the get-reg-list test. Currently this info > can be retrieved through the KVM_CAP_ARM_* API in aarch64, but in > riscv, this info was only exposed through the KVM_GET_ONE_REG on > KVM_REG_RISCV_ISA_EXT pseudo registers. > > Signed-off-by: Haibo Xu > --- > tools/testing/selftests/kvm/get-reg-list.c | 32 +++++++++++----------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/tools/testing/selftests/kvm/get-reg-list.c b/tools/testing/selftests/kvm/get-reg-list.c > index f6ad7991a812..f1fc113e9719 100644 > --- a/tools/testing/selftests/kvm/get-reg-list.c > +++ b/tools/testing/selftests/kvm/get-reg-list.c > @@ -99,6 +99,20 @@ void __weak print_reg(const char *prefix, __u64 id) > } > > #ifdef __aarch64__ > +static void check_supported(struct vcpu_reg_list *c) > +{ > + struct vcpu_reg_sublist *s; > + > + for_each_sublist(c, s) { > + if (!s->capability) > + continue; I was going to say that making this function aarch64 shouldn't be necessary, since riscv leaves capability set to zero and this function doesn't do anything, but then looking ahead I see riscv is abusing capability by putting isa extensions in it. IMO, capability should only be set to KVM_CAP_* values. Since riscv doesn't use it, then it should be left zero. If we're going to abuse something, then I'd rather abuse the 'feature' member, but since it's only an int (not an unsigned long), then let's just add an 'unsigned long extension' member. Then, the finalize_vcpu() call can be moved back to run_test(), from aarch64's vcpu_config_get_vcpu(). Both aarch64 and riscv will call it right after vcpu_config_get_vcpu() and the riscv version of it will do what your current riscv check_supported() is doing, using the new 'extension' member instead of 'capability'. And this patch gets dropped. Thanks, drew > + > + __TEST_REQUIRE(kvm_has_cap(s->capability), > + "%s: %s not available, skipping tests\n", > + config_name(c), s->name); > + } > +} > + > static void prepare_vcpu_init(struct vcpu_reg_list *c, struct kvm_vcpu_init *init) > { > struct vcpu_reg_sublist *s; > @@ -126,6 +140,8 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm > struct kvm_vcpu_init init = { .target = -1, }; > struct kvm_vcpu *vcpu; > > + check_supported(c); > + > prepare_vcpu_init(c, &init); > vcpu = __vm_vcpu_add(vm, 0); > aarch64_vcpu_setup(vcpu, &init); > @@ -140,20 +156,6 @@ static struct kvm_vcpu *vcpu_config_get_vcpu(struct vcpu_reg_list *c, struct kvm > } > #endif > > -static void check_supported(struct vcpu_reg_list *c) > -{ > - struct vcpu_reg_sublist *s; > - > - for_each_sublist(c, s) { > - if (!s->capability) > - continue; > - > - __TEST_REQUIRE(kvm_has_cap(s->capability), > - "%s: %s not available, skipping tests\n", > - config_name(c), s->name); > - } > -} > - > static bool print_list; > static bool print_filtered; > > @@ -165,8 +167,6 @@ static void run_test(struct vcpu_reg_list *c) > struct kvm_vm *vm; > struct vcpu_reg_sublist *s; > > - check_supported(c); > - > vm = vm_create_barebones(); > vcpu = vcpu_config_get_vcpu(c, vm); > > -- > 2.34.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel