Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp320184rdg; Thu, 12 Oct 2023 06:44:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2ticKmz8PET0S4zqiet0+JfaTOf46fJvvdwkST+wtt0RTczHZ/dpMAj/wkDRwdFjVHiBR X-Received: by 2002:a17:90a:bb15:b0:274:8951:b5e4 with SMTP id u21-20020a17090abb1500b002748951b5e4mr18938601pjr.48.1697118297115; Thu, 12 Oct 2023 06:44:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697118297; cv=none; d=google.com; s=arc-20160816; b=NpPTowbI0XUQ59GbMGJPN7F80pWsh5+74c4nPxq3hPwYQwfJdR3DkAqZq0TJUHEyrI V/ayrTquTMjClF6kJn05KW++WuNVD/ia3szafLlSEfq2wHF66spyP0V+EGqMtrPgvGsq BJb8o1uXi13FRBm/CiAxg99OqLilHtw1Cqo0sQEm19MTg+bWEm+zghmn0Uwu4qf1WlIv l37jpi541Eopy604rIJVWRy4Lr2NtJxrO4N9yJPuF8DK1DOG9yXYcSAVVkVFYvuRmeua kKSbklMhAfWQjPNyrkm1+wKile/WsK2ACWKNGfCzksUpY4lruca6YVtY1ZExB58hrn/V gZew== 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=3YeQNCi5I9TqMhLfVG8VlYOgAuXpSTrcqQ3sfxubQaM=; fh=MLy11C7KiJYQ54yNHTHLFdYStHCzALJLq8LTe5z6D0E=; b=twEct2bNII2+hr6WJ3x5MEDaYZ1PcaWuCjr1wsWleuFhYynKLNs/NEyZKj2yxQW/uQ xkeIkVubQrLRhM5bGPxG2VhBAqJ6uTY4pMNuOHztiRuvhsC8S1653zYedfc4RHEu8Euc 3IDQ2XBYD+MJSjC6S3BqWW/T7D3J/mtlp4zDwp3D6ebYVksiZq83DiHUesN4dclHnUle O4kfedoviBSgro4ygoX/0LRbNmOyjbAa8oQz+qE4VYdeV59/t3T/k9HJW2eMCAmV/yjp NRS6uIlgl+DM0y8x8ISGv2bjEY4vcDMzRBhJ7Rawuw+eP0huJuz8r5cJGBRuqrHrjhYd VgDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iKGum11t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id g14-20020a17090a67ce00b0027491203b43si2288002pjm.189.2023.10.12.06.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 06:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iKGum11t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1D408822D568; Thu, 12 Oct 2023 06:44:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378899AbjJLNog (ORCPT + 99 others); Thu, 12 Oct 2023 09:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378679AbjJLNoe (ORCPT ); Thu, 12 Oct 2023 09:44:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0199DBE for ; Thu, 12 Oct 2023 06:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697118229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3YeQNCi5I9TqMhLfVG8VlYOgAuXpSTrcqQ3sfxubQaM=; b=iKGum11t/BM1BsJbGOXytigVtoaxXJvhAFb9uRd49SGTUI8WGMR5lHnOok3UVQHTj5FGWk TU85Ip8v5S9LnPjBjp2yFYUpQKfORRIkSDyvDCvZh8WM9F0ZZdkut3NTeimpXasnKs8qud Uj7PyxXu4D/mmimljPhSBtG0kfPCE68= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-15-TB8FSkt_O_W_RWri-YtCqQ-1; Thu, 12 Oct 2023 09:43:42 -0400 X-MC-Unique: TB8FSkt_O_W_RWri-YtCqQ-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-538128e18e9so781929a12.2 for ; Thu, 12 Oct 2023 06:43:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697118222; x=1697723022; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3YeQNCi5I9TqMhLfVG8VlYOgAuXpSTrcqQ3sfxubQaM=; b=v/AtIKUH8Hs5/yccE72Qg9IxjO9Ql/ZAdUIBwlv5D7RBk4LJOi7ARR0oFpW9ImuOkC 8VND/T4qZ6R3hjlL9RG4JVUdvyR7SbqtMd0WSrfx51VosF2b7gfXSb+u9C4KmTthNdro jkYuusNC7HYKqiR4T0aUqxa65d7XPyqsASbMkyaAPBceZ9soZ32n8PDhip0tyVwDOuDG wtW3x+11RB8wZC9yfXCeWak17uGSbR0ilfWFwtomxtM41IdSdlf7HGq9RLe9BaI5iMwZ eUKxVSJTKwu6d9ySDfB9Q+KpyBgLIR4h7N3eh6MvDlnxd1D0EapHaXHQG6IVYZCiPcIL hDvg== X-Gm-Message-State: AOJu0Yzgxv3h7btSRn/xmQpcNDls/LeIr9OYfGUc8kqa20hHj0hP5Iiv I2UERmyuBJaIsL3mkpe993ix9gORdcwImSPs1yzsb3HSgVhtNgHeCMPHlzX+OizcfnoiNJcNUR1 pUtsKHOnKvIjAlvxVd5N8yJko X-Received: by 2002:a05:6402:371a:b0:53d:af00:1682 with SMTP id ek26-20020a056402371a00b0053daf001682mr5374475edb.40.1697118221754; Thu, 12 Oct 2023 06:43:41 -0700 (PDT) X-Received: by 2002:a05:6402:371a:b0:53d:af00:1682 with SMTP id ek26-20020a056402371a00b0053daf001682mr5374460edb.40.1697118221361; Thu, 12 Oct 2023 06:43:41 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:4783:a68:c1ee:15c5? ([2001:b07:6468:f312:4783:a68:c1ee:15c5]) by smtp.googlemail.com with ESMTPSA id d5-20020aa7ce05000000b005346a263bb1sm10062063edv.63.2023.10.12.06.43.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Oct 2023 06:43:40 -0700 (PDT) Message-ID: <9faf1a1a-af49-5f6f-9f33-6cf57f884c44@redhat.com> Date: Thu, 12 Oct 2023 15:43:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] kvm/sev: remove redundant MISC_CG_RES_SEV_ES Content-Language: en-US To: =?UTF-8?Q?Jos=c3=a9_Pekkarinen?= , seanjc@google.com, skhan@linuxfoundation.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org References: <20231010174932.29769-1-jose.pekkarinen@foxhound.fi> From: Paolo Bonzini In-Reply-To: <20231010174932.29769-1-jose.pekkarinen@foxhound.fi> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 06:44:54 -0700 (PDT) On 10/10/23 19:49, José Pekkarinen wrote: > SEV-ES is an extra encrypted state that shares common resources > with SEV. Using an extra CG for its purpose doesn't seem to > provide much value. This patch will clean up the control group > along with multiple checks that become redundant with it. > > The patch will also remove a redundant logic on sev initialization > that produces SEV-ES to be disabled, while supported by the cpu > and requested by the user through the sev_es parameter. In what sense is it shared? The SEV ASIDs and the SEV-ES ASIDs are separate (and in both cases limited) resources, and therefore they have separate cgroups. Paolo > Signed-off-by: José Pekkarinen > --- > arch/x86/kvm/svm/sev.c | 18 +++--------------- > include/linux/misc_cgroup.h | 2 -- > 2 files changed, 3 insertions(+), 17 deletions(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 07756b7348ae..8a06d92187cf 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -37,13 +37,9 @@ > * this file are not used but this file still gets compiled into the KVM AMD > * module. > * > - * We will not have MISC_CG_RES_SEV and MISC_CG_RES_SEV_ES entries in the enum > - * misc_res_type {} defined in linux/misc_cgroup.h. > - * > * Below macros allow compilation to succeed. > */ > #define MISC_CG_RES_SEV MISC_CG_RES_TYPES > -#define MISC_CG_RES_SEV_ES MISC_CG_RES_TYPES > #endif > > #ifdef CONFIG_KVM_AMD_SEV > @@ -125,13 +121,13 @@ static bool __sev_recycle_asids(int min_asid, int max_asid) > > static int sev_misc_cg_try_charge(struct kvm_sev_info *sev) > { > - enum misc_res_type type = sev->es_active ? MISC_CG_RES_SEV_ES : MISC_CG_RES_SEV; > + enum misc_res_type type = MISC_CG_RES_SEV; > return misc_cg_try_charge(type, sev->misc_cg, 1); > } > > static void sev_misc_cg_uncharge(struct kvm_sev_info *sev) > { > - enum misc_res_type type = sev->es_active ? MISC_CG_RES_SEV_ES : MISC_CG_RES_SEV; > + enum misc_res_type type = MISC_CG_RES_SEV; > misc_cg_uncharge(type, sev->misc_cg, 1); > } > > @@ -2167,7 +2163,7 @@ void __init sev_set_cpu_caps(void) > void __init sev_hardware_setup(void) > { > #ifdef CONFIG_KVM_AMD_SEV > - unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count; > + unsigned int eax, ebx, ecx, edx, sev_asid_count; > bool sev_es_supported = false; > bool sev_supported = false; > > @@ -2236,14 +2232,7 @@ void __init sev_hardware_setup(void) > if (!boot_cpu_has(X86_FEATURE_SEV_ES)) > goto out; > > - /* Has the system been allocated ASIDs for SEV-ES? */ > - if (min_sev_asid == 1) > - goto out; > - > - sev_es_asid_count = min_sev_asid - 1; > - WARN_ON_ONCE(misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count)); > sev_es_supported = true; > - > out: > if (boot_cpu_has(X86_FEATURE_SEV)) > pr_info("SEV %s (ASIDs %u - %u)\n", > @@ -2271,7 +2260,6 @@ void sev_hardware_unsetup(void) > bitmap_free(sev_reclaim_asid_bitmap); > > misc_cg_set_capacity(MISC_CG_RES_SEV, 0); > - misc_cg_set_capacity(MISC_CG_RES_SEV_ES, 0); > } > > int sev_cpu_init(struct svm_cpu_data *sd) > diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h > index c238207d1615..23d3cd153f60 100644 > --- a/include/linux/misc_cgroup.h > +++ b/include/linux/misc_cgroup.h > @@ -15,8 +15,6 @@ enum misc_res_type { > #ifdef CONFIG_KVM_AMD_SEV > /* AMD SEV ASIDs resource */ > MISC_CG_RES_SEV, > - /* AMD SEV-ES ASIDs resource */ > - MISC_CG_RES_SEV_ES, > #endif > MISC_CG_RES_TYPES > }; > --