Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp242789pxb; Mon, 13 Sep 2021 18:09:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/7WV25Jmm8aZzhO9XQ0YZ5+xkqBtkN2701BkV/flsxCGoykVfy5RjA1KB31rYeej8rHlL X-Received: by 2002:a17:906:2ec5:: with SMTP id s5mr15366991eji.192.1631581742766; Mon, 13 Sep 2021 18:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631581742; cv=none; d=google.com; s=arc-20160816; b=EioeKj4BGD0JCYCbsvGw7CT5k/z32+TMHALEskuhostVLkJDxaEC43n4rs2BgN8hCP K21M+1rhkVmWmNZubPdCZ7gMVlfTK6N5yG5kq0uC1bnDS686O3TFU1h8aB+EFeenkE6n Ct+qmcwIbRbzzOuqsa8ak3Rfwiy3ZfKecBMb+P0P0Pt+Y0kjtiMLBhau3uhQ+2Q3tN5I rLqrxAGic4e4l+ZyLxOfNWvD5RreZYd+2XE69CamM79OAAU4kINhF41UxZ71PvgvRFjF iw5+VNUZwvCIreDM3F3okfReKtF5mcmnUjnNupeiZJ2vlD9akF5YqzjPsdpBsghVtum7 8U/Q== 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=RWLkxwAGH4p5Pdoxfij5wy1qPizfWIeL9rDQUdVvDWKV0QqGOuwvqDiHEuKRS9ACse Rz3gTIm+KdBmXc0pmJAOHIoLNlyO8Hr4TMF8Pa+v4nJ1Lvfpxeuz50ZetL/6euJrQO91 de0osUiIkL9ZzinnViI6LQNl9oAeFPBb2vJEu8cY1runW6JdnDWVX+298mi8AsPLirCZ ezwinsB+vtDgqvkpxNSkoY9x8XWqG1bMGAoPNK4bBc8Q/P2vZwTWHAKCK9LWH5mhyINC LYcAmlpV4W7lK+HZbromk0P0g2r4BV38R4zohIf6ERJxs3eiOZdDs30kLkdHM+pBnQ+6 cH8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="XCvIJVs/"; 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 g4si8787170edb.272.2021.09.13.18.08.38; Mon, 13 Sep 2021 18:09:02 -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="XCvIJVs/"; 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 S244633AbhIMUwF (ORCPT + 99 others); Mon, 13 Sep 2021 16:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348197AbhIMUvc (ORCPT ); Mon, 13 Sep 2021 16:51:32 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2929DC0613DF for ; Mon, 13 Sep 2021 13:49:59 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id n15-20020a170902e54f00b0013b7a095210so1567167plf.15 for ; Mon, 13 Sep 2021 13:49:59 -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=XCvIJVs/DuwD6DVXVIzmTZNaPbpYhKQLqpZ+rykxYdMxB/84Qi3vvYNUM88AonXgYm 3V6M6oTDcFmeLBGC5wdKY8zvWQpQhY0wyzDGjzao2o0kiQeF8MKozUm6aPUJDoNJvQ0v Lmji7B2c73sTFVtY40SkEnXFX4/nn96K40bYLwW1C3pGJ5ybkts2yHh9IuwHH2le2c/F bklsQntTOO03t4HxTTxahmaU0/nj5BytTybtnNuD2k1GS2D8URinNWESa7cXIMFXBD7G 9OnHFMdEybV2SP5svwz3As2tL0s9uOYNxase9+yjgy4dHZZJJIzB8FxgLSP4ZBdHFgbL qNbw== 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=U84VXpxOodpj4390j46D7dMU8gMN1x/Uwi5a9kVa2XGwFXhCfSSKffHqm+VLTSDuE0 tzmN62GcTXEBGZuwhIR/c9fGbu5PjYlXWiPC778lEdkEDFa+75YcgKBFxT+HzAQ6zRfh BHBNi8nz9IHgQJ8cDsmQKIR6GpBdf/9nwZq2/JDbkwo++xt5z3q0AP6g6hwzDjktVuLo 00aESdnqWpLJ4UlLEKKTYxEK9a0APoaM9RipOdG9XXTTVG2HOUS0f++NJXFFouMWjMKM IekPbl9+dWCCxwuGvjSBACCGOg57nkoGrmRY3yVpqIUIMcto+OJNpoKysR2y3lrTNyvX tLQA== X-Gm-Message-State: AOAM532iCAM0Ef/iYC1w4NnB2mLpM0UZeVxKu9kCbYvqZI2fxZMVb2JQ LAZQDmDbF2KZLlQEGxRLO+ZpIcionES6 X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a05:6a00:1706:b0:434:9def:d275 with SMTP id h6-20020a056a00170600b004349defd275mr1328644pfc.1.1631566198555; Mon, 13 Sep 2021 13:49:58 -0700 (PDT) Date: Mon, 13 Sep 2021 20:49:23 +0000 In-Reply-To: <20210913204930.130715-1-rananta@google.com> Message-Id: <20210913204930.130715-8-rananta@google.com> Mime-Version: 1.0 References: <20210913204930.130715-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v5 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