Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4396273rdh; Tue, 28 Nov 2023 23:27:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvk/YhDSrcvfcQNszcg4rIIeF+UJoQ86fWmUSON4XWMXUlQe1gP6DdntwO7DXAsH+sD2Hf X-Received: by 2002:a17:90b:4d0d:b0:280:4ec6:97e9 with SMTP id mw13-20020a17090b4d0d00b002804ec697e9mr20226546pjb.30.1701242867611; Tue, 28 Nov 2023 23:27:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701242867; cv=none; d=google.com; s=arc-20160816; b=0dYjbQ/y1XANsp0FnBxa6rNAPUczBIESD1f8NP34PfeEHPyOnsxKrWXypeCCcSwgsa gXBM+DNQeZWBok1ss3SlwSD74rpW31xkdxY3rhv1C7NsMUTFiBpCvAEO/eVv/EtJJS0v 5JQZGcfhRDe3cgPay6XfEs7kJNou+s8WEou2U/HYT5HnXzePB/4OgV4SrP5IBoisNUA/ ZznFujP2PLOJtLH/WNxnv6kBKohjfzf3mlE5l0xUD4QE0WkwLKalFFFKwckRGinZV8+e i7g6Yx01uIT6Z6saAPNUGAOuoi+ksz983ITOmxbFj912WyouEem8KUTXSYFXrjFZgMPL qIfQ== 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=d/PkR03f+9VfCYETbYP2LE2uGV5Kg0J9vteA61mMgJc=; fh=iDxqS2ylYbPnsqv8HSvHCqUt+745msxjAtp8mswlLTk=; b=t70xnZOEEwLCPLYJRMNrj7NSsF1m+U8gOzMKUAEAHUpsVlpLhKd4OUP8TeCSS1auh6 3yUelkUEznwPk/NzFVuJGXh/WF4uHoAuAYqNel0dtyf+pSt+Ks64U4jyhOuVJHFIUFH4 ChFKf08mv9cXvesgPzHRH3VXHuD3RxJZ7gXfh1qDtn0bX+y6xU1nb8rTwxIYBjDUzRU7 YSiFgto2PKQoKpFjZeCjW+alzM6U2GLmlhmuGim2iPuQLfIAOM3nMIVbnJqemVlROxpo AAnuMkSN1RFctrrILec2n9ypF96QNOD7bCnoARQrwAKFDOHlf3UCoStiBnm1UL1Sd2G/ cn2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JyL3TsoA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o10-20020a170902d4ca00b001cfabbeeda5si11599138plg.291.2023.11.28.23.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 23:27:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JyL3TsoA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 553C380C0398; Tue, 28 Nov 2023 23:27:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbjK2H11 (ORCPT + 99 others); Wed, 29 Nov 2023 02:27:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjK2H1X (ORCPT ); Wed, 29 Nov 2023 02:27:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA7001735 for ; Tue, 28 Nov 2023 23:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701242849; 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=d/PkR03f+9VfCYETbYP2LE2uGV5Kg0J9vteA61mMgJc=; b=JyL3TsoAkuey+RXG1BmUOIsQVlID2K1bOGdTs/LXlJFKORtOjTN9qKTr09DAsmmgC2MLWq SDwNCyLhl+6+cxvljrhiHstHDq9mn/q4hoiu8134NmTDt2DsJZdoRsIViziP1KB0mhR0k7 /0+hupve3ybssdKlLdwJiWg0RWTVAOw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-QeP6sf1_M6WC6fNL7yu2Ig-1; Wed, 29 Nov 2023 02:27:27 -0500 X-MC-Unique: QeP6sf1_M6WC6fNL7yu2Ig-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21C19852ACB; Wed, 29 Nov 2023 07:27:27 +0000 (UTC) Received: from virt-mtcollins-01.lab.eng.rdu2.redhat.com (virt-mtcollins-01.lab.eng.rdu2.redhat.com [10.8.1.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10FB01C060AE; Wed, 29 Nov 2023 07:27:27 +0000 (UTC) From: Shaoqin Huang To: Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev Cc: Eric Auger , Shaoqin Huang , James Morse , Suzuki K Poulose , Zenghui Yu , Paolo Bonzini , Shuah Khan , linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] KVM: selftests: aarch64: Fix the buggy [enable|disable]_counter Date: Wed, 29 Nov 2023 02:27:05 -0500 Message-Id: <20231129072712.2667337-4-shahuang@redhat.com> In-Reply-To: <20231129072712.2667337-1-shahuang@redhat.com> References: <20231129072712.2667337-1-shahuang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 23:27:46 -0800 (PST) In general, the set/clr registers should always be used in their write form, never in a RMW form (imagine an interrupt disabling a counter between the read and the write...). The current implementation of [enable|disable]_counter both use the RMW form, fix them by directly write to the set/clr registers. At the same time, it also fix the buggy disable_counter() which would end up disabling all the counters. Signed-off-by: Shaoqin Huang --- tools/testing/selftests/kvm/include/aarch64/vpmu.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/include/aarch64/vpmu.h b/tools/testing/selftests/kvm/include/aarch64/vpmu.h index e0cc1ca1c4b7..644dae3814b5 100644 --- a/tools/testing/selftests/kvm/include/aarch64/vpmu.h +++ b/tools/testing/selftests/kvm/include/aarch64/vpmu.h @@ -78,17 +78,13 @@ static inline void write_sel_evtyper(int sel, unsigned long val) static inline void enable_counter(int idx) { - uint64_t v = read_sysreg(pmcntenset_el0); - - write_sysreg(BIT(idx) | v, pmcntenset_el0); + write_sysreg(BIT(idx), pmcntenset_el0); isb(); } static inline void disable_counter(int idx) { - uint64_t v = read_sysreg(pmcntenset_el0); - - write_sysreg(BIT(idx) | v, pmcntenclr_el0); + write_sysreg(BIT(idx), pmcntenclr_el0); isb(); } -- 2.40.1