Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp962618lqj; Mon, 3 Jun 2024 06:26:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUyA27iHJ51bPfM+D6TXqxnn65W09objCknwSvnVr4hr2UqULh63gp4xnEzIkQpumERa1nhFTJ19h3EFCsa4ea63fF0fSFMwDI98ISPIA== X-Google-Smtp-Source: AGHT+IGq73LhC8V4GmDtqTRNB4IN3gOehOpYYfiBeqHgzD/bRfGJ5pYtFx7io7raOxQLe+TqwLu9 X-Received: by 2002:a17:902:da91:b0:1f6:828e:8683 with SMTP id d9443c01a7336-1f6828e87f8mr17291945ad.41.1717421183092; Mon, 03 Jun 2024 06:26:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717421183; cv=pass; d=google.com; s=arc-20160816; b=IAfeC6vv5j5j2saZujDWN45IxchLKOQqCQqE0MSAuzVCaZOAwh+fHe0zbq3XcolLOp ovlfvqw9hOgDcmeZuFZ1wbsY+FObOOtjoHqzcSUNoRrYzmv1tpLxh2lBLpT+3GunIr0/ rbupEvH9oEV7/tRrKR+PNnRg6gATUlxQU+qpuBzu4kh6GGSxfTYbbR+E8dEBNX+BJjum a9LSZpBslK3nCAz5rogT8nA8aiUHF9/Qte+OUmYcI+8UxtPLXMbxzejk6Ed6njIv9p7H fXQ87iqX8jStklMkS/fjc5YY2Lsfio9CfRbMRinGGbPSFZe/9q71mR9Uw8qO6o7Ufy3n E5Ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=IvEydmzzbvl2Ff0xpZlhwXwl7LHoKN1DgH3CccwPGZw=; fh=T2X+d6nj6Nq9usuF0jMYH820OxUMFWhBJfdMbqu+SVw=; b=XlO5uiJjQS/jvB9zEHuqstDvyoKlcc4p/twsFYXijisBeR4mdMIY20GeZUvF+BtezZ JWzZckGKlXdoD174MAqhEuW5OkwH0sP7jPH9gxl26o1VX6k7InllmPs44elJg5+ZjgJH sgCO9kFIlh+BzVit6jTtTlsOU8W+kcsr21R5bRRk4F7qNBv5IGKBEK3/QMswwYJkOkgQ fsuxwM3xrEiAeiIlKlwZOl7qNVLf+KFPB9tiPQWDhHyer7lS1I/89YSgBfjCYMMsKefQ m7p5Umex65THZK7fITysYlYuEq7Po/HBsVcYg+H8vIqdIYjHwtYEAS+4oq+SzyiW83tH Qg2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="JiNRe/6j"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199181-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199181-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f64ba676absi44806145ad.193.2024.06.03.06.26.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199181-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="JiNRe/6j"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199181-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199181-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 7BF96B22F4D for ; Mon, 3 Jun 2024 13:07:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81C4A130495; Mon, 3 Jun 2024 13:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JiNRe/6j" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2204212F360 for ; Mon, 3 Jun 2024 13:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419936; cv=none; b=Ebtyg4UNt3xeQeMmkkLiqEqgyjHg8FLD+llSY3JN2e3VquSKTglgzCGwA4SvroPYiK3Z1Mhm7FpDsTuv5xWZOU8CL4bfzc15+K15P2wCp45PYcdvWmXoPBXCLef1FjUp8POdQHQdQP5PpF3lOdfvWKQwDi2ruSUlTfbcz4rDcvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419936; c=relaxed/simple; bh=Xg3rnsN00i+ckdDX25UYE+Fpofh+iwRaHfKXTsHVsqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZWCFAT3OP8ppQE1KdAjTfZMANcNgwZfHBU5SwKZsNr1gusuwgsJmO+9EGDM/+9bLFWDlDMOMsqQbIpZ+1+EPWC/pl9Q5OKQoo+eeTBKmhGR1Hl30Rj2s8vxJCWQTt2109g2q8SjTpQJt9E+o9yGsrIxF6bVCwm32dGdgr52f0Bc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JiNRe/6j; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717419934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IvEydmzzbvl2Ff0xpZlhwXwl7LHoKN1DgH3CccwPGZw=; b=JiNRe/6jfe6gW9ME/ieHCX7eSgkd77ACa2/8fdziYwtoWXtBAxJ27/5pyeKW92KTmL86jf lV7jh3e5U9X/U941nwE1PhoxbeWbxwpCw2UdEhFSBdseiO00e1Hb3nt8AjoFJbwCj/7M33 AJ16W6eTKTYTuE1Mgpmh7Lhi1U5jaPg= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-290-gX13Fg-6N_ObKaiGZhgVnA-1; Mon, 03 Jun 2024 09:05:32 -0400 X-MC-Unique: gX13Fg-6N_ObKaiGZhgVnA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6ae1535f30fso44309256d6.0 for ; Mon, 03 Jun 2024 06:05:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717419932; x=1718024732; 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=IvEydmzzbvl2Ff0xpZlhwXwl7LHoKN1DgH3CccwPGZw=; b=tpjOQqUk5yIkSVWWMJedQGxv8wq3NsBC1mKd72IV2jAVXV0mrr8VrjAznK5UWevZ9p 8FUnkGSZysY1a/1DSdzcEk1XIlO5vhMoAfIRC92qtuYFuhjJ/25v9IomEnPigjpdls39 7zWRXeufQogw9yJTjyjPU+sL+uO+/ZDw9q7aGfWQHZ/DhbgrtUFbY+oDaHV/5WLjjHqw QIO3dbxJ8anE7mu5TDM4EVN6NZlcarhu00nZwVzHcWJuE4BFSPV+LvJmRBDZ7jE6jZ2M N8UJl9a+mQKBamybudE1tXBIENkOpZgrFJAHYZoBmgXtlhx6B6qQKBAyLfpTNeqFj7Nf 0hiQ== X-Forwarded-Encrypted: i=1; AJvYcCWTgvb7fiOtGFdHSHmocy1HarwK1tSIwosj4AN19Ef3P5LBxtxcrj2Uc2YAn2JJ5NNL/CFqaX5o2EIWzNp01ZbX7iVib38M9WS48qs+ X-Gm-Message-State: AOJu0YxqrpPgrPubeNytk+GwNSCHeaKeWQgFBSNp9p5J7QV4WlyF9a98 yilO48l4bR89LfNjCUWRQCUEOLI541c/ieBNbA91nUNye9FxdrjwFayoY44oO3kqW5195uTublm XWAvAdOwgn19KDp4Yf/yqFaHatLXoY4SyRxqPBFTGgT39tp3xFvbn2JO8ZdFj8Q== X-Received: by 2002:a05:6214:3f8d:b0:6ae:1063:eea7 with SMTP id 6a1803df08f44-6aecd598cafmr108985796d6.20.1717419931976; Mon, 03 Jun 2024 06:05:31 -0700 (PDT) X-Received: by 2002:a05:6214:3f8d:b0:6ae:1063:eea7 with SMTP id 6a1803df08f44-6aecd598cafmr108985266d6.20.1717419931395; Mon, 03 Jun 2024 06:05:31 -0700 (PDT) Received: from rh.redhat.com (p200300c93f02d1004c157eb0f018dd01.dip0.t-ipconnect.de. [2003:c9:3f02:d100:4c15:7eb0:f018:dd01]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ae4b4179f4sm30558826d6.113.2024.06.03.06.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:05:30 -0700 (PDT) From: Sebastian Ott To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , Shaoqin Huang , Eric Auger Subject: [PATCH v4 6/6] KVM: selftests: arm64: Test writes to CTR_EL0 Date: Mon, 3 Jun 2024 15:05:07 +0200 Message-ID: <20240603130507.17597-7-sebott@redhat.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240603130507.17597-1-sebott@redhat.com> References: <20240603130507.17597-1-sebott@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Test that CTR_EL0 is modifiable from userspace, that changes are visible to guests, and that they are preserved across a vCPU reset. Signed-off-by: Sebastian Ott Reviewed-by: Eric Auger --- .../testing/selftests/kvm/aarch64/set_id_regs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/testing/selftests/kvm/aarch64/set_id_regs.c b/tools/testing/selftests/kvm/aarch64/set_id_regs.c index a7de39fa2a0a..9583c04f1228 100644 --- a/tools/testing/selftests/kvm/aarch64/set_id_regs.c +++ b/tools/testing/selftests/kvm/aarch64/set_id_regs.c @@ -219,6 +219,7 @@ static void guest_code(void) GUEST_REG_SYNC(SYS_ID_AA64MMFR1_EL1); GUEST_REG_SYNC(SYS_ID_AA64MMFR2_EL1); GUEST_REG_SYNC(SYS_ID_AA64ZFR0_EL1); + GUEST_REG_SYNC(SYS_CTR_EL0); GUEST_DONE(); } @@ -490,11 +491,25 @@ static void test_clidr(struct kvm_vcpu *vcpu) test_reg_vals[encoding_to_range_idx(SYS_CLIDR_EL1)] = clidr; } +static void test_ctr(struct kvm_vcpu *vcpu) +{ + u64 ctr; + + vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_CTR_EL0), &ctr); + ctr &= ~CTR_EL0_DIC_MASK; + if (ctr & CTR_EL0_IminLine_MASK) + ctr--; + + vcpu_set_reg(vcpu, KVM_ARM64_SYS_REG(SYS_CTR_EL0), ctr); + test_reg_vals[encoding_to_range_idx(SYS_CTR_EL0)] = ctr; +} + static void test_vcpu_ftr_id_regs(struct kvm_vcpu *vcpu) { u64 val; test_clidr(vcpu); + test_ctr(vcpu); vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_MPIDR_EL1), &val); val++; @@ -525,6 +540,7 @@ static void test_reset_preserves_id_regs(struct kvm_vcpu *vcpu) test_assert_id_reg_unchanged(vcpu, test_regs[i].reg); test_assert_id_reg_unchanged(vcpu, SYS_CLIDR_EL1); + test_assert_id_reg_unchanged(vcpu, SYS_CTR_EL0); ksft_test_result_pass("%s\n", __func__); } -- 2.42.0