Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1062003rdb; Wed, 6 Dec 2023 07:38:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGE4oXNIARPsK7Ta2LspvjHj79QNHIQiW/B/9FqhcvcSQO0qtIEVG17GTCK1IVp5Oirb3rM X-Received: by 2002:a17:90a:784e:b0:286:6cc0:8860 with SMTP id y14-20020a17090a784e00b002866cc08860mr783247pjl.77.1701877113022; Wed, 06 Dec 2023 07:38:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701877113; cv=pass; d=google.com; s=arc-20160816; b=r3MDZKrtr+EmYkZy5l/kCoajpW8O4AABxEcHL9HEH3GrbuvSs9Pxgcp1e8aUjZKqRk UZ0b7YKCnYXo19da2ZWdNNa614DqoJMWzYsmfXiHHPwRWs0d/7I24ouKIEWqELfeJrB/ QHJjqxjMBMCOtGEIEzh+l3Jminm+tt7SAxaCD2SyVojP5sJ/V70PCfw9EoK12Eku9eHv Z4wLzl9zR9XEkEYC5931G+XL9C+gGZjr/qr/Yrc+KoMJYehuLtEMv7Yn4aubuuKUwJPo cJmsx9JhAhyzI7RSEkPbZVOwI5JwYyepJDDM7NL9mcKQJ/s7444WnBE1N3NzKqWrFYqR 04gQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ENTAnW6Vnq/r2xFW1aroqscCPTf8UT4lD2uAoZy4FFw=; fh=hRnlz9zcjjwzOj/PRtP1cmpz7R92GIS6+kOUelhEKLs=; b=l/X+yFfFA6Zk9svwlr+tyiXUe6YjEqe/8m0QDthLU9Kd/XYDUMzuS6e4oPLRCy8prD 8Pjgg81IJhrq9MHfi1sxmKYxOxfzQvFrY/+XQBMMf9qg1xCvA6hx/xKlJExoH3g+juFt Tngaat4Gi4KNR+PGGe7tVHZPubMC5eghIWNvDeSaZgAoKHS13uBOhieiDddUhUaO4uLm vvJ8/IIDI1PYjvKKlxVF2+g4weR+ikmJQbJqx+MEfHfeD8Mcl0SjQMYrf2MNMxj2yaRm +WHfViN3kXJq3C+5JWOu9Us/Vq8vveZZ9BDVlH1SW8cbY/h59GhO3tCDEMxgeD3JG/71 K7Vg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=nscj9pEH; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o5-20020a17090ac70500b00286d8cf5b5dsi19744pjt.149.2023.12.06.07.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:38:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=nscj9pEH; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4DCB680D0C74; Wed, 6 Dec 2023 07:38:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379281AbjLFPiJ (ORCPT + 99 others); Wed, 6 Dec 2023 10:38:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379240AbjLFPiI (ORCPT ); Wed, 6 Dec 2023 10:38:08 -0500 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2088.outbound.protection.outlook.com [40.107.95.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37D139C; Wed, 6 Dec 2023 07:38:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lAokY4l41VZRgDr968TA5D42QKzb8CRL1jhTZ9p+lTzFGN/o5zAjtmU+DDm3xN9/tqEDAtVp+tBaOM8LSTyxWuG+Wu3jLfY7tv56QhK7V3eXmcmtkj4SEvBBw/wUY7myoaz71kazy4hm97oKi1s52a/QY+Yk7d1Ry2/bgeuiaRR8scR1jqxWlZPghDMHVTBjQn0vSF/UhwBzuDqPDMH/mSXF9OVJlkV6FJcFL5wcZGeB6Z8pY8SAaMlP4UYRRUPbQXRpve/lodyQStjwVrE7bIudxNcefCfmCwmcxrRLRz3MKqDLUZroo5hcS2pnaKqemOM8QiGkTxqszA/jvd/QQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ENTAnW6Vnq/r2xFW1aroqscCPTf8UT4lD2uAoZy4FFw=; b=cfBHvYZ95c3G7+81oJov8edRAEgzh4hT1kOu1UYvvYTV/ZaWmDdvCN4cMh8n43eKWEdpiW23C2SYPuVMMgnm2ww8i69im94ja7XvDsJJxo6rUHu/X8eP0hm/tQbDmyi24U/qRXtpn7RBjlT0sOXWR6mQ0nFiI69cFzQ2a0D5Q5/wCXx/417xPYBM0xMIKWebN6xOvSUCTuX0pihqJvUL2ABP9Igsqp6kzC1pFmAPYt2xL7iMW6yT9LdIizL00ele0/PDVQYWSHdmSNhMpai8AWXfxjIZA7dyhPpWV5E2BdQajRXRKTk6vVhv5kWXuyrmRnl6ahahL/SGPZOxgdBmjw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ENTAnW6Vnq/r2xFW1aroqscCPTf8UT4lD2uAoZy4FFw=; b=nscj9pEHRlUmXO4DkATXuGg2OuSOpCkaKWnB68Qb82YRK6suTgYlp/881sXCcw1aDRIIaRrnu0CU54rotmpaZdY/RrwwcMXaa8iLg9VioF1tJA1SnI4gyQ9QhqXBDHm2glRzi6HM0ao/Ih8BmCtIl7i2oPu/GqFesYm3Lb0Qcgxzwb+JkfgPSIlTrFbUfygHUhhDzwTqu32U7AvxAPiGkT+/E4AlIlTxXwGT+iCbOD9g5jqAQ2UsbBU3mdAY0oeYomekZR0D5wVvnAbqxr3zw6DLg2QWhW1x9OLiCbweEqZBdoTevaI6byk8+S7GFNumJeShbzMVDqXUI4Nf26Scsw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by MN0PR12MB5980.namprd12.prod.outlook.com (2603:10b6:208:37f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 15:38:11 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.7046.034; Wed, 6 Dec 2023 15:38:11 +0000 Date: Wed, 6 Dec 2023 11:38:09 -0400 From: Jason Gunthorpe To: Lorenzo Pieralisi Cc: Catalin Marinas , Marc Zyngier , ankita@nvidia.com, Shameerali Kolothum Thodi , oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, will@kernel.org, ardb@kernel.org, akpm@linux-foundation.org, gshan@redhat.com, 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, mochs@nvidia.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 1/1] KVM: arm64: allow the VM to select DEVICE_* and NORMAL_NC for IO memory Message-ID: <20231206153809.GS2692119@nvidia.com> References: <86fs0hatt3.wl-maz@kernel.org> <20231205130517.GD2692119@nvidia.com> <20231205164318.GG2692119@nvidia.com> <20231205194822.GL2692119@nvidia.com> <20231206150556.GQ2692119@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0417.namprd13.prod.outlook.com (2603:10b6:208:2c2::32) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN0PR12MB5980:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e0269d6-9c44-45df-ac23-08dbf67159db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iDOnXAwpqddZLot1dWOzy+487PRaQjISHFfmhM6ex2XbRWK7h98yeNHils8oSDPXR0j6gg94IEdA5hCf+aZyBb72K7qMlGS61OjyOlEr8rwXY6tWS2OyyL8P0P94NUJEwyp1tkqakJTcyxZvF3pNQQITFucCqTN1gnwZEZzrGZixW9OmlqNPp9wXJ8PPFACGope6bJEIOPj3bvRq3dEWjq+LgxtYJrtWgVTwkkc+UWUlQgI+ZWWIozA/4lk/5H1zMGBtjyTXTmMd60jj0Z2n5Bu9APr57PDIWwrByzhAJp1fFyoiBIacEzkR8+T3jOYwMKoUlAxDHjjGB6jaNRQDAoeDI8lExhXOjcFEAN08lUGTsOsNgYSxlM0X3ZWyaXrM49bgj/WGacwKKHU2JkJusD7IbNnMYGKCOJkelZ8l0LC/JbWA7NaVFsyOgPuOY7hwwVJ1/SUTfz4EpokExVl2mXP9tdNB2uwVYLYTlmErZvV0NEgb85Xie1/nqPJFcpAqvsAmINwHARCFKbHAFM0nbMEqO4a1dMLj0eoRx6RtCmvW4zT9W+uiSD50DZrxZC8z X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(136003)(346002)(366004)(39860400002)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(6486002)(478600001)(5660300002)(54906003)(66476007)(66556008)(316002)(6916009)(66946007)(8936002)(4326008)(8676002)(6506007)(86362001)(83380400001)(36756003)(38100700002)(41300700001)(33656002)(2616005)(1076003)(7416002)(2906002)(26005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JORLi2ffC8OvRHrCOQsfR48giCBrxTh1nAXoh8q3ZyTRf5k4hDVnF/G0+/A9?= =?us-ascii?Q?HAvSkw6viNhy7XYISxzrSang2DG/tP+2zFy9bncxngzTrPB5WE7hD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wqiBFYMT+xuSaBIPlSHqdG1DXaE3P2qvwlGcfRAWBLcurF?= =?us-ascii?Q?sa2MO5o7NC/lC33xqT678ImCa0L3zlrKI2Y+ynKTykwjW6FUb0/9AaG2s0Ux?= =?us-ascii?Q?aZ0nDWf2LKol0HFOeHMRPekHIYI++r1r1zj2Z3bPxS8YSYhuY+RCwrNUbGv1?= =?us-ascii?Q?kaHicVoqoQY1QcDzgyf5nsxL1Cx15h1EQYd0jbarfBOSrcoBF+20WBQM1xFE?= =?us-ascii?Q?07/l4BVf8h8ldqscWImlSxARuM/SNdPdgWehroQEh8tqbEPHcFH98fCQvpDD?= =?us-ascii?Q?yFXueTMiD5q619XC5Ccvyv2FBEPPagkE+e/eEO3hsUhf6G1SODziJ//mwWHd?= =?us-ascii?Q?UuY0KrgJxyBRuUL6sRxiSQS+ryv6pziz/Ro8jYiyfru6tAD0z5uU+pQH0t1V?= =?us-ascii?Q?FQ3ZEbUkAOZNq7Zm/QR5+mNpa5FBQ9jsXQPeTD39obOBbfSatnW+pjuSbd4s?= =?us-ascii?Q?SeW2RQ3NNZ5FUgaXXRkzHs7t0S3PvNtf3t+kv9aH1iplaiznNy0m0wiro+zc?= =?us-ascii?Q?REbtpwgusQBjrwKNGk8tTVHTBPRYI1A52RIZLy3bVeX/xvMDXt0KNo+5k7nH?= =?us-ascii?Q?biCeO0f6+vhaJajFHr5tqEvrLjkoSr2AXwIPbX8y?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e0269d6-9c44-45df-ac23-08dbf67159db X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 15:38:10.4246 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7Gfi/qvtE5jYIiXmCtzMfLFxaDxHTpVOmSKDAn+7jGPPQg0l0wW0SAbPVTUyJ4kh X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5980 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 07:38:29 -0800 (PST) On Wed, Dec 06, 2023 at 04:18:05PM +0100, Lorenzo Pieralisi wrote: > On Wed, Dec 06, 2023 at 11:05:56AM -0400, Jason Gunthorpe wrote: > > On Wed, Dec 06, 2023 at 02:49:02PM +0000, Catalin Marinas wrote: > > > On Tue, Dec 05, 2023 at 03:48:22PM -0400, Jason Gunthorpe wrote: > > > > On Tue, Dec 05, 2023 at 07:24:37PM +0000, Catalin Marinas wrote: > > > > > On Tue, Dec 05, 2023 at 12:43:18PM -0400, Jason Gunthorpe wrote: > > > > > > What if we change vfio-pci to use pgprot_device() like it already > > > > > > really should and say the pgprot_noncached() is enforced as > > > > > > DEVICE_nGnRnE and pgprot_device() may be DEVICE_nGnRE or NORMAL_NC? > > > > > > Would that be acceptable? > > > > > > > > > > pgprot_device() needs to stay as Device, otherwise you'd get speculative > > > > > reads with potential side-effects. > > > > > > > > I do not mean to change pgprot_device() I mean to detect the > > > > difference via pgprot_device() vs pgprot_noncached(). They put a > > > > different value in the PTE that we can sense. It is very hacky. > > > > > > Ah, ok, it does look hacky though (as is the alternative of coming up > > > with a new specific pgprot_*() that KVM can treat differently). > > > > > > BTW, on those Mellanox devices that require different attributes within > > > a BAR, do they have a problem with speculative reads causing > > > side-effects? > > > > Yes. We definitely have had that problem in the past on older > > devices. VFIO must map the BAR using pgprot_device/noncached() into > > the VMM, no other choice is functionally OK. > > Were those BARs tagged as prefetchable or non-prefetchable ? I assume the > latter but please let me know if I am guessing wrong. I don't know it was quite old HW. Probably. Just because a BAR is not marked as prefetchable doesn't mean that the device can't use NORMAL_NC on subsets of it. Jason