Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp265883rdb; Mon, 15 Jan 2024 22:11:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGO6cUpE1Sttzza3/d3ZRhALS6LlOfePQ5ZdoFuyBmqpmQjjK8elS3ERZpw6nS6IgLvzpt X-Received: by 2002:a17:907:728a:b0:a2c:9fcb:b1b3 with SMTP id dt10-20020a170907728a00b00a2c9fcbb1b3mr3840884ejc.20.1705385504211; Mon, 15 Jan 2024 22:11:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705385504; cv=none; d=google.com; s=arc-20160816; b=OrEkyKVTLSGbM3+GrdmT2kJHWcwt88U6z0184oTFso7jWcqZRk/B7nQ2ECWhHYKjzC 7S5Bxot8MPToHNeLGGVi7AOtHA5lJt7K1Mm4S4lwJBEZQ50OpOlVOjNhxLiTbUoU8gAP H3dcHeYoxpo9wNIP1O3dQHN9VwYw1LhD6zpFCNIes/fz2X63usCBhQYq44p4eC3N0tU4 gsc8E91rJZur2RNnpo0Ov0IUGA5XW9k09uBqM10be5ROx90xbDjY8Q47/3kk12ma3nlj qfkshvNg3UpMISTzE1LlN/mjN6kywty3jZaK8YjtvfpHy60g7dX9KrlWZwrWOd+R/hJZ V1WA== ARC-Message-Signature: i=1; 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=U9F5YnPtqeaOtnF1jbWP/C35kmOg9rX0z8z8z6VZYAU=; fh=VuUlYqvMXabbrxSvl5QPcnzeZiyktiyWLJ0H4umU7EU=; b=l4jPXGEITg+tPOaHdZpqi2/BO36qSkV2dee6IdG5DeMVj1MFbIFxXWzMluwNpxCOLO 1HPcdhGBY3zy259n8XvqBhV1jhP1Bi/66BUdSJyfdfgJZFf7+UktgDaIzM3nzvqmpE5Y GMekl/2nl4w4NF/E1d4REEucDmKdRVEuMSlQxO6ZBtaOoHrnvmeDhzuAMzlZiHUtND/T C+6gKOYDsSeZ3iSwk7gRkBIfzpl7iWcWNS055vqXgsV7Bb6rSsbej4R7IfqybaVGjS3t +yciEdWvfSbPSpFEjWr6BwmF6XGV32CBCPEDTSPVE5YFpNVQr+rLc4bZDmlGoc4mpWn5 5muw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MDqQd6JR; spf=pass (google.com: domain of linux-kernel+bounces-27028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27028-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hb26-20020a170906b89a00b00a2d0a4feb13si2843686ejb.419.2024.01.15.22.11.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 22:11:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MDqQd6JR; spf=pass (google.com: domain of linux-kernel+bounces-27028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27028-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CDAE91F24DB9 for ; Tue, 16 Jan 2024 06:02:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3688111AC; Tue, 16 Jan 2024 06:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MDqQd6JR" 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 B6DCB10A1D for ; Tue, 16 Jan 2024 06:01:39 +0000 (UTC) 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=1705384898; 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=U9F5YnPtqeaOtnF1jbWP/C35kmOg9rX0z8z8z6VZYAU=; b=MDqQd6JRVC0831ofRESKpA2ITEYBe7Lz4P1veMYCJDoJIzYlP8ux/m+I25dphljLzkyIu7 PvgWWalInbvpDo5Mip5ydqOPpgtfHm5b9NgMQ2C/XSCAhCoISQp/FVsBYqJuCCixYq5cEJ s9ucIbch1ui41u4SGYBZGpesIa5LoNw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-341-Myyr4p0TPemJrsDxd090_Q-1; Tue, 16 Jan 2024 01:01:35 -0500 X-MC-Unique: Myyr4p0TPemJrsDxd090_Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 B8CE01C05ABF; Tue, 16 Jan 2024 06:01:34 +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 A5B1B2026D6F; Tue, 16 Jan 2024 06:01:34 +0000 (UTC) From: Shaoqin Huang To: Oliver Upton , Marc Zyngier , kvmarm@lists.linux.dev Cc: Eric Auger , Shaoqin Huang , Eric Auger , 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 v3 3/5] KVM: selftests: aarch64: Fix the buggy [enable|disable]_counter Date: Tue, 16 Jan 2024 01:01:21 -0500 Message-Id: <20240116060129.55473-4-shahuang@redhat.com> In-Reply-To: <20240116060129.55473-1-shahuang@redhat.com> References: <20240116060129.55473-1-shahuang@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 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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. Reviewed-by: Eric Auger 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