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 8816AC71153 for ; Mon, 4 Sep 2023 14:05:20 +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=ivSq1a4JfGbG0dO4CL4a24+Sm84aeWBGs8IiiNGzPzQ=; b=j2v/AlsajDTwTu a9NEih8rN0z3oVlhvlaEejaxBZP28shngbAi02gawvbkxvTnwRw7/Ke8wBzWFyNCCFwRkUnNj8IYr 04kq2b4x5eYGahGh5fcU7toY7DIhRxr762A0+abEcOb8vSVKekKVmlnOSS6DCMbTPEIIErtXkT5Yl LB+kn/isHrwYp2Ga3BQHBrGKvIyxSUauIWR1E8Lz58ToxI66+jxer07t+Jy9rr1hHFB1do5jqkKxr y/f2RF7qDFSCXgynVua4i0ayVdfKpGXzcEWcCPOr+4qE/4kZNnE1YXGgCMcgiDwkVN0e6rdr37Uoe fvIRTgvZUOcI8Ldel79Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdABu-004EAQ-3C; Mon, 04 Sep 2023 14:04:34 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdABs-004E90-1a for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2023 14:04:33 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5007616b756so2530197e87.3 for ; Mon, 04 Sep 2023 07:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693836267; x=1694441067; darn=lists.infradead.org; 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=O9tH83s7KCzR3FLIzIaXHcz20Hx2Sr3w2Og6WosJQfY=; b=dDSdmjW1YXYROsv3Bus1UeKsAHfemtilv9h2b1J+/1n1ZkyWYnolbo00jso0YDAYNB Bnt5Snh9lZ3fdG4mmpxyA+ZFGjRzficDF6OE1ZUVgUb9dq4rZjmWtRcclYItWPn2Blny w5vh2CAVG3RX8XtAMGuv23fWqpR548Xa6fcyg+UorFHrsweWBghpfAQxI+PdbMLBC9/h y/2I6xV+kEys/mR8RwzuqLSovPiPULbQxUrf4/VsAiIQwurWxX+kO+m11eBx8+/onyJR ahH/Ai6TCsD2uNOVCZCCAkd9iUFUIvmR6gaWp70BD8IqIYqTveX3uORQYMmz9pR4eCtD fv0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693836267; x=1694441067; 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=O9tH83s7KCzR3FLIzIaXHcz20Hx2Sr3w2Og6WosJQfY=; b=MFkOa6NteYexCXRNfjHGS3bsnVz3Ig/EpzVculh/Xn7N9TXa3NQJCgVr3JRcVPfU3/ Z99Hj7DPCRSGmJkJFBKpcI3GdIq9QtDm+RxuLhuGbh+gCHVYtXiY5sUq2wcZ07I5J0tC 1zb95+QWRgdcSmbz1hiD83hwuOjmYc3RAktRyvG+rCu3d2VvXCTJMFddjMKtPK3U3v+N wpO2STxmLBLxsN0xYFMs+tFYYlCNk7OzVay3bl48L1LboFo0qlPg98AYW3+8ONGFJKPD M/mEj3AQmz1YND6pyrvWJX+hhqm3Mlmg/gDTXbSSbBsiBLclZczqD33/ySKnA8R1cwQ4 1q/g== X-Gm-Message-State: AOJu0YxScMwFrrr5G34DDY2iHKilbNYu2jt8oCIByyB/bsTjjYAQ6jpK NK6Se7q35FcWfOnvbe0sqMXxRw== X-Google-Smtp-Source: AGHT+IFF/9PKy4T0NHsglzBux4yLOD/vizZwx8Nlo/Ot5FXCeYE3JH7zKOg8I6O1HYXtVBq3ndfieA== X-Received: by 2002:a19:5e11:0:b0:500:c566:1797 with SMTP id s17-20020a195e11000000b00500c5661797mr5671974lfb.3.1693836266646; Mon, 04 Sep 2023 07:04:26 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id j8-20020a50ed08000000b0052333d7e320sm5801086eds.27.2023.09.04.07.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Sep 2023 07:04:25 -0700 (PDT) Date: Mon, 4 Sep 2023 16:04:24 +0200 From: Andrew Jones To: Haibo Xu Cc: xiaobo55x@gmail.com, 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: <20230904-aa8b0d8d23d391586686038a@orel> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230904_070432_535506_DC965D23 X-CRM114-Status: GOOD ( 21.30 ) 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 Sat, Sep 02, 2023 at 08:59:29PM +0800, Haibo Xu wrote: > Move vcpu_has_ext to the processor.c so that other test cases > can use it for vCPU extension check. > > Signed-off-by: Haibo Xu > --- > .../selftests/kvm/include/riscv/processor.h | 2 ++ > tools/testing/selftests/kvm/lib/riscv/processor.c | 9 +++++++++ > tools/testing/selftests/kvm/riscv/get-reg-list.c | 14 -------------- > 3 files changed, 11 insertions(+), 14 deletions(-) > > diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h > index d1e5d9f7ad45..6087c8fc263a 100644 > --- a/tools/testing/selftests/kvm/include/riscv/processor.h > +++ b/tools/testing/selftests/kvm/include/riscv/processor.h > @@ -42,6 +42,8 @@ static inline uint64_t __kvm_reg_id(uint64_t type, uint64_t idx, > #define RISCV_ISA_EXT_REG(idx) __kvm_reg_id(KVM_REG_RISCV_ISA_EXT, \ > idx, KVM_REG_SIZE_ULONG) > > +bool vcpu_has_ext(struct kvm_vcpu *vcpu, int ext); > + > struct ex_regs { > unsigned long ra; > unsigned long sp; > diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c > index 39a1e9902dec..5ececa566f24 100644 > --- a/tools/testing/selftests/kvm/lib/riscv/processor.c > +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c > @@ -15,6 +15,15 @@ > > static vm_vaddr_t exception_handlers; > > +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; > +} > + > static uint64_t page_align(struct kvm_vm *vm, uint64_t v) > { > return (v + vm->page_size) & ~(vm->page_size - 1); > 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. > -} > - > void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) > { > struct vcpu_reg_sublist *s; > -- > 2.34.1 > Thanks, drew _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel