From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758754AbdACPik (ORCPT ); Tue, 3 Jan 2017 10:38:40 -0500 Received: from foss.arm.com ([217.140.101.70]:59000 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756406AbdACPiJ (ORCPT ); Tue, 3 Jan 2017 10:38:09 -0500 Subject: Re: [sample] A sample program for MRS emulation To: Dave Martin References: <1480518901-18544-1-git-send-email-suzuki.poulose@arm.com> <1480518901-18544-11-git-send-email-suzuki.poulose@arm.com> <20161130162720.GN1574@e103592.cambridge.arm.com> Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, ryan.arnold@linaro.org, sid@reserved-bit.com, aph@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, marc.zyngier@arm.com, adhemerval.zanella@linaro.org From: Suzuki K Poulose Message-ID: <008f25f9-662c-fbed-1623-520f424b74d6@arm.com> Date: Tue, 3 Jan 2017 15:37:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161130162720.GN1574@e103592.cambridge.arm.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/11/16 16:27, Dave Martin wrote: > On Wed, Nov 30, 2016 at 03:15:01PM +0000, Suzuki K Poulose wrote: >> Here is a sample program which demonstrates how to use mrs >> emulation to fetch the ID registers. > > Are we planning to add this in Documentation/? If so, we might want > some tweaks (noted below). Dave, Thanks for taking a look. Apologies for the late response. We could either add it to the Documentation or stick it into samples/. I prefer the Documentation, as it would help the text. > >> >> ----8>---- >> /* >> * Sample program to demonstrate the MRS emulation >> * ABI. > > overwrapped? will fix it. > >> int main() > > (void) > >> { > > We don't wan't people using the MRS emulation without checking for its > availability first. > > Something like this may work (untested), with the caveat that getauxval() > is a GNU libc extension, and other environments may require a different > mechanism to obtain the hwcaps. > Makes sense. > --8<-- > > #include > #include > > /* ... */ > > if (!getauxval(AT_HWCAP) & HWCAP_CPUID) { > fputs("CPUID registers unavailable\n", stderr); > return 1; > } > > -->8-- Cheers Suzuki