linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Get rid of BUG()
@ 2017-01-26 21:20 Jarkko Sakkinen
  2017-01-26 21:20 ` [PATCH 1/3] intel_sgx: do not use BUG() in sgx_free_page() Jarkko Sakkinen
  2017-01-28 13:32 ` [PATCH 0/3] Get rid of BUG() Andy Shevchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2017-01-26 21:20 UTC (permalink / raw)
  To: intel-sgx-kernel-dev
  Cc: Jarkko Sakkinen, open list, open list:X86 PLATFORM DRIVERS

The use of BUG() is not favored for any new kernel code. This patch set
implements more reasonable error recovery. In all cases the recovery is not
ideal but it is an improvement to the current situation.

In addition, sgx_free_page() has been simplified by removing the parameter for
skipping EREMOVE. EREMOVE can be successfully executed for an unused EPC page.

Jarkko Sakkinen (3):
  intel_sgx: do not use BUG() in sgx_free_page()
  intel_sgx: remove flags parameter from sgx_free_page()
  intel_sgx: fix error paths for EBLOCK and ETRACK

 drivers/platform/x86/intel_sgx.h            |  4 +-
 drivers/platform/x86/intel_sgx_ioctl.c      | 12 ++--
 drivers/platform/x86/intel_sgx_page_cache.c | 89 +++++++++++++++--------------
 drivers/platform/x86/intel_sgx_util.c       |  6 +-
 drivers/platform/x86/intel_sgx_vma.c        |  6 +-
 5 files changed, 55 insertions(+), 62 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] intel_sgx: do not use BUG() in sgx_free_page()
  2017-01-26 21:20 [PATCH 0/3] Get rid of BUG() Jarkko Sakkinen
@ 2017-01-26 21:20 ` Jarkko Sakkinen
  2017-01-27 15:45   ` Andy Shevchenko
  2017-01-28 13:32 ` [PATCH 0/3] Get rid of BUG() Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Jarkko Sakkinen @ 2017-01-26 21:20 UTC (permalink / raw)
  To: intel-sgx-kernel-dev
  Cc: Jarkko Sakkinen, Darren Hart, open list:X86 PLATFORM DRIVERS, open list

EREMOVE fails on non-EPC page or when a SECS page with children is to be
removed. These do not happen if the driver is working correctly. Log the
error but do not crash the driver.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/platform/x86/intel_sgx_page_cache.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/intel_sgx_page_cache.c b/drivers/platform/x86/intel_sgx_page_cache.c
index d073057..7f73ac7 100644
--- a/drivers/platform/x86/intel_sgx_page_cache.c
+++ b/drivers/platform/x86/intel_sgx_page_cache.c
@@ -551,10 +551,8 @@ void sgx_free_page(struct sgx_epc_page *entry,
 		ret = __eremove(epc);
 		sgx_put_epc_page(epc);
 
-		if (ret) {
-			pr_err("EREMOVE returned %d\n", ret);
-			BUG();
-		}
+		if (ret)
+			sgx_err(encl, "EREMOVE returned %d\n", ret);
 	}
 
 	spin_lock(&sgx_free_list_lock);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] intel_sgx: do not use BUG() in sgx_free_page()
  2017-01-26 21:20 ` [PATCH 1/3] intel_sgx: do not use BUG() in sgx_free_page() Jarkko Sakkinen
@ 2017-01-27 15:45   ` Andy Shevchenko
  2017-01-29 15:11     ` Jarkko Sakkinen
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2017-01-27 15:45 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: intel-sgx-kernel-dev, Darren Hart,
	open list:X86 PLATFORM DRIVERS, open list

On Thu, Jan 26, 2017 at 11:20 PM, Jarkko Sakkinen
<jarkko.sakkinen@linux.intel.com> wrote:
> EREMOVE fails on non-EPC page or when a SECS page with children is to be
> removed. These do not happen if the driver is working correctly. Log the
> error but do not crash the driver.
>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
>  drivers/platform/x86/intel_sgx_page_cache.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/x86/intel_sgx_page_cache.c b/drivers/platform/x86/intel_sgx_page_cache.c
> index d073057..7f73ac7 100644
> --- a/drivers/platform/x86/intel_sgx_page_cache.c
> +++ b/drivers/platform/x86/intel_sgx_page_cache.c
> @@ -551,10 +551,8 @@ void sgx_free_page(struct sgx_epc_page *entry,
>                 ret = __eremove(epc);
>                 sgx_put_epc_page(epc);
>
> -               if (ret) {
> -                       pr_err("EREMOVE returned %d\n", ret);
> -                       BUG();
> -               }
> +               if (ret)
> +                       sgx_err(encl, "EREMOVE returned %d\n", ret);

Do you have something like critical level? For me seems reasonable to
increase the level of message if BUG() was somehow related to actual
situation.

>         }
>
>         spin_lock(&sgx_free_list_lock);

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] Get rid of BUG()
  2017-01-26 21:20 [PATCH 0/3] Get rid of BUG() Jarkko Sakkinen
  2017-01-26 21:20 ` [PATCH 1/3] intel_sgx: do not use BUG() in sgx_free_page() Jarkko Sakkinen
@ 2017-01-28 13:32 ` Andy Shevchenko
  1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-01-28 13:32 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: intel-sgx-kernel-dev, open list, open list:X86 PLATFORM DRIVERS

On Thu, Jan 26, 2017 at 11:20 PM, Jarkko Sakkinen
<jarkko.sakkinen@linux.intel.com> wrote:
> The use of BUG() is not favored for any new kernel code. This patch set
> implements more reasonable error recovery. In all cases the recovery is not
> ideal but it is an improvement to the current situation.
>
> In addition, sgx_free_page() has been simplified by removing the parameter for
> skipping EREMOVE. EREMOVE can be successfully executed for an unused EPC page.
>
> Jarkko Sakkinen (3):

By some reason I only see first patch.
What's going on?

>   intel_sgx: do not use BUG() in sgx_free_page()
>   intel_sgx: remove flags parameter from sgx_free_page()
>   intel_sgx: fix error paths for EBLOCK and ETRACK
>
>  drivers/platform/x86/intel_sgx.h            |  4 +-
>  drivers/platform/x86/intel_sgx_ioctl.c      | 12 ++--
>  drivers/platform/x86/intel_sgx_page_cache.c | 89 +++++++++++++++--------------
>  drivers/platform/x86/intel_sgx_util.c       |  6 +-
>  drivers/platform/x86/intel_sgx_vma.c        |  6 +-
>  5 files changed, 55 insertions(+), 62 deletions(-)
>
> --
> 2.9.3
>



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] intel_sgx: do not use BUG() in sgx_free_page()
  2017-01-27 15:45   ` Andy Shevchenko
@ 2017-01-29 15:11     ` Jarkko Sakkinen
  0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2017-01-29 15:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: intel-sgx-kernel-dev, Darren Hart,
	open list:X86 PLATFORM DRIVERS, open list

On Fri, Jan 27, 2017 at 05:45:03PM +0200, Andy Shevchenko wrote:
> On Thu, Jan 26, 2017 at 11:20 PM, Jarkko Sakkinen
> <jarkko.sakkinen@linux.intel.com> wrote:
> > EREMOVE fails on non-EPC page or when a SECS page with children is to be
> > removed. These do not happen if the driver is working correctly. Log the
> > error but do not crash the driver.
> >
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > ---
> >  drivers/platform/x86/intel_sgx_page_cache.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/platform/x86/intel_sgx_page_cache.c b/drivers/platform/x86/intel_sgx_page_cache.c
> > index d073057..7f73ac7 100644
> > --- a/drivers/platform/x86/intel_sgx_page_cache.c
> > +++ b/drivers/platform/x86/intel_sgx_page_cache.c
> > @@ -551,10 +551,8 @@ void sgx_free_page(struct sgx_epc_page *entry,
> >                 ret = __eremove(epc);
> >                 sgx_put_epc_page(epc);
> >
> > -               if (ret) {
> > -                       pr_err("EREMOVE returned %d\n", ret);
> > -                       BUG();
> > -               }
> > +               if (ret)
> > +                       sgx_err(encl, "EREMOVE returned %d\n", ret);
> 
> Do you have something like critical level? For me seems reasonable to
> increase the level of message if BUG() was somehow related to actual
> situation.

Hmm... I think that would make sense. This could only happen when
the driver implementation is working incorrectly.

/Jarkko

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-29 15:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 21:20 [PATCH 0/3] Get rid of BUG() Jarkko Sakkinen
2017-01-26 21:20 ` [PATCH 1/3] intel_sgx: do not use BUG() in sgx_free_page() Jarkko Sakkinen
2017-01-27 15:45   ` Andy Shevchenko
2017-01-29 15:11     ` Jarkko Sakkinen
2017-01-28 13:32 ` [PATCH 0/3] Get rid of BUG() Andy Shevchenko

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).