From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EC99C636D4 for ; Tue, 31 Jan 2023 14:15:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ABD686B0071; Tue, 31 Jan 2023 09:15:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A46746B0073; Tue, 31 Jan 2023 09:15:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90EBF6B0075; Tue, 31 Jan 2023 09:15:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7D79F6B0071 for ; Tue, 31 Jan 2023 09:15:10 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 302C8A0C11 for ; Tue, 31 Jan 2023 14:15:10 +0000 (UTC) X-FDA: 80415291180.20.ACD1F36 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by imf24.hostedemail.com (Postfix) with ESMTP id 5515F180026 for ; Tue, 31 Jan 2023 14:15:08 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=f4of6yuJ; spf=pass (imf24.hostedemail.com: domain of jpiotrowski@linux.microsoft.com designates 13.77.154.182 as permitted sender) smtp.mailfrom=jpiotrowski@linux.microsoft.com; dmarc=pass (policy=none) header.from=linux.microsoft.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675174508; a=rsa-sha256; cv=none; b=w+uLktaKk0X44ozGfCjDvZalYziyhJoFcKcUNTD/gX3co6Q6VOcVFXVZpWfORvPurMkmD2 MDglgWioy4i8Hf/K+tPZ0YKGOtfFIWTZ9BPHCh1NxrACHF6alheviqoxJqa3RKrH5Vpzk9 yrKxC2zjdLdhKkSpqa1BX/7fnBYoy8g= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=f4of6yuJ; spf=pass (imf24.hostedemail.com: domain of jpiotrowski@linux.microsoft.com designates 13.77.154.182 as permitted sender) smtp.mailfrom=jpiotrowski@linux.microsoft.com; dmarc=pass (policy=none) header.from=linux.microsoft.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675174508; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mT19G71ucLF+4CaSTXOpXQE/L4+jsWO6AotXm3MMpfA=; b=drcL5IZsD+qv1Mu6fZrLxMjLp+RToWGaBVQ96RgDrh06iKo376Sk+Begj8tHs5yPX3SWHz NLevquAvnt9mVwyARYmCawMzQUItWlJsWmeyR5jgZp6WjVeI6nZr6wA2CWrkdcL9hy64eh tBNpoar5iPMFNHKipO/T0JfNvAQkwRA= Received: by linux.microsoft.com (Postfix, from userid 1112) id 0A33C20EA201; Tue, 31 Jan 2023 06:15:07 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0A33C20EA201 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1675174507; bh=mT19G71ucLF+4CaSTXOpXQE/L4+jsWO6AotXm3MMpfA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f4of6yuJuqxU4bwC8lYZggOCEjPalaQPNsTBE3fhlgDrMgY+vtzzXGQlAff+wYAVQ mbZHxNBhfyk66pyhrYtonfjcK3mmagigi+pYRKBanuiMtQCkDmPuMUds8loo3afvqF C3+wntX9R8q9w9AwgdpOxAJU1QKzbRugpppPtnig= Date: Tue, 31 Jan 2023 06:15:07 -0800 From: Jeremi Piotrowski To: Michael Roth Cc: kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, jroedel@suse.de, thomas.lendacky@amd.com, hpa@zytor.com, ardb@kernel.org, pbonzini@redhat.com, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, luto@kernel.org, dave.hansen@linux.intel.com, slp@redhat.com, pgonda@google.com, peterz@infradead.org, srinivas.pandruvada@linux.intel.com, rientjes@google.com, dovmurik@linux.ibm.com, tobin@ibm.com, bp@alien8.de, vbabka@suse.cz, kirill@shutemov.name, ak@linux.intel.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com, alpergun@google.com, dgilbert@redhat.com, jarkko@kernel.org, ashish.kalra@amd.com, harald@profian.com, Nikunj A Dadhania Subject: Re: [PATCH RFC v7 07/64] KVM: SEV: Handle KVM_HC_MAP_GPA_RANGE hypercall Message-ID: <20230131141506.GA14449@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20221214194056.161492-1-michael.roth@amd.com> <20221214194056.161492-8-michael.roth@amd.com> <20230127163558.GA22533@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230127163558.GA22533@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Rspam-User: X-Rspamd-Queue-Id: 5515F180026 X-Rspamd-Server: rspam01 X-Stat-Signature: 1b3cdtwp4x1pmtqkkioucnfqb6bbsjy3 X-HE-Tag: 1675174508-897988 X-HE-Meta: U2FsdGVkX1/y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RLYcJ8/zCkL8+3lCW4iIC+zBr6jD/wh0TorCG7TUyOkudrT/cmzgraqmBbxJCnGQhLe3dqRqpH/qMYf4bLF+kDYNVrclrmkDTdaD2lO7LsudrvwrF0b1eew1YIgIoKXwMIpxnAubF0a9wA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jan 27, 2023 at 08:35:58AM -0800, Jeremi Piotrowski wrote: > On Wed, Dec 14, 2022 at 01:39:59PM -0600, Michael Roth wrote: > > From: Nikunj A Dadhania > > > > KVM_HC_MAP_GPA_RANGE hypercall is used by the SEV guest to notify a > > change in the page encryption status to the hypervisor. > > > > The hypercall exits to userspace with KVM_EXIT_HYPERCALL exit code, > > currently this is used for explicit memory conversion between > > shared/private for memfd based private memory. > > > > Signed-off-by: Nikunj A Dadhania > > Signed-off-by: Michael Roth > > --- > > arch/x86/kvm/x86.c | 8 ++++++++ > > virt/kvm/kvm_main.c | 1 + > > 2 files changed, 9 insertions(+) > > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index bb6adb216054..732f9cbbadb5 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -9649,6 +9649,7 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) > > Couldn't find a better commit to comment on: > when the guest has the ptp-kvm module, it will issue a KVM_HC_CLOCK_PAIRING > hypercall. This will pass sev_es_validate_vmgexit validation and end up in this > function where kvm_pv_clock_pairing() is called, and that calls > kvm_write_guest(). This results in a CPU soft-lockup, at least in my testing. > > Are there any emulated hypercalls that make sense for snp guests? We should > block at least the ones that definitely don't work. > > Jeremi So turns out the soft-lockup is a nested issue (details here for those interested: [^1]), but the questions still stands, of whether we should block kvm_write_page (and similar) explicitly or rely on the rmp fault. [^1]: https://github.com/jepio/linux/commit/6c3bdf552e93664ae172660e24ceceed60fd4df5