Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp656246lqp; Fri, 5 Apr 2024 05:18:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdp3TOBgEDQ6/pzZF9x4e8oXb3WUD0LiW6zEGMLkkD7brfkcTguCr6b2pQmuVB2prdH/+nfquf8D1jmmW+lZYUfLPDq+Lh1feRnqT5TQ== X-Google-Smtp-Source: AGHT+IGN1sf3DyBBl5XJJws0avalh7e5rI9DoUd75TH2FZch0N4S/lcTbXmashnoZQw4wUh3FSmR X-Received: by 2002:a05:6402:501d:b0:568:a5b5:8591 with SMTP id p29-20020a056402501d00b00568a5b58591mr1957430eda.1.1712319491049; Fri, 05 Apr 2024 05:18:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712319491; cv=pass; d=google.com; s=arc-20160816; b=h075uG/RwFytYGUqM8cKhpmmIYA/so04DPdIP+ynsPBOde5B6mWPonUn0yUz7YfIkl LYfTr3pF2MaE7x5vrou2nGHFfCU1I5JthQ1AfFJwi/7xsPeZ1UunqphUiiY62bRIJPt/ 5ToZb7PQ8rZmuG3RJ7PoIQZLwJ3GlwFYbJ1JBVqYPqgh4ODLxuTt/gDa1HmI1d/h04sG Jqc5LxhlPR88kdFpGd82DEoJTvm8uswJCufHVonhCPOVBTmIdCfW0zd9c2u21h5Rncd/ 509l1y/f6jNqJWtXAywKByDl1z3Ux5mlOSx1WON5iDZExE745Cyh3Hw+kJ0+YPp8kyOE 1DtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0g33fTsVSlizqg1S+bo16IuI7wIXRqKOdHvOtcRNGdQ=; fh=Lk7//7iNkscH6+8djnyDUCq/yshm8ZrpGXdrKVOEVdI=; b=P4ov9UjFTd7dBO0ulHw4Cvc4dn3U/Dw06C3/lXxZwYiuvFCUMUF4IXS0tgg/rPz2Kb boUr8idOXxnYjcSjqA51ApoD87LMlrBtYmsE3KNPXlg1ZIWdpzQB3ulGQpi7xqhG+3bM XjTfsD3UZhq4kzXqsFgEA2BDxu0RSr30hPJ91niYmlBQcZEjT6f2qgezAidunlgqtVku zBtIO556P+KBshTdFHo9kPKWdx2IBGM7c0bo918BVa/qhZ7eceXy8vO/jKbMSf2J87EQ aetrvFndqVR2xY+raMeESoBT5lx/b8sAuK63g5zuvjpLStossHgp64Q1PsdGx121R/o5 KM9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ThBkYjQl; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-132976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132976-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 30-20020a508e5e000000b0056e1193a35dsi657505edx.257.2024.04.05.05.18.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:18:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ThBkYjQl; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-132976-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132976-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 93E7D1F21E31 for ; Fri, 5 Apr 2024 12:18:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BD8B16D304; Fri, 5 Apr 2024 12:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ThBkYjQl" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6E4516C85F for ; Fri, 5 Apr 2024 12:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319475; cv=none; b=Ol1HZ620PIEHSs3QguJF55zHvc1PIMQJIEeUuRP6GIj/9Bl4TO7JaoWo6w2OYbrsmTXYFZwOhJNmDMTpJ/McWugOPVtBhpWDXs5mjG8xdn1ZaelTzmAVkA5DuRnmGR5AOfvJ5nD3cl4yCanLMu2LOrdRuNhysKbTgIzUUeBF7oY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319475; c=relaxed/simple; bh=ZaMBHOKq748J8AuTwS4EK3v5U+cz98pQBcMrLhGPsgY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IBM8NSvf+DpZ3jKVuER8UivC80WgEs2kgg9mzG8YuT4sENRBOL9Vh++pDVSbMFHrxb9xbdfnx+X6oWUjC4dDiGKSVQJAXQ5VvCirfs9GCeIWLI9ZGyHu+BmrA3NLH7cN6z5V+l44qx0ARvToLtRZ3FSiUYJ64oSHyRYYBbSMGQI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=ThBkYjQl; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-415446af364so19112945e9.0 for ; Fri, 05 Apr 2024 05:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1712319470; x=1712924270; 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=0g33fTsVSlizqg1S+bo16IuI7wIXRqKOdHvOtcRNGdQ=; b=ThBkYjQl6uV/iBvNVjAaem3u0Bgf/+NRfeJEAMf11QyW1dxqUnsLF3pAskIf8i/5Hq DZR7BcLaEX0qeCA/rd81A6QGcTf8KuG9NeR0l070fe9j4Hjs3t8tTxOM+WqZwZHHSRh1 20jXHLff1tf0cLG5t/2yN/KlxVFH0f3vfefKY/yleZTsxx68EhLiNHFYke2ZfNLjrzu4 /g7zPuOf6mxxCxs1SpkpuLKqBOcCEKCpb2cLlncGEVPET8Z3FqON/TlsDO2hblCFxJ6w uxkFEN25Ml1HgKAcb5SUc594Fz2G68SJHr2FvEvRiJv5vGsQGuCxSBrDaCyUsz7WS13U YrmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712319470; x=1712924270; 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=0g33fTsVSlizqg1S+bo16IuI7wIXRqKOdHvOtcRNGdQ=; b=MVHsiOd6uXfnBpyGkTDJHglqFszdAsJSrlzBcIm+LEm6JNjlpqWwjp9SbavXU1y+Gl ZAvSe641JItwqoNY/Wz/gW9w0cii71GUrDr2h9VX/3c1IZtJaCy8M40jT36QXIBw+y58 QlCB0CKLbVWGVRDYFcTxgbdkbBD+YtWjuRD2IYn47BNAJd5YczedSr/UZatDpuZiK06H eNBt57Afo55F6YXPyl9BxOu/dzSOnPDsJ4LLVbONf2gb+Xt3DQHhHO2yo4l1wyZRDYJF 80wEIFFDp7OoDcfOjl5lYfACJrrZddD28s95T9WhgtmwaDMuv1y++RrYandKmRGxzgTB qh/Q== X-Gm-Message-State: AOJu0Yxr8NNn/7OxauQI0oNQNMfhkxpsR4+WQfzXJEzVCqKi/3Y3l30T EomNifSkCgvkjH9xO9sW5f+/wCM/k9KQ+tEPo8OashU/DGCL8t/W0eVM6VwEEOQ= X-Received: by 2002:a05:600c:4746:b0:415:431d:7747 with SMTP id w6-20020a05600c474600b00415431d7747mr2014418wmo.7.1712319470607; Fri, 05 Apr 2024 05:17:50 -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 j10-20020a05600c488a00b004161ea7ed6dsm6093903wmp.38.2024.04.05.05.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:17:50 -0700 (PDT) Date: Fri, 5 Apr 2024 14:17:49 +0200 From: Andrew Jones To: Atish Patra Cc: linux-kernel@vger.kernel.org, Ajay Kaher , Alexandre Ghiti , Alexey Makhalov , Anup Patel , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, VMware PV-Drivers Reviewers , Will Deacon , x86@kernel.org Subject: Re: [PATCH v5 17/22] KVM: riscv: selftests: Add helper functions for extension checks Message-ID: <20240405-dae6363b92b742554e85cf4c@orel> References: <20240403080452.1007601-1-atishp@rivosinc.com> <20240403080452.1007601-18-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240403080452.1007601-18-atishp@rivosinc.com> On Wed, Apr 03, 2024 at 01:04:46AM -0700, Atish Patra wrote: > __vcpu_has_ext can check both SBI and ISA extensions when the first > argument is properly converted to SBI/ISA extension IDs. Introduce > two helper functions to make life easier for developers so they > don't have to worry about the conversions. > > Replace the current usages as well with new helpers. > > Signed-off-by: Atish Patra > --- > tools/testing/selftests/kvm/include/riscv/processor.h | 10 ++++++++++ > tools/testing/selftests/kvm/riscv/arch_timer.c | 2 +- > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h > index 3b9cb39327ff..5f389166338c 100644 > --- a/tools/testing/selftests/kvm/include/riscv/processor.h > +++ b/tools/testing/selftests/kvm/include/riscv/processor.h > @@ -50,6 +50,16 @@ static inline uint64_t __kvm_reg_id(uint64_t type, uint64_t subtype, > > bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext); > > +static inline bool __vcpu_has_isa_ext(struct kvm_vcpu *vcpu, uint64_t isa_ext) > +{ > + return __vcpu_has_ext(vcpu, RISCV_ISA_EXT_REG(isa_ext)); > +} > + > +static inline bool __vcpu_has_sbi_ext(struct kvm_vcpu *vcpu, uint64_t sbi_ext) > +{ > + return __vcpu_has_ext(vcpu, RISCV_SBI_EXT_REG(sbi_ext)); > +} > + > struct ex_regs { > unsigned long ra; > unsigned long sp; > diff --git a/tools/testing/selftests/kvm/riscv/arch_timer.c b/tools/testing/selftests/kvm/riscv/arch_timer.c > index e22848f747c0..6a3e97ead824 100644 > --- a/tools/testing/selftests/kvm/riscv/arch_timer.c > +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c > @@ -85,7 +85,7 @@ struct kvm_vm *test_vm_create(void) > int nr_vcpus = test_args.nr_vcpus; > > vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); > - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], RISCV_ISA_EXT_REG(KVM_RISCV_ISA_EXT_SSTC)), > + __TEST_REQUIRE(__vcpu_has_isa_ext(vcpus[0], KVM_RISCV_ISA_EXT_SSTC), > "SSTC not available, skipping test\n"); > > vm_init_vector_tables(vm); > -- > 2.34.1 > Reviewed-by: Andrew Jones