Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6077841pxv; Thu, 29 Jul 2021 06:04:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhFzsW6lCkAxwBkP6mlWAUrPgAhPA2Ol2kmOuLn7GUQ0ENZumOaB2E40lH5+W7uqdJp3ZB X-Received: by 2002:a05:6402:54f:: with SMTP id i15mr6078488edx.24.1627563849322; Thu, 29 Jul 2021 06:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627563849; cv=none; d=google.com; s=arc-20160816; b=ik47JuEuwkG2MracC67Qv/D+T7OF+xmIx5IhRLX9JlBLVjhifkb6c5kHMjQtGPQetI JKVFmQrevgthQSqRaTRJgdml00eJwePl5wL8V2kpVnIy072dfh7UQ29LQjs+aiGKTG8S KKYF96BgKZVa4O069AgjRbA5/6TX3bAGG8tmZaWvPmAq/nx2+B0M1m52nen3Pi5HOH9j mjtcf3XZ+pLHF7ve7xWmCzZjuVjucF3qiQBnaFSmwz3IXhyv3OW2tnHablvxpjl+1PoZ QYQQG+BUvJAkHY7uMEWpYvJPIcrK7eAjggOh5+uhe2j1yfaEOCKjt7fKbzixO3gn5SU2 foAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=xWZDnZQ7Uje44tOvyd+WhPXcE6YbxVNUTkV2DmxlC/I=; b=R2WwqX4xkDxbGJcTpWWLNYXzH9wIZZYXfJg8yN6sSi9606ZLdrUzaiWjBcK7SQ6yU3 4Jp8kcawpzyxyjokNE5MqZKLUAaIYYlRcU4/pkO1bvZamDgTVmybTRk/xZjQ+hHcr1V1 v/MVkoWCy2QZfbzy6N36IzJjRA02J5wmKnuRZe1udj9O99nEBJcVjWz/p3W2cDATuetH JjHnM58x5gFZ2WdbeDSqKAGpb1PL0vXrVUB+QL9H1dRUgfGWhMjcmeAJ+bxIva77ciWZ ELvkrqH+UAdwZXjjYDHqSXfy6l5XzjRJeana7IAY/FiEFgGj4F7Ezazswz9XwHPLGsCo LImQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ExonRuvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si2542835edc.520.2021.07.29.06.03.46; Thu, 29 Jul 2021 06:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ExonRuvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237417AbhG2NCL (ORCPT + 99 others); Thu, 29 Jul 2021 09:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237222AbhG2NCK (ORCPT ); Thu, 29 Jul 2021 09:02:10 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83771C061765; Thu, 29 Jul 2021 06:02:06 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id f13so6921510plj.2; Thu, 29 Jul 2021 06:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xWZDnZQ7Uje44tOvyd+WhPXcE6YbxVNUTkV2DmxlC/I=; b=ExonRuvAP6deeZWP4ARMhx8XszTEeQWKqexdxGr8TsuL+Bz8VPrFj6Y730SphdAQDC 84Fqe2zxnVuAY/b+yUA8Eq195vN/ev0qbH1bKyG9MpEY83Z3AAYzJOmRRNOSb1q264YH H1r0MDXkAlN2lmoLmNB9pMzmaE8qMyQJV2yXvzwM4lU7+cUmxyAefZ33Vtx/QsvY0B2Y 7299cOKI8WViF8nwItNn9KeFY/6ShDYN3GG/09Lm/PkrJetdxTquTYKbp14IyHKNKJri w4KULmdKqUg3LoIRw+FRYrv+H/B2Jf9av5u6lx3SllYemnIcK4W70fMX/uAcJnqsyzu9 1r1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xWZDnZQ7Uje44tOvyd+WhPXcE6YbxVNUTkV2DmxlC/I=; b=OKSsg36e2e0ZcnJpSj2aoLw7c6+REdPtjvpZ/b1IqKRyUvsRcP9N16R+FrCqK8UK/f 7AekgCk+pEXIGbjUJsosowiKw/P/z35J3ic/Cflhq9jJtTgnZF75LMCdHTbFNrJy+GeM jbmkvPs72e2YdwAagE83Q3/SWQAHGBW4H2aXdNGH/PSgcXoW+mT3dB0U7N5liIQFfVI4 7DnEyCfvAN15hvQ8MWRKpYrysmhUjCt4nslMC5XDTb5S58Ekv7PbHh19d4isTs5yGPMD vqe6U+klAS2j6e5MAP/UPP/eNRA6YXyYCadPUK9W0SvIBcpEvAxuPko3UXywvSmxZLAL QRsA== X-Gm-Message-State: AOAM531dX/7sgntf3H/1rq+UMQYYzdKThFIzYGN5cG46iWGxyJnYZgSA nz1rxUK/zGspf/yvmlWd5o0= X-Received: by 2002:a05:6a00:24c6:b029:332:6773:165c with SMTP id d6-20020a056a0024c6b02903326773165cmr4937276pfv.33.1627563725957; Thu, 29 Jul 2021 06:02:05 -0700 (PDT) Received: from ?IPv6:2404:f801:0:5:8000::4b1? ([2404:f801:9000:1a:efea::4b1]) by smtp.gmail.com with ESMTPSA id w2sm9730504pjt.14.2021.07.29.06.01.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jul 2021 06:02:05 -0700 (PDT) Subject: Re: [PATCH 03/13] x86/HV: Add new hvcall guest address host visibility support To: Dave Hansen , kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, joro@8bytes.org, will@kernel.org, davem@davemloft.net, kuba@kernel.org, jejb@linux.ibm.com, martin.petersen@oracle.com, arnd@arndb.de, hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, ardb@kernel.org, Tianyu.Lan@microsoft.com, rientjes@google.com, martin.b.radev@gmail.com, akpm@linux-foundation.org, rppt@kernel.org, kirill.shutemov@linux.intel.com, aneesh.kumar@linux.ibm.com, krish.sadhukhan@oracle.com, saravanand@fb.com, xen-devel@lists.xenproject.org, pgonda@google.com, david@redhat.com, keescook@chromium.org, hannes@cmpxchg.org, sfr@canb.auug.org.au, michael.h.kelley@microsoft.com Cc: iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, netdev@vger.kernel.org, vkuznets@redhat.com, anparri@microsoft.com References: <20210728145232.285861-1-ltykernel@gmail.com> <20210728145232.285861-4-ltykernel@gmail.com> From: Tianyu Lan Message-ID: <0d956a05-7d24-57a0-f4a9-dccc849b52fc@gmail.com> Date: Thu, 29 Jul 2021 21:01:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/29/2021 1:06 AM, Dave Hansen wrote: > On 7/28/21 7:52 AM, Tianyu Lan wrote: >> @@ -1986,7 +1988,9 @@ static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc) >> int ret; >> >> /* Nothing to do if memory encryption is not active */ >> - if (!mem_encrypt_active()) >> + if (hv_is_isolation_supported()) >> + return hv_set_mem_enc(addr, numpages, enc); >> + else if (!mem_encrypt_active()) >> return 0; > > One more thing. If you're going to be patching generic code, please > start using feature checks that can get optimized away at runtime. > hv_is_isolation_supported() doesn't look like the world's cheapest > check. It can't be inlined and costs at least a function call. Yes, you are right. How about adding a static branch key for the check of isolation VM? This may reduce the check cost.