Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2513106lqo; Tue, 14 May 2024 00:23:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxTYujxlP7nsY9P5QDyuEMkyFAGDOmQiCp6QPGrGK6hKPab5uKHxJLrabDcMwFeOTy40pH+zFtoauFKpBlsOH7IjU8PWKyJ927AQl25Q== X-Google-Smtp-Source: AGHT+IE6OSHHUPXA2WyuPWZO33lLm6SnaX0eLLQKmLzfgNOCUHtv9d4YiHB86h5HmIqvcqq/UlOC X-Received: by 2002:a17:903:41c2:b0:1e4:6e70:25d8 with SMTP id d9443c01a7336-1ef43d2e2c3mr146563835ad.13.1715671418947; Tue, 14 May 2024 00:23:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715671418; cv=pass; d=google.com; s=arc-20160816; b=MUJpYUrvDJ3GFlXfpLD25wfngHBcos/Bdjf9GzTU0xtwLOBQwzjjd05wayx4UnXqqj dzjHry3eg8ZHiP6Pfy927rrpM1HLS8RbrsIOOVRgCGIzFUlJ7NppHMZyhg1pqBoYsWOR ZC9Je2MUoLn5NnQm0xY6k2EoOLJOqPKWzVohLf0DpBbhzo4Mgj47ybySv8w8iR+mXMjj v4a0LMA42JNSJzjUqzYmWc569pDyT2mgETPS2t1EWNlqI+3VjhST0trNvN8epGXqBwRb Y94iktjup1z44V5HRsNKqJ1QSj9GGIHQRncW0OamqEhwOMzzBbJtIXHI7kJJAr2R7dqN Urew== 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=qmTJtxNzwCydsCweSeZKkzPt91K1xWWXybaXzLbEATg=; fh=ZQnGu3vFMJaIEmyLKBxVrs4zAnprSO5CyQzEVS2lzwc=; b=Nvt9TZjAvz1nj64EVXPB4ghB3WBSTJ++XOeIinqhg5l9NEj4UY5T0N1SWDaqc5drTY jZaNawQk8VBObrvqDlJsJuyRu07Zln4FRcTq/DkkYqRk1WC8Po+oUSQV0+DBM4cWsvEv S4afY9Ho+06mNXaXRkzSWe9PV7DCloGcz+KlbroOHuzSBRziC6ruQ3qSf0qiUKb3GX+H edR11qXN9/qdYFyAMSbc6mU7oz599DAqLH/5Y52dvYlhqdpBN5AK9fhwj59EUjwNFeib /uAWcZCSUjCy7iP15x4GM2FQOMTMnmNoyEaNKwkTv7EUoZsB2ow+LW5gSCf7dZvllu1Z XhNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BqvWTVEZ; 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-178375-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178375-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-1ef0bf31a5bsi111784475ad.227.2024.05.14.00.23.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 00:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178375-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=BqvWTVEZ; 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-178375-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178375-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 A6B80B216E2 for ; Tue, 14 May 2024 07:23:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F6E017BB9; Tue, 14 May 2024 07:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BqvWTVEZ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 2E1C515EA6 for ; Tue, 14 May 2024 07:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715671395; cv=none; b=gq9rMZdG8+WKdxYJTp0+fqBHB1fvpU+kamXcYSW0HloAvJbzl52Z/+SE8hFo2m3AiObTF1CXCxX4Fs5O6M+VM/i40bA0kMl5xivjSHXsNGqvceDK9tsvGwp545QPvdUjEKUuc8TFDbdGnjL/M+3/QktrPjk3+HRJh7mWA7ZkH6o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715671395; c=relaxed/simple; bh=wY+GRzCRFH5gnq+ih1QfRxaZi4OYPpugBgelwQ2YeW4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SJJGFECm4zJVjyU4qDygTFYCZ/W+uf9uz9CgXFCZGMq9ahDVWsX0e0f0xLu8r/6GG0ptO6jZeNgD/cGCNABO/M4sN5yPVKwOkMJzGmdW+nPeL0t8ib5oUamwiOaEDoD2QI0QpNIJ9tTZYQFXhAsw/v02BdbcgURjJuEjgzoO4qg= 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=BqvWTVEZ; arc=none smtp.client-ip=170.10.129.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=1715671393; 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=qmTJtxNzwCydsCweSeZKkzPt91K1xWWXybaXzLbEATg=; b=BqvWTVEZamN6OO+g9CpoFWHLO8RZxz6jAyYvHYI02r7pf9lBiEQuBj1gfG+RzLyMlBFtVS SBcWQZOGG4+rnsqOqJezauoQdW/5i1bx9s3PPJHJxGGVqmKHSsmp91yvfhDOH0WFC6bkC5 emtcCsF6vt1jifgfa8aaKgHjcbM+8r0= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-7-ECFLzTMqqfLicpe3mnIQ-1; Tue, 14 May 2024 03:23:11 -0400 X-MC-Unique: 7-ECFLzTMqqfLicpe3mnIQ-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-43de2f59d09so65725751cf.0 for ; Tue, 14 May 2024 00:23:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715671390; x=1716276190; 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=qmTJtxNzwCydsCweSeZKkzPt91K1xWWXybaXzLbEATg=; b=V7IJZypS48FXYoOTDr7cFGiaSuVkwe8RLvzKvqiui8zD+1Zo/QwKggIqhJkVoYZdJb Qyby7T4XLQ7PMeLhvUubWCqQ4qFJpbhdgwY9Op/ifDDSdKJKFWSfnK0PmVUyjJfqHNpb SbfaXMkL5VgLglV7vuOrlkaVIgdHpdGNt0WzXXCmAbq8kPtDKrAqxocLzIJQo0CqWgDX eeks95itvHlNvBSrqSwHF7W5nLx5mtZzcJSp3Cl1Ls73h1NCpNc/D5y2svXuojxLqR83 dgU7lO+jDja45OAVdncZIhTGSzAmfnHAxortZ83Z9yfvmiVCki2mZ1OrgegeqHP8hdf3 b3KA== X-Forwarded-Encrypted: i=1; AJvYcCWRPgxDc99/pnlixkntMp2vcGT+CqUGjUbEL22irBfjq7sm2m/gI/q1vx0GylLKtp2oCpSrimY5q9MYtSl/qV2JUR7O3bO5EgJ7wLib X-Gm-Message-State: AOJu0Yxe5+rNk1tehJR0/vBaOBW+ej6krlGeSuSJIN9OKHzTKRXAo+aX bas2L4kC2FE7QXUFIupSRBzGHVqsXO2+h26lhnfJvqzgnpD4Ri5alDfZCjVMFJ51doGgUlk1PpU FvZLL/v0GFBFw+F2rCiwyjqGSWUWt1PzlFSmCSpBQ/jau3tH6UIE4lQTwfyYLpQ== X-Received: by 2002:a05:6214:5b87:b0:6a0:cd69:374d with SMTP id 6a1803df08f44-6a16824151fmr150030376d6.50.1715671390420; Tue, 14 May 2024 00:23:10 -0700 (PDT) X-Received: by 2002:a05:6214:5b87:b0:6a0:cd69:374d with SMTP id 6a1803df08f44-6a16824151fmr150030156d6.50.1715671389920; Tue, 14 May 2024 00:23:09 -0700 (PDT) Received: from rh.redhat.com (p200300c93f4cc600a5cdf10de606b5e2.dip0.t-ipconnect.de. [2003:c9:3f4c:c600:a5cd:f10d:e606:b5e2]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6a15f1ccd4esm50917516d6.97.2024.05.14.00.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 00:23:09 -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 Subject: [PATCH v3 6/6] KVM: selftests: arm64: Test writes to CTR_EL0 Date: Tue, 14 May 2024 09:22:52 +0200 Message-ID: <20240514072252.5657-7-sebott@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240514072252.5657-1-sebott@redhat.com> References: <20240514072252.5657-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 --- .../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