Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2130397rwe; Fri, 2 Sep 2022 08:58:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6I1JypTWNmN1boCdRoJlglO39ctsWLuos4YNVCd4dWvdUk0phDl4PqygO83CsFbKQt+CPj X-Received: by 2002:a17:907:8a14:b0:731:2198:627b with SMTP id sc20-20020a1709078a1400b007312198627bmr28023263ejc.635.1662134288349; Fri, 02 Sep 2022 08:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662134288; cv=none; d=google.com; s=arc-20160816; b=Onh+cyZ/YOjidU1KNl1bCiEMnvTCgimhtBxKbd//CdaTPNetPhyDV9cHz+LTCybege ylwbXkacnD59JPvrAhV6ZnJW3H2hOcemgIDi0mE8z8bcEb1ET2qgIgLZsHWCgid2ghQx 0TO0cFRkgwy5sn7smFBqMIlKwqs/SwOu2AlwhnjxQLYc8sCWbNc2/TvasGb9zaP4bsnG tP+dtNufwbF4GRiBwBJ/ZQ1OWDwaEgaTPH0ybdWmH+x5yA8BA9p7AwPHf9AJ6/rr7oQL rRcXWttDgjmnlnxOLUvmR55K36fKIMkADHYI6Fzlcn16HotdhNpnxn9JPzH1ZMA75ALu 1WkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=r967+3xqVPhudTE78uCOHf8jHXOBDJf4mp/gbna5jUg=; b=aXa4SDgpvRlXkATf2swDt6x/jawOf+bIjebFUeWDvMHSf4wMH4/ipoXnC9IJ8PHI5U I2XjbR+X5HfMK0xY1p3szpbBkcDj1CVGERY4bQ1DcPcUkzhKyF0IxDZW+DsmnpMCQiiI g0HuT0uXR/VAo7tBtdu+cbtY50Ziw9ZGpbLAGovYLkhWSrUQ4R2K7xvfEDxCF4AxHRgF GmTO4x+8wAYPuVK6gnDpY60VN2sADSNIKHLuJ6gaXImOXrUnRN9NI2aT1v1Z3sDVuOZE pU1hS7zFhH52sd5qNJFsQJjbExkCyktPMPTS9m1sym2HXux+025CCIt0VzDu5hU+5JAg ojMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jRLbk8LS; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw31-20020a1709066a1f00b007316ac034a1si1943716ejc.831.2022.09.02.08.57.41; Fri, 02 Sep 2022 08:58:08 -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=@intel.com header.s=Intel header.b=jRLbk8LS; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237131AbiIBPjS (ORCPT + 99 others); Fri, 2 Sep 2022 11:39:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236633AbiIBPi1 (ORCPT ); Fri, 2 Sep 2022 11:38:27 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6851BE0FFE; Fri, 2 Sep 2022 08:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662132346; x=1693668346; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=WkkhMq7jUWQDxjct1eMk17xBl5izK88Vwv+Go0eqOMw=; b=jRLbk8LS8vs1mCFlWkwctJj5KNT1MhDJJqPVDTvnsChb5k3aB7/17C3v DFkHtVaHOM4HSVbTHQrkTWM77mlRlBjk1b/Vl79wUdvtOEDUzgjy/gxUf CFH1OvaeXrq+6dN8Oj5scsnBQv8VpTe2OTxoQUWNDbRQG5Wh/Vz/FtPu2 XNpZKIjguSTzBO8+a5FOjT8xmFQhXHJR3RUTp9Dgx57C1Xk+pwdmd4evG +zF9w194GlEn8IjlKuBz3FCm+Gwfmlg2Iqs5JQk8LxdtSXj6UjesPsxgf 7oykpm/dGDopJhjIzm7oNqFNYNYjZkTDs8afRxQ/lcpBb6KU08BAQToSE A==; X-IronPort-AV: E=McAfee;i="6500,9779,10458"; a="296782558" X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="296782558" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2022 08:25:45 -0700 X-IronPort-AV: E=Sophos;i="5.93,283,1654585200"; d="scan'208";a="642942553" Received: from tanjeffr-mobl1.amr.corp.intel.com (HELO [10.212.156.60]) ([10.212.156.60]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Sep 2022 08:25:44 -0700 Message-ID: <5d667258-b58b-3d28-3609-e7914c99b31b@intel.com> Date: Fri, 2 Sep 2022 08:25:44 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] KVM: SVM: Replace kmap_atomic() with kmap_local_page() Content-Language: en-US To: Sean Christopherson , Zhao Liu Cc: Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ira Weiny , "Fabio M . De Francesco" , Zhenyu Wang , Zhao Liu References: <20220902090811.2430228-1-zhao1.liu@linux.intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, 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 9/2/22 08:15, Sean Christopherson wrote: >> for (i = 0; i < npages; i++) { >> - page_virtual = kmap_atomic(pages[i]); >> + page_virtual = kmap_local_page(pages[i]); >> clflush_cache_range(page_virtual, PAGE_SIZE); > SEV is 64-bit only, any reason not to go straight to page_address()? Yes. page_address() is a hack. People get away with using it, but they really shouldn't, especially when it is used on pages you didn't allocate yourself. IOW: page = alloc_page(GFP_KERNEL); ptr = page_address(page); is fine. But: page = alloc_page(GFP_HIGHUSER); ptr = page_address(page); even on something that's Kconfig'd 64-bit only is a no-no in my book. The same goes for a generic-looking function like sev_clflush_pages() where the pages come from who-knows-where. It's incredibly useful for kernel accesses to random pages to be bounded explicitly. Keeping the kmap() *API* in place means it can be used for things other than highmem mappings (like protection keys). The kmap*() family is a pretty thin wrapper around page_address() on 64-bit most of the time anyway.