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 8AD80ECAA24 for ; Thu, 25 Aug 2022 16:54:11 +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=k4QkTRr817nk7hfdshfFJeEwnPg8cz/n5mYKLa2GWlo=; b=F7Weq32AznKJq9 8Nb8pmDq5BEdRaWxRseEaWpT/AKz8to7q97e80G57cbGVJhBeKCmUilqYboIcwUK3o7h17rpe40mj 2wacmoNbi/1WYSCEssv61SLDtiw509b7CyWLX/FtG7nFkJb7YEgl1I3l+zgnfZfnW3GLoEfIeCKnn svQz7pWa5QCe7cNVwQVZTkAgtlwDVY9ZfeN6yvx2QDc2rMC+/24iGZ9vHQ4m7giG4vK3CInWbhU6E Da8FkRlobcrlu/aLVEsAPvCxy4G8zWTEqVsaqakz/vJkZnLu6LxSggW0KIorn1iepNJBuZs2uecDj kYR1JCDmCqz3s1ZSfpkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRG6L-00GSS0-81; Thu, 25 Aug 2022 16:53:05 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oRG6I-00GSOA-AD for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2022 16:53:03 +0000 Received: by mail-pf1-x429.google.com with SMTP id x19so17573044pfq.1 for ; Thu, 25 Aug 2022 09:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=vJj32hJvJGqkLqOH+3ra6D6nxOVq8DAl1sAc3dJpCjQ=; b=A1nxbuvolMJoJdVb4d2CeQ4deHP4rqOZs/TGKqEa/qgD20Q02IBCEc7eW+rStkj5K0 D21GMCjOP5e+syC4ioQV2krjxXU3tlECG79YnCr/mqa7dW1y3k6V1iF+pKdPw3gs9jc3 RPbmWLoQnxwHxEo4e0ueRPrkmNH9MZX/WT83UdZl0/xKtVmHzW/B/PsoXYeF71v6DW1Q SLQO+5avsNIKeAMF+hneHrKaaHt8oP/WjoFWKerxjct5NLGVqO0os2PrCDr5xMFGqFkC KmZGD2U9lEFfXh/XMifNiI/81vv/RCaPOyyGHwkg5quLecKl7Enr21eRs/2f7LYv4vGN 9NAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=vJj32hJvJGqkLqOH+3ra6D6nxOVq8DAl1sAc3dJpCjQ=; b=1AlzNk34099ECndVUciJjElkUoialErDalqGZiWa997kqiob6b0t2MR5gcr3aZ3sEo Yh/1Xp11wUOo23pmHME/gDJ4dtryX93aBxo349NQ+suRGlXSWpudHY0dj3TFF1iBzm9R cFVpQX0IWwlCOYNgb31sDkmFBaA1j1xxmURJ2FHWBwpjEQulH7wk+g3wgduDPB/k9irQ PAwmPPxfGeayyorkxWB7J+vy6LoR0ve3gQ3kTdHavGTFWg0M9jm3xSUBYeUfFQaFUhwt XJr8mMIr8oakXQ+cMJVUaUk5ELlHu3h+jJeEVYN7WduNbUvaFkk6yW0aaOtVHpDvBBkL Fvqw== X-Gm-Message-State: ACgBeo1+CaQoJCn1hc4EsQrCYn2lIAl8qHC2kNZcmyZ9GdD1JOcwS/6m Og73/hFs2e2FG53OumvEOc0SDg== X-Google-Smtp-Source: AA6agR5NVWXmyuXOgXsVmLZCpYheZR95GpW+RbkOLt2FXFMx1LD4VylP1CW8x/Hy3QYEIDM/dHONMw== X-Received: by 2002:a63:e74d:0:b0:429:ead9:a350 with SMTP id j13-20020a63e74d000000b00429ead9a350mr30400pgk.194.1661446377961; Thu, 25 Aug 2022 09:52:57 -0700 (PDT) Received: from google.com (220.181.82.34.bc.googleusercontent.com. [34.82.181.220]) by smtp.gmail.com with ESMTPSA id j125-20020a625583000000b00535fd3290f0sm13789154pfb.113.2022.08.25.09.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Aug 2022 09:52:56 -0700 (PDT) Date: Thu, 25 Aug 2022 09:52:53 -0700 From: Ricardo Koller To: Oliver Upton Cc: Reiji Watanabe , kvm@vger.kernel.org, Marc Zyngier , Andrew Jones , Paolo Bonzini , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/9] KVM: arm64: selftests: Add helpers to extract a field of an ID register Message-ID: References: <20220825050846.3418868-1-reijiw@google.com> <20220825050846.3418868-2-reijiw@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220825_095302_378247_C8D32735 X-CRM114-Status: GOOD ( 26.02 ) 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 Thu, Aug 25, 2022 at 09:48:35AM -0700, Oliver Upton wrote: > Hi Reiji, > > On Wed, Aug 24, 2022 at 10:08:38PM -0700, Reiji Watanabe wrote: > > Introduce helpers to extract a field of an ID register. > > Subsequent patches will use those helpers. > > > > Signed-off-by: Reiji Watanabe > > --- > > .../selftests/kvm/include/aarch64/processor.h | 2 ++ > > .../testing/selftests/kvm/lib/aarch64/processor.c | 15 +++++++++++++++ > > 2 files changed, 17 insertions(+) > > > > diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h > > index a8124f9dd68a..a9b4b4e0e592 100644 > > --- a/tools/testing/selftests/kvm/include/aarch64/processor.h > > +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h > > @@ -193,4 +193,6 @@ void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1, > > > > uint32_t guest_get_vcpuid(void); > > > > +int cpuid_get_sfield(uint64_t val, int field_shift); > > +unsigned int cpuid_get_ufield(uint64_t val, int field_shift); > > #endif /* SELFTEST_KVM_PROCESSOR_H */ > > diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > index 6f5551368944..0b2ad46e7ff5 100644 > > --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c > > +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > @@ -528,3 +528,18 @@ void smccc_hvc(uint32_t function_id, uint64_t arg0, uint64_t arg1, > > [arg4] "r"(arg4), [arg5] "r"(arg5), [arg6] "r"(arg6) > > : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7"); > > } > > + > > +/* Helpers to get a signed/unsigned feature field from ID register value */ > > +int cpuid_get_sfield(uint64_t val, int field_shift) > > +{ > > + int width = 4; > > + > > + return (int64_t)(val << (64 - width - field_shift)) >> (64 - width); > > +} > > I don't believe this helper is ever used. > > > +unsigned int cpuid_get_ufield(uint64_t val, int field_shift) > > +{ > > + int width = 4; > > + > > + return (uint64_t)(val << (64 - width - field_shift)) >> (64 - width); > > +} > > I would recommend not open-coding this and instead make use of > ARM64_FEATURE_MASK(). You could pull in linux/bitfield.h to tools, or do > something like this: > > #define ARM64_FEATURE_GET(ftr, val) \ > ((ARM64_FEATURE_MASK(ftr) & val) >> ftr##_SHIFT) > > Slight preference for FIELD_{GET,SET}() as it matches the field > extraction in the kernel as well. Was doing that with this commit: [PATCH v5 05/13] tools: Copy bitfield.h from the kernel sources Maybe you could just use it given that it's already reviewed. > > -- > Thanks, > Oliver > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel