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 256D5C433FE for ; Thu, 20 Oct 2022 19:09:32 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=r4+gST1EO6h8zkfRIyrwJ/EH2Bg8S9bmKun1vTa1NxI=; b=wIOnMnfV/R8bYx jzT8Zu3IyHMrRO6sjyTqRd8vVDUpUn8DuzKqJsm134DpGOEJQJnBkvvVwVuD3izgycfiPYTsU09z0 Z1Q3aerJuk1VLY53fUvbq25+kB7bSLqzY/ESJPwkMz2P5vfZ/hEYXtIS1lJNNw5ZVLMmkppbV5/5J /5UWj/PZyS5Rzt2ZoD+jbtg6hQcY0bWko2tyaEIweVO0NbL/KjaKBDpC/nok8XJnq5QLu1qukvCZi LV0GuT2TB5t+JDzo5NGXOVjYr2yTRbXHxbc8VqGR0H+l3Jyo7it8sV7PjQ/UQqly6gqa6uOzYSEE6 b8z0aplXKBHqhnuW0fyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olatm-001H0a-Ce; Thu, 20 Oct 2022 19:08:10 +0000 Received: from out0.migadu.com ([94.23.1.103]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olatj-001GyS-OC for linux-arm-kernel@lists.infradead.org; Thu, 20 Oct 2022 19:08:09 +0000 Date: Thu, 20 Oct 2022 22:08:00 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1666292882; 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=PiZzGkBrb0Pmhrx3lF3phKX07wonyvh6N79EhbYQ9YM=; b=mF2OxDQ1HxBVIawk2bmNq8Bm7iyc/MhjIb9HEX0EF4BkyC/oX0pEyxm0sUL411qg96fZBl vvYl9XnLSkacPHNqFcFZCrBHaC0854Il3yhS7XfUy7F00lguUY9JyO0xv63crUfhlv8oYV BG9d4KxfLL7QmpHGT2e+ZZ5tDNqTFdE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Reiji Watanabe Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Andrew Jones , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata Subject: Re: [PATCH v2 1/9] KVM: arm64: selftests: Use FIELD_GET() to extract ID register fields Message-ID: References: <20221020054202.2119018-1-reijiw@google.com> <20221020054202.2119018-2-reijiw@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221020054202.2119018-2-reijiw@google.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221020_120808_120514_B11EDFBC X-CRM114-Status: GOOD ( 14.79 ) 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 Wed, Oct 19, 2022 at 10:41:54PM -0700, Reiji Watanabe wrote: > Use FIELD_GET() macro to extract ID register fields for existing > aarch64 selftests code. No functional change intended. > > Signed-off-by: Reiji Watanabe > --- > tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c | 3 ++- > tools/testing/selftests/kvm/aarch64/debug-exceptions.c | 3 ++- > tools/testing/selftests/kvm/lib/aarch64/processor.c | 7 ++++--- > 3 files changed, 8 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c b/tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c > index 6f9c1f19c7f6..b6a5e8861b35 100644 > --- a/tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c > +++ b/tools/testing/selftests/kvm/aarch64/aarch32_id_regs.c > @@ -13,6 +13,7 @@ > #include "kvm_util.h" > #include "processor.h" > #include "test_util.h" > +#include > > #define BAD_ID_REG_VAL 0x1badc0deul > > @@ -145,7 +146,7 @@ static bool vcpu_aarch64_only(struct kvm_vcpu *vcpu) > > vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64PFR0_EL1), &val); > > - el0 = (val & ARM64_FEATURE_MASK(ID_AA64PFR0_EL0)) >> ID_AA64PFR0_EL0_SHIFT; > + el0 = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL0), val); > return el0 == ID_AA64PFR0_ELx_64BIT_ONLY; > } > > diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > index 947bd201435c..3808d3d75055 100644 > --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > @@ -2,6 +2,7 @@ > #include > #include > #include > +#include > > #define MDSCR_KDE (1 << 13) > #define MDSCR_MDE (1 << 15) > @@ -284,7 +285,7 @@ static int debug_version(struct kvm_vcpu *vcpu) > uint64_t id_aa64dfr0; > > vcpu_get_reg(vcpu, KVM_ARM64_SYS_REG(SYS_ID_AA64DFR0_EL1), &id_aa64dfr0); > - return id_aa64dfr0 & 0xf; > + return FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_DEBUGVER), id_aa64dfr0); > } > > static void test_guest_debug_exceptions(void) > diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c > index 6f5551368944..7c96b931edd5 100644 > --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c > +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c > @@ -11,6 +11,7 @@ > #include "guest_modes.h" > #include "kvm_util.h" > #include "processor.h" > +#include > > #define DEFAULT_ARM64_GUEST_STACK_VADDR_MIN 0xac0000 > > @@ -486,9 +487,9 @@ void aarch64_get_supported_page_sizes(uint32_t ipa, > err = ioctl(vcpu_fd, KVM_GET_ONE_REG, ®); > TEST_ASSERT(err == 0, KVM_IOCTL_ERROR(KVM_GET_ONE_REG, vcpu_fd)); > > - *ps4k = ((val >> 28) & 0xf) != 0xf; > - *ps64k = ((val >> 24) & 0xf) == 0; > - *ps16k = ((val >> 20) & 0xf) != 0; > + *ps4k = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64MMFR0_TGRAN4), val) != 0xf; > + *ps64k = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64MMFR0_TGRAN64), val) == 0; > + *ps16k = FIELD_GET(ARM64_FEATURE_MASK(ID_AA64MMFR0_TGRAN16), val) != 0; Not your code, but since we're here... Should we change the field values to use the #define's? Also, the test for TGRAN64 looks wrong. We should test != ID_AA64MMFR0_TGRAN64_NI. A value greater than 0 would indicate an extension of the feature. But for this exact change: Reviewed-by: Oliver Upton _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel