[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bfaa49c58626932e65096b433c7f37a2c35ca382.camel@intel.com>
Date: Thu, 22 Jan 2026 11:42:39 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "tianwentong2000@...il.com" <tianwentong2000@...il.com>,
"jarkko@...nel.org" <jarkko@...nel.org>, "dave.hansen@...ux.intel.com"
<dave.hansen@...ux.intel.com>
CC: "linux-sgx@...r.kernel.org" <linux-sgx@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>, "mingo@...hat.com"
<mingo@...hat.com>, "tglx@...nel.org" <tglx@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "bp@...en8.de"
<bp@...en8.de>, "x86@...nel.org" <x86@...nel.org>
Subject: Re: [PATCH] x86/sgx: use vm_flags_t for vm_prot_bits
On Thu, 2026-01-22 at 13:54 +0800, Wentong Tian wrote:
> The vm_flags_t type is the dedicated type for virtual memory flags.
> Architecture and driver code should use this type instead of assuming
> vm_flags is an unsigned long, as the underlying type may change in the
> future.
>
> This follows the cleanup in commit d75fa3c94750 ("mm: update
> architecture and driver code to use vm_flags_t") by converting the
> remaining vm_prot_bits usage in SGX code.
>
> No functional change intended.
>
> Signed-off-by: Wentong Tian <tianwentong2000@...il.com>
> ---
> arch/x86/kernel/cpu/sgx/encl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c
> index cf149b9f4916..814edcde225d 100644
> --- a/arch/x86/kernel/cpu/sgx/encl.c
> +++ b/arch/x86/kernel/cpu/sgx/encl.c
> @@ -281,7 +281,7 @@ static struct sgx_encl_page *sgx_encl_load_page_in_vma(struct sgx_encl *encl,
> unsigned long addr,
> vm_flags_t vm_flags)
> {
> - unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
> + vm_flags_t vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
> struct sgx_encl_page *entry;
>
> entry = xa_load(&encl->page_array, PFN_DOWN(addr));
Since commit d75fa3c94750 ("mm: update
architecture and driver code to use vm_flags_t") already converted one
'vm_prot_bits' to vm_flags_t in sgx_encl_may_map(), this looks good to me
too.
One thing though:
'vm_prot_bits' is later bit-ANDed with entry->vm_max_prot_bits:
if ((entry->vm_max_prot_bits & vm_prot_bits) != vm_prot_bits)
return ERR_PTR(-EFAULT);
But 'vm_max_prot_bits' a 8-bit field of 'unsigned long' in 'struct
sgx_encl_page':
struct sgx_encl_page {
unsigned long desc;
unsigned long vm_max_prot_bits:8;
...
};
Not sure we should change that too:
struct sgx_encl_page {
unsigned long desc;
vm_flags_t vm_max_prot_bits:8;
...
};
?
Powered by blists - more mailing lists