Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2084945pxu; Fri, 9 Oct 2020 07:35:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFHIbW4Jb746DhdsvXdiakIcjJE+9AKIgybDtO54EXenwDcD2+RI72q1rxJQwdwAKkXa2t X-Received: by 2002:a17:907:429f:: with SMTP id ny23mr14183270ejb.150.1602254156368; Fri, 09 Oct 2020 07:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602254156; cv=none; d=google.com; s=arc-20160816; b=bcMz+ksjhQ+ygg5l0kBjtU6ELRwVU5Z4A+0Ksmuq2JO4iszEjZqFThcsMmZ1/T3Vf2 IvF87eekIWefZD243Rw2GQNBte4vk85ZwsgU8Dr3f1syipimMw/wMrVcPTF6zkk/4Eat bgHeze4jvoJBz1LcnzKKWJk8G0e2YrGxxT9LEo3jPMzVarClB4QObIw9z/fl0W0z/fi8 OjpatTLMqFf2+hawGtfOOXXnFrCiSx0I2gue3UUakkXe7HC9zftnt2Qcanpg4FMU5d0A pNhcgF960jx1yPivLHua0WkF8VfRTXAK3yC1DBdqhbmP4P7rtsefkLYZWDF47nEqin0i Z4dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=73DpVirPZ06c1n2mkJSkENlUc+TenafPYOh6N9YsRj8=; b=0xX3LN4uoyHxI96u9NRxQnDB1hJSAQAwOLgW+yW55xcQGG2jl054/za8aKl83Lx16A MyH/I888S424AENIVODfksN53Bqj8s3aiRzfUybo9Y/iLdA+HdbglnpCaW3lUOiR6JHI H01bWrjPYn9zn7E56MfotnU1qCt2ltweb0c8eLj/OnmkPbWUIEqMumBOSbhQujqGsuVw Tt/ZUzBebbB1ClRC7GKGKFAq20T12USSJ1S1Fx27SRr4aCD/OMp+HM5qvy7jmu6TTExB OFhFQLBQ1SLlVjGGx7JREEseqzsZuJk/Qvi6jjkNDlHLt1miCili1QGGV7Re47CDn50s BK8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=j3fuCopb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m23si6213621eja.217.2020.10.09.07.35.32; Fri, 09 Oct 2020 07:35:56 -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=@ziepe.ca header.s=google header.b=j3fuCopb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389060AbgJIOcf (ORCPT + 99 others); Fri, 9 Oct 2020 10:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389023AbgJIOcL (ORCPT ); Fri, 9 Oct 2020 10:32:11 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70616C0613D8 for ; Fri, 9 Oct 2020 07:32:11 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id c2so10710806qkf.10 for ; Fri, 09 Oct 2020 07:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=73DpVirPZ06c1n2mkJSkENlUc+TenafPYOh6N9YsRj8=; b=j3fuCopb7iniyL2y53HSklILSjdWqx7XXY5J7anSdWIzVAS51yHUg1bH+xWsQqV3an hVaIqQtPYG5XhAZxJubl7tnA+2dzIyrb1eABP/rsrrjt9Ddzi0d1WmSuwF0UQqwD1tgr 69SltM6wnxkhZu8y4olirPc3PCASUILXSC5ua6+ynVuzP7VwBBECaBlnoZLOtcJNGGyr NOkdDPv6Ux3fvUs6FlZoAKLjSdk3YJbxq2oDe3QQYv1fkcF15D+45H8TBvKAbi8SeVAg F1hEOalHcniDpc4tE9aqUhgdNW4MqmHYSXYkxAhz5TsGfdhszvZtn/5ZEIEGhUQjLvR4 psaA== 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=73DpVirPZ06c1n2mkJSkENlUc+TenafPYOh6N9YsRj8=; b=Rx17V6HnU4/1rxXiqNXGEFxAvEm3X1QyxDopM89SM217OxKERBIyvNbRMUJP/k33KH NoSUzpXNKfT+zo2RXFyau0lDExjCScqAWzFXLbLSMW2Wp8FrJwMTdjEv9oX+eeFUsKsI wwufqvAZd+OJIyHNCIuGOffxbt1k7sxA83eywskpTCJThUbtGBoqpeHKAC4WuYC1RaKx xfX/TkorGR55JGfwRFtz7msFpur1koeBxlzYUUrMLz2ZulzvAhiAvXbR8FSko8UfJ0p5 tUGRSjUzjGuI3tezfVBXvlZ36KWwwmC6DWCoUujSduI2HRGaHKtjTww6JvW/fDD9BYuf IvOw== X-Gm-Message-State: AOAM533oWdteM1yrLWj/cCRvu8wF5jbPAMqhQ4ASplf8aKgFPrL8UCDe 7dKkqFiLs+5BcKL9V/TSHo/pNA== X-Received: by 2002:a37:4d95:: with SMTP id a143mr13781409qkb.248.1602253930622; Fri, 09 Oct 2020 07:32:10 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id r64sm6400897qkf.119.2020.10.09.07.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 07:32:10 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kQtRJ-001zsY-G1; Fri, 09 Oct 2020 11:32:09 -0300 Date: Fri, 9 Oct 2020 11:32:09 -0300 From: Jason Gunthorpe To: Daniel Vetter Cc: DRI Development , LKML , KVM list , Linux MM , Linux ARM , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , linux-s390 , Daniel Vetter , Kees Cook , Dan Williams , Andrew Morton , John Hubbard , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Jan Kara , Arnd Bergmann , Greg Kroah-Hartman , David Hildenbrand , "Rafael J. Wysocki" Subject: Re: [PATCH v2 14/17] resource: Move devmem revoke code to resource framework Message-ID: <20201009143209.GS5177@ziepe.ca> References: <20201009075934.3509076-1-daniel.vetter@ffwll.ch> <20201009075934.3509076-15-daniel.vetter@ffwll.ch> <20201009123109.GO5177@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 09, 2020 at 04:24:45PM +0200, Daniel Vetter wrote: > On Fri, Oct 9, 2020 at 2:31 PM Jason Gunthorpe wrote: > > > > On Fri, Oct 09, 2020 at 09:59:31AM +0200, Daniel Vetter wrote: > > > > > +struct address_space *iomem_get_mapping(void) > > > +{ > > > + return iomem_inode->i_mapping; > > > > This should pair an acquire with the release below > > > > > + /* > > > + * Publish /dev/mem initialized. > > > + * Pairs with smp_load_acquire() in revoke_iomem(). > > > + */ > > > + smp_store_release(&iomem_inode, inode); > > > > However, this seems abnormal, initcalls rarely do this kind of stuff > > with global data.. > > > > The kernel crashes if this fs_initcall is raced with > > iomem_get_mapping() due to the unconditional dereference, so I think > > it can be safely switched to a simple assignment. > > Ah yes I checked this all, but forgot to correctly annotate the > iomem_get_mapping access. For reference, see b34e7e298d7a ("/dev/mem: > Add missing memory barriers for devmem_inode"). Oh yikes, so revoke_iomem can run concurrently during early boot, tricky. > The reasons for the annotations is that iomem requests can happen > fairly early, way before fs_initcalls happen. That means revoke_iomem > needs to check for that and bail out if we race - nothing bad can > happen since userspace isn't running at this point anyway. And > apparently it needs to be a full acquire fence since we don't just > write a value, but need a barrier for the struct stuff. Yes, if that is what is happening it release/acquire is needed. Jason