Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3825466rdb; Thu, 14 Sep 2023 04:03:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2k91QKqZun+K1uA9TEpa5aB9wdMovcUDrOzLSM5naFyfmIjTZstQ9gSoSyvQciqcZy0vk X-Received: by 2002:a17:902:ab8d:b0:1b8:6cab:db7f with SMTP id f13-20020a170902ab8d00b001b86cabdb7fmr5039878plr.53.1694689421582; Thu, 14 Sep 2023 04:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694689421; cv=none; d=google.com; s=arc-20160816; b=IiDamzcnzTrTZWGnbg9owPVrUu3YBr9I+A84j01jA3iwEz3C2KT8c3bE+7C9KqjcNP pmCW6PNg14Oj65Xi1YBeKzTjqvrx2itfXsgWiFp8b9cpUb9K5Q4t8wC8Z0DjsrnSdQWt NxE72P0ym1osPWaMtQmmBiX1qCsBiMHh7Fvq+TIhia0SISB4LxeVZQs4CHn/g9tbl8GR Yd7A4KkYL4h/IJxcVZxiypz1lFU5jzbvGU3uDOjw0slQWz4/fNcB4OF7ygcNuW7VPWPK i2fN95CuCTUybc7qldGUo8siVnvwOxCCg9WoC4mRPLbuQPAtKk/0NS/zUpuwi5z26Q8j 27Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/mRrBnh8S4j8WTa2+bV8lSaUBhWpdN931kOj5VJSEI8=; fh=1m3Eo4t0catK/5hBwW3aQS9rWPCJCnGYoaJKMZahC+Y=; b=wp9+HZ13y/D6RXdq4OMHLkvryNOl42amWQXe2Oc7/mfgHi7mo1T3MXDhIVFZTXnpmM oMJWeIzzmJ8a9EgeYlLgRaV7uJ7w2QqpnaO4/DwA7q3u4/YBZ5RQOsS+1WnQWqVr/6gj qi2NsSINnBXIHjdNEQv2KHuZU3RPe7miVc8dmYEbKY6EWwCc/x3+sx2bdP8UMfZRKByd 2pRCmBMyw0BtQ5ptXlIHaIBsSDjsoCN6YLfjpPlTLaRGs21w3LSTKd+2QMAzCAoynuiE u1ENAschCaFJLaqNaEEmQ1xcu0/AaOobU3BBNfaf4VkOmhNB5JpM5kv8Hsr+RD3zNFWg muRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=UOl8Qzy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d15-20020a170902654f00b001bc67506b38si1374533pln.367.2023.09.14.04.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 04:03:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=UOl8Qzy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id A3AFB811907A; Thu, 14 Sep 2023 02:05:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236606AbjINJFW (ORCPT + 99 others); Thu, 14 Sep 2023 05:05:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236610AbjINJFV (ORCPT ); Thu, 14 Sep 2023 05:05:21 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E271A2 for ; Thu, 14 Sep 2023 02:05:17 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-403012f27e3so7782965e9.3 for ; Thu, 14 Sep 2023 02:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694682315; x=1695287115; darn=vger.kernel.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=/mRrBnh8S4j8WTa2+bV8lSaUBhWpdN931kOj5VJSEI8=; b=UOl8Qzy11vgi3rOc9gqjGmspZmIl8dqJBmzSdR9xllQC9RfcRK9KLqZrQlquTOj/BK nOvJVMGO4npz3FSEuXm9+JUHBQ+tPVg/cg6LZlwigL1dDZtstYVpgwUup+4Gk8kpYFtP /knFoHf7hkrSf9PC9keILr94tV9MwNQqWB/KNKpwgce/t4R/f8Zm+UQO9uLACDzdPIEJ wPH6hQE6MdXgy1fJSp4x+XG3KWe+MVA6blipJNpLcvupwmGtI0YBj7Y2HIihfdbY69VM ywjS7fW3MxAnnIoKmhH/Y8zW6wj8DYxuTmosOESxqTXv7D/Ys83/SmfBUqaxJoJCsLL0 ASzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694682315; x=1695287115; 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=/mRrBnh8S4j8WTa2+bV8lSaUBhWpdN931kOj5VJSEI8=; b=SGGqg4q8FWNzPw//S1/DiYQyfGJ7tTOy9z0ASmhoHcFg5A9i4cauZlV6DcX4g9hGjI xTIj+Ha6DaxtXwDo2bHA4EfCIEIXLp6onxy6OwlotXxplimFR4dJfpsEJv2Zzpl3wHPz xlflJ9BPtVp44imYMsxtJUMzO/Z484gEiYoAKjod/aeaQH1HW1NItUUCYn6jjalDuDRT 0MNpKJfN9IQ9TRcUMbmtFHtg+Z6gDJ22Q67B9dcl5+WbSNfuJVoc8wWW0ak8AHe6aiFZ 9VI12FnimKM0ZFeIKRnKs2vAPa3CGx/Dc3eZ0ISmpPXWegPq19nWc+Rx6zCvJ4A94/z7 L5mA== X-Gm-Message-State: AOJu0YzHL2wTJ6URbIFGytYmRbCgq3psEwFFzRDc3rSGRhYLxEyq1Bzz VU73aP3JDyWqy/ahOy4KwjdUsA== X-Received: by 2002:a05:600c:6d7:b0:404:74e3:27a4 with SMTP id b23-20020a05600c06d700b0040474e327a4mr285671wmn.40.1694682315033; Thu, 14 Sep 2023 02:05:15 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id m10-20020a7bce0a000000b003fee53feab5sm1391448wmc.10.2023.09.14.02.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 02:05:14 -0700 (PDT) Date: Thu, 14 Sep 2023 11:05:13 +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 , Sean Christopherson , Ricardo Koller , Vishal Annapurve , Vitaly Kuznetsov , Vipin Sharma , David Matlack , Thomas Huth , Colton Lewis , Aaron Lewis , 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 v3 8/9] KVM: riscv: selftests: Change vcpu_has_ext to a common function Message-ID: <20230914-d6645bbc5ac80999674e9685@orel> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:05:25 -0700 (PDT) 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 agentk.vger.email On Thu, Sep 14, 2023 at 09:37:02AM +0800, Haibo Xu wrote: > Move vcpu_has_ext to the processor.c and rename it to __vcpu_has_ext > so that other test cases can use it for vCPU extension check. > > Signed-off-by: Haibo Xu > --- > .../selftests/kvm/include/riscv/processor.h | 2 ++ > .../testing/selftests/kvm/lib/riscv/processor.c | 9 +++++++++ > tools/testing/selftests/kvm/riscv/get-reg-list.c | 16 +--------------- > 3 files changed, 12 insertions(+), 15 deletions(-) > > diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h > index 2c975d9cead2..7d5517648ea7 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..e527ad0abc30 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; I'd rather not assume that value will remain zero across a system call which fails. Let's write this as unsigned long value = 0; int ret; ret = __vcpu_get_reg(vcpu, RISCV_ISA_EXT_REG(ext), &value); return !ret && !!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..0dcff823f287 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; > -} > - > void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) > { > struct vcpu_reg_sublist *s; > @@ -77,7 +63,7 @@ void finalize_vcpu(struct kvm_vcpu *vcpu, struct vcpu_reg_list *c) > __vcpu_set_reg(vcpu, RISCV_ISA_EXT_REG(s->feature), 1); > > /* Double check whether the desired extension was enabled */ > - __TEST_REQUIRE(vcpu_has_ext(vcpu, s->feature), > + __TEST_REQUIRE(__vcpu_has_ext(vcpu, s->feature), > "%s not available, skipping tests\n", s->name); > } > } > -- > 2.34.1 > Otherwise, Reviewed-by: Andrew Jones Thanks, drew