Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp80594rdg; Tue, 10 Oct 2023 05:03:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGg4+c91EbA33qyhOnWfnZ9LL3bhC0XXtpWz+ItpMO0dIsaaQ5g5NkDaTL1IuT3UVnXPpUj X-Received: by 2002:a05:6a00:22c7:b0:68b:f529:a329 with SMTP id f7-20020a056a0022c700b0068bf529a329mr17980420pfj.5.1696939412862; Tue, 10 Oct 2023 05:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696939412; cv=none; d=google.com; s=arc-20160816; b=vN1Tqs4vLHpr1XK8If8bKcHaS3+qbm6khb88TeTQKQIylBXC76KMZ0eIyS7OnL5G5l xAdTBWN5fCFKi5Cf182lH3zPcZRHpWCffKo5RdjfW6/bn13bvXWOQWbo8l3WmfvHZla6 ncctUwEpaQeH1dsodnBjK99Z2EctcIq5+0r7iYZ6/bLzqnn538ZdJnf3UQp/E+V5lSQF L4DhkH2fl8udX41Cc794UDAk5bXBwkRnhuoEZwIWYguu+qGNShT/E/s9SaZD31wt99Qr ZSBIco14LoeuSFdmOqV9A8SeZsvoidM2VGV4etG3ND7d3uG5Ms88kgz8l6M/K7U3zfHR sU1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :message-id:user-agent:references:in-reply-to:subject:cc:to:from :date:mime-version; bh=L+bVn40OxV8ZLpCTcvDUSqfV8Hbdq1usPShr5KkTbYo=; fh=FcPpT3GSyNmpPhWQRZOQc2+es5WCGlPq/EuH/suWjN4=; b=wB2wdwtR/b1NQm5eHRG79segUSsnhEf5wL3pgi8JrHVD8mRa90GVaRyiUYGPDt7y33 5UVYrBceEIAVbQcmdMjGScn42K0MazwGGaeeCxh4wFyKXxTn+quf3tvai5D+jnc/6A/C B9LH/28Zxgu3WJJai1MKkqawxlhrP/IdQCZnoWgiGwgZk4oL5CyRdI6oGSyCzrDDBNm1 FXcsDiPv330kk/TeY0MTNexFYPhj1dKwFOKYvuZkekJMTSHhIAbtLqx7jac/GEX+hAyR EuW0H5T3tK1cuIyGxsVUWjMj9KmjwgqtYpg5Q1IoxF6/94YDtjVbnegN06R4g13vdFQF DZHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r184-20020a632bc1000000b00566022bbcafsi11227696pgr.566.2023.10.10.05.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 084D1815CDBE; Tue, 10 Oct 2023 05:03:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231869AbjJJMDN (ORCPT + 99 others); Tue, 10 Oct 2023 08:03:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjJJMDD (ORCPT ); Tue, 10 Oct 2023 08:03:03 -0400 Received: from 1.mo560.mail-out.ovh.net (1.mo560.mail-out.ovh.net [46.105.63.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E6D268D for ; Tue, 10 Oct 2023 05:02:00 -0700 (PDT) Received: from director11.ghost.mail-out.ovh.net (unknown [10.109.156.73]) by mo560.mail-out.ovh.net (Postfix) with ESMTP id 6D56528524 for ; Tue, 10 Oct 2023 12:01:58 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-x96xs (unknown [10.111.172.101]) by director11.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 71EFA1FEDD; Tue, 10 Oct 2023 12:01:57 +0000 (UTC) Received: from RCM-web10.webmail.mail.ovh.net ([151.80.29.18]) by ghost-submission-6684bf9d7b-x96xs with ESMTPSA id PiQoGDU9JWXNqgAAoY8iwA (envelope-from ); Tue, 10 Oct 2023 12:01:57 +0000 MIME-Version: 1.0 Date: Tue, 10 Oct 2023 15:01:56 +0300 From: =?UTF-8?Q?Jos=C3=A9_Pekkarinen?= To: Greg KH Cc: seanjc@google.com, pbonzini@redhat.com, skhan@linuxfoundation.org, dave.hansen@linux.intel.com, kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, tglx@linutronix.de, linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: [PATCH] kvm/sev: make SEV/SEV-ES asids configurable In-Reply-To: <2023101050-scuff-overstay-9b43@gregkh> References: <20231010100441.30950-1-jose.pekkarinen@foxhound.fi> <2023101050-scuff-overstay-9b43@gregkh> User-Agent: Roundcube Webmail/1.4.13 Message-ID: X-Sender: jose.pekkarinen@foxhound.fi Organization: Foxhound Ltd. X-Originating-IP: 185.233.100.23 X-Webmail-UserID: jose.pekkarinen@foxhound.fi Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 4410712886810617510 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrheehgdeghecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeggfffhvfevufgjfhgfkfigohhitgfgsehtkehjtddtreejnecuhfhrohhmpeflohhsrocurfgvkhhkrghrihhnvghnuceojhhoshgvrdhpvghkkhgrrhhinhgvnhesfhhogihhohhunhgurdhfiheqnecuggftrfgrthhtvghrnhepkefhgeduudefgedvleegtddvffeghedvtdekveekjeevvdegiedtfeelhedtiedtnecukfhppeduvdejrddtrddtrddupddukeehrddvfeefrddutddtrddvfedpudehuddrkedtrddvledrudeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeojhhoshgvrdhpvghkkhgrrhhinhgvnhesfhhogihhohhunhgurdhfiheqpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdfovfetjfhoshhtpehmohehiedtpdhmohguvgepshhmthhpohhuth X-Spam-Status: No, score=4.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 10 Oct 2023 05:03:30 -0700 (PDT) X-Spam-Level: **** On 2023-10-10 14:35, Greg KH wrote: > On Tue, Oct 10, 2023 at 01:04:39PM +0300, José Pekkarinen wrote: >> There are bioses that doesn't allow to configure the >> number of asids allocated for SEV/SEV-ES, for those >> cases, the default behaviour allocates all the asids >> for SEV, leaving no room for SEV-ES to have some fun. > > "fun"? > > Also, please use the full 72 columns for your changelog. > Alright. >> If the user request SEV-ES to be enabled, it will >> find the kernel just run out of resources and ignored >> user request. This following patch will address this >> issue by making the number of asids for SEV/SEV-ES >> configurable over kernel module parameters. >> >> Signed-off-by: José Pekkarinen >> --- >> arch/x86/kvm/svm/sev.c | 28 +++++++++++++++++++++++----- >> 1 file changed, 23 insertions(+), 5 deletions(-) >> >> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c >> index 07756b7348ae..68a63b42d16a 100644 >> --- a/arch/x86/kvm/svm/sev.c >> +++ b/arch/x86/kvm/svm/sev.c >> @@ -51,9 +51,18 @@ >> static bool sev_enabled = true; >> module_param_named(sev, sev_enabled, bool, 0444); >> >> +/* nr of asids requested for SEV */ >> +static unsigned int requested_sev_asids; >> +module_param_named(sev_asids, requested_sev_asids, uint, 0444); >> + >> /* enable/disable SEV-ES support */ >> static bool sev_es_enabled = true; >> module_param_named(sev_es, sev_es_enabled, bool, 0444); >> + >> +/* nr of asids requested for SEV-ES */ >> +static unsigned int requested_sev_es_asids; >> +module_param_named(sev_es_asids, requested_sev_asids, uint, 0444); > > Why more module parameters? Why can't this "just work" properly > without > forcing a user to make manual changes? This isn't the 1990's anymore. I could think of setting both cgroup caps to the maximum number of asids and then check the code in the module to make sure anytime a sev/sev_es asid is reserved both cgroups get updated to reflect the remaining asids, or even better, just use only one cgroup to keep track of them. That way the parameters become redundant, would any of these ideas work for you? Do you, or anybody else, have better ideas or preferences in this topic? >> + >> #else >> #define sev_enabled false >> #define sev_es_enabled false >> @@ -2194,6 +2203,11 @@ void __init sev_hardware_setup(void) >> if (!max_sev_asid) >> goto out; >> >> + if (requested_sev_asids + requested_sev_es_asids > max_sev_asid) { >> + pr_info("SEV asids requested more than available: %u ASIDs\n", >> max_sev_asid); > > Why isn't this an error? Good question, I'll address it in v2. Thanks! José.