Message ID | 7b633cc441f5133608597463301fef122f5174d3.1702371136.git.haibo1.xu@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7602973vqy; Tue, 12 Dec 2023 01:21:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWC6hsO85mUfaDjgFR4TN65WJE1AmLL6KA4HEsay9ASEar8eZi8AtWCLBl+98IQ2XEhYXM X-Received: by 2002:a05:6358:2490:b0:16d:bb7b:c0a7 with SMTP id m16-20020a056358249000b0016dbb7bc0a7mr4837954rwc.10.1702372861045; Tue, 12 Dec 2023 01:21:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702372861; cv=none; d=google.com; s=arc-20160816; b=TDoHMyE5ZIutATqWsFDVXLA8RK9OKah3nREj9PlUcybc4dGK4bAGSC2EqdLytzdGtZ 2FVe8ygwYYOer7/RokIUOoGZwJ4U/dQ8Fom3hsIzMfi2ds8HFongrxTCZoweS2N2b7/S skjblSlwWOiuubgfvZTqavt6M9DkcZSuOQCsBTTT3g+QioN+ZJ7S5AuH9a6sxEv6d+MC 3slIUSH2WaPjoctEHDLcKTArzDikZdth2rO1B5zIHQ1wTBGDHV8NXMPZou8B9wfWje+w M0Y21xSLu0UK1dgiRy0KolNixEu+NL9dMw8i9UqquNQYSiz1Tau5jROKrtUUa8+6jzF4 gpWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=zRhAXHM20iJDSFlOKpNSb+QKU8t9/br2ByqmxVnbVCs=; fh=zc8kibcv/FWMYhNHnwP7KVzCij9dtoCjf+QhQ60GO3E=; b=da9J0bB95QhPkHtzod3DNb/uVMWoQAhqzGVFTXMghbbzBmDZyr4wZsUuPGG7oE15Pw HIZM50+1Zfh8gCHdFto+sgMqieM1qdT8XxmkRrx+FWaneBmX1xZHbYhm571CxVD/tWX+ Iw/EVzBZaezCxZ07XmeNaxomuef275tlJsfGgRwRSbJUqwTX07rdXehn6DPqmTkuCghx M7K8OeagZZ62ItbhXv4NKJsEWIdhs9ULpWUBiymtn8dTe2nOR4vNiehHJRzDnrIhmXRd wgukhHEAoKYd0Fl83iiwX1QyBoj6QaRK1pGI4b33V5oV9w6IFMdA14gFgpP5Jz9vjUU5 xadw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=n7z9RbHl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id cb7-20020a056a02070700b005b90b2d9178si7725913pgb.796.2023.12.12.01.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:21:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=n7z9RbHl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1C9BC8093D61; Tue, 12 Dec 2023 01:20:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346283AbjLLJUd (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Tue, 12 Dec 2023 04:20:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346185AbjLLJUV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 12 Dec 2023 04:20:21 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27982EB; Tue, 12 Dec 2023 01:20:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702372828; x=1733908828; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f3eiUKT+cKcrQtCN2MDItspu7jMjjWkhuuJpCpoi/JE=; b=n7z9RbHlWpmX++R9/nW5SMu7v+8qm4da5teoR+PR7e64kfu2uSMC1eRq BayggVD3GGnQeQJ3lWFU69Lsjxr5/+D0YQ39ZtaMhB1FB7e0rGmKYyNCS OOvIvi8l4RyRvBtrP4DoHD/dDXWRMiCDDoMrV7k0DVWVwvnsvFfezVAK9 ldFQ2yDqtZIZx2Kv5WDUhEHpjaHhRtxkn00EKXpMW5KO97xwPC1odQbQe ObpMVJ7pgQN22o4btQRtpbOGsNR41JRKk14TZ5YQssu6R4iydjRL1kqgf 3aQzUOToBOuWGbzMeG97IB2XL0TL5wcPc5dChpufzLEzTql94X0XRvT11 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="480974301" X-IronPort-AV: E=Sophos;i="6.04,269,1695711600"; d="scan'208";a="480974301" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 01:20:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10921"; a="917213010" X-IronPort-AV: E=Sophos;i="6.04,269,1695711600"; d="scan'208";a="917213010" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 01:20:20 -0800 From: Haibo Xu <haibo1.xu@intel.com> Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Paolo Bonzini <pbonzini@redhat.com>, Shuah Khan <shuah@kernel.org>, Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Zenghui Yu <yuzenghui@huawei.com>, Anup Patel <anup@brainfault.org>, Atish Patra <atishp@atishpatra.org>, Guo Ren <guoren@kernel.org>, Conor Dooley <conor.dooley@microchip.com>, Mayuresh Chitale <mchitale@ventanamicro.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Jisheng Zhang <jszhang@kernel.org>, Samuel Holland <samuel@sholland.org>, Minda Chen <minda.chen@starfivetech.com>, Sean Christopherson <seanjc@google.com>, Peter Xu <peterx@redhat.com>, Like Xu <likexu@tencent.com>, Vipin Sharma <vipinsh@google.com>, Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>, Thomas Huth <thuth@redhat.com>, Aaron Lewis <aaronlewis@google.com>, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [PATCH v4 05/11] tools: riscv: Add header file vdso/processor.h Date: Tue, 12 Dec 2023 17:31:14 +0800 Message-Id: <7b633cc441f5133608597463301fef122f5174d3.1702371136.git.haibo1.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <cover.1702371136.git.haibo1.xu@intel.com> References: <cover.1702371136.git.haibo1.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 01:20:49 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785067325376270004 X-GMAIL-MSGID: 1785067325376270004 |
Series |
None
|
|
Commit Message
Haibo Xu
Dec. 12, 2023, 9:31 a.m. UTC
Borrow the cpu_relax() definitions from kernel's
arch/riscv/include/asm/vdso/processor.h to tools/ for riscv.
Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
---
tools/arch/riscv/include/asm/vdso/processor.h | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 tools/arch/riscv/include/asm/vdso/processor.h
Comments
On Tue, Dec 12, 2023 at 05:31:14PM +0800, Haibo Xu wrote: > Borrow the cpu_relax() definitions from kernel's > arch/riscv/include/asm/vdso/processor.h to tools/ for riscv. > > Signed-off-by: Haibo Xu <haibo1.xu@intel.com> > --- > tools/arch/riscv/include/asm/vdso/processor.h | 32 +++++++++++++++++++ > 1 file changed, 32 insertions(+) > create mode 100644 tools/arch/riscv/include/asm/vdso/processor.h > > diff --git a/tools/arch/riscv/include/asm/vdso/processor.h b/tools/arch/riscv/include/asm/vdso/processor.h > new file mode 100644 > index 000000000000..662aca039848 > --- /dev/null > +++ b/tools/arch/riscv/include/asm/vdso/processor.h > @@ -0,0 +1,32 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +#ifndef __ASM_VDSO_PROCESSOR_H > +#define __ASM_VDSO_PROCESSOR_H > + > +#ifndef __ASSEMBLY__ > + > +#include <asm-generic/barrier.h> > + > +static inline void cpu_relax(void) > +{ > +#ifdef __riscv_muldiv > + int dummy; > + /* In lieu of a halt instruction, induce a long-latency stall. */ > + __asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy)); > +#endif > + > +#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE > + /* > + * Reduce instruction retirement. > + * This assumes the PC changes. > + */ > + __asm__ __volatile__ ("pause"); > +#else > + /* Encoding of the pause instruction */ > + __asm__ __volatile__ (".4byte 0x100000F"); > +#endif > + barrier(); > +} > + > +#endif /* __ASSEMBLY__ */ > + > +#endif /* __ASM_VDSO_PROCESSOR_H */ > -- > 2.34.1 > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
diff --git a/tools/arch/riscv/include/asm/vdso/processor.h b/tools/arch/riscv/include/asm/vdso/processor.h new file mode 100644 index 000000000000..662aca039848 --- /dev/null +++ b/tools/arch/riscv/include/asm/vdso/processor.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_VDSO_PROCESSOR_H +#define __ASM_VDSO_PROCESSOR_H + +#ifndef __ASSEMBLY__ + +#include <asm-generic/barrier.h> + +static inline void cpu_relax(void) +{ +#ifdef __riscv_muldiv + int dummy; + /* In lieu of a halt instruction, induce a long-latency stall. */ + __asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy)); +#endif + +#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE + /* + * Reduce instruction retirement. + * This assumes the PC changes. + */ + __asm__ __volatile__ ("pause"); +#else + /* Encoding of the pause instruction */ + __asm__ __volatile__ (".4byte 0x100000F"); +#endif + barrier(); +} + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_VDSO_PROCESSOR_H */