From: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
To: "Nysal Jan K.A." <nysal@linux.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Segher Boessenkool <segher@kernel.crashing.org>,
linuxppc-dev@lists.ozlabs.org,
Kevin Brodsky <kevin.brodsky@arm.com>,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests/mm: Fix a build failure on powerpc
Date: Mon, 28 Apr 2025 22:19:28 +0530 [thread overview]
Message-ID: <a1d2c51c-7959-4446-81b7-bfc48ced606e@linux.ibm.com> (raw)
In-Reply-To: <20250428131937.641989-2-nysal@linux.ibm.com>
On 28/04/25 6:49 pm, Nysal Jan K.A. wrote:
> The compiler is unaware of the size of code generated by the ".rept"
> assembler directive. This results in the compiler emitting branch
> instructions where the offset to branch to exceeds the maximum allowed
> value, resulting in build failures like the following:
>
> CC protection_keys
> /tmp/ccypKWAE.s: Assembler messages:
> /tmp/ccypKWAE.s:2073: Error: operand out of range (0x0000000000020158
> is not between 0xffffffffffff8000 and 0x0000000000007ffc)
> /tmp/ccypKWAE.s:2509: Error: operand out of range (0x0000000000020130
> is not between 0xffffffffffff8000 and 0x0000000000007ffc)
>
> Fix the issue by manually adding nop instructions using the preprocessor.
>
> Fixes: 46036188ea1f5 ("selftests/mm: build with -O2")
> Reported-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Signed-off-by: Nysal Jan K.A. <nysal@linux.ibm.com>
> ---
> tools/testing/selftests/mm/pkey-powerpc.h | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/pkey-powerpc.h b/tools/testing/selftests/mm/pkey-powerpc.h
> index d8ec906b8120..17bf2d1b0192 100644
> --- a/tools/testing/selftests/mm/pkey-powerpc.h
> +++ b/tools/testing/selftests/mm/pkey-powerpc.h
> @@ -104,8 +104,18 @@ static inline void expect_fault_on_read_execonly_key(void *p1, int pkey)
> return;
> }
>
> +#define REPEAT_8(s) s s s s s s s s
> +#define REPEAT_64(s) REPEAT_8(s) REPEAT_8(s) REPEAT_8(s) REPEAT_8(s) \
> + REPEAT_8(s) REPEAT_8(s) REPEAT_8(s) REPEAT_8(s)
> +#define REPEAT_512(s) REPEAT_64(s) REPEAT_64(s) REPEAT_64(s) REPEAT_64(s) \
> + REPEAT_64(s) REPEAT_64(s) REPEAT_64(s) REPEAT_64(s)
> +#define REPEAT_4096(s) REPEAT_512(s) REPEAT_512(s) REPEAT_512(s) REPEAT_512(s) \
> + REPEAT_512(s) REPEAT_512(s) REPEAT_512(s) REPEAT_512(s)
> +#define REPEAT_16384(s) REPEAT_4096(s) REPEAT_4096(s) \
> + REPEAT_4096(s) REPEAT_4096(s)
> +
> /* 4-byte instructions * 16384 = 64K page */
> -#define __page_o_noops() asm(".rept 16384 ; nop; .endr")
> +#define __page_o_noops() asm(REPEAT_16384("nop\n"))
>
> static inline void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey)
> {
Tested this patch by applying on top of mainline kernel v6.15-rc4, and
it fixes the build issue. Hence,
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Without this Patch:
CC protection_keys
/tmp/ccG0zLKW.s: Assembler messages:
/tmp/ccG0zLKW.s:1694: Error: operand out of range (0x0000000000020138 is
not between 0xffffffffffff8000 and 0x0000000000007ffc)
/tmp/ccG0zLKW.s:2577: Error: operand out of range (0x0000000000020110 is
not between 0xffffffffffff8000 and 0x0000000000007ffc)
In file included from pkey_util.c:5:
With this patch:
make -j 33
/bin/sh ./check_config.sh gcc
CC cow
CC compaction_test
CC gup_longterm
CC gup_test
CC hmm-tests
CC hugetlb-madvise
CC hugetlb-read-hwpoison
CC hugetlb-soft-offline
CC hugepage-mmap
CC hugepage-mremap
CC hugepage-shm
CC hugepage-vmemmap
CC khugepaged
CC madv_populate
CC map_fixed_noreplace
CC map_hugetlb
CC map_populate
CC migration
CC mkdirty
CC mlock-random-test
CC mlock2-tests
CC mrelease_test
CC mremap_dontunmap
CC mremap_test
CC mseal_test
CC on-fault-limit
CC pagemap_ioctl
CC thuge-gen
CC transhuge-stress
CC uffd-stress
CC uffd-unit-tests
CC uffd-wp-mremap
CC split_huge_page_test
CC ksm_tests
CC ksm_functional_tests
CC hugetlb_fault_after_madv
CC hugetlb_madv_vs_map
CC mdwe_test
CC hugetlb_dio
CC droppable
CC guard-regions
CC soft-dirty
CC protection_keys
CC va_high_addr_switch
CC virtual_address_range
CC write_to_hugetlbfs
CC [M] page_frag_test.o
MODPOST Module.symvers
CC [M] page_frag_test.mod.o
CC [M] .module-common.o
LD [M] page_frag_test.ko
Regards,
Venkat.
next prev parent reply other threads:[~2025-04-28 16:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 13:19 [PATCH 1/2] selftests/mm: Fix build break when compiling pkey_util.c Nysal Jan K.A.
2025-04-28 13:19 ` [PATCH 2/2] selftests/mm: Fix a build failure on powerpc Nysal Jan K.A.
2025-04-28 16:49 ` Venkat Rao Bagalkote [this message]
2025-04-28 17:13 ` Donet Tom
2025-04-28 16:47 ` [PATCH 1/2] selftests/mm: Fix build break when compiling pkey_util.c Venkat Rao Bagalkote
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=a1d2c51c-7959-4446-81b7-bfc48ced606e@linux.ibm.com \
--to=venkat88@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=kevin.brodsky@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=nysal@linux.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=shuah@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