Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2137900lqt; Mon, 22 Apr 2024 02:32:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKTGeX3VzmDzVSxLfkNu+KW3JwxPhcasvie2SCjQsgLyj/PvgSjdXreJ79/MQzaEnyYAtf2Afb93hiWFX7tmtxCDeadg7aSDLluTRILQ== X-Google-Smtp-Source: AGHT+IEWRRuRhcCCSv1WL0vvw0I4epfL1ZyMKedak6Qg3bvZmmyXtYdYlHqk7e9xq0S8FgXTwA90 X-Received: by 2002:a17:903:120f:b0:1e4:200e:9c2b with SMTP id l15-20020a170903120f00b001e4200e9c2bmr10918613plh.21.1713778336874; Mon, 22 Apr 2024 02:32:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713778336; cv=pass; d=google.com; s=arc-20160816; b=Ty1AtLIPCmF8e1r99ioERPMML+o9BRPKQMu01fE7L1qcW0vAaMlbOkqPrkdfSlEwod /3yYa+j6P6N27ybnjZ26Jl2jLw1nG+kUjLoA6uVcX9tkDrmfH/01tYnJbGgCZvdF28oS A92jJCPiwwQOEFDxCpWzXPC41SpRZjeH+422sPJ0Xa4paIudIOVld9tsYH5da4RPs3Y2 24EZS3wG9B0BgGWT+zCLamgnXzkh1xmhHFkM0SdGL084KBy4igiDhejciDXEs7hnQ7od 8ALbSw6ti85fmLPuLHE3U3iX1sr4dI4YNwMU4v7Vk7T7hynyYGsZYRTuXROPRDaQqivh li2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/u4byTUlDNwKD7I4IoEN6osZEpNF6BpvONGOZchupOs=; fh=A4o1dfTWrAjNg1kbsgLVw4fFrmHsgZRIuWsPcb89/Ww=; b=EwilfBkxA28NlM6XDBcwr79Jib2IxIx+3wwXQ/2CyR3L0lpAoACbntx33E0QcjU0pv K12+wn0YFrl1FM75vJjvqMRvp7G5FZk8jCoPlA6V4DhdxL20kyPikPVIhr/7Lay1JM9w 2nuN8mbMquEjqTTlqCXSAVhoQGwfo3A9A/kgGYfpCa2elmfLSWKEozasj+GRsZlaY3xk KH10VwrYZyHG9Dz+0pTOn9koaPwrnWXhmbiU4hTBpU9Fy0Q8e55RTtH8PJLyLjbtkQRO 24ohr0ArGCKiHRhHZE6vsqQs1b7YCvHfIGwlPGcOGvf94J/vxsvBFPj00ozRsk0GgaEO XL1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=Vr2lFj0D; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-152743-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152743-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k14-20020a170902ce0e00b001e905195d0esi4367518plg.89.2024.04.22.02.32.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 02:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152743-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=Vr2lFj0D; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-152743-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152743-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6A19AB21C13 for ; Mon, 22 Apr 2024 05:29:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B079E18654; Mon, 22 Apr 2024 05:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="Vr2lFj0D" Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (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 9501917C74 for ; Mon, 22 Apr 2024 05:29:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713763778; cv=none; b=rnAHp0GX/9O6cx3LQNMkOuxP6QIOW3fw0gs3T2YzeNgRqpgMWUZfJQnRexanNMmwsSAOEQa4+UCQx61/uIAuPHGBfcnCnZZLDkUeojtHQ37mL4eaIuT7t+wnK4O8uc+3nAq6IjMejirBUR5hOZdsBq9U/6+2u3mB3SBqG7wHHa4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713763778; c=relaxed/simple; bh=hfR8wFHUTqy0PtbXA2fJ051uKSvhoqdLre89/yRBZd4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BxUB7Q3gQlRNZRDd3z7DfxAdI8tK6XL843EoEMchmXUp6q5VHjrb4zXEYcmWGLWldo0zeWC5md57oHZSQJHbV2cG+bP6lNrY0kDcnFe0zMmZNHBoK5Oaukez+lWRq06Ixs5AXgzqxPlRuaS4hfrhF5QcDKpzdG1phdxmOI+KFJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org; spf=none smtp.mailfrom=brainfault.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b=Vr2lFj0D; arc=none smtp.client-ip=209.85.166.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-36a15df0f8cso18061395ab.1 for ; Sun, 21 Apr 2024 22:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1713763777; x=1714368577; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/u4byTUlDNwKD7I4IoEN6osZEpNF6BpvONGOZchupOs=; b=Vr2lFj0DyqkilRapfwd6i4wKL5VcIM8nGySz8CyoDZFT+6P6z6WZyn0B7YuSPzXPkO rMZSVkZk1UXBDZTX4IMlY6JFhVVDeEyk9piwjzoWYVFjAc/2WGfCsK/9WQdyKHrVX637 CaVwOnUMD3kI5rHEGdw1OxVKmG8qbM0BsbAqdgY5G+XB2tZJEGWz0MXhrSD1FpKzY7f1 A2NRHThlRBGLsL8z0fufbexuuwjv31JO022Tklujsj+94PincZppX6yh4M0HlF1xrw4H LfU69tgm+fSHbwd6MReFEujgo8V0nyaYckqONN32+3C8tzLLLjn3SjXMY+qE/vggDKbP ptmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713763777; x=1714368577; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/u4byTUlDNwKD7I4IoEN6osZEpNF6BpvONGOZchupOs=; b=nxexr4PsgdWJA6ibL2+J6UJIDLMpM+668L92JmHhcxSV3doakqWI04fFJGBSvE5Ogr BdQgVVwzxkmry+sc8vJ/T0Y6lFjTJ8jlN5uOh4WrWpIssipJBmS5dW9JQVAKbrfSQ8W+ +wuVS6GMSnEXdGcE2zuDV3VYF239/uzyXqcX1iJ74xyGBN6+JkHdqOOilNMxNCM0c9mk 05GyVBoHO80G86tbF1Dg69UKJqkg+OHQRRH/9Y8VG8ReCVA0D6dEID4CyC3qvlMOGwkQ KN4eCwTLdwc/nitggtRI1PNbUzZXsB8FsLc7jol3x1GIhy2KFvcL6QpPh2Biw4PAK4qj +Jpg== X-Gm-Message-State: AOJu0Yz7aPPi8qc90AdIu5s2wXZW1j1QSBHYlbFdrQ0diZRWYthgWyRm WPDbgW7f71Ba04n06fVWJU8XbY2bdAVSfgvDcuLLawsZM0CSt3QZFrTmv0qyORTL+xVTBoZlqBu ZZ6Gxhh+nwL49Me5mdP5uyB34pCsjMMnyE7C2Lg== X-Received: by 2002:a92:cd89:0:b0:36a:fa7a:629f with SMTP id r9-20020a92cd89000000b0036afa7a629fmr13121951ilb.21.1713763776638; Sun, 21 Apr 2024 22:29:36 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240420151741.962500-1-atishp@rivosinc.com> <20240420151741.962500-19-atishp@rivosinc.com> In-Reply-To: <20240420151741.962500-19-atishp@rivosinc.com> From: Anup Patel Date: Mon, 22 Apr 2024 10:59:25 +0530 Message-ID: Subject: Re: [PATCH v8 18/24] KVM: riscv: selftests: Add helper functions for extension checks To: Atish Patra Cc: linux-kernel@vger.kernel.org, Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , samuel.holland@sifive.com, 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, Will Deacon , x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Apr 20, 2024 at 5:18=E2=80=AFAM Atish Patra w= rote: > > __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. > > Reviewed-by: Andrew Jones > Signed-off-by: Atish Patra LGTM. Reviewed-by: Anup Patel Regards, Anup > --- > 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/tool= s/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, uin= t64_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 is= a_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 sb= i_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/testi= ng/selftests/kvm/riscv/arch_timer.c > index 0f9cabd99fd4..735b78569021 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 =3D test_args.nr_vcpus; > > vm =3D vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); > - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], RISCV_ISA_EXT_REG(KVM_RIS= CV_ISA_EXT_SSTC)), > + __TEST_REQUIRE(__vcpu_has_isa_ext(vcpus[0], KVM_RISCV_ISA_EXT_SST= C), > "SSTC not available, skipping test\n")= ; > > vm_init_vector_tables(vm); > -- > 2.34.1 >