Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1537954rdh; Mon, 25 Sep 2023 16:30:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrLaXUKJLoBqV9i+NzlFZOEGbZXkZRKSuK7KTQadExDgD5ulgMUCHUgtlBHA136zg4UIYl X-Received: by 2002:a17:903:247:b0:1bb:77a2:edda with SMTP id j7-20020a170903024700b001bb77a2eddamr8979994plh.36.1695684625635; Mon, 25 Sep 2023 16:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695684625; cv=none; d=google.com; s=arc-20160816; b=azDBmXPfLvEqG/BbqkYBSeRUR8hvdP47P9Bl3iYUAHx+m7eAlKj0Mhz+RZv2tEXrgF 9oCmOxC64kXVPfaBIrSkKiPtQtYUCBqqMCphKWRAjXWf05IwoUuY299Y/ln9A4LGskiD iTm+bQuwWKUeWsiQp/PZvkeJnS+Mjozy10KquVlqSEi6G524JBcR45Gbwui09UxA+VHP G5mM440otyMRNRIwhCa9ieaHXubtd8kkYB2Dr4l6XZld8Lah9qIdNQNooCTCX8I7vF+A EHBHf9ZJUznm97QoARAboPBuMMSDG8hBwU/eCUArfeaLiOJ5FiYlm419BCieHItR8/3d Yd7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uNHkjMM9HHYX8X83JcKOMwoHgKf/W4d95vsynq44CKo=; fh=Nnw/Dw3prVIT5KLOVQO3DcS15zu3mo0yAEjXPL5Uo9Q=; b=gcj6pIdvxm/LehbN5DRNrUtVXiWetevtyiXviH8Erhr1sJSt1Mswb3U/bVJvC7olS2 0X0PwOSaziLrHHJvaVLAZ6bBVcfkgBIHs3mlvG7hyOW72sBBvwPncvqJXz8miooG5HYb SNLd/HXmSDTOGvEfjEhqDDLTUGAKoG+A+g0iLA9vDGsKnbFZvYUXPUaxT1ViVlpWSpz2 eYk1tOLhVWE+r91BDzV7zAV3QlSK644foQgh4VC7PlmTW9GkAzZCiixXaKVrfu2tQ3kG K1bUAz8RvB7FxdbVr7Ex/uw6MruZAMmvmkEgXx/EzC2rtTYb879uhA+/736d486OAJyl qzbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="DcPfR/9E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id le6-20020a170902fb0600b001c62b659f98si1037983plb.79.2023.09.25.16.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 16:30:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="DcPfR/9E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 BAB7C808986C; Mon, 25 Sep 2023 06:41:03 -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 S232388AbjIYNkb (ORCPT + 99 others); Mon, 25 Sep 2023 09:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232289AbjIYNkT (ORCPT ); Mon, 25 Sep 2023 09:40:19 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 163791B8 for ; Mon, 25 Sep 2023 06:40:07 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c364fb8a4cso58188685ad.1 for ; Mon, 25 Sep 2023 06:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1695649206; x=1696254006; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uNHkjMM9HHYX8X83JcKOMwoHgKf/W4d95vsynq44CKo=; b=DcPfR/9E9VIPS1KbhspDAtONK1QO7eCSq9YKJW/V31SnY0ALc1hafseuwAifZZ3zlc ILC5PMi6e8eBlnnHfR3H7hNH3iaS2krL5aKqxy8E+bPbXHk1+neCoqn3nFUp6eGOwLsu bGq63E8omdmTzQKn+q+k9iyLCGUHCxsepV81iLrDBMJtl0tgKVXyIJwpcFAY/Cq48Iai iozTYONBEmDY+0NVUN/wTo3TjL3DW99sqEa7twTAfTl0L35IDQHn0m7H+Mt+1mCG/k2f 5S87FVsMKy9EQ1BzuqCtB2CojIMGkLZk08EmQKNoNfV9NK+8jdV7Pm93GLauRB0rKFC7 B8GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695649206; x=1696254006; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uNHkjMM9HHYX8X83JcKOMwoHgKf/W4d95vsynq44CKo=; b=QS3b9ivcP+oBIGPhMQ0zUua1bwqu+oIV4HMarGFzCVS3RquJgQOrl8m2J9pA4L1TtQ rPeWxZSuplCflmBtwFnZHaGpbCN07eOtWia/gRspLWuRJtVls0i352iUqqPCT01ZAOcS Ux30YQEuu33WDsYtTToU3g+/m0D2fPNWM8YUjrUF/ZbQ5jH/vl029MvkG4kpE4f/uIWI Rr9XVPHZ3R2gGN5yz620Q0sPO8kEOspgL0uK79uSoUeE4qawQ+oS+mSHmasi/eHM0btN m/63cuYZrWxa28LBUadYEUXexPyUQiZlnhJdb9NsadTR1suEqo0L3KIRWSkJHCzcTZ7w /95A== X-Gm-Message-State: AOJu0YyaOLBXywi4LMroT+JAWRINgTmwYiZoMqW7+LAih1wgUP2vhOcs 5dRuLLlVUQ1/8bk07xLO5TmaIA== X-Received: by 2002:a17:902:d50e:b0:1c5:74db:dc8b with SMTP id b14-20020a170902d50e00b001c574dbdc8bmr8353875plg.58.1695649206310; Mon, 25 Sep 2023 06:40:06 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id p11-20020a170902eacb00b001c625d6ffccsm969433pld.129.2023.09.25.06.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:40:05 -0700 (PDT) From: Anup Patel To: Paolo Bonzini , Atish Patra , Palmer Dabbelt , Paul Walmsley , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Shuah Khan Cc: Andrew Jones , Mayuresh Chitale , devicetree@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Anup Patel Subject: [PATCH v2 8/9] KVM: riscv: selftests: Add smstateen registers to get-reg-list test Date: Mon, 25 Sep 2023 19:08:58 +0530 Message-Id: <20230925133859.1735879-9-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925133859.1735879-1-apatel@ventanamicro.com> References: <20230925133859.1735879-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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]); Mon, 25 Sep 2023 06:41:03 -0700 (PDT) We have a new smstateen registers as separate sub-type of CSR ONE_REG interface so let us add these registers to get-reg-list test. Signed-off-by: Anup Patel Reviewed-by: Andrew Jones --- .../selftests/kvm/riscv/get-reg-list.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/testing/selftests/kvm/riscv/get-reg-list.c b/tools/testing/selftests/kvm/riscv/get-reg-list.c index 6cec0ef75cc7..625118d53b74 100644 --- a/tools/testing/selftests/kvm/riscv/get-reg-list.c +++ b/tools/testing/selftests/kvm/riscv/get-reg-list.c @@ -36,6 +36,7 @@ bool filter_reg(__u64 reg) case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_I: case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_M: case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_V: + case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SMSTATEEN: case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SSAIA: case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SSTC: case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SVINVAL: @@ -186,6 +187,8 @@ static const char *core_id_to_str(const char *prefix, __u64 id) "KVM_REG_RISCV_CSR_GENERAL | KVM_REG_RISCV_CSR_REG(" #csr ")" #define RISCV_CSR_AIA(csr) \ "KVM_REG_RISCV_CSR_AIA | KVM_REG_RISCV_CSR_REG(" #csr ")" +#define RISCV_CSR_SMSTATEEN(csr) \ + "KVM_REG_RISCV_CSR_SMSTATEEN | KVM_REG_RISCV_CSR_REG(" #csr ")" static const char *general_csr_id_to_str(__u64 reg_off) { @@ -243,6 +246,18 @@ static const char *aia_csr_id_to_str(__u64 reg_off) return NULL; } +static const char *smstateen_csr_id_to_str(__u64 reg_off) +{ + /* reg_off is the offset into struct kvm_riscv_smstateen_csr */ + switch (reg_off) { + case KVM_REG_RISCV_CSR_SMSTATEEN_REG(sstateen0): + return RISCV_CSR_SMSTATEEN(sstateen0); + } + + TEST_FAIL("Unknown smstateen csr reg: 0x%llx", reg_off); + return NULL; +} + static const char *csr_id_to_str(const char *prefix, __u64 id) { __u64 reg_off = id & ~(REG_MASK | KVM_REG_RISCV_CSR); @@ -255,6 +270,8 @@ static const char *csr_id_to_str(const char *prefix, __u64 id) return general_csr_id_to_str(reg_off); case KVM_REG_RISCV_CSR_AIA: return aia_csr_id_to_str(reg_off); + case KVM_REG_RISCV_CSR_SMSTATEEN: + return smstateen_csr_id_to_str(reg_off); } TEST_FAIL("%s: Unknown csr subtype: 0x%llx", prefix, reg_subtype); @@ -332,6 +349,7 @@ static const char *isa_ext_id_to_str(__u64 id) KVM_ISA_EXT_ARR(I), KVM_ISA_EXT_ARR(M), KVM_ISA_EXT_ARR(V), + KVM_ISA_EXT_ARR(SMSTATEEN), KVM_ISA_EXT_ARR(SSAIA), KVM_ISA_EXT_ARR(SSTC), KVM_ISA_EXT_ARR(SVINVAL), @@ -637,6 +655,11 @@ static __u64 aia_regs[] = { KVM_REG_RISCV | KVM_REG_SIZE_ULONG | KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SSAIA, }; +static __u64 smstateen_regs[] = { + KVM_REG_RISCV | KVM_REG_SIZE_ULONG | KVM_REG_RISCV_CSR | KVM_REG_RISCV_CSR_SMSTATEEN | KVM_REG_RISCV_CSR_SMSTATEEN_REG(sstateen0), + KVM_REG_RISCV | KVM_REG_SIZE_ULONG | KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SMSTATEEN, +}; + static __u64 fp_f_regs[] = { KVM_REG_RISCV | KVM_REG_SIZE_U32 | KVM_REG_RISCV_FP_F | KVM_REG_RISCV_FP_F_REG(f[0]), KVM_REG_RISCV | KVM_REG_SIZE_U32 | KVM_REG_RISCV_FP_F | KVM_REG_RISCV_FP_F_REG(f[1]), @@ -744,6 +767,8 @@ static __u64 fp_d_regs[] = { {"zihpm", .feature = KVM_RISCV_ISA_EXT_ZIHPM, .regs = zihpm_regs, .regs_n = ARRAY_SIZE(zihpm_regs),} #define AIA_REGS_SUBLIST \ {"aia", .feature = KVM_RISCV_ISA_EXT_SSAIA, .regs = aia_regs, .regs_n = ARRAY_SIZE(aia_regs),} +#define SMSTATEEN_REGS_SUBLIST \ + {"smstateen", .feature = KVM_RISCV_ISA_EXT_SMSTATEEN, .regs = smstateen_regs, .regs_n = ARRAY_SIZE(smstateen_regs),} #define FP_F_REGS_SUBLIST \ {"fp_f", .feature = KVM_RISCV_ISA_EXT_F, .regs = fp_f_regs, \ .regs_n = ARRAY_SIZE(fp_f_regs),} @@ -871,6 +896,14 @@ static struct vcpu_reg_list aia_config = { }, }; +static struct vcpu_reg_list smstateen_config = { + .sublists = { + BASE_SUBLIST, + SMSTATEEN_REGS_SUBLIST, + {0}, + }, +}; + static struct vcpu_reg_list fp_f_config = { .sublists = { BASE_SUBLIST, @@ -903,6 +936,7 @@ struct vcpu_reg_list *vcpu_configs[] = { &zifencei_config, &zihpm_config, &aia_config, + &smstateen_config, &fp_f_config, &fp_d_config, }; -- 2.34.1