Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp977886pxb; Wed, 1 Sep 2021 14:16:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRqssfg6BsknvfprvTH/EnI0WkVRzi2QDO2rXGZIcpK2qHrZIemC3ncZEr4LVZvPZlvtCI X-Received: by 2002:a17:906:468f:: with SMTP id a15mr1665170ejr.326.1630531005780; Wed, 01 Sep 2021 14:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630531005; cv=none; d=google.com; s=arc-20160816; b=sn/OnL7Q5tsdcqBJfiKbRhQRyu77r8XQBiqAnGQmzBY5li+ZetOC78aXPgaWGhtHxS bFTEOJCtOKnobJP1xDq36uR9D4Fed+r6T9DnCYNR2CFRb0kPZhqb+OKWzL3Gw0lVXHhW FjaAz3Ak7dGrG/LpbUfTUrDk44qyuvtOfBtFIwQ8xsIIJu3bUBX3/9QMWPaStkonJF1L pAqAx6mQJ0TlvOyHf8J9e8nyu8xLGWtJZ38Iv/HDchLW0U6n/ZACZf0NIJJPo+5dZONh nlWHuScIgBL4fs0U7Xn3FaAczT7prxhdzAJLbRc/1IXdWTCYfrHzywi0AEeLUTLaTiiH NbCQ== 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=+AY8FeEMdxANwbygbtDaWIs43jeZEXZSs/Nh/5qOONM=; b=lU7+gXaECd+kHGvUJaLFas+ycIzcrmMvhu12QexPDlj02p4MjHwrMwi9c4Sp8UIdoi BB7fJo7Q9xjlSMamsKYMZIoiUUTN8HAgkAiLI7R+FNaTuBa3i7W3SAlKATrE80kJIFKl iCIKUCMjh15Y5pcadSO1J24DT6cKMMgKA2KevYJ24vrQ7nWj3P4OFGSBE5VaEuYb32Kw tYskqvcPZFAOkqnR0gqVzT3PC8LIhhLAYjYG4s0IpyKn5G+FpOsJmH1YZ33o43Gp7rqs CiJtqNw3cHyDUj80gZAKJUsS9/4faulAP9Ih97gXcK94ZHNeTFpK68ciXeUiUkp0Set8 fEzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sEIY6pZW; 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 n10si765486edx.474.2021.09.01.14.16.21; Wed, 01 Sep 2021 14:16:45 -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=20161025 header.b=sEIY6pZW; 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 S1344561AbhIAVPi (ORCPT + 99 others); Wed, 1 Sep 2021 17:15:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343812AbhIAVPa (ORCPT ); Wed, 1 Sep 2021 17:15:30 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E38DC061757 for ; Wed, 1 Sep 2021 14:14:33 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id q26-20020aa7961a000000b003ef3d207770so451056pfg.16 for ; Wed, 01 Sep 2021 14:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+AY8FeEMdxANwbygbtDaWIs43jeZEXZSs/Nh/5qOONM=; b=sEIY6pZWU9JUoxbD3SFQAJZ+HaGDWEhhiX68l598G5kx1J0UFKGKlaSU38oiDTa1Tx M7YtesHq9xYqY0otdE0WpP3W5upth9uNrvUqlySOeWYnXdGfchoX7OqBLWKau4auWQci /Ml7YMnAC38eUFvCK8SQG8vG3CCC+WSwiLxcpI2nY/kIbj7jXbgrh4aijRFluLZH8qTQ r6862jdf17hMV2ehP0rYONQtfJac19PddlZr8gfK+HFjgAhjc3Uz1i5jonJrhI12qoMx tF06MUmg9WXAq6agNAue9s+mZxU7IgFJhBH9Ayn0+bL0etqXxP9RchKd8tiKtxV4bPA6 xt9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+AY8FeEMdxANwbygbtDaWIs43jeZEXZSs/Nh/5qOONM=; b=oDRc1YIKPouXy34HSXd8VLK/6HZ1lrMjWt1cj85vbZEBjGpHieqiCi/GtW10r7V+rN UbE6dkJI75jTHLwUu1sfAvCQLOBWpvEk9UG3F5xXXIirY9oaftTFgNFfM7OXYEB0umh4 D6aXbCiVz+bvh6WSeaffaCWW6QT0zX4JZ65FZYMDT+WGPdHqC+tULBDdwXxyDJGNKczd yjMfOHKITi3K6dUg+tmI5vVW0J2UwXS3cZtSGVjEMK7IPZRED4O1KSGvshNdAIndc0Av SHTHNc5smKWsU95GRy6TK7KtkXKSNKnmZKpSePAF8vJTTvflicRsgQJqJcKxkOngKKDC xf0A== X-Gm-Message-State: AOAM533gp7E/fi5WLbJv/EPwOIAim/ZH6G1k97ELWqsRU3kt8Al7wNnv YVgzu+nTRQkhp6c5x0bE02K0vuqaVB2U X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a62:1888:0:b029:3c9:7957:519b with SMTP id 130-20020a6218880000b02903c97957519bmr1345245pfy.17.1630530872495; Wed, 01 Sep 2021 14:14:32 -0700 (PDT) Date: Wed, 1 Sep 2021 21:14:05 +0000 In-Reply-To: <20210901211412.4171835-1-rananta@google.com> Message-Id: <20210901211412.4171835-6-rananta@google.com> Mime-Version: 1.0 References: <20210901211412.4171835-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.153.gba50c8fa24-goog Subject: [PATCH v3 05/12] KVM: arm64: selftests: Add basic support to generate delays From: Raghavendra Rao Ananta To: Paolo Bonzini , Marc Zyngier , 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 --- .../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.153.gba50c8fa24-goog