Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp669687pxk; Wed, 16 Sep 2020 13:57:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAwQzBoZ21sUQk42MkojCEhYgkbxOsMykrhGolN6k5ty4VjjQhebOgEF+T8Fk+HLXApRVy X-Received: by 2002:aa7:d58e:: with SMTP id r14mr12112264edq.52.1600289855579; Wed, 16 Sep 2020 13:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600289855; cv=none; d=google.com; s=arc-20160816; b=oyytF4gnjlNwLUPMyj7rBdB9mX4YbURNT6pDdLprhJjS9hbfD0kHYcF9cBzXDarxza oE391InqLfx2vk5ZyuiAEUlVCWNl3/Kr4vcQIdtv1nINyaN+KTMt56vjuIUcpCZSUYdK WnE5tODLQp3vwBwgYjEAxAUXOSuoxeB3DRPjBHxzxJycqYdqp1Ze9D/EHTsdSEkrHfOW 6fiA7jhhfm5CGf/7zhHuT79RdMPhT4AknHvKwgf+imr8kpe7bKvV4z0ThgTOcVVm9SBS HZMWjUoyJ8CCl2JR6mbSAKqBzFTztHnPyoq34dUDVMqMmEK+Xe0fdR7plsiHuz/a8A3p XATg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=YMyM5XWKI2ypvrXLfwgPUIUROxXcQefmH5W0oZrib2E=; b=az4d1eOhwFTLT57TPplcZ8k13vVrAaLgGP3j10W7vROoDuLCGm4Gv0kv0hUI47cWlS 4B5QhxJwjZ2i2oq837fRECXDlzzOiQF6lmgkBIRZmQAsY4Vz7gszq+BPPM/1XsLlpYJ5 1g0PNBmQT9IE708lD0jEq1jVn2bQ+icNIgZ4UCPn9qcWpyzLbfu1IkWUistjw68UmCs/ WSacdxn0FxzmTQbI0ME0BlZFJWVkyd8Uhw48bt5nPGzNcpZlG1wlKLJlzUvfZGR4Wer7 HXM8vjBApvu1cU1DweObm+UHkfmH7+WdMONWkVsPx31sgeNlmkeHdghxOZa2f7OL5Erm JxbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si13594663ejg.656.2020.09.16.13.57.11; Wed, 16 Sep 2020 13:57:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726494AbgIPU4P (ORCPT + 99 others); Wed, 16 Sep 2020 16:56:15 -0400 Received: from mga12.intel.com ([192.55.52.136]:51996 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgIPQww (ORCPT ); Wed, 16 Sep 2020 12:52:52 -0400 IronPort-SDR: gWixcFHN3jAoJ6gFiDZSr7Ro9EuMOUod1GmMM5zhwcoPNfmbrpWhFohWWYwAfD/cOy/eOKS7sE FRNdkuXsirmQ== X-IronPort-AV: E=McAfee;i="6000,8403,9746"; a="139024811" X-IronPort-AV: E=Sophos;i="5.76,433,1592895600"; d="scan'208";a="139024811" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2020 09:49:25 -0700 IronPort-SDR: 9XPDFBcq2CYfeTnmvu0XQg2wz09WgX6OsPOZPKgeySGJ/G5i9vFKH+uih3kTRLcOlE6xtadwXz BKL5zDVguypQ== X-IronPort-AV: E=Sophos;i="5.76,433,1592895600"; d="scan'208";a="307109500" Received: from sjchrist-ice.jf.intel.com (HELO sjchrist-ice) ([10.54.31.34]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2020 09:49:24 -0700 Date: Wed, 16 Sep 2020 09:49:23 -0700 From: Sean Christopherson To: Tom Lendacky Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Paolo Bonzini , Jim Mattson , Joerg Roedel , Vitaly Kuznetsov , Wanpeng Li , Borislav Petkov , Ingo Molnar , Thomas Gleixner , Brijesh Singh Subject: Re: [RFC PATCH 08/35] KVM: SVM: Prevent debugging under SEV-ES Message-ID: <20200916164923.GC10227@sjchrist-ice> References: <58093c542b5b442b88941828595fb2548706f1bf.1600114548.git.thomas.lendacky@amd.com> <20200914212601.GA7192@sjchrist-ice> <20200915163010.GB8420@sjchrist-ice> <5e816811-450f-b732-76f7-6130479642e0@amd.com> <20200916160210.GA10227@sjchrist-ice> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 16, 2020 at 11:38:38AM -0500, Tom Lendacky wrote: > > > On 9/16/20 11:02 AM, Sean Christopherson wrote: > > On Wed, Sep 16, 2020 at 10:11:10AM -0500, Tom Lendacky wrote: > >> On 9/15/20 3:13 PM, Tom Lendacky wrote: > >>> On 9/15/20 11:30 AM, Sean Christopherson wrote: > >>>> I don't quite follow the "doesn't mean debugging can't be done in the future". > >>>> Does that imply that debugging could be supported for SEV-ES guests, even if > >>>> they have an encrypted VMSA? > >>> > >>> Almost anything can be done with software. It would require a lot of > >>> hypervisor and guest code and changes to the GHCB spec, etc. So given > >>> that, probably just the check for arch.guest_state_protected is enough for > >>> now. I'll just need to be sure none of the debugging paths can be taken > >>> before the VMSA is encrypted. > >> > >> So I don't think there's any guarantee that the KVM_SET_GUEST_DEBUG ioctl > >> couldn't be called before the VMSA is encrypted, meaning I can't check the > >> arch.guest_state_protected bit for that call. So if we really want to get > >> rid of the allow_debug() op, I'd need some other way to indicate that this > >> is an SEV-ES / protected state guest. > > > > Would anything break if KVM "speculatively" set guest_state_protected before > > LAUNCH_UPDATE_VMSA? E.g. does KVM need to emulate before LAUNCH_UPDATE_VMSA? > > Yes, the way the code is set up, the guest state (VMSA) is initialized in > the same way it is today (mostly) and that state is encrypted by the > LAUNCH_UPDATE_VMSA call. I check the guest_state_protected bit to decide > on whether to direct the updates to the real VMSA (before it's encrypted) > or the GHCB (that's the get_vmsa() function from patch #5). Ah, gotcha. Would it work to set guest_state_protected[*] from time zero, and move vmsa_encrypted to struct vcpu_svm? I.e. keep vmsa_encrypted, but use it only for guiding get_vmsa() and related behavior.