Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp213865rwb; Wed, 5 Oct 2022 17:36:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5a40KohzNuqvc9yWRM2JgKRmk1NjVrzPRDqSC54YNL+lygzEQqKOOxrDzVTGg3DwFnc14R X-Received: by 2002:a17:907:2d24:b0:78d:3a06:c95e with SMTP id gs36-20020a1709072d2400b0078d3a06c95emr1793738ejc.9.1665016585243; Wed, 05 Oct 2022 17:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665016585; cv=none; d=google.com; s=arc-20160816; b=fa7zohJtqbUMrI7MOFcC1OhNig8WQ6jRJgQkN3jkNYtu+x1DAoxVkNRga0L+ULqBNK 33rOyn6XMIk44pn1SXhR669Yt/Zdufe3j+uZ4nZTdUJilIrMeik8KOMrnzFm7mb92siM /BBQHQTlQve6O+9bR1eOdeo3aOU+0WcpwLi+mxncafBMu6QFEBlijLdR4X6sRrjqmlqi dr5KK7T7U1fUYg+y6ypNUNqWgadr9zUF2fHJtgCa5E9EZrG2MbUeRaruNZBiaU0l2RgR 3UWg+koXdGMzBuqRCo4mT+e4H/Ye9Sb+Hu7rBq4VG0ckzBcFHRy74pb5GvFA1ZaQg4Mn snCA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NPRVzBaVZ9YyNu6FLenRmgIhaa2hp6qDkfP+CaVAIGk=; b=D3OhAz6U+7S3xYXWG+5eMWdDFpFC//xyMVyRANi5VUbYli9kyhgyu9yVaejeSJw0zV BhRMk9QchaHZmQjrLXJc88Yb9ERNzys+e6E8vwEnHIHDNihequuFo0BDan97j4SzjUEB Yl+Cw2R5qM6iwBFtA7PPHgg/puL0r/0TvxCB7a1qCh2IQwFwh8IKyzdd/GTnGn5Nhky6 daFB3emnOWpbVA3MXxcgWu60mYOv+75Iv5aSWZFaTZ2gXFrDfP/wtXPuzgbiBxKwC4K1 UbPbDYZ4Wzoe42EzS1DEHR8xMd7dXCL4C6lpwLPLIMs+TuTrJzdEDQMyAS9FP68XqRKI BTQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mXMNHH5X; 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=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xe9-20020a170907318900b007882926848bsi7307019ejb.818.2022.10.05.17.35.56; Wed, 05 Oct 2022 17:36:25 -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=@google.com header.s=20210112 header.b=mXMNHH5X; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbiJFAO1 (ORCPT + 99 others); Wed, 5 Oct 2022 20:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbiJFAOX (ORCPT ); Wed, 5 Oct 2022 20:14:23 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC0D3678D for ; Wed, 5 Oct 2022 17:14:22 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id t12-20020a17090a3b4c00b0020b04251529so186773pjf.5 for ; Wed, 05 Oct 2022 17:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NPRVzBaVZ9YyNu6FLenRmgIhaa2hp6qDkfP+CaVAIGk=; b=mXMNHH5XOl9a3BpyRf0OW6UGuW1+o3c6nzSKeK5JBv9QS9paVtX4nkcuw6ilwpO8M9 pTD6cSMXs+0UvLHDnlJ4F4/rsxZfru1+vLHH/UfKYRY2y1BXCwsA4cs2LCOCcLGbJ48t 9Dc0pS8GCk+589pZrnZCC4pCk77x7UkKvxioO7XEHs1YTrBJLoT2dwArISPIUhXvM3yY /ZF6wWLK/ghCYPh397SdcvDfclw+HCck00Nhaf5skY2HA/6pCZvNqKc8cj/29lGeZaGw JepT+QwpU9qas/Rpba6GzdH4qUD/MJSh/l10+RskCMaNwY0GqnMejOC32nh0dn/mtALK VWpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NPRVzBaVZ9YyNu6FLenRmgIhaa2hp6qDkfP+CaVAIGk=; b=UXJKnMYSk14EANtjzF/0Dl0XfSVAahnnMfAEXIFsXdb1OrP2msablRRH8fPbUmzH7L M6Y/tRbKytkglHiBGLlrykkC9EkevztvXao4Nl3xNX4L8OKrESNjrmZp4QdYm/tYAuvW j7ylvXTsIn3xc79eFKcUo8VLsoSAZBqt1UsRpWQYHKJnek1IgGq0s8JndVaAgVQ52w3p D6kiXIeQvRQ15hIglC/CEBtQAOo15Bt7JgZF06Jn0VM6MUjqT8bKfWRsHzslP50t8jI9 abNjV13MPftBBs9WW07f+ORsnIa81q0qD9tY8V6B5OYCdKeAyrCs4fQ/ZtYB74TaiuN1 5e9A== X-Gm-Message-State: ACrzQf0o3RWpJdbAw5eScascRcXzHyEZUQouvPs0y/rZNRT6N1r/We6a uEWIFyjhmI4s4SL6KjpS1pAZQw== X-Received: by 2002:a17:902:bd05:b0:179:bbad:acff with SMTP id p5-20020a170902bd0500b00179bbadacffmr1771135pls.170.1665015261532; Wed, 05 Oct 2022 17:14:21 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id t24-20020a17090a449800b001f8c532b93dsm1691353pjg.15.2022.10.05.17.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 17:14:21 -0700 (PDT) Date: Thu, 6 Oct 2022 00:14:17 +0000 From: Sean Christopherson To: 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 , Dave Hansen Subject: Re: [PATCH v2] KVM: SVM: Replace kmap_atomic() with kmap_local_page() Message-ID: References: <20220928092748.463631-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220928092748.463631-1-zhao1.liu@linux.intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Wed, Sep 28, 2022, Zhao Liu wrote: > From: Zhao Liu > > The use of kmap_atomic() is being deprecated in favor of > kmap_local_page()[1]. > > The main difference between kmap_atomic() and kmap_local_page() is the > latter allows pagefaults and preemption. Uber nit, I would phrase this as saying that local mappings don't disable page faults and preemption, which is slightly different than stating that they allow pagefaults/preemption. E.g. if preemption is already disabled. > There're 2 reasons we can use kmap_local_page() here: > 1. SEV is 64-bit only and kmap_locla_page() doesn't disable migration in Nit, s/kmap_locla_page/kmap_local_page For future reference, even better would be to use human language after "introducing" the functions, e.g. The main difference between atomic and local mappings is that local mappings don't disable page faults or preemption. Obviously that doesn't magically prevent typos, but it does make the changelog easier to read (IMO). > this case, but here the function clflush_cache_range() uses CLFLUSHOPT > instruction to flush, and on x86 CLFLUSHOPT is not CPU-local and flushes > the page out of the entire cache hierarchy on all CPUs (APM volume 3, > chapter 3, CLFLUSHOPT). So there's no need to disable preemption to ensure > CPU-local. > 2. clflush_cache_range() doesn't need to disable pagefault and the mapping > is still valid even if sleeps. This is also true for sched out/in when > preempted. > > In addition, though kmap_local_page() is a thin wrapper around > page_address() on 64-bit, kmap_local_page() should still be used here in > preference to page_address() since page_address() isn't suitable to be used > in a generic function (like sev_clflush_pages()) where the page passed in > is not easy to determine the source of allocation. Keeping the kmap* API in > place means it can be used for things other than highmem mappings[2]. > > Therefore, sev_clflush_pages() is a function that should use > kmap_local_page() in place of kmap_atomic(). > > Convert the calls of kmap_atomic() / kunmap_atomic() to kmap_local_page() / > kunmap_local(). > > [1]: https://lore.kernel.org/all/20220813220034.806698-1-ira.weiny@intel.com > [2]: https://lore.kernel.org/lkml/5d667258-b58b-3d28-3609-e7914c99b31b@intel.com/ > > Suggested-by: Dave Hansen > Suggested-by: Ira Weiny > Suggested-by: Fabio M. De Francesco > Signed-off-by: Zhao Liu > --- No need to send a v3, the above are all the nittiest of nits. Reviewed-by: Sean Christopherson