Message ID | 20231108111806.92604-18-nsaenz@amazon.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp843441vqo; Wed, 8 Nov 2023 03:23:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFw8F2PBfZHvsgfG0fNvfteq4zH1u/taLttZudf9kH/0AL0DzsYCPQrMjb4tk0n7UIzisoE X-Received: by 2002:a9d:6e84:0:b0:6cd:941:418c with SMTP id a4-20020a9d6e84000000b006cd0941418cmr1789641otr.21.1699442586985; Wed, 08 Nov 2023 03:23:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699442586; cv=none; d=google.com; s=arc-20160816; b=QYGbXS0wfS4a/xYdsDMbvwretMyVOqCIIW7mzuaZNha7lzgVv6axMgRXldUkwPC9ov 8RXeZ59DsbIVbkSPCHLvlgifRU+rx4hAfU1AmkJTXBJSeSdXpn3pshHXvTDmrCtrzlb9 MBGvSEQpPosLEjLgInlUkcoYwgNjUwnMUjgJUvzWVSKaedDedHDw+KHESDQNV9PqwnQn 5eZUuNkLEb5dZZ94Pmw/gJQWODhJIZ6MHGGo9u6tkmOELzjP6+QwTm2OPmrm1diM9N4L XpF7ofL7VgExlUN+KD/qXmSaHdZZEuALIPmUBWbsaQ2Od5R62lf9+utOioJJ41uj98xF dg7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v9CrHyw1JpyXXRLGKDb9DzQRe5BqtRC9dyxOB/2B9Mo=; fh=Qdq7NqGm5JR9LpctBpXjoRI38Lb2mCk6xy26GEDp1Bg=; b=DHZru6E1O3N8ZVoF2BuLnOr8bWOAkW3tye6T6uNu/YDoAkaiVd6K1uRjqPC7xsTQP0 JfPkGGf+POxJcg2zDHQockYCdIMoo5Z46mPmErDlDASO5zcPpp1TdwmHtK6K23H4Bync tKHZzgK3BrKSrcKDSBnlniQb7+dZOu9KxFhfGXFdyglJ3aGCCczj/Bdlp8WiDDfiNjqZ 7I8fIcI/6TP2m1+gdQd/C3reNM1+OeRJIKdkXacOwgSvYvHq2P2+Fy4wKcYSeRKneeyN yEI2mbLdPCforulelX8KOOMR0x0Q7cgS+RtQiUZ1Cg2mn5AqlzYK/3r915jGd1qCkJg9 N09Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=kKfzBpCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ay29-20020a056a00301d00b006c3211608adsi12908977pfb.80.2023.11.08.03.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:23:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=kKfzBpCq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E5E89826BB8A; Wed, 8 Nov 2023 03:22:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344652AbjKHLWQ (ORCPT <rfc822;jaysivo@gmail.com> + 32 others); Wed, 8 Nov 2023 06:22:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344634AbjKHLV5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Nov 2023 06:21:57 -0500 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D02D1BE1; Wed, 8 Nov 2023 03:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1699442515; x=1730978515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v9CrHyw1JpyXXRLGKDb9DzQRe5BqtRC9dyxOB/2B9Mo=; b=kKfzBpCqkT/h6wLsqI+jdt228IuVPdJRChlL4wuFcfzpSUgzKmFwfG5l vIXYKjZFv7WgL5B1VfC4pEy0KboL7P6IEWTpVg2mRJHNfSlxcW+hwWQ1V RbkMtzuUuZdG0SsYrK7Jp9RYQ1Snx+lhZ1DhuvRZ612IyVwygY1gsY09i 8=; X-IronPort-AV: E=Sophos;i="6.03,286,1694736000"; d="scan'208";a="366812660" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-m6i4x-f323d91c.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 11:21:53 +0000 Received: from smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev (pdx2-ws-svc-p26-lb5-vlan2.pdx.amazon.com [10.39.38.66]) by email-inbound-relay-pdx-2b-m6i4x-f323d91c.us-west-2.amazon.com (Postfix) with ESMTPS id 3352840D95; Wed, 8 Nov 2023 11:21:52 +0000 (UTC) Received: from EX19MTAEUA001.ant.amazon.com [10.0.17.79:36943] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.22.222:2525] with esmtp (Farcaster) id a2d9683d-2fd0-47e3-9e16-e83a0bd5b6ea; Wed, 8 Nov 2023 11:21:51 +0000 (UTC) X-Farcaster-Flow-ID: a2d9683d-2fd0-47e3-9e16-e83a0bd5b6ea Received: from EX19D004EUC001.ant.amazon.com (10.252.51.190) by EX19MTAEUA001.ant.amazon.com (10.252.50.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 8 Nov 2023 11:21:44 +0000 Received: from dev-dsk-nsaenz-1b-189b39ae.eu-west-1.amazon.com (10.13.235.138) by EX19D004EUC001.ant.amazon.com (10.252.51.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 8 Nov 2023 11:21:39 +0000 From: Nicolas Saenz Julienne <nsaenz@amazon.com> To: <kvm@vger.kernel.org> CC: <linux-kernel@vger.kernel.org>, <linux-hyperv@vger.kernel.org>, <pbonzini@redhat.com>, <seanjc@google.com>, <vkuznets@redhat.com>, <anelkz@amazon.com>, <graf@amazon.com>, <dwmw@amazon.co.uk>, <jgowans@amazon.com>, <corbert@lwn.net>, <kys@microsoft.com>, <haiyangz@microsoft.com>, <decui@microsoft.com>, <x86@kernel.org>, <linux-doc@vger.kernel.org>, Nicolas Saenz Julienne <nsaenz@amazon.com> Subject: [RFC 17/33] KVM: x86/mmu: Allow setting memory attributes if VSM enabled Date: Wed, 8 Nov 2023 11:17:50 +0000 Message-ID: <20231108111806.92604-18-nsaenz@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231108111806.92604-1-nsaenz@amazon.com> References: <20231108111806.92604-1-nsaenz@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.13.235.138] X-ClientProxiedBy: EX19D043UWA003.ant.amazon.com (10.13.139.31) To EX19D004EUC001.ant.amazon.com (10.252.51.190) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 08 Nov 2023 03:23:00 -0800 (PST) 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, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781994710093069136 X-GMAIL-MSGID: 1781994710093069136 |
Series |
KVM: x86: hyperv: Introduce VSM support
|
|
Commit Message
Nicolas Saenz Julienne
Nov. 8, 2023, 11:17 a.m. UTC
VSM is also a user of memory attributes, so let it use
kvm_set_mem_attributes().
Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com>
---
arch/x86/kvm/mmu/mmu.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On Wed, 2023-11-08 at 11:17 +0000, Nicolas Saenz Julienne wrote: > VSM is also a user of memory attributes, so let it use > kvm_set_mem_attributes(). > > Signed-off-by: Nicolas Saenz Julienne <nsaenz@amazon.com> > --- > arch/x86/kvm/mmu/mmu.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index feca077c0210..a1fbb905258b 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -7265,7 +7265,8 @@ bool kvm_arch_pre_set_memory_attributes(struct kvm *kvm, > * Zapping SPTEs in this case ensures KVM will reassess whether or not > * a hugepage can be used for affected ranges. > */ > - if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm))) > + if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm) && > + !kvm_hv_vsm_enabled(kvm))) > return false; IMHO on the long term, memory attributes should either be always enabled, or the above check should became more generic. But otherwise this patch looks reasonable. > > return kvm_unmap_gfn_range(kvm, range); > @@ -7322,7 +7323,8 @@ bool kvm_arch_post_set_memory_attributes(struct kvm *kvm, > * a range that has PRIVATE GFNs, and conversely converting a range to > * SHARED may now allow hugepages. > */ > - if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm))) > + if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm) && > + !kvm_hv_vsm_enabled(kvm))) > return false; > > /* Best regards, Maxim Levitsky
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index feca077c0210..a1fbb905258b 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -7265,7 +7265,8 @@ bool kvm_arch_pre_set_memory_attributes(struct kvm *kvm, * Zapping SPTEs in this case ensures KVM will reassess whether or not * a hugepage can be used for affected ranges. */ - if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm))) + if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm) && + !kvm_hv_vsm_enabled(kvm))) return false; return kvm_unmap_gfn_range(kvm, range); @@ -7322,7 +7323,8 @@ bool kvm_arch_post_set_memory_attributes(struct kvm *kvm, * a range that has PRIVATE GFNs, and conversely converting a range to * SHARED may now allow hugepages. */ - if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm))) + if (WARN_ON_ONCE(!kvm_arch_has_private_mem(kvm) && + !kvm_hv_vsm_enabled(kvm))) return false; /*