Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3492136pxb; Mon, 4 Apr 2022 18:43:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz5vfg93+Wo6bA0rybys6J6GFWNQPli5jyyk503GmQQRHPEifcrJxmFl/dEEep1U/oEi7U X-Received: by 2002:a05:6a00:1695:b0:4f7:decc:506b with SMTP id k21-20020a056a00169500b004f7decc506bmr1226317pfc.7.1649122985822; Mon, 04 Apr 2022 18:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649122985; cv=none; d=google.com; s=arc-20160816; b=gUpp0j7R37eTrIvaIDOXeDO9qP9kiH50QFYNr2xdYIzLjJcPTtqjuSiXdkzA3ZtCaK ntWTtS2dtg3Z4+GJFV/x1JCVntgdPsCbQBWY7y/685c1cM9K5ALNCRGG/2u3ew4N3jeE 5yCmkxIuFmCtX3kKro0L2cRn3moJhdAvm4d0XI4B1eKY26NOPxMQhijcHefrR8m7ARWv qq6KGVTlrzUIDmLRfpT4nciqzymSSnJDDMHBqGEJrNTchrA2+TptCQYCCnAuCWc83JJp JKDm43S4wqE+IbYyuCPc7Rx/2h0K2Fw+x6Fr0rJJHGSuhsxDepRTFLgxOegF8+P6w/Gl IFuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MxT81FCXQshI2R4WLW+dKqR+EAmXr4SXEbrPEsxLO5E=; b=I3rR0XvwjPf9buzktJdqL7bZvx0/aQllicfphdPml2CDlN9OQtcRqxJQIeR4G9bqdc RTMS1NJ3Pfwt6zoMIseGYkFlpy5doiFvcb0NH6yYg4Y6nkdP+8JXEE3jpCu52R3pR6Pd n3NWPHPkH+NUDVoONQnHTarTPFJExIjaXakkfWBCbTsdp6v7WHpQM4NrfRhCNgA2EeHG lQ0RMHYpa+K4Q8nVqTYAL2NRil62WBXUrVXVXPz6t57yWNOHIPggDU5ITIL7znjo3Io5 O5D5LhoFcNaj30NG9ChCkZ16bNarEmNtbdNHV1CmA76XI6MYYFtJ3JX6DBM9pN9t/zTd +BGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qoT/vNIg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f11-20020a170902ce8b00b00153b2d1653dsi11667506plg.325.2022.04.04.18.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="qoT/vNIg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 917F1939A1; Mon, 4 Apr 2022 17:41:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351902AbiDDJQN (ORCPT + 99 others); Mon, 4 Apr 2022 05:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351372AbiDDJQK (ORCPT ); Mon, 4 Apr 2022 05:16:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01DF13B3D4 for ; Mon, 4 Apr 2022 02:14:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C1483B80315 for ; Mon, 4 Apr 2022 09:14:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35C4BC2BBE4; Mon, 4 Apr 2022 09:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649063652; bh=NKL1EMyqM5qjBiWdcT5gUouD5/1b34+eJQzWDgHHZs8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qoT/vNIgOLQ06jEs199YdWMr0/J5wbhY/ICzffkk7/nQxqZybEI0cI696tgVBdcfL EKPcer4PgO2goyaXxILTEzk2vkWTKaj6sD+0Va4ckSoxtYIhr7EyOu7EuC1NTgr+8G DC+H2jkyXcyT8eGy05kETEuJPEyLu2UxGs//FwUCYU9RK3OnzXfJKgmsDad+QFMPcz ccuGhFopKlCT0o1y8xhLeYsajQjpdc1aEwm0whETvmtlpucSshlJ4IXXH0K/cAOXXq afrP12ojdhp/RUyKnuVudJW8qwj/WbG5Z46TFEhVC+7OcBxeJ6Saz/v97JRdmnQmzS ShtPfIUh9Ge8g== Date: Mon, 4 Apr 2022 10:14:06 +0100 From: Will Deacon To: Ard Biesheuvel Cc: Andrew Pinski , Mark Rutland , Jeremy Linton , GCC Mailing List , f.fainelli@gmail.com, maz@kernel.org, marcan@marcan.st, LKML , opendmb@gmail.com, Catalin Marinas , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] arm64/io: Remind compiler that there is a memory side effect Message-ID: <20220404091405.GB22649@willie-the-truck> References: <20220401164406.61583-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 03, 2022 at 09:47:47AM +0200, Ard Biesheuvel wrote: > On Sun, 3 Apr 2022 at 09:47, Ard Biesheuvel wrote: > > On Sun, 3 Apr 2022 at 09:38, Andrew Pinski wrote: > > > It might not be the most restricted fix but it is a fix. > > > The best fix is to tell that you are writing to that location of memory. > > > volatile asm does not do what you think it does. > > > You didn't read further down about memory clobbers: > > > https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobbers-and-Scratch-Registers > > > Specifically this part: > > > The "memory" clobber tells the compiler that the assembly code > > > performs memory reads or writes to items other than those listed in > > > the input and output operands > > > > > > > So should we be using "m"(*addr) instead of "r"(addr) here? > > > > (along with the appropriately sized casts) > > I mean "=m" not "m" That can generate writeback addressing modes, which I think breaks MMIO virtualisation. We usually end up using "Q" instead but the codegen tends to be worse iirc. In any case, for this specific problem I think we either need a fixed compiler or some kbuild magic to avoid using it / disable the new behaviour. We rely on 'asm volatile' not being elided in other places too. Will