From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA19CCDB47E for ; Wed, 18 Oct 2023 12:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=erGCXenvG3Hju2fxSDlcnoN28haKFcvd+2mTR78YXAw=; b=HF/pZMUvBAdTcn 2ncwKPbV4oYULrEIil20D/KnkzAx85Y4dVy0THcg9XyaIhbp19v/iQzZp22/z90aJzbk447vi7NL/ hJ4Sk6ioFrimvwQxHDdjoF3AtEZAdEB/nkwShMV0XpjT/6jHBcG6x/YNUSrdYUmUlOcK2m9VHw52t n9rMey+n9I35/QtwWCC/a8AQs/9BIrcMLTQM91OCJ6bCDz3Mp3c+KAL54iJ4mr5/nxoiPAb+Ykgb4 dTnW/i3fufCQoLUGW6ExF0j2qkc1nbFGQ5TK7ftqA4oMAXnc+rwgvGpMem5JpWHcdDEA5/RpcCh/a hHqugxaWuCm+5V/T+I9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qt5lp-00EfaS-1j; Wed, 18 Oct 2023 12:35:29 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qt5lk-00EfZo-1n for linux-arm-kernel@lists.infradead.org; Wed, 18 Oct 2023 12:35:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697632520; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Lz7XMhYS02Gm6gaNbc9MQCWSsb5Mo/qLQc74Gx24w/Y=; b=gBlP0n+stbHoNgvoQR1Ds6RY3FDnVtg/1YwP3ou1F6VrU1KtgY1O1rcP7rINb6IUwieVS8 yeIeEwtLNUIyNio3ZhlbAUVm7mK52d45MyfB/i3j+XAA5PLx0Cv+01Ni/FcwHjfFf/PHN2 9AS62SjHAdkPZ4+wmfOkMB/nqE/TmL4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-S5U5UdzuNTiPHi-fdTr-cw-1; Wed, 18 Oct 2023 08:35:05 -0400 X-MC-Unique: S5U5UdzuNTiPHi-fdTr-cw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E544C886C62; Wed, 18 Oct 2023 12:35:03 +0000 (UTC) Received: from localhost (dhcp-192-239.str.redhat.com [10.33.192.239]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5055B2166B28; Wed, 18 Oct 2023 12:35:03 +0000 (UTC) From: Cornelia Huck To: Oliver Upton Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, Mark Brown , Jing Zhang , Zenghui Yu , Suzuki K Poulose , James Morse , Marc Zyngier , Paolo Bonzini , Adrian Hunter , Ian Rogers , Namhyung Kim , Jiri Olsa , Alexander Shishkin , Mark Rutland , Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra Subject: Re: [PATCH v3 5/5] KVM: arm64: selftests: Test for setting ID register from usersapce In-Reply-To: Organization: "Red Hat GmbH, Sitz: Werner-von-Siemens-Ring 12, D-85630 Grasbrunn, Handelsregister: Amtsgericht =?utf-8?Q?M=C3=BCnchen=2C?= HRB 153243, =?utf-8?Q?Gesch=C3=A4ftsf=C3=BChrer=3A?= Ryan Barnhart, Charles Cachera, Michael O'Neill, Amy Ross" References: <20231011195740.3349631-1-oliver.upton@linux.dev> <20231011195740.3349631-6-oliver.upton@linux.dev> <87fs2aegap.fsf@redhat.com> User-Agent: Notmuch/0.37 (https://notmuchmail.org) Date: Wed, 18 Oct 2023 14:35:02 +0200 Message-ID: <87mswgcdmx.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231018_053524_737554_6CBDDAC6 X-CRM114-Status: GOOD ( 25.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 17 2023, Oliver Upton wrote: > On Mon, Oct 16, 2023 at 05:30:06PM +0200, Cornelia Huck wrote: >> On Wed, Oct 11 2023, Oliver Upton wrote: >> >> > From: Jing Zhang >> > >> > Add tests to verify setting ID registers from userspace is handled >> > correctly by KVM. Also add a test case to use ioctl >> > KVM_ARM_GET_REG_WRITABLE_MASKS to get writable masks. >> > >> > Signed-off-by: Jing Zhang >> > Signed-off-by: Oliver Upton >> > --- >> > tools/testing/selftests/kvm/Makefile | 1 + >> > .../selftests/kvm/aarch64/set_id_regs.c | 479 ++++++++++++++++++ >> > 2 files changed, 480 insertions(+) >> > create mode 100644 tools/testing/selftests/kvm/aarch64/set_id_regs.c >> >> (...) >> >> > +static void test_user_set_reg(struct kvm_vcpu *vcpu, bool aarch64_only) >> > +{ >> > + uint64_t masks[KVM_ARM_FEATURE_ID_RANGE_SIZE]; >> > + struct reg_mask_range range = { >> > + .addr = (__u64)masks, >> > + }; >> > + int ret; >> > + >> > + /* KVM should return error when reserved field is not zero */ >> > + range.reserved[0] = 1; >> > + ret = __vm_ioctl(vcpu->vm, KVM_ARM_GET_REG_WRITABLE_MASKS, &range); >> > + TEST_ASSERT(ret, "KVM doesn't check invalid parameters."); >> >> I think the code should first check for >> KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES -- newer kselftests are supposed >> to be able to run on older kernels, and we should just skip all of this >> if the API isn't there. > > Ah, thanks! I'll apply the following on top: > > diff --git a/tools/testing/selftests/kvm/aarch64/set_id_regs.c b/tools/testing/selftests/kvm/aarch64/set_id_regs.c > index 5c0718fd1705..bac05210b539 100644 > --- a/tools/testing/selftests/kvm/aarch64/set_id_regs.c > +++ b/tools/testing/selftests/kvm/aarch64/set_id_regs.c > @@ -452,6 +452,8 @@ int main(void) > uint64_t val, el0; > int ftr_cnt; > > + TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_SUPPORTED_REG_MASK_RANGES)); > + > vm = vm_create_with_one_vcpu(&vcpu, guest_code); > > /* Check for AARCH64 only system */ Thanks, LGTM. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel