[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191217144548.GF28788@zn.tnic>
Date: Tue, 17 Dec 2019 15:45:48 +0100
From: Borislav Petkov <bp@...en8.de>
To: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org,
linux-sgx@...r.kernel.org, akpm@...ux-foundation.org,
dave.hansen@...el.com, sean.j.christopherson@...el.com,
nhorman@...hat.com, npmccallum@...hat.com, serge.ayoun@...el.com,
shay.katz-zamir@...el.com, haitao.huang@...el.com,
andriy.shevchenko@...ux.intel.com, tglx@...utronix.de,
kai.svahn@...el.com, josh@...htriplett.org, luto@...nel.org,
kai.huang@...el.com, rientjes@...gle.com, cedric.xing@...el.com,
puiterwijk@...hat.com
Subject: Re: [PATCH v24 06/24] x86/sgx: Add wrappers for ENCLS leaf functions
On Sat, Nov 30, 2019 at 01:13:08AM +0200, Jarkko Sakkinen wrote:
> +/**
> + * encls_failed() - Check if an ENCLS leaf function failed
> + * @ret: the return value of an ENCLS leaf function call
> + *
> + * Check if an ENCLS leaf function failed. This happens when the leaf function
> + * causes a fault that is not caused by an EPCM conflict or when the leaf
> + * function returns a non-zero value.
> + */
> +static inline bool encls_failed(int ret)
> +{
> + int epcm_trapnr =
> + boot_cpu_has(X86_FEATURE_SGX2) ? X86_TRAP_PF : X86_TRAP_GP;
> + bool fault = ret & ENCLS_FAULT_FLAG;
> +
> + return (fault && ENCLS_TRAPNR(ret) != epcm_trapnr) || (!fault && ret);
> +}
Can we make this function more readable?
static inline bool encls_failed(int ret)
{
int epcm_trapnr;
if (boot_cpu_has(X86_FEATURE_SGX2))
epcm_trapnr = X86_TRAP_PF;
else
epcm_trapnr = X86_TRAP_GP;
if (ret & ENCLS_FAULT_FLAG)
return ENCLS_TRAPNR(ret) != epcm_trapnr;
return !!ret;
}
I hope I've converted it correctly but I might've missed some corner
case...
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists