Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1330863imm; Wed, 17 Oct 2018 18:15:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV63foDK+AGwoTvH/2mTRytgatUI65zJMaeTUNDMnWHcDvlT8rd2YXomB1qcjOLZ32AZRWj2x X-Received: by 2002:a62:d808:: with SMTP id e8-v6mr15788796pfg.103.1539825354006; Wed, 17 Oct 2018 18:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539825353; cv=none; d=google.com; s=arc-20160816; b=gO8/RdUcXXfLkq0JmRYZDXk4fx/HZUhBJnnnf/BlvcmA+IjrmoYWCrKFtWu1DGfjG9 TewJVAW4/8p83gNwTjeYp1u8Y3c+/Ltzco7OStbCA0veM821qUEFcvb/Y4SA9rNUiYyP VQHybDCvfjnziZ40wsCpJ17tUGLkfTuqQPNLpHu+DZqrODLI4cbMrEYdvASFA+syd6gJ +8dQmV1r9bkR97XMCRnjjN32gWTpyYk6iIjFyIkZ97WcLfZXk6XzseaIITzCJX5/c7Zu 16FOGZJCrx2OL6/94NoB1TPURwPRSJ+2yrKKCGS/mRw9rGjrh2Yak0CyhS+MrJilZu0z 1aPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=aGuzJU80PFUHIskyAueEiEH4rpUPgJ8eZQqpuYFEm1I=; b=D1ztPsnTLn+8V6l3nJS59vKqfFT5MtrbbxglLyVDBdulu2+j16THuxxg5unxL9MXTh K2ZX35wBqQ0Nf4AR+USMZSkd69Ge8H/a3hX7Agr6N1KnZ7olDf3oJjec+szfadewAJFZ ex7qIdXTIGYOkPvqX62G5wlwaTc8ucaxevSHtJC+/B6NGnKzIsNUuk8vlMt2gmupMCtk juFVz/B4SBrJB5FLQWtuihOqbddT7MyI6UrYt4sOkuAUs+eHTHs737QAH5GTh04KddTE DSFrbUag2znMKphZk5lkyY2FB1GqeX2UiCHSuq275R0MALZNwTiAAZdomxD6DBNLka18 Sbeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ysrjk40B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d16-v6si19186190pfj.251.2018.10.17.18.15.35; Wed, 17 Oct 2018 18:15:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ysrjk40B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727245AbeJRJN1 (ORCPT + 99 others); Thu, 18 Oct 2018 05:13:27 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:44198 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbeJRJN1 (ORCPT ); Thu, 18 Oct 2018 05:13:27 -0400 Received: by mail-ot1-f66.google.com with SMTP id p23so28143290otf.11 for ; Wed, 17 Oct 2018 18:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aGuzJU80PFUHIskyAueEiEH4rpUPgJ8eZQqpuYFEm1I=; b=Ysrjk40B5o74rAN1O0ctn0ffD31V1ZJ8SgeerE16XK2YHIQ90RFo/QX1VHncxsurZB BCWXQoRCIwuyKMtl3cln1LGZICaNmzsSKqx3L8HXqmPAm/fzoIbGr0EkQsQfaRypPYmC 7hPNbDQwqr8NLrp0q1HodrrE83uWWm/NJNEApkncLqUlF5eUNwXGVmH/h7Vi9c8WKUtA /DaYade5/5NOtErqs8UWScrulmz7iEfFMbe3zElZZma6y33rb+2B/0Kt4AIPAafIPnqy JGZLrAi0psFlSPqHdzf2vXHdyeGO5ZkWHJ7ocdoiTZJ7fJ9TdZOVtUeDd9xH4StFD+uP Pvxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aGuzJU80PFUHIskyAueEiEH4rpUPgJ8eZQqpuYFEm1I=; b=WxVSYWm1Hz8sY0NyXBbpH+vExCmKPfBNCuo4ykTfi03QWpyM48en5j4snQmNlIBI8n iGAAeOl+6d6QkbWq4+DR7v8qsBZOC7RsZHD5FV1YMdZ9eFbP8rHdTIDBjIthU11PLJb+ MHv/ZEICHqDBAKBwMO0cHLMLGa1KZ4pDfbxhBrgocql6esVZKQy6NLaFJdWZ0rgLdO4g pXCwsnmKDKIRVQF2iwFmgRRJ7ae6SIsMmRd+06xscyeVmI3eoGFy9yZbOxIDB+s+y3Ew fcdWRBjZ+OKG6TEh0uQoSB2SeXJCPpI4Or6Ktnb654Q+l7JmG4Lx3w47t0fKuRl8Ifdo hTFA== X-Gm-Message-State: ABuFfohvnjqxOABWv9S6QzMZtAXRNaCwRbGPNZ7+rJ6Z7AYuB9WvURT1 FLLcwm2jnnquo2OEVCxVqNLsLdmP3f2FjWcI9Ecr3A== X-Received: by 2002:a9d:2117:: with SMTP id i23mr17274277otb.230.1539825301680; Wed, 17 Oct 2018 18:15:01 -0700 (PDT) MIME-Version: 1.0 References: <20181016235120.138227-1-brendanhiggins@google.com> <20181016235120.138227-27-brendanhiggins@google.com> In-Reply-To: From: Brendan Higgins Date: Wed, 17 Oct 2018 18:14:49 -0700 Message-ID: Subject: Re: [RFC v1 26/31] arch: um: added stubs for mock iomem for KUnit To: Rob Herring Cc: Greg KH , Kees Cook , mcgrof@kernel.org, shuah@kernel.org, Joel Stanley , mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, Julia Lawall , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Linux Kernel Mailing List , jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 17, 2018 at 3:28 PM Rob Herring wrote: > > diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common > > index 07f84c842cc31..72e7efb74f7fd 100644 > > --- a/arch/um/Kconfig.common > > +++ b/arch/um/Kconfig.common > > @@ -19,7 +19,13 @@ config MMU > > default y > > > > config NO_IOMEM > > - def_bool y > > + bool > > + default y if !KUNIT > > + > > +config HAS_IOMEM > > HAS_IOMEM is essentially a disable flag for lots of drivers on UML. > Ignoring drivers, it doesn't really control a significant amount of > code (albeit small amount of code you need for this series). As a > driver disable, it does a poor job as lots of drivers aren't MMIO and > aren't disabled. I think we should decouple these 2 things. Perhaps > get rid of the driver disable part altogether. We already do 'depends > on ARCH_FOO || COMPILE_TEST' for lots of drivers. > I think that makes sense. Any code that can build should be able to build under KUnit, but we probably want to turn that on on a per driver basis as we write tests for them. > Also, I wouldn't be surprised if turning on HAS_IOMEM causes UML > randconfig failures. Arnd does lots of randconfig testing and might be > willing to help check. > It almost certainly would fail randconfig. As you point out below, I don't implement everything that's required, just enough to show off KUnit in a couple examples. > > + bool "Turns on fake IOMEM support for KUnit" > > + depends on KUNIT > > + select MOCK_IOMEM > > > > config ISA > > bool > > diff --git a/arch/um/Kconfig.um b/arch/um/Kconfig.um > > index 20da5a8ca9490..8d35e0e2c23d1 100644 > > --- a/arch/um/Kconfig.um > > +++ b/arch/um/Kconfig.um > > @@ -122,3 +122,8 @@ config SECCOMP > > defined by each seccomp mode. > > > > If unsure, say Y. > > + > > +config PLATFORM_MOCK > > + bool "Enable a mock architecture used for unit testing." > > + depends on KUNIT && OF > > + default n > > diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild > > index b10dde6cb793b..9fd2827ab76d1 100644 > > --- a/arch/um/include/asm/Kbuild > > +++ b/arch/um/include/asm/Kbuild > > @@ -12,7 +12,6 @@ generic-y += ftrace.h > > generic-y += futex.h > > generic-y += hardirq.h > > generic-y += hw_irq.h > > -generic-y += io.h > > generic-y += irq_regs.h > > generic-y += irq_work.h > > generic-y += kdebug.h > > diff --git a/arch/um/include/asm/io-mock-shared.h b/arch/um/include/asm/io-mock-shared.h > > new file mode 100644 > > index 0000000000000..6baf59cb17a58 > > --- /dev/null > > +++ b/arch/um/include/asm/io-mock-shared.h > > @@ -0,0 +1,33 @@ > > +/* SPDX-License-Identifier: GPL-2.0 */ > > +#ifndef _ASM_UM_IO_MOCK_SHARED_H > > +#define _ASM_UM_IO_MOCK_SHARED_H > > + > > +#define readb readb > > +u8 readb(const volatile void __iomem *); > > What about all the other flavors of MMIO accessors like __raw_readb, > readb_relaxed, etc.? readX/writeX is intended for PCI based drivers > which doesn't seem to be what you are targeting in this series. > Those need to be done too. I just mostly wanted to illustrate that it can be done, and what is needed to support mocking MMIO. I wasn't sure how controversial my approach would be, so I didn't want to put any more work than was necessary for illustration without getting some feedback. > I think it would be good if this capability was not just on UML. I > could also imagine wanting to run tests on real h/w. Perhaps you just I think that's reasonable. > want to log and/or check i/o accesses. Or you need some dependencies > in place rather than trying to fake everything (clocks, gpios, pinmux, > irq, etc.). That being said, I'm not trying to add a bunch of things > for you to do. Though maybe it makes sense to split this series some. Almost definitely. I figured this patchset, as is, is a good illustration of what I am trying to do, what is possible, and the kind of work that is necessary to get there. If people like what I am doing and want more of this type of thing, I think focussing on getting base support in and then working on features separately is the way to go. > How many of the patches are needed to convert the DT unittests for > example? At first glance, just you probably only need the stuff in the first 9 patches for that. You don't appear to be doing any IO of any sort, so you don't need this stuff. You appear to depend only on some fake data; everything else seems pretty self contained, so you don't need any of the mocking support for that. So if I understand correctly you just need the base support needed for bare bones unit tests, all that stuff is in the first 9 patches. Cheers