From patchwork Wed Sep 1 21:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghavendra Rao Ananta X-Patchwork-Id: 12470387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22408C4320E for ; Wed, 1 Sep 2021 21:19:08 +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 DC8F960F92 for ; Wed, 1 Sep 2021 21:19:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DC8F960F92 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=bO/YfUaRCGZRJgeWU0IxsAx44sIj4IMjg7V7C/8Nu7g=; b=1n7nru2DVcg7j52fdrAsm3YOIJ MAfxvzR4cwjFP12Pbudi4+4S2XwkWsNCSzNvWNhzWAqXCyCJgK+GIPMVfi4r+wqCpnuDto6usTd7g c6s9p9J+3LbNvg8WOm4zyYHGvh8jewe1mL72SsPUIshHYxMk98XR8shhuLCDsbOjgfk0aBM//GUV+ yI7NjxBKakZ4iuj+g4vgVlBNzBh/4rAHzJbyJdRNWuL0YTQq2djilIkSlD02h7VXY0moo/0cMvQiV nw2n/V4ArJwFTsVHa51NN3ajwNPot1pvwtRH1wXRkDVgqBKxeuNwn+Hy+kq1C4/ftCdbSsSBXnUeb hqALEWnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLXbg-007S0r-MW; Wed, 01 Sep 2021 21:17:18 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLXZ4-007Qga-DX for linux-arm-kernel@lists.infradead.org; Wed, 01 Sep 2021 21:14:35 +0000 Received: by mail-pf1-x449.google.com with SMTP id g2-20020a62f9420000b029035df5443c2eso452492pfm.14 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=syWt50wKc0o9G1bOX+mz9dTOkWWA782dJfyaK/usbLTGF0jGv2XtuiTUg90xYLSs2q yGGz1GnZbHAx+azW7YnPZJb4wMGvdX9DlvGZT9xZb0ImwUlRkcBNe3YByV6k6e/pmiS7 OJ/ojR2CJIGGZsTuk01nOkIjCF2uwrYP7WqdwIpaOGwynmKOZWO3PQuT/BMVMj6/Zwkh /e6DyEU3FVfHqnkq5kqyCS9VxbHtz9JLtLwZPT7mVAUtVoYWQCBmUoCQaD2c9Ops21T/ xODwfvGhoEoYLnVlsuDhJ3eSRDJJtvoBhnX0xn/a5jXofju46JBsbU+0EMwtctZKgukd SdEg== X-Gm-Message-State: AOAM531ItEMtryYiS1lAbY9Ugser041B7GgLM7ZDRw6BdzoGoyZwU96p d6Vf7qD5/DLm5TMSXIH/zG5wNIw1DJXv X-Google-Smtp-Source: ABdhPJzfQCQqY7ZDdEh40WA7Lnhk+LTL8HLswLGjRlSmvbVQ8MCEnZQQ9EpYsHt2TdSwBvGTdcslFJvAEGDG 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210901_141434_504592_0D8A257B X-CRM114-Status: GOOD ( 12.94 ) 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: , 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 */