Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1062125pxb; Tue, 14 Sep 2021 15:34:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYKE6B/NQYXW/LWEw2CHR1vjyk73XKqoxG12I+zMh3laanuWkoA/L7pDhYxKbiBd3i6Mu1 X-Received: by 2002:a92:d3c1:: with SMTP id c1mr9000885ilh.223.1631658856838; Tue, 14 Sep 2021 15:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631658856; cv=none; d=google.com; s=arc-20160816; b=ERfXWpUewCQjjcubFt62QNjzeQaRh3G8nNY8nTKY5HVbxOx57PrHgwV8JthIdLCbGY yjtiAUt2lBOhjfs4+UNNo6G02qYl/G6WCgNN3tuCKYnWNgeFMTukqVa6Dk52SaGd9UDt t8NAfGqk4UzOQ5lbGKxWIKDAZa7ISpCYQ8r4IRUgHGQZlR9HOYrDVAO05EFnkC8mCN1Y QQH2M7STyInNLml2sEOKUOxe6o6dri5bsUxf3hV8JJiXcSgbFkKug3jtglxoSE4tIXA0 99AybGkyUvncniKedmO4B37ZFeJUfVcPBkjCgM4fJrDQrh4NkwzvxF68vVyGCFt3XMIa QlTQ== 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=z1oSOC8U1k9jkSPo9/Jsmbo7AgNW4rV7mUJC47xll2MvKl0uufAg9R6D0hT4MVNwOC j7Mizpqvi2rMyhD+6N14Olz83KcyicsQPBSQDVPjQW1ZotVCt0TW9YAMruyKWnix26l5 ZDQ/ixYxvWX0hPiLWQbF8DwWFRcOjj3H4r70QhZGijSfoXaO2YwuA97k4KrHfKTDHQM/ PSpabUCv25c48MEoZGbgEIgkDSqkJcivfnA3lcjlkB/n9gTdSJSfKS4xVbrG1bxLDoYN xcBdAibIbpqQBl3AF4zA6W/0a+m9vw2T7GpZzbrUZA7ciNU+DElU4G65cDIYDyil9Rde l60A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BIj10Eok; 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 q17si1996820ilm.90.2021.09.14.15.34.04; Tue, 14 Sep 2021 15:34:16 -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=BIj10Eok; 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 S236165AbhINWdj (ORCPT + 99 others); Tue, 14 Sep 2021 18:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235815AbhINWc4 (ORCPT ); Tue, 14 Sep 2021 18:32:56 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF28C061766 for ; Tue, 14 Sep 2021 15:31:38 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id f8-20020a2585480000b02905937897e3daso984486ybn.2 for ; Tue, 14 Sep 2021 15:31:38 -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=BIj10EokpMKVIQvprsrN7AGSS04qrri+1fJcyz+LKoNcHUz6j8rumrXcsiDSnFs74L 9FDCrCun3Ns1u9bqKeeY6R1UBzZHKV3TC7bWqekk9UDFkvxAnqgIAZkKWETHfVfnNJIO V3hPt9oyY+k9HY3GAvt4y5fuYMjBhEHoTb7lT1apdLkLojeyq56RwWjSplDAAgxXXSXz k72BBzzUlAYpu8xxAEVAtyh699qXYz7ZFlfDQ1dLvloxD2CtrwRjAZHg+snteBBYW3sA LrqQ4rXsno5KpGxAbJWg5DroQw0n1PtxFlJ5gy/AFbhGWS37uQgYCsDnV0idazo6jKiS dHzA== 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=fZIVxL4V1ZJ1nNzX5ZydgqKpC2SlypqG31ck9c2HKTLXji6Lh/kb3vGQTXUFcQ/nSk bOmtPzsjj+HjnNszZ+aiLX4sfsgjxFm9DyI+qE+0q653plMZyAmHYpy+9zirKM9clc4z BVxoGcwcFL/NoBjeaT81hIbQsbnh9hmTUcunBUooCmtGE+804jJY63+CbvRMwWBNZZ+g emwD2YZw+QO0sjD8jGFG9n4ak9LjW2wQM6HvEaei8+nSOOAZ73oFmGX0103HW4qabuD4 FurRjFRCWUngC/LlEwWuVmHe3a6R6p8XBlcQ+IbYEZ+0dkMwzdtIzaalox26LDNR+tgi EtTg== X-Gm-Message-State: AOAM531qO6Zinq25Nu3UAQJSMZRD8N4ghmd1rUiqCGamSDg0UHQOVX9s j2LVKmGV6CJYEuq7G/p88KsMfJrGirpw X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a25:c9c5:: with SMTP id z188mr2033066ybf.223.1631658697938; Tue, 14 Sep 2021 15:31:37 -0700 (PDT) Date: Tue, 14 Sep 2021 22:31:06 +0000 In-Reply-To: <20210914223114.435273-1-rananta@google.com> Message-Id: <20210914223114.435273-8-rananta@google.com> Mime-Version: 1.0 References: <20210914223114.435273-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v7 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.309.g3052b89438-goog