linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai Huang <kai.huang@intel.com>
To: Dave Hansen <dave@sr71.net>, Sean Christopherson <seanjc@google.com>
Cc: linux-sgx@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org,
	jarkko@kernel.org, luto@kernel.org, rick.p.edgecombe@intel.com,
	haitao.huang@intel.com, pbonzini@redhat.com, bp@alien8.de,
	tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com
Subject: Re: [RFC PATCH v6 03/25] x86/sgx: Wipe out EREMOVE from sgx_free_epc_page()
Date: Mon, 01 Mar 2021 19:13:25 +1300	[thread overview]
Message-ID: <c528da37e6ea6172d68270d8bdc1280afc1e98c8.camel@intel.com> (raw)
In-Reply-To: <55e0f003-ca2b-24d2-5a23-31a77c5b943d@sr71.net>

On Fri, 2021-02-26 at 12:12 -0800, Dave Hansen wrote:
> On 2/26/21 11:52 AM, Sean Christopherson wrote:
> > > We must give a more informative message saying that the page is leaked.
> > >  Ideally, we'd also make this debuggable by dumping out how many of
> > > these pages there have been somewhere.  That can wait, though, until we
> > > have some kind of stats coming out of the code (there's nothing now).  A
> > > comment to remind us to do this would be nice.
> > Eh, having debugged these several times, the WARN_ONCE in sgx_reset_epc_page()
> > is probably sufficient.  IIRC, when I hit this, things were either laughably
> > broken and every page was failing, or there was another ENCLS failure somewhere
> > else that provided additional info.  Not saying don't add more debug info,
> > rather that it's probably not a priority.
> 
> Minimally, I just want a warning that says, "Whoops, I leaked a page".
> Or EREMOVE could even say, "whoops, this *MIGHT* leak a page".
> 
> My beef is mostly that "EREMOVE failed" doesn't tell and end user squat
> about what this means for their system.  At least if we say "leaked",
> they have some inclination that they've got to reboot to get the page back.

Agreed that a msg to say EPC page is leaked is useful. However I found with current
sgx_reset_epc_page() I cannot find a suitable place to add:

Theoretically, it's not that right to add "EPC page is leaked", or even *might* (btw,
I don't think we should use *might* since it is vague), in to sgx_reset_epc_page(),
since whether leak or not is controlled by whether to call sgx_free_epc_page() upon
error, which is not in sgx_reset_epc_page(). And

	if (!sgx_reset_epc_page())
		sgx_free_epc_page();

is called 3 times so I don't want to add a msg for each of them.

I ended up with this solution: 

1) Rename existing sgx_free_epc_page() to sgx_encl_free_epc_page() to make it more
specific that it is used to free EPC page that is assigned to an enclave. 2) Wrap
non-EREMOVE part (putting back to free EPC pool) to sgx_free_epc_page() so it can be
used by virtual EPC.

In this way we can just put the error msg in sgx_encl_free_epc_page().

And as you said it's time to get RFC tag off, so I'll send out formal patch with
above solution, but w/o your Acked-by on this particular patch. Thanks :)


  parent reply	other threads:[~2021-03-01  6:14 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26 12:14 [RFC PATCH v6 00/25] KVM SGX virtualization support Kai Huang
2021-02-26 12:14 ` [RFC PATCH v6 01/25] x86/cpufeatures: Make SGX_LC feature bit depend on SGX bit Kai Huang
2021-02-26 12:14 ` [RFC PATCH v6 02/25] x86/cpufeatures: Add SGX1 and SGX2 sub-features Kai Huang
2021-02-26 12:14 ` [RFC PATCH v6 03/25] x86/sgx: Wipe out EREMOVE from sgx_free_epc_page() Kai Huang
2021-02-26 17:08   ` Dave Hansen
2021-02-26 19:52     ` Sean Christopherson
2021-02-26 20:12       ` Dave Hansen
2021-02-26 22:34         ` Sean Christopherson
2021-03-01  6:13         ` Kai Huang [this message]
2021-02-26 12:14 ` [RFC PATCH v6 04/25] x86/sgx: Add SGX_CHILD_PRESENT hardware error code Kai Huang
2021-02-26 12:14 ` [RFC PATCH v6 05/25] x86/sgx: Introduce virtual EPC for use by KVM guests Kai Huang
2021-02-26 12:14 ` [RFC PATCH v6 06/25] x86/cpu/intel: Allow SGX virtualization without Launch Control support Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 07/25] x86/sgx: Initialize virtual EPC driver even when SGX driver is disabled Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 08/25] x86/sgx: Expose SGX architectural definitions to the kernel Kai Huang
2021-02-26 17:09   ` Dave Hansen
2021-02-26 12:15 ` [RFC PATCH v6 09/25] x86/sgx: Move ENCLS leaf definitions to sgx.h Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 10/25] x86/sgx: Add SGX2 ENCLS leaf definitions (EAUG, EMODPR and EMODT) Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 11/25] x86/sgx: Add encls_faulted() helper Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 12/25] x86/sgx: Add helper to update SGX_LEPUBKEYHASHn MSRs Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 13/25] x86/sgx: Add helpers to expose ECREATE and EINIT to KVM Kai Huang
2021-03-05 17:51   ` Dave Hansen
2021-03-08  9:30     ` Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 14/25] x86/sgx: Move provisioning device creation out of SGX driver Kai Huang
2021-03-05 17:45   ` Dave Hansen
2021-02-26 12:15 ` [RFC PATCH v6 15/25] KVM: x86: Export kvm_mmu_gva_to_gpa_{read,write}() for SGX (VMX) Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 16/25] KVM: x86: Define new #PF SGX error code bit Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 17/25] KVM: x86: Add support for reverse CPUID lookup of scattered features Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 18/25] KVM: x86: Add reverse-CPUID lookup support for scattered SGX features Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 19/25] KVM: VMX: Add basic handling of VM-Exit from SGX enclave Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 20/25] KVM: VMX: Frame in ENCLS handler for SGX virtualization Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 21/25] KVM: VMX: Add SGX ENCLS[ECREATE] handler to enforce CPUID restrictions Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 22/25] KVM: VMX: Add emulation of SGX Launch Control LE hash MSRs Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 23/25] KVM: VMX: Add ENCLS[EINIT] handler to support SGX Launch Control (LC) Kai Huang
2021-02-26 12:15 ` [RFC PATCH v6 24/25] KVM: VMX: Enable SGX virtualization for SGX1, SGX2 and LC Kai Huang
2021-02-26 12:16 ` [RFC PATCH v6 25/25] KVM: x86: Add capability to grant VM access to privileged SGX attribute Kai Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c528da37e6ea6172d68270d8bdc1280afc1e98c8.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=bp@alien8.de \
    --cc=dave@sr71.net \
    --cc=haitao.huang@intel.com \
    --cc=hpa@zytor.com \
    --cc=jarkko@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).