Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2769367imw; Wed, 6 Jul 2022 11:24:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u9m8NRcEX8B8yXyZp+ddZA1n6Afm9EJ/brJjBwJsCHSN18jrIbxePKwFgh/kAaigZCd0Y4 X-Received: by 2002:a05:6402:194d:b0:43a:82da:b0f3 with SMTP id f13-20020a056402194d00b0043a82dab0f3mr9354600edz.104.1657131883012; Wed, 06 Jul 2022 11:24:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657131883; cv=pass; d=google.com; s=arc-20160816; b=llLuQ0Ffm1jGyb7Rhu6yf1ERuQMYhz5QE/Xo4lD3ysymyWvuCyZxLyMcs+aKspTiSU +MoP6Dw15WJR5N7VxzYf4HrfsWQ0x7Xxi6gRyygi4Zwopcxmn17tM2Qykv70p5zE9Ald uCHjCsF7dTKVkPNay3oUwJbnJDNUzANxaYlyeozfuL07muSqAuB4KEiApKsLXMGOiMGe z2PdzLhLtHfXGM7jopq3keZTET1E9txDjvV0Pr8W85sbIBbcarU1Mv/c/Iv+5L6IbDaM 28lMwJzkAyFzG1TG+RAgTcEl1bvAQF95VXQDRV5Yd81YdF1LbIKGWjbaaYpVzQtXL/IH ikWg== 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=cqqCaJUTDwkQzINKh1omiIkhvxtSOljICtjbbMkdZYc=; b=rRZB5Z7OiA1vktQZ9MCSBSTUMc0ITqMX/9ScHJxPXCaOE27vvWDzTVvUGEgOuhNIga ZVOROpOy6HLYzfsVOcJLfX+3NrZF9tkd+HpZhMronrYvlnsS++NSUGNpghJZTNjB+T7p 6+CMTE+Z8okbTRP9Q8DCTTED0bTvLimvUXULUlpuqLsc93MkLKLftSgwlPVk0r8jW/HC NnJ2KRdm6fJEJo2krSLGjz4SG+a7P8L35xY/1RRX8hA6iOAwrrNkBWuEDNLYzkflej9W XsOnvztm/txk9lfPBwTYhHOl7bEcpo+fnUQhaTY/VMLgxc9Qs6gbMhZuJ20lYNuxW1Cs wMwA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=RkbgEhTQ; 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::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e15-20020a056402330f00b0043a6dd548ffsi3239041eda.202.2022.07.06.11.24.16; Wed, 06 Jul 2022 11:24:43 -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; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=RkbgEhTQ; 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::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232592AbiGFSRV (ORCPT + 99 others); Wed, 6 Jul 2022 14:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234059AbiGFSRR (ORCPT ); Wed, 6 Jul 2022 14:17:17 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F8052A272; Wed, 6 Jul 2022 11:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nD0mZK/iWrilnkplbeolFnPUtzot9Tq48dnUc5hnqqd46ZE7b21+ClT2hQin7nodsLpmRS9gapNJ4CoIW9NuySvUUIarwaBt5zgu6tYGlvfwEea6LiKy2gpMbcoFDt7WatDWn3hvFS7SALc07LObsXkJcMlhwhXNw6axr1wdXpgLNEy+Dv3PqkNEqnKe2szPJbp+a/H7hUNQzW4A9u6weKivC1iI26k8MwanbAkrRqRvamX2O977ecmPgGOsWmjUaOB3v/tHyP4owHQcJAt9lK3TnrAtrANQxoQ54twiuG906FyhmZIx0ONP3jAiz/QkbBGo/rMJ1Zs3V09FnzIu9Q== 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=cqqCaJUTDwkQzINKh1omiIkhvxtSOljICtjbbMkdZYc=; b=hCqzOAApaRWSvzsvuPOUXEKyyEer4Kur5uVoUosgduBsvj5/XeOE3TLtJWv4Y0DMpzG/47pQZMoMD6MT6mDyNj75+jmYHXr/v9ol9E7sLR5THp9Izp+BGXsCzXmyCCbY2z3Pn9nXifdJmC8UNANt4MGJmXEM/iI2vZJkCi8CgkXtc3ry/r77Sa48SR2PFfUSf8AVf1YCSd9qQ12NThXuayjXvvuPXe0Xs7ya88oaZVHIHSStPasGOZI2n1vSYdRqLgwE2PJAQvtYun3J3wchYPJv2vr03LgR47G9F0Obe6awbPbfFaUEKv3hG1aePGkZ4fpBF9Wx8oyyymzU5G9RHA== 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=cqqCaJUTDwkQzINKh1omiIkhvxtSOljICtjbbMkdZYc=; b=RkbgEhTQBgjXp0//QP2/R1wDlsDBSNH6WnZKv+kzKmuT92ZDD31wSt1wCwkZtpWCAQyD4Azn2dfmJL3//mO+/AscWhiii5n2Om5KSssUrbUIL6ZGnRPF65jcQ9zypRZa9ufrKxJBH3t8wLKMk0Shh4vZXEObMsEMn9+9Q+Y2nIFTeJH7NKbO2kF0tcxtSTE4TvXnqqm/4AiJnNp8z3ePbUAlTqkxZAfCLtKuSzr3PwezCZKUPFnW6htPWvyBdaXh3sE2J9x630NPkIY63NqBh8wjIEgBfW+WDKeRaVqakxDejAYoJp2O0hNAxn4PzQkN+SbzRZXd++tXE2+ryma/vA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) by BY5PR12MB4952.namprd12.prod.outlook.com (2603:10b6:a03:1d8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Wed, 6 Jul 2022 18:17:05 +0000 Received: from MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::ac35:7c4b:3282:abfb]) by MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::ac35:7c4b:3282:abfb%3]) with mapi id 15.20.5395.021; Wed, 6 Jul 2022 18:17:05 +0000 Date: Wed, 6 Jul 2022 15:17:04 -0300 From: Jason Gunthorpe To: Nicolin Chen Cc: kwankhede@nvidia.com, corbet@lwn.net, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, zhenyuw@linux.intel.com, zhi.a.wang@intel.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tvrtko.ursulin@linux.intel.com, airlied@linux.ie, daniel@ffwll.ch, farman@linux.ibm.com, mjrosato@linux.ibm.com, pasic@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, akrowiak@linux.ibm.com, jjherne@linux.ibm.com, alex.williamson@redhat.com, cohuck@redhat.com, kevin.tian@intel.com, hch@infradead.org, jchrist@linux.ibm.com, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: Re: [RFT][PATCH v2 8/9] vfio/ccw: Add kmap_local_page() for memcpy Message-ID: <20220706181704.GP693670@nvidia.com> References: <20220706062759.24946-1-nicolinc@nvidia.com> <20220706062759.24946-9-nicolinc@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220706062759.24946-9-nicolinc@nvidia.com> X-ClientProxiedBy: MN2PR13CA0011.namprd13.prod.outlook.com (2603:10b6:208:160::24) To MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f95bc4ff-7b64-414a-86fc-08da5f7bbaf5 X-MS-TrafficTypeDiagnostic: BY5PR12MB4952:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2bxRzMFuYYft40WJXyfzt0IkuKUb2W6CkHcVeeagcsTs8/UkPIJhTaBEl8O1AJMfbqOJg3cpeGkZx3gI2szskQIMzwyt4fFcqm8kHOr9nEGbKKYOQN9XInuszWPXSRef57gLqjcScNB0IHsYw5pEOkBB1J6i6xAQ9TPB+lk5UfRS7GuF18W3ie9+5IMQRDoPWdTXiOrtY+Oxg9boKZO/6i6UH+BPh+NExTqEdpwWjFRlrmpPRr2iWsMjCmofWZKNcStDDs8ycsFTHCf6+IKOxUeF0SWAxUP7h7TO8obSQ/tAZPlighgQ3rJ584Ark62mj4cIWe5zUBeWZrR/LGCXzF066UPoA0q5hIRngCL3js+I2y/mT7AfwhADARHsw+BkEm0HMcPkUf373NrlorgswSqKF7NdGQZNonLVJsJYLfdz9+9U2vq6KH4zQiZWBJil88ZFZg4JAeHDtcIReDFFLfPB/UWar0LLcUVL1mCaH6XdepIo9T34U6eYX73JMD+G0b+tjGn6xErea8yQHd9xRON72MWv73wPWrl/Tkwj4mkG0wxe7a1qsV2aOVSP+gpZ4ECCkHjXLJl/ZBQfI0VblhJpgjFhWGf/J1eEZ55BSZqW2JRnFXQ8TKSCG7aucjGBONb5mvc6AhfGGihfxA7eT2NMECIAo0X9UnFjDsasr+xgCj42JjjucYBd7BHhxRHjjycla5zhJ+AI+1dy+zVe1ztQT17ILTzGqLGMKoIHT7hFcq6okbfVj53Z6ZiEx5/yZXXBW1PmO3qI2SvHsFSyqsG7yHESOj9yYz0/Q7TvovXEQxEO6SfQv8gHR9AQFDYR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4192.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(376002)(346002)(366004)(39860400002)(396003)(478600001)(6486002)(38100700002)(2906002)(36756003)(2616005)(1076003)(33656002)(186003)(6506007)(66476007)(41300700001)(316002)(6862004)(86362001)(7416002)(5660300002)(7406005)(8936002)(6636002)(37006003)(26005)(6512007)(4326008)(83380400001)(66946007)(66556008)(8676002)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Ant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XuipJsGCD4Wlo+nSN9fFy/Ssz8U/INbJeth?= =?us-ascii?Q?14vk3iAxp6Baq9u7hPYeQjKnUMuYof+Fg/nwyMDyOSTcavDMieO2gegvqC8k?= =?us-ascii?Q?ugJJJSTDhnyf1PrQKcbTTHhGOd5hV1l+BhrGwAiuEXldi9VTovGXi8BO86a2?= =?us-ascii?Q?J8V/APElEnYOVpD8G80jckvZFC58djyjJ5Gt1c9XL7vKOV/ef/vHXkkEMA6p?= =?us-ascii?Q?sdMgTlyrmYMUCitcmUVJScnqc4/IVXd5kBtFSvS8tE13cpgmPtDqbC9kBTkp?= =?us-ascii?Q?ylikwLBxW7QyngWXxjwnj5InqZeQPC99Gk0WBVwTtYkcr7Rea5jBi1U53gwP?= =?us-ascii?Q?ujCBJyZo0tACXECoFdKdhPR6RTafIkGRrpnyzCBLvnT7hdK1ZRESfaZmR95A?= =?us-ascii?Q?KQeHbq74sUkqs9yeCLmdgOEG3it+pYLB7iqJ8QTV/Lm51L4j210r0oNBQx3Z?= =?us-ascii?Q?XK0VsxaOSwGuAGr+Lh2Z+AR8eHK0n7e30iHOhI0VFBTVswsMJuRfHqGJpL+s?= =?us-ascii?Q?obc1VyF8phOecCuFcV4xMdbo202FhqdDgDO7vWRIottkcaLHcfOsEerXlwwq?= =?us-ascii?Q?k8K1OCvuEDvCmscIzpcGzO/JTV5kH1RJzHyU7IIZoHMTqboq4akWZOM25q9K?= =?us-ascii?Q?YYIPndM/Z+c0yigTr7ox8EYtwduj5Yazolf4jkt5Qu2IP39T+FbsI6KPNQsF?= =?us-ascii?Q?DJROoXT8hGBDA9SENdb66Bl7G0HQFRtP/QevXP+M?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f95bc4ff-7b64-414a-86fc-08da5f7bbaf5 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4192.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2022 18:17:05.0646 (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: O3a+ZyPY2LJd01cSjVrtFF5jWPWm/L5Fn056qIPPu+4tBX7vzDUfK4Mn7/tBjEKq X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4952 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, Jul 05, 2022 at 11:27:58PM -0700, Nicolin Chen wrote: > A PFN is not secure enough to promise that the memory is not IO. And > direct access via memcpy() that only handles CPU memory will crash on > S390 if the PFN is an IO PFN, as we have to use the memcpy_to/fromio() > that uses the special S390 IO access instructions. On the other hand, > a "struct page *" is always a CPU coherent thing that fits memcpy(). > > Also, casting a PFN to "void *" for memcpy() is not a proper practice, > kmap_local_page() is the correct API to call here, though S390 doesn't > use highmem, which means kmap_local_page() is a NOP. > > There's a following patch changing the vfio_pin_pages() API to return > a list of "struct page *" instead of PFNs. It will block any IO memory > from ever getting into this call path, for such a security purpose. In > this patch, add kmap_local_page() to prepare for that. > > Suggested-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/s390/cio/vfio_ccw_cp.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) Reviewed-by: Jason Gunthorpe Jason