Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp640806rdb; Fri, 8 Sep 2023 11:22:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDUE6yRkcgrtAZ6vtAxtLNcnIiQ0RioAI33HpWk4KFg6PmTxqZ1iP+fxGI2f91MFjRjKUr X-Received: by 2002:a05:6a20:4305:b0:13d:2f80:cf1c with SMTP id h5-20020a056a20430500b0013d2f80cf1cmr3768350pzk.17.1694197374360; Fri, 08 Sep 2023 11:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694197374; cv=none; d=google.com; s=arc-20160816; b=eG53/WQprJ9mMrExORfbxPO2ccODpuINirBWsxIBFG8zmNr1OtUxI2mA6M1AinhtZ/ aHOmUkn0Q7+eML7aAGEnaON9sT5e7fapOivKhdcdo1W51NI+zuOyUo+YQPLMCTlbXxwI 86X3WjxB4vm9/EDvXo2d2wBatvF0MpO81ia3cCl1BMLyj80nSLJRy7blwW+Y/tLAnYh7 iaiuaFqP39LmF1lUK/TBI6ioNn0ybtRXUprhB37m68TQpd5KcbuiscIFuSYpe1c2uWEs PHtsA7RTk81vOopwzAHvIxhQNqiARSuQ1M6hQJ1yB6sKs39MN18wtIwU6urkriiRWejv /4Ww== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+vgyBAO6XQOCjTpZg6wM6Uk5bbh349a4G9/RkdB1VE0=; fh=xEudZGj8yMbtDug4JudiLZRtI4zHJ66jjC/dep8b53E=; b=yT2XX/EGZN7us4pWAMDgB8GBHIStnRvzMzVIdbd5GJNEiuaeWV3pVKYGA+dtyGiC5I gvvWO8WOM/SdCKrx+5p12UAJ8HdOElQ2JgWPJOrJtePA82j2SaGYda+3Mc/74OUDfdNc udaX144/VrsjhzLwov3HTX38MmdMcdcv8wnvm28dfpmWXwHNA98xWpRsLcX4kmPt1H/S hzrg1ZTjtp132JNklERtXJyyFdvWRhGt/CUvCN9pTz7byyB8NAInIgpmBxOC/Dd3smeC ZQzfvvoFMcBAJ8iYa50gi7VypnLZ1/YVRPrfAoW+JJkppcyXz49/oegd9sqEOZ3Gti5l EbjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w7-20020a636207000000b00573f89ac5a1si1759856pgb.102.2023.09.08.11.22.41; Fri, 08 Sep 2023 11:22:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242065AbjIHQlG (ORCPT + 99 others); Fri, 8 Sep 2023 12:41:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231775AbjIHQlF (ORCPT ); Fri, 8 Sep 2023 12:41:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C68D199F for ; Fri, 8 Sep 2023 09:41:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4839DC433C9; Fri, 8 Sep 2023 16:40:58 +0000 (UTC) Date: Fri, 8 Sep 2023 17:40:55 +0100 From: Catalin Marinas To: ankita@nvidia.com Cc: jgg@nvidia.com, maz@kernel.org, oliver.upton@linux.dev, will@kernel.org, aniketa@nvidia.com, cjia@nvidia.com, kwankhede@nvidia.com, targupta@nvidia.com, vsethi@nvidia.com, acurrid@nvidia.com, apopple@nvidia.com, jhubbard@nvidia.com, danw@nvidia.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Lorenzo Pieralisi Subject: Re: [PATCH v1 2/2] KVM: arm64: allow the VM to select DEVICE_* and NORMAL_NC for IO memory Message-ID: References: <20230907181459.18145-1-ankita@nvidia.com> <20230907181459.18145-3-ankita@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230907181459.18145-3-ankita@nvidia.com> X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=no 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 + Lorenzo On Thu, Sep 07, 2023 at 11:14:59AM -0700, ankita@nvidia.com wrote: > From: Ankit Agrawal > > Linux allows device drivers to map IO memory on a per-page basis using > "write combining" or WC. This is often done using > pgprot_writecombing(). The driver knows which pages can support WC > access and the proper programming model to generate this IO. Generally > the use case is to boost performance by using write combining to > generate larger PCIe MemWr TLPs. > > Allow VMs to select DEVICE_* or NORMAL_NC on a page by page basis for > all IO memory. This puts the VM in charge of the memory attributes, > and removes the KVM override to DEVICE_nGnRE. > > Ultimately this makes pgprot_writecombing() work correctly in VMs and > allows drivers like mlx5 to fully operate their HW. > > After some discussions with ARM and CPU architects we reached the > conclusion there was no need for KVM to prevent the VM from selecting > between DEVICE_* and NORMAL_NC for IO memory in VMs. There was a fear > that NORMAL_NC could result in uncontained failures, but upon deeper > analysis it turns out there are already possible cases for uncontained > failures with DEVICE types too. Ultimately the platform must be > implemented in a way that ensures that all DEVICE_* and NORMAL_NC > accesses have no uncontained failures. > > Fortunately real platforms do tend to implement this. > > This patch makes the VM's memory attributes behave as follows: > > ?S1?????????? |?? S2????????? |? Result > ?NORMAL-WB????|? NORMAL-NC????|? NORMAL-NC > ?NORMAL-WT????|? NORMAL-NC????|? NORMAL-NC > ?NORMAL-NC????|? NORMAL-NC????|? NORMAL-NC > ?DEVICE?|? NORMAL-NC????|? DEVICE > > See section D8.5.5 of DDI0487_I_a_a-profile_architecture_reference_manual.pdf > for details. > > Signed-off-by: Ankit Agrawal From the discussions with the hardware people in Arm and Nvidia, we indeed concluded that relaxing S2 to Normal-NC is not any worse than Device (and actually Device memory is more prone to generating uncontained errors, something to do with the Device memory ordering semantics). For this change: Reviewed-by: Catalin Marinas -- Catalin