Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1131549rdb; Wed, 6 Dec 2023 09:21:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZxB6BVUw7Idw6zlj08ad/u6MCOADQ2o/uUADh9kHF+gdQoX4ru9XQbHFN1+cLaWwfMS0m X-Received: by 2002:a05:6871:3a2c:b0:1fb:706b:5160 with SMTP id pu44-20020a0568713a2c00b001fb706b5160mr1429535oac.111.1701883284789; Wed, 06 Dec 2023 09:21:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701883284; cv=pass; d=google.com; s=arc-20160816; b=QSxOwMp2aUbnIBV9yKosOAdK60Dvc2Pi02y15VhJDw57Vw2utpj0AfzbLv7BhEdSKT hosgQZXfPHzhy82letE+AdSUSOy8L3N8+5g5Eb1OsxJLPrx9wjZ1loc/HhyAmwW1hpgV pMiv88Qe3Csi7Cxr8naP4acM1/onavbdw3s8zKLM0c0/eRtsq5lMChabz0ETpRCb3+34 jdRXiuXqTs8GrquqaJq0ym2U+9xwSYhnfVqeS27fkQtMHP+xjF2afZXwNxF/wiY3pavU 2QL1tQVCAzRXDvfwzKTFymUTjcrK835oSqG0ez8uEQ7OvO7skK0w7ymrSW/VkxfDIyjw NIiw== 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=vVUE0rOnDjben9YuQw5c2i8NkkAISTFLCehfbKPtf9E=; fh=x5wuDVxvWGXhL6vdq3JKSA4Eu23vEnmKbmHajwWLwoI=; b=L0HmhyCd9Fav8xpBvWsPx+9R9uYuJrQgcn7F0vvfdmgHNlez2m/pnbzHl+kGYtSFlW IfB4v0rss8+NCkIYeYtmlGZ3ousw0qUHIbbQpz1kt5Dn2DPHLn8G1WLYjg+FtacKEjmd XNEH7Dbnl43UL/gGcNKTZsN1WQDtWYhBd8iHEVgGAh+eOD38zkL9EscLcFkwoP5yGcUY RsdIfWhW4WV25fN8uSIlBDj5guJz2W6dVjCThxoj5ko8ZPs8xm8uc4EJs2yiFMm/xZ2/ 7NL2T6hXbmnkTJZquwaBjc9ygWL1vPbj8NfMr+GP8uBXZAUNfxYjBC63C9XZcktiACtm nMrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=SHmA1xuR; 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 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id d13-20020a631d4d000000b005c201808430si201960pgm.120.2023.12.06.09.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 09:21:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=SHmA1xuR; 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 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 4DD5E80CFD4E; Wed, 6 Dec 2023 09:21:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442709AbjLFRUg (ORCPT + 99 others); Wed, 6 Dec 2023 12:20:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379796AbjLFRUe (ORCPT ); Wed, 6 Dec 2023 12:20:34 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2058.outbound.protection.outlook.com [40.107.212.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C7BD4B; Wed, 6 Dec 2023 09:20:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ihelwTm6uZRY/glxuvHh6aVPpBj9YeN/d13A94TA/CNoxfek3ZeC0fUaF7Moz3NwHlkHVg/0urMW+iGIUx7MmxtfOMnMY+OVzoDkwfY5S7q4DmtGsNwWPZs4Xsc0cxMt0x62W8VKfPaDUJcfjHW4V9/DswF9rQWturYGxnHwmmEq16skxBsXyycDXtiGOU3b+eaZ4Y10tfM0tLDDOlCmRdxDKOk82if4fZeZ8I1sjCivk3bnwJovTVCsNfJTKmlgdO9LwVHLHofThDBpsBOYtlgO+mtfRWrgZIeofmOUpxZ3NRpt695DTbgYPSmM79ajpqRUs8Una5SC968F8w7+Sw== 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=vVUE0rOnDjben9YuQw5c2i8NkkAISTFLCehfbKPtf9E=; b=kPDbHSm4KbYCTERVOavrY3DKEqbo/wyeAqt53ejGD9Se2e17y5PGCM+33vMRExsTxOB6ZHyU20XkS7locfPZ/fUTxQE+CLaQDbwSlq82Th+pyuVogR1wG1/lDYal7f1qQZFa6t4PpGjP5KJRpN3dseLdRAWhHK+fAq+Iuf2VoxuASLcd/o4UD73fNUlLSobAwhNR2xudlFisAtvRn6lvAu0qv10WZnOlV97M/03hThWRMoVyoKKfucf1K4Ym7BBzc8ktLBH0CwZMyiIHjh69cKaaRmtUYgwGZ1UwXvzI3U336L+nYsI67yP1G4BAdiXvWGE4eSLg3nVNQFDN+QlpVw== 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=vVUE0rOnDjben9YuQw5c2i8NkkAISTFLCehfbKPtf9E=; b=SHmA1xuRZmyhT6JWsScdIgDODdM25YLAWciAsgwByPSThCkBm5ycX6XyIfx3cbnJ1OlEE2x89Dk7A6KfN8teBtW3u30wNqKoRlPhAgUQFINgmr+g8Cqchc+3tZvddU8HvEqWkHdiv+fxAYzJxNtPS4GLfTgGuI8+H+wogqjZfycCov725Le7jxRQ39BQBE/HqdlKa6lMxYgDxe9tqhtJNFHUjhRpHIlqrIX2pq9BGF2vUIZcRGMFp2qz/vy/+YIJiQS5Krx1EYCD0eXTAgqvI2D6RY5eelMdEzfnrmFcuzcrzWWFzdI8Vrvl3qjuiSvHlQXBdhu4cG13Sq8Bge0q/w== 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 DM6PR12MB4057.namprd12.prod.outlook.com (2603:10b6:5:213::9) 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 17:20:37 +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 17:20:37 +0000 Date: Wed, 6 Dec 2023 13:20:35 -0400 From: Jason Gunthorpe To: Catalin Marinas Cc: 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, lpieralisi@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: <20231206172035.GU2692119@nvidia.com> References: <20231205164318.GG2692119@nvidia.com> <86bkb4bn2v.wl-maz@kernel.org> <86a5qobkt8.wl-maz@kernel.org> <868r67blwo.wl-maz@kernel.org> <20231206151603.GR2692119@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: BL1PR13CA0109.namprd13.prod.outlook.com (2603:10b6:208:2b9::24) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM6PR12MB4057:EE_ X-MS-Office365-Filtering-Correlation-Id: 085ca220-403a-46e2-6cb2-08dbf67fa9a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +EbR6enDrIhiuG4mxoYJMPudX42UP1jRXkAhPX60Ec7FWTX0hnn/QuYUzeX5hXM97rzZWWG3K5bW33jBbO5AuDNgxrWgUQYsjjtDyq9Eht1cE+msy2LrchLkjjfEjgnx3jEAuz9NAW1wP4ExD/0N3sIBt9/RXmjgSr54Xpm9rC5nwQeXp1mdwvyOqchMwgDkMYrKP3oxAUDqwNr7GAzV4Q6qrpgIpsMpT4/KS08aElt+7t791bqvn3HcqpuaptQWVmplmvTDWj2+jXtDgho6i8NJ2GmGXvCrZ1bU7WwX7pqQXK7GErAhHejrY04X8TV1BBAVHjiMQAI8NWCiPx4NJSXAn0phkTbRgfjabiw849DgA2OcyErYHOZHiiLdadOUIZr6D3eLN3OtW7BcPAvOQfuMBUkL9zoYTqbGSnNhJdSgZv27kZIGxwu5qyoUKBJW9qJ7jtyWsHBt7TNtUje0gnv9f9W0wAL42I88OLLo9gg1sN9/F+V9eVFOs98jNxw/49S1wk0Ixi3bW7baazC/tRK7MvAvYN162PjC+6y39129sXg8QumBFrdyTAzkHdMx 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)(39860400002)(396003)(346002)(136003)(376002)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(38100700002)(6512007)(6506007)(6486002)(478600001)(54906003)(66946007)(66556008)(66476007)(316002)(26005)(2616005)(1076003)(4326008)(8676002)(8936002)(6916009)(5660300002)(2906002)(7416002)(33656002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?kBVnosITWAeDzgtSXO9TxTToBRB30CpIaElW/4IeCcn18Pex0eicT+qF3hqG?= =?us-ascii?Q?B0MCnJK88LZXw62bWoq7dRzzQT5liNnBpyO7oeMNiJnpeQO37r7mKHTYBBt+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iso81s5udxlsp4pqVJny7EpwFON05603V63ljP1kAHkZ7?= =?us-ascii?Q?lanIoi2vhXm44e88Hl3S1U4E/J9elhyMRs+NJOFqUKCuWbYot3oRPvyIg1KA?= =?us-ascii?Q?Hu9fdlz8vbVDTT5Svp5OQqlgyUl9zpP9KhHUGbyDqvUBsmTeKJsjQcySmaPs?= =?us-ascii?Q?D5dygoyVdk/f8mv0OQzZhsD8a5vP5bG9ZaqtyQsFX3qKuSDCFFAy+lkdc1br?= =?us-ascii?Q?7xHrlBbLqNPct3k54xaCvAzpN/3x50DIA4/avfsESxF41wMkhfFm5Peq6LNb?= =?us-ascii?Q?EQaoFlCPp4mtTEgCgF5JcOj78mxnyV26DRwx4X1OsySceixGY61XIFJwU9so?= =?us-ascii?Q?sRmvSTX1zJvfTDsUe7agpy8iM5K6o1ji20RWXB1Qc+kHO/1vpaun6kmq4zJQ?= =?us-ascii?Q?1KFG+wzrk2ApBF9JhdgQ7fGjRuAiPJQIavaCCP16U6gjcGxfvhhbMBAHCkNP?= =?us-ascii?Q?vwjndTQOCRreL+RvRf+MSHI0wotNA25lHSKdW0929tqisTj6PZA3+zYNSGGt?= =?us-ascii?Q?g1OIR28G5vp0BsvPbitBIzbBX/tStzjmVSANVOLRwx5ry2zcDYZJy6cuWdue?= =?us-ascii?Q?iCnyt8PvIlrUvI6EA1BgFnBFvTJpbr5rACiBd5YU?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 085ca220-403a-46e2-6cb2-08dbf67fa9a4 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 17:20:37.2119 (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: zDs2OKmci2tMSCfZ8bA5Lyc4+ta19BSfiU3OF/OMxVJf8FpcQ+W1n/b3fXod96Rp X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4057 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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 06 Dec 2023 09:21:17 -0800 (PST) On Wed, Dec 06, 2023 at 04:31:48PM +0000, Catalin Marinas wrote: > > This would be fine, as would a VMA flag. Please pick one :) > > > > I think a VMA flag is simpler than messing with pgprot. > > I guess one could write a patch and see how it goes ;). A lot of patches have been sent on this already :( > > > If we want the VMM to drive this entirely, we could add a new mmap() > > > flag like MAP_WRITECOMBINE or PROT_WRITECOMBINE. They do feel a bit > > > > As in the other thread, we cannot unconditionally map NORMAL_NC into > > the VMM. > > I'm not suggesting this but rather the VMM map portions of the BAR with > either Device or Normal-NC, concatenate them (MAP_FIXED) and pass this > range as a memory slot (or multiple if a slot doesn't allow multiple > vmas). The VMM can't know what to do. We already talked about this. The VMM cannot be involved in the decision to make pages NORMAL_NC or not. That idea ignores how actual devices work. Either the VM decides directly as this patch proposes or the VM does some new generic trap/hypercall to ask the VMM to change it on its behalf. The VMM cannot do it independently. AFAIK nobody wants to see a trap/hypercall solution. That is why we have been exclusively focused on this approach. > > > The latter has some benefits for DPDK but it's a lot more involved > > > with > > > > DPDK WC support will be solved with some VFIO-only change if anyone > > ever cares to make it, if that is what you mean. > > Yeah. Some arguments I've heard in private and public discussions is > that the KVM device pass-through shouldn't be different from the DPDK > case. I strongly disagree with this. The KVM case should be solved without the VMM being aware of what mappings the VM is doing. DPDK is in control and can directly ask VFIO to make the correct pgprot with an ioctl. You can hear Alex also articulate this position in that video. > There was some statement in there that for x86, the guests are > allowed to do WC without other KVM restrictions (not sure whether > that's the case, not familiar with it). x86 has a similar issue (Sean was talking about this and how he wants to fix it) where the VMM can restrict things and on x86 there are configurations where WC does and doesn't work in VM's too. Depends on who made the hypervisor. :( Nobody has pushed hard enough to see it resolved in upstream, but I understand some of the cloud operator set have their own solutions. > > We talked about this already, the guest must decide, the VMM doesn't > > have the information to pre-predict which pages the guest will want to > > use WC on. > > Are the Device/Normal offsets within a BAR fixed, documented in e.g. the > spec or this is something configurable via some MMIO that the guest > does. No, it is fully dynamic on demand with firmware RPCs. Jason