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 4D37FEC873E for ; Thu, 7 Sep 2023 16:40:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240719AbjIGQkB (ORCPT ); Thu, 7 Sep 2023 12:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239587AbjIGQjl (ORCPT ); Thu, 7 Sep 2023 12:39:41 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2AC146BD for ; Thu, 7 Sep 2023 09:37:26 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2bcb89b4767so20191321fa.3 for ; Thu, 07 Sep 2023 09:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694104575; x=1694709375; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=SUKo+1CllhDiFuk8e5kRvChp7TbG5sdYIOTqTfNiyNA=; b=W/uNJx0gEVpL1lyZsb+2CYMoeh+M3cwXUDF2RXF65wxNvZ+atCoVrTVUbSGr/sMhsp ErumCmWOzwYZt9vrig793BMntnS4wF1pDThT9IHmlI3423mItX01yu4UJ0g6KOmRWMk7 mQLoMT9Pon//j15SV8gfEhJryC+QKKck4FrWaCHVIrbTqsmI/EuBY6iK5yoB4gqRue6A vL1dwjbg9QUrNYU0zzp0qa6vWSA+30NKsfyDV6OTGrDPrgX7pn5uAqWjNid8Q4FxcAGS bWxfxWdUTWkTdj+royRj59M2ZUYYxAEDh48Z/Khu7yEFfU2FqbMnMsrlFEDqkJeCNKB/ dctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694104575; x=1694709375; h=in-reply-to:content-transfer-encoding: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=SUKo+1CllhDiFuk8e5kRvChp7TbG5sdYIOTqTfNiyNA=; b=JD17mYiJbZOVEmPIauI60Jh0EJCBsFyaRr2XcFEp2IGc/mquDK1axjzGlXo3NPcUs/ Gf7blcFq0Gk+I4UHaS7OiX8imB9qrDvrCAhBdAk4+ZGm25zdsc4KPsOISToeymQ6Z/v1 VF/5dBLp01Xfh8TZYmX2/5QWdorgQvgB1XJT0eQ5sVwR3UCJsOxN8kUSzDHUB8GFEUIg BZ/T3Qc5DB5xVxY9+3uvM6L8uFBjXI9HP9/R+VtQmXXoZ/q/Td0I6+EuftJPlk4miEUp CQq5mwPh0HIqj6Y+GWFu8gvscyTgTGrO39TSwPY6XoVVIGC8V3rXqiRpi6iwBT+qcVuK aDsA== X-Gm-Message-State: AOJu0Yyjg29qlBdneG/Tf4EQmqJdGoeESP0bui7afTqgNPLYmgEAva2G r89dE/aVwjhb4jyJpyMrzgEHD6h/1QhR4JNEr2E= X-Google-Smtp-Source: AGHT+IFpt5OHjqn8E5AQWQ3lRTTwlRHl603sQrss7nLMvcblN8lMTU9C4YqIhqBmSU5t7umjGBWQQA== X-Received: by 2002:a7b:c414:0:b0:3fe:f74c:b4f6 with SMTP id k20-20020a7bc414000000b003fef74cb4f6mr4055831wmi.17.1694077304089; Thu, 07 Sep 2023 02:01:44 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id s13-20020a7bc38d000000b003fe24441e23sm1882132wmj.24.2023.09.07.02.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 02:01:43 -0700 (PDT) Date: Thu, 7 Sep 2023 11:01:42 +0200 From: Andrew Jones To: Haibo Xu Cc: Haibo Xu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Anup Patel , Atish Patra , Guo Ren , Daniel Henrique Barboza , wchen , Sean Christopherson , Ricardo Koller , Vishal Annapurve , David Matlack , Aaron Lewis , Vitaly Kuznetsov , Ackerley Tng , Mingwei Zhang , Jim Mattson , Lei Wang , Vipin Sharma , Maxim Levitsky , Like Xu , Peter Gonda , Thomas Huth , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , David Woodhouse , Michal Luczaj , Paul Durrant , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: Re: [PATCH v2 7/8] KVM: riscv: selftest: Change vcpu_has_ext to a common function Message-ID: <20230907-bde62d037a3aaeedfe31f964@orel> References: <20230904-aa8b0d8d23d391586686038a@orel> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 07, 2023 at 11:57:00AM +0800, Haibo Xu wrote: > On Wed, Sep 6, 2023 at 6:10 PM Haibo Xu wrote: > > > > On Mon, Sep 4, 2023 at 10:04 PM Andrew Jones wrote: > > > > > > On Sat, Sep 02, 2023 at 08:59:29PM +0800, Haibo Xu wrote: > > > > diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c b/tools/testing/selftests/kvm/riscv/get-reg-list.c > > > > index d8ecacd03ecf..c4028bf32e3f 100644 > > > > --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c > > > > +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c > > > > @@ -44,20 +44,6 @@ bool check_reject_set(int err) > > > > return err == EINVAL; > > > > } > > > > > > > > -static inline bool vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) > > > > -{ > > > > - int ret; > > > > - unsigned long value; > > > > - > > > > - ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); > > > > - if (ret) { > > > > - printf("Failed to get ext %d", ext); > > > > - return false; > > > > - } > > > > - > > > > - return !!value; > > > > > > get-reg-list will now assert on get-reg when an extension isn't present, > > > rather than failing the __TEST_REQUIRE(), which would do a skip instead. > > > We need both the return false version and the assert version. > > > > > > > Ok, Will keep this one for get-reg-list and add another one for > > arch-timer specific usage. > > > > Just thought about it again, maybe we only need the "return false" > version for both get-reg-list > and arch-timer tests since if an extension was not available, the test > can be skipped with a message. > > bool vcpu_has_ext(struct kvm_vcpu *vcpu, int ext) > { > unsigned long value = 0; > > __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); > > return !!value; > } Yup, I had actually seen that when reviewing a later patch in this series, but I wasn't concerned if we added the assert type anyway, since we frequently end up with the two function types for KVM queries. If we don't have a need for an assert type yet, then we don't need to introduce it. However, we should introduce the non-assert type as __vcpu_has_ext(), reserving the vcpu_has_ext() name for the assert type, per the kvm selftests naming convention. Thanks, drew