Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1837074pxb; Thu, 7 Oct 2021 16:37:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwydQAf63G3pwC4k8HD10ruzNgZki4l14dWziGeWkUCUR359HZYZuwxhEd+SePLWfJBO5Lu X-Received: by 2002:a17:906:784:: with SMTP id l4mr9180388ejc.469.1633649868133; Thu, 07 Oct 2021 16:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633649868; cv=none; d=google.com; s=arc-20160816; b=EdrOao7ZnzeyBGL+5T+9+4Yu9cTadWJDF+KWWxokgytKJhDMxvlbCSSk8/FClUUHYo /OHzfSnpqeVH82ZYEwXc4wiYivn9d3oWqWIb5BEfaGUx+igyh66bGOhjljQiKdppiDEw PkdtsJZp9hk5/mQ82y9we7vyY0AgYjLj7Z/XbDN1jrd18uxASJ2A397nsYhuCLzL/Mym Uac2yvQPxSAev1lTV5Bq87hUkxQGjvi/+0civmzB14SxXhcjag/0qgsa7PSy8ctL2TM9 cTN8HTx9LdJJi7HeyaIZP83TafGth7qVTNSX8tPFKbslf3apEdWrtcJ3bfn01BNNR5yr XXHQ== 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=zdzYxOXw6HRBi/j9Q4Djh6DlKsT7KOqy9GkRVsRm4i4=; b=epFATyTfUENxfJ2ADEpSia8jB9wa2V5hgl6VYKDU1THz3H545M+PNxJJ1tvOz1VYOQ VgBpBs1IQdVov2YMSHr/Tau4rbkFJbq7pMGODy3i9uDQGULL4JhX76qYYxu9N4jhyWZ5 G18yEJB0SxdxayVsH3vrRoF/N+a7lOwHaZIEdxTZ/f1emPlTV6VocuWfIUg8UQg4fR86 lWI8lbi1d9/ZJReIzwz/gn/qXxxb27X6vHC4BFJMlwzUKu7qidZmIR4GoOkvAf+G7H0P qOHCBye13kIQS2MCFW/lNDupF8njQt1PKJxv7M2bhr7iWzklt6V9lwBrs8VrztDiKEBX aAfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PvCCl4ZE; 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 b5si1092685edn.435.2021.10.07.16.37.24; Thu, 07 Oct 2021 16:37:48 -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=PvCCl4ZE; 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 S242345AbhJGXhG (ORCPT + 99 others); Thu, 7 Oct 2021 19:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238590AbhJGXg7 (ORCPT ); Thu, 7 Oct 2021 19:36:59 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65300C061766 for ; Thu, 7 Oct 2021 16:35:05 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id z19-20020a631913000000b00252ede336caso588609pgl.4 for ; Thu, 07 Oct 2021 16:35:05 -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=zdzYxOXw6HRBi/j9Q4Djh6DlKsT7KOqy9GkRVsRm4i4=; b=PvCCl4ZEQDsLP+V4LSuwH3sCogQbp1B9/TjEPTV8Nu5kiq6lYaDWIAyAbL60TcCriO TvK03v2M+Fk6kFFH8ucJeeM6OQTB1aTWP1gmvUqjbGltaij4+2MAeHFGuX4HCenQLwzT nNb/riJFKx1B2mLcVjIq+qwj1R8H7LegcugghClZjUKpaskRXhrO4DA6ZdCJfuB/XTnL 62oIU8it2w+FC9kvR7JrAZq4iWZLeYlkl7mTVgjJLhcU+nP2uohiXmICjub5LWvb1ad8 TRrchyPGubtZPJSPWL/JIdDssStNCNcvQo8H2EqT/ReRwJw2ZJutddbBu7KoJPNit/CD +M+g== 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=zdzYxOXw6HRBi/j9Q4Djh6DlKsT7KOqy9GkRVsRm4i4=; b=39i4SV1HWb8eETfPDVtgUn4BFwa3UIzjdMt8OAqG3pxsaohcfA1hDmW+bCzKJhH2mg qQbX98ZWYiGRV/Z4knIRaSTg3U9bqs17UIsBBmSl1IvrY9TXTE7gpqfb4F9kwuzyrZ+X 0SBlMokLOxTpbBwUr2lnf957iEBCGjmP3VKgSPhtcyrjNB3zxp47rjPC/3u4Pq1G+0DB qEibayv94PckEO8nx1AUHsW940vNfiHbncA82BAoZrXeZR5WTOfL6jWNBQAzvZlT/AR/ +CgHZ91rGyVgtpgN9C9OmcEQW4eW1OQpnIEnTa/ldA0wZt4yH9t1qkXM7njuHTOHU3a6 2EDA== X-Gm-Message-State: AOAM531b/G3Ph1yRT1cxJSa6pOKNPnrjf2Qg/RTTOrxWaMNUWBzmM3v9 0kczqJRS9kzkXhWjbhH7Oj3LR7+FMZLH X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:902:b093:b029:12c:843:b55a with SMTP id p19-20020a170902b093b029012c0843b55amr6613361plr.83.1633649704900; Thu, 07 Oct 2021 16:35:04 -0700 (PDT) Date: Thu, 7 Oct 2021 23:34:31 +0000 In-Reply-To: <20211007233439.1826892-1-rananta@google.com> Message-Id: <20211007233439.1826892-8-rananta@google.com> Mime-Version: 1.0 References: <20211007233439.1826892-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.882.g93a45727a2-goog Subject: [PATCH v8 07/15] 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.882.g93a45727a2-goog