Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp385571rdg; Tue, 10 Oct 2023 13:14:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLJRj89j2zsYvUtKbaahSp1SuNg90E5Miij5Z8nEb8QYVI9bxMjY85r/3YbhQQ6bU2/+UT X-Received: by 2002:a05:6e02:12c5:b0:351:2104:64f6 with SMTP id i5-20020a056e0212c500b00351210464f6mr25491036ilm.1.1696968899168; Tue, 10 Oct 2023 13:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696968899; cv=none; d=google.com; s=arc-20160816; b=Apb9kgeuY+breExKefBlR8w95rlBpgmN+9u7CcfhQT9qGpWVmi+Q4Hf872WRIrUTcD G4KDqeMSvoS6Uj34BqhEauaTNrsX1lZJSDBqo5bW/u7TWssTNv794hGxrKts12c9k3tT EKBbYT24R+SpQ0KbiM2BrQqVjKA/gFzxDCuPgGuxSPj8Hj4N4PlBzl4kNV17RpLvaT2a behoZNZD4wtnYnfn4SayTk7Iwb5OfjCJ5zmVl9V41aKwC2aRa3MNqRyw/j7YsgrtzqkW J0Spc8dueDWt08+aLfhhBWxkXX0kiic4hKPXsXSeDLBnlIoDY0wQftPZjsjtYCvUnRjs xfkw== 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 :message-id:date:subject:cc:to:from; bh=6ggnzrF2JzBDrhJYVdWLKyXhJJRUta4jwj1DiRanMaw=; fh=g/oAorp3D6UsRmd1L7iAr7vd4b1bKLrnwD0FCn0DGaA=; b=kXNhRB2UOx3b0FWjxFC8x2XbSFYh29vRUXEQSqbxh/FoHkAVuJL35nwSbtqbOqB24y xu3hqveuPWVjphHU2N0B/OxgFc30VW1j+3jCuaVZZIfyEvwmt6Wu7lkAnVOaFuKt8Sur MIifjidi37kf9Z4zJGCvOu9oQTWeWkpLAWLvVR+ekyQCPPEITQWzcrYKzOQj8eEWT/Ox ZDGZvxSTTZjru9/fpdMSw+IfvZwquuaWI0Xi0y1L5Xb2UHLZRetisi348lLxRs8mxvXs saDJGvxxzq10f7mmCZj/fdV07I8iFRouQbqxA38JgSKSWOd1r1rhVDDJeXOVbaN57DRh r6ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id c16-20020a637250000000b00578a7f5a0afsi12882060pgn.357.2023.10.10.13.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 13:14:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 41AB4802903E; Tue, 10 Oct 2023 13:14:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbjJJUOk (ORCPT + 99 others); Tue, 10 Oct 2023 16:14:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbjJJUOj (ORCPT ); Tue, 10 Oct 2023 16:14:39 -0400 Received: from 16.mo581.mail-out.ovh.net (16.mo581.mail-out.ovh.net [46.105.72.216]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A839E for ; Tue, 10 Oct 2023 13:14:35 -0700 (PDT) Received: from director11.ghost.mail-out.ovh.net (unknown [10.109.138.52]) by mo581.mail-out.ovh.net (Postfix) with ESMTP id AC2FE28188 for ; Tue, 10 Oct 2023 17:48:28 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-stm2z (unknown [10.110.115.58]) by director11.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 6CCDA1FD7A; Tue, 10 Oct 2023 17:48:27 +0000 (UTC) Received: from foxhound.fi ([37.59.142.96]) by ghost-submission-6684bf9d7b-stm2z with ESMTPSA id 8psZFmuOJWW+IgUAE6teJg (envelope-from ); Tue, 10 Oct 2023 17:48:27 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-96R0014c201574-7c4e-4efe-b59f-e4ee1977f006, 0BECE3FDD040DFF140D1580490AC4D25886584D9) smtp.auth=jose.pekkarinen@foxhound.fi X-OVh-ClientIp: 91.157.111.220 From: =?UTF-8?q?Jos=C3=A9=20Pekkarinen?= To: seanjc@google.com, pbonzini@redhat.com, skhan@linuxfoundation.org Cc: =?UTF-8?q?Jos=C3=A9=20Pekkarinen?= , 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 Subject: [PATCH] kvm/sev: remove redundant MISC_CG_RES_SEV_ES Date: Tue, 10 Oct 2023 20:49:13 +0300 Message-ID: <20231010174932.29769-1-jose.pekkarinen@foxhound.fi> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 10262577655121553062 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrheehgdduudehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffogggtgfesthekredtredtjeenucfhrhhomheplfhoshorucfrvghkkhgrrhhinhgvnhcuoehjohhsvgdrphgvkhhkrghrihhnvghnsehfohighhhouhhnugdrfhhiqeenucggtffrrghtthgvrhhnpeeftdelueetieetvdettdetueeivedujeefffdvteefkeelhefhleelfeetteejjeenucfkphepuddvjedrtddrtddruddpledurdduheejrdduuddurddvvddtpdefjedrheelrddugedvrdelieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoehjohhsvgdrphgvkhhkrghrihhnvghnsehfohighhhouhhnugdrfhhiqedpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheekuddpmhhouggvpehsmhhtphhouhht X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 10 Oct 2023 13:14:56 -0700 (PDT) X-Spam-Level: ** 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. 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 }; -- 2.41.0