Skip to content

Commit b7c3527

Browse files
yosrym93hansendc
authored andcommitted
x86/mm: Cleanup prctl_enable_tagged_addr() nr_bits error checking
There are two separate checks in prctl_enable_tagged_addr() that nr_bits is in the correct range. The checks are arranged such the correct case is sandwiched between both error cases, which do exactly the same thing. Simplify the if condition and pull the correct case outside with the rest of the success code path. Signed-off-by: Yosry Ahmed <yosryahmed@google.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Link: https://lore.kernel.org/all/20240702132139.3332013-4-yosryahmed%40google.com
1 parent ec225f8 commit b7c3527

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

arch/x86/kernel/process_64.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,9 @@ static void enable_lam_func(void *__mm)
812812

813813
static void mm_enable_lam(struct mm_struct *mm)
814814
{
815+
mm->context.lam_cr3_mask = X86_CR3_LAM_U57;
816+
mm->context.untag_mask = ~GENMASK(62, 57);
817+
815818
/*
816819
* Even though the process must still be single-threaded at this
817820
* point, kernel threads may be using the mm. IPI those kernel
@@ -846,13 +849,7 @@ static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)
846849
return -EBUSY;
847850
}
848851

849-
if (!nr_bits) {
850-
mmap_write_unlock(mm);
851-
return -EINVAL;
852-
} else if (nr_bits <= LAM_U57_BITS) {
853-
mm->context.lam_cr3_mask = X86_CR3_LAM_U57;
854-
mm->context.untag_mask = ~GENMASK(62, 57);
855-
} else {
852+
if (!nr_bits || nr_bits > LAM_U57_BITS) {
856853
mmap_write_unlock(mm);
857854
return -EINVAL;
858855
}

0 commit comments

Comments
 (0)