From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31788C433EF for ; Thu, 7 Oct 2021 23:39:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D8B3661076 for ; Thu, 7 Oct 2021 23:39:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D8B3661076 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=h7TgheyqnV4CKsu/JbGkg9qbN/xtmnZ5LuQR757tbiA=; b=QCtG2wDKAxzj5wcBa9+nF0FI4H yDWI0MguVnOYhVliAa1OXnUvuMdAz3NJ3VD79xPvbPuGMjzNHaEj8QDXDF+wKFh54j+q3AZa5Yw82 jNZjKA6zXnGf2xMIJEgnLhTNpLmItcVrEV35oKUqmuVKmqCeaw2a9Ss0Jndyju0IXre6koKAKMfZc iKim1ceLSz9ktbL2PGpgf5K00mcSrDEfX4vQ/1L8Cac7D7UEH7DiQs2PixLRwV3jHk/B66nKm2lFR 8BLE7WQwH5OB9yqYCACk02WixBemCFCbx3zgGtOs56zFAfOvmGGKCTgfAx7dhVExCoZdmo8ViEn3B fG2OFEcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYcwj-000z8U-MX; Thu, 07 Oct 2021 23:37:06 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYcup-000yGU-ER for linux-arm-kernel@lists.infradead.org; Thu, 07 Oct 2021 23:35:08 +0000 Received: by mail-pg1-x549.google.com with SMTP id z12-20020a655a4c000000b0029506c80060so565270pgs.20 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=mTQ/PTOBC/P9D4CpYtU9q3CFHLevYxkXz1Kg+zABC3UrI+X9eMz9k7U1hFvddDEE/f +MMrararBk1VfMCjLFM30ZOn2t1toFzs2h7boX54AfRoPcwnQ+NDTx2woMtclQbJVYpb K733SqAJGTPU/qKnTuqFQr5EL5wZKYJQlPnVTV5s4C43og1xFFG/eeiBOMNfvEY3u594 vRHOfCMpba5hEL44JhSjUHfOZrQXeAMiXfe+PhcnZVWx/awCQ6DkBoW7TilDXAXnYs/o 6QDWtcU2d+Q/1b6TuSkVdEvWvZ9undjrOteKj9Aakkw24JSxDFFeUEk8Fn7Gs49u8yyC r49g== X-Gm-Message-State: AOAM531ILozQngVpU+g1ZBEThZphrT4VFFuWK7YPllLIFf7Rc5hHmrtX JDbTzVkFsqyfxrCwbHtPPZ8hdWP0Wt2a X-Google-Smtp-Source: ABdhPJyilhCRZk0a0SoW62S+ez80OkitwK2J0PNfM9M/q/wH8V2CCWfESNfQOqN3LyPJYXZ7p4mJxSOzXVdc 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211007_163507_529347_F706E9D7 X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel