Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4514168rdb; Tue, 12 Dec 2023 01:21:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IElcivYlG9xIVGpx7bkkBVQcAf0+TZOYy8zTtK0fBVdVV0zxtem7BPHXORfcXWP+vn/GXgA X-Received: by 2002:a05:6870:35cf:b0:1fb:75b:12f9 with SMTP id c15-20020a05687035cf00b001fb075b12f9mr7784225oak.75.1702372864503; Tue, 12 Dec 2023 01:21:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702372864; cv=none; d=google.com; s=arc-20160816; b=YwRNgWYgpooif8LfGYbST/v5cLBPb91otEvGZo2Jt1NnjkcUfuFit1XWKiEOboIuUU CDv6GxkgS3gbvmFeIfeB/gTGmZIj9yasqbHtYsgM+Wmoc/moeQ7P7Z2SSEIXYrxg9Hfe QE7BbuHp2Fu0z+qnaWF7AU5wxMxg73bvNERmrSYzWc5bNxYtxKhwAPwqSfa9A8MRM9Rh DcvXJp/vOJ/egDrlcuBH3R/0WBkwBzJpcgT3nLxh46sr6O4lWPC0e1e1GCQ3Cm73Wu2H egujh6zEF/Muft+6C9TqdvTW6gl1A88vVOuUC2QqvdnaAXIb7gGTEmzyZY4xuSy12juJ OErA== 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k1-20020a6568c1000000b005b96c4292basi7376695pgt.29.2023.12.12.01.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 01:21:04 -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 F399A8054EF5; Tue, 12 Dec 2023 01:20:57 -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 + 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 ); 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 Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Anup Patel , Atish Patra , Guo Ren , Conor Dooley , Mayuresh Chitale , Daniel Henrique Barboza , Jisheng Zhang , Samuel Holland , Minda Chen , Sean Christopherson , Peter Xu , Like Xu , Vipin Sharma , Maciej Wieczor-Retman , Thomas Huth , Aaron Lewis , 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: References: 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: 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:58 -0800 (PST) Borrow the cpu_relax() definitions from kernel's arch/riscv/include/asm/vdso/processor.h to tools/ for riscv. Signed-off-by: Haibo Xu --- 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 + +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