From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 EDE6EC432BE for ; Thu, 2 Sep 2021 13:23:34 +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 B371D60F42 for ; Thu, 2 Sep 2021 13:23:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B371D60F42 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yvzhC2zE4N30tGlUbYBcIilC3Ne8tAukkz0KvNLna58=; b=lejxJD9RTI3cTX 0zJP5gA5ZnlNTBqnGXrfuqoZoQN26MrGZZX5Z/GHEBKRXXKLcI1qxIXQMYJyTVHh8RHHasTforJUK CKKNHZwjXhIarTq2uDoVSPU/QcFbynvwYt2QhTsbMA3waZvlO/gp4psklfM/mqcxTLlTLfFzDLdmW us5hvbmcHLzgIfOhn2wV4q6dwhEkvfeNE4DIbIqGFkUR38G3DvYv5yLTpkEEugHQHezoWIdXZMX9n x5i3pMRGbUbfPo9afiDJmdTQ+c0wolk/rbPxeVQkETEFQUH5yu6VqFYSCShDov/DPO6aG3OXR/Gl/ sZAULqOzC+cnZ0WkSwrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLmeo-009gnS-Q2; Thu, 02 Sep 2021 13:21:30 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLmeg-009glx-Nv for linux-arm-kernel@lists.infradead.org; Thu, 02 Sep 2021 13:21:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630588881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6tJf5xIvKDCnRwuvzEhUuuc4fd9eQkxx1PjNi93Vu3s=; b=CXT7bYZT8N08NW3VaWxi1vEmAQqmj805uPjf2YTKUH9fBj8zpB2CJX4d1jvb9AwVUiMUQg qvMzKNInRy25FbXKgOocNVwwmKiVoivRgz9BcRa8wGUpNsoidOogplWtllcNevU3+4gcVi dRohzDUZuAnZVI5m+cfBKvX5kZnEEXc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-GnrhVqPKPp6zvPFtVgV_qQ-1; Thu, 02 Sep 2021 09:21:17 -0400 X-MC-Unique: GnrhVqPKPp6zvPFtVgV_qQ-1 Received: by mail-qv1-f69.google.com with SMTP id e14-20020a056214162e00b00375ec21dd99so1475079qvw.23 for ; Thu, 02 Sep 2021 06:21:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6tJf5xIvKDCnRwuvzEhUuuc4fd9eQkxx1PjNi93Vu3s=; b=lvY5M1+LawhWgAY6HeWaPUOlfKPPJZUi4Im+O/+IH6BxaMr39pppWPM0wOIie2Jm2T 5wE8GracD6RcwXSyJs6LCULFoARItTRoRluLSiktlZAzly70D7skVSlH25/M58cTn+il VK2Bey+mvRxm9ZC/yU19OycoNaVVugm4WycsMSprHR+aiahuAZ/4RViyeXGqsOGNzvBP 3p1B7zu9pBv7iFVdljeJwTLYCQHgDlPnvwQyHFRvkYiR3xhzmvgmLllwMBUCsT45XDq2 2Vl2on0L61X+EnzpfjiliukEt4dvfhQuHdZcAwU9kDhX8YGODmKg8xs9np/ZIk/07hVv 6mBw== X-Gm-Message-State: AOAM532l+hIhoUVZbTwbzjBpU8tu3F4QhsaARMuQeR5v9uLVKd1jRemd NQETGOUOZtw190VZmsthcnQu7xCiASVTTEI5jfQq/61VL2odOp6jTiN4562XKVM3fxOgn1ECWa2 jifMbbSxPQxildTwkga+WfJuo6uG3lJXOr9s= X-Received: by 2002:ad4:562c:: with SMTP id cb12mr1587966qvb.6.1630588877098; Thu, 02 Sep 2021 06:21:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG9JfvU8t2EsYROxxRPXPNKTs00M8PoYMUrrQVfghePFKxWKnhmt6JBf3fCTGn9rsZbouzrg== X-Received: by 2002:ad4:562c:: with SMTP id cb12mr1587947qvb.6.1630588876898; Thu, 02 Sep 2021 06:21:16 -0700 (PDT) Received: from gator (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id g8sm1319814qkm.25.2021.09.02.06.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 06:21:16 -0700 (PDT) Date: Thu, 2 Sep 2021 15:21:12 +0200 From: Andrew Jones To: Raghavendra Rao Ananta Cc: Paolo Bonzini , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , kvm@vger.kernel.org, Catalin Marinas , Peter Shier , linux-kernel@vger.kernel.org, Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 01/12] KVM: arm64: selftests: Add MMIO readl/writel support Message-ID: <20210902132112.yyz7iiqims3nlmmi@gator> References: <20210901211412.4171835-1-rananta@google.com> <20210901211412.4171835-2-rananta@google.com> MIME-Version: 1.0 In-Reply-To: <20210901211412.4171835-2-rananta@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210902_062123_024774_7C2E77A5 X-CRM114-Status: GOOD ( 22.74 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 01, 2021 at 09:14:01PM +0000, Raghavendra Rao Ananta wrote: > Define the readl() and writel() functions for the guests to > access (4-byte) the MMIO region. > > The routines, and their dependents, are inspired from the kernel's > arch/arm64/include/asm/io.h and arch/arm64/include/asm/barrier.h. > > Signed-off-by: Raghavendra Rao Ananta > --- > .../selftests/kvm/include/aarch64/processor.h | 45 ++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h > index c0273aefa63d..3cbaf5c1e26b 100644 > --- a/tools/testing/selftests/kvm/include/aarch64/processor.h > +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h > @@ -130,6 +130,49 @@ void vm_install_sync_handler(struct kvm_vm *vm, > val; \ > }) > > -#define isb() asm volatile("isb" : : : "memory") > +#define isb() asm volatile("isb" : : : "memory") > +#define dsb(opt) asm volatile("dsb " #opt : : : "memory") > +#define dmb(opt) asm volatile("dmb " #opt : : : "memory") > + > +#define dma_wmb() dmb(oshst) > +#define __iowmb() dma_wmb() > + > +#define dma_rmb() dmb(oshld) > + > +#define __iormb(v) \ > +({ \ > + unsigned long tmp; \ > + \ > + dma_rmb(); \ > + \ > + /* \ > + * Courtesy of arch/arm64/include/asm/io.h: \ > + * Create a dummy control dependency from the IO read to any \ > + * later instructions. This ensures that a subsequent call \ > + * to udelay() will be ordered due to the ISB in __delay(). \ We don't have udelay or __delay yet, but I assume they're coming soon. > + */ \ > + asm volatile("eor %0, %1, %1\n" \ > + "cbnz %0, ." \ > + : "=r" (tmp) : "r" ((unsigned long)(v)) \ > + : "memory"); \ > +}) > + > +static __always_inline void __raw_writel(u32 val, volatile void *addr) > +{ > + asm volatile("str %w0, [%1]" : : "rZ" (val), "r" (addr)); > +} > + > +static __always_inline u32 __raw_readl(const volatile void *addr) > +{ > + u32 val; > + asm volatile("ldr %w0, [%1]" : "=r" (val) : "r" (addr)); > + return val; > +} > + > +#define writel_relaxed(v,c) ((void)__raw_writel((__force u32)cpu_to_le32(v),(c))) > +#define readl_relaxed(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; }) Might want to explicitly include linux/types.h for these __force symbols. > + > +#define writel(v,c) ({ __iowmb(); writel_relaxed((v),(c));}) > +#define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(__v); __v; }) > > #endif /* SELFTEST_KVM_PROCESSOR_H */ > -- > 2.33.0.153.gba50c8fa24-goog Reviewed-by: Andrew Jones Thanks, drew > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel