Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp253083pxb; Mon, 13 Sep 2021 18:26:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPszFAbJBuGmEM+6OJH8GsTs43wbeSavorkY1DNDkeapVSwL/BKXcMSkMvZhD/USzO55k4 X-Received: by 2002:a05:6638:1352:: with SMTP id u18mr12421780jad.147.1631582813386; Mon, 13 Sep 2021 18:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631582813; cv=none; d=google.com; s=arc-20160816; b=jZeWkxzd87adJQoIfODc5tw93sb1oYFFllu+5B6xrJvlv0eFHS22hPQZDBsDWDSm3f hi0G6Xn7ikumEdUj3UJhi4/sAC8nq8xJNHbfiyuipAqR3ZBXlOgVeDXc3IjFSp2BHCG8 UYxhW/ySRU8w03X1J2LWaNdrK/AiICZ1gxhLr3+4yLTQY74kippdkLCsaVrB7Gh0W27Q QIIX7fkpsPCur1k3IZqpiHCrtPphB3on0cCPPNMiYhfCXK+KPrXCOuTA1zWej0YgmXA6 u4srM1kg/rtL1Ex7XkGq7HgiKyN2wnbuZ7wE9e1q6SDwR3cbTMZGRApskeUtJuwH61dz cyYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=++4XnYRgMyNMsEZoy1OpwZj4635Oms83QujRa32HDH4=; b=H+k40KaAAOmZU5pkuTNyqjCdtHr1BSqYJjFYeNB4qZ9OAIqgVPbRvi7b2b5sdYj0jn cSf9CJtm4LGEvpL227c4BpeXiQ82ue+A+wxufpoeqrmjm5XIlo/HqbaxdtwzKiMsBUXz JfXmQhzXtcE4ZlMYpD/Kg/OOkdj0f/9BjQUWU8L5jzUgp0hQMa/u50CBKuT4lzixH1Xw uV96awQgMNBsWYZ4fqRAdbKD7m8Zsmc0DQ7uWvnniCgLbNkt6n3p3tWj571veiathNXo 7D9S9p5xfZGipDwW0DhJsyA4RC08rD8qDrNsa6Pb/zNvmdW+t4zTijB00AnyjXWZZiye tDtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=L74ftL0M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si7701420jaa.28.2021.09.13.18.26.42; Mon, 13 Sep 2021 18:26:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=L74ftL0M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345367AbhIMXM5 (ORCPT + 99 others); Mon, 13 Sep 2021 19:12:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349551AbhIMXL5 (ORCPT ); Mon, 13 Sep 2021 19:11:57 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 900ABC0613E5 for ; Mon, 13 Sep 2021 16:10:17 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id s22-20020a056a001c5600b0041028eb25a5so7091900pfw.12 for ; Mon, 13 Sep 2021 16:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=++4XnYRgMyNMsEZoy1OpwZj4635Oms83QujRa32HDH4=; b=L74ftL0MnBDplytzX70ckvtTydMK0Eqbh058KvbeC7UELLvibodQtUhzEX3sYxlYaJ A2UkkQkn/G8fh+gpTXpjWgOV6XSPp1b7hJCymZ/nnuhX99gImgZBDhAsLQ+gcmxawHmq Ff+VM14GiOcjF0C8O95JMlr+EnM4Dv+iTOybu/LJosUhlXrnoelVNW0b3qmZAsAYxN8W 96Fwg3AuXRFT68xYPygavi2uYU+F47+Ri4xMSufvj9uNMeya/FU8TN97LCCo15fY6210 PYSQVNmyPuSLz+SeTHQrezFBodpaX0Hc2kB6Bd6aphu2xJpd4xO2ce/NNiM/ppfyeYKl Qkxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=++4XnYRgMyNMsEZoy1OpwZj4635Oms83QujRa32HDH4=; b=TLw6gEPxXik28eUUEQ5RgDjNfD/vJXXz69HfeZ2sCcvf7dMxTI0EUi9iUMotUd9dVh o64eGGy1Z098ZQpWg2ScdWYOvpFSCBrwSfJqS4ebO63VMghz50thf18Ck+lOua02tYQI gvFTqWUbkZgPy30Z2Ey2P8KoAleogBsLonRiPnUVS19wfWBXikcSxJds0Raq/Os2/tsg iFH3lFqfYbww1Q5BPPnO6gKyTGAVcX8dj2mdDrO++l5V/6ZM0BjJ3G8rm9XEEDmLOo3E ZniCRgr37xNkTQOJgys67XNwUdqOA/xlzodaUThLF+z7fVAc/VlAoxGux2Ygw7cN6egp BVlg== X-Gm-Message-State: AOAM532Rv/L2MKcBViIK+8AM5YeKUEpgDsS6iQev/vzRlm0fiBbAKP5X 7efEqUKcNV6ciMLJUa7gbL1xXCfs8WU/ X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:90a:6c97:: with SMTP id y23mr2075372pjj.117.1631574617035; Mon, 13 Sep 2021 16:10:17 -0700 (PDT) Date: Mon, 13 Sep 2021 23:09:48 +0000 In-Reply-To: <20210913230955.156323-1-rananta@google.com> Message-Id: <20210913230955.156323-8-rananta@google.com> Mime-Version: 1.0 References: <20210913230955.156323-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v6 07/14] KVM: arm64: selftests: Add basic support to generate delays From: Raghavendra Rao Ananta To: Paolo Bonzini , Marc Zyngier , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose Cc: Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add udelay() support to generate a delay in the guest. The routines are derived and simplified from kernel's arch/arm64/lib/delay.c. Signed-off-by: Raghavendra Rao Ananta Reviewed-by: Andrew Jones Reviewed-by: Oliver Upton --- .../selftests/kvm/include/aarch64/delay.h | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tools/testing/selftests/kvm/include/aarch64/delay.h diff --git a/tools/testing/selftests/kvm/include/aarch64/delay.h b/tools/testing/selftests/kvm/include/aarch64/delay.h new file mode 100644 index 000000000000..329e4f5079ea --- /dev/null +++ b/tools/testing/selftests/kvm/include/aarch64/delay.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * ARM simple delay routines + */ + +#ifndef SELFTEST_KVM_ARM_DELAY_H +#define SELFTEST_KVM_ARM_DELAY_H + +#include "arch_timer.h" + +static inline void __delay(uint64_t cycles) +{ + enum arch_timer timer = VIRTUAL; + uint64_t start = timer_get_cntct(timer); + + while ((timer_get_cntct(timer) - start) < cycles) + cpu_relax(); +} + +static inline void udelay(unsigned long usec) +{ + __delay(usec_to_cycles(usec)); +} + +#endif /* SELFTEST_KVM_ARM_DELAY_H */ -- 2.33.0.309.g3052b89438-goog