Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp100823pxb; Wed, 8 Sep 2021 18:41:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNvgFSuZIooDnf0q4/5zNCh/qgnzGDwSVWgspWQ94R6tsB6dATSOgIvoGmMeBc9incuDfU X-Received: by 2002:a05:6638:d11:: with SMTP id q17mr472507jaj.63.1631151703231; Wed, 08 Sep 2021 18:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631151703; cv=none; d=google.com; s=arc-20160816; b=Lo1NOwK1lMKvg105ItX3uiKK7o6j2O3Kn7Kp60I3ts0CDVvbUJt1V2nK1J58XtiCUz bKgG8vB+sxy75vxA0FNQ8NPK3x2/cH6cH2wtHmFbou/fD0h7cQq4pMxhIi6NAFl9CFRB IHgTC6Llb8XlGMpC77aJ840RY7YaKTfjT7U7I3hdXWgxLK5rBPFMf8aQxt6RjZcj60rq Q20pVYvgkX02io1Yn1KT6acq6rKZvBzAQcUBm6RAcCNszui+t/L5qctFKY2VyO9Mv8s1 1CsRo95JD1PPvZUhlWqPNDRAEseFPMaVykOQWVcWu2oo7nxj2kgWnTNq5WQRaA02gWfB OgQQ== 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=hjRX/HftaWd94e+jvOSEuHmijk3nZocmEtVUiH9mvr8=; b=pIq2HZ2/KcoHBB650wbOFtjQDNP2Z0DWqYLTJlWQocTL5fJyf9L/63sSnsgwyadSBw 5NwXqBLxdFSJM7wHGt9oCaodr+NsiWpc+w5AiWbmhK48l8ZNa0a5YwRqHz9FDq0/E+zi r3K+2LAVGmccnCev68tdazCUY7KTAN9NqjGuJCPQAarXmIxaF2p34ELqIoMed+fwsNPa CsRYO9p3seiWHnF+gAwnnHgkuEq30PtsuMLnqKzG1lz1TaW92ML5gA8ihy8VnMoX1T0a PK1JRsadHo2A0ZUV1xd+XBgEsKTpZ2Ecm6MlfplRvSxekOBu3RdMtV1bSuQr6Dmkd8pE 2+HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="DNT8H+P/"; 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 x6si341482ilu.80.2021.09.08.18.41.32; Wed, 08 Sep 2021 18:41:43 -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="DNT8H+P/"; 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 S1349717AbhIIBj5 (ORCPT + 99 others); Wed, 8 Sep 2021 21:39:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349711AbhIIBjv (ORCPT ); Wed, 8 Sep 2021 21:39:51 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97D2FC0613CF for ; Wed, 8 Sep 2021 18:38:42 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id z127-20020a633385000000b002618d24cfacso132643pgz.16 for ; Wed, 08 Sep 2021 18:38:42 -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=hjRX/HftaWd94e+jvOSEuHmijk3nZocmEtVUiH9mvr8=; b=DNT8H+P/i3+0pP+A8ae3zx+/69e/d6GKxdp5tnytAlBYxL1bysblA3Z96zvM7faRnp MiPxYxeza9JLHN0GpF4GmSXez3T0p4LoZRVFrVHQYzEr0LcPVUlKEELrUiWxD6I0A9Wm taOxz6ZoahTr8qdnhqB/tnCUY5TNl9VfVe5mDKpPeuQeDd5EQckZgFf63OfLJ5Pvjd0e IM/ym6YPja6fesLQKlJwdRY5BdXDUXU7h6AVrtoCG6Pmgk0KHvtPv9klWAhie36Uqena wWc0B+bDczYGE1Sq2/AfitLnfQKqzh5MeXwN4J65tKUXEmoCgUXw+E0W60fmyDJKwhst rOzg== 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=hjRX/HftaWd94e+jvOSEuHmijk3nZocmEtVUiH9mvr8=; b=NQfh/aE30iT39XBBOUw8BxdctVb7+QfQXNFdN1rJQujt7h+Moe9NM0vonijTzwrGUh KqlRJ6kEdUrssAUzpmUtYnaCTIzPoXyaFAmlKQzEpcfrLnpQl6W9bUW23ImXeV1DOqES 7beE5UtE56cqzDPGno9Uuw/bgKMh27RW5v1qL9H8rL2Y+OxD1PkdqbapDoJa7ja5rQ6S 6i4ihIyyIK5M86pmfLbkBCy4pBQmJe2eJgVqkd8YZtxtgl2xss12eo55UjzJpJEJVYK6 nzNS41hwbUuK6gLBTrSyitEFloFmtxrKw+TIPjbmsfYueuyg54LwDzTrfnp0VTa1Qmd8 4GJw== X-Gm-Message-State: AOAM532dhr1iDab0MdBeRKFHKXR34Eb6dhKk/uxdlvKvYQzWSmkOOYvT L+DIXBrZlx2R7xzhddqFFOJCz5L0/BO8 X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a17:902:a415:b029:129:5342:eab7 with SMTP id p21-20020a170902a415b02901295342eab7mr420693plq.26.1631151521851; Wed, 08 Sep 2021 18:38:41 -0700 (PDT) Date: Thu, 9 Sep 2021 01:38:07 +0000 In-Reply-To: <20210909013818.1191270-1-rananta@google.com> Message-Id: <20210909013818.1191270-8-rananta@google.com> Mime-Version: 1.0 References: <20210909013818.1191270-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.153.gba50c8fa24-goog Subject: [PATCH v4 07/18] 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.153.gba50c8fa24-goog