* [PATCH] libffi: Fix MIPS r6 support
@ 2021-08-27 4:58 YunQiang Su
2021-08-27 21:28 ` Jeff Law
0 siblings, 1 reply; 8+ messages in thread
From: YunQiang Su @ 2021-08-27 4:58 UTC (permalink / raw)
To: gcc-patches; +Cc: syq, doko, YunQiang Su
for some instructions, MIPS r6 uses different encoding other than
the previous releases.
1. mips/n32.S disable .set mips4: since it casuses old insn encoding
is used.
https://github.com/libffi/libffi/pull/396
2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
different value for r6 and pre-r6.
https://github.com/libffi/libffi/pull/401
libffi/
PR libffi/83636
* src/mips/n32.S: disable .set mips4
* src/mips/ffi.c: use different JR encoding for r6.
---
libffi/src/mips/ffi.c | 8 ++++++++
libffi/src/mips/n32.S | 2 ++
2 files changed, 10 insertions(+)
diff --git a/libffi/src/mips/ffi.c b/libffi/src/mips/ffi.c
index 5d0dd70cb..ecd783a56 100644
--- a/libffi/src/mips/ffi.c
+++ b/libffi/src/mips/ffi.c
@@ -698,7 +698,11 @@ ffi_prep_closure_loc (ffi_closure *closure,
/* lui $12,high(codeloc) */
tramp[2] = 0x3c0c0000 | ((unsigned)codeloc >> 16);
/* jr $25 */
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
tramp[3] = 0x03200008;
+#else
+ tramp[3] = 0x03200009;
+#endif
/* ori $12,low(codeloc) */
tramp[4] = 0x358c0000 | ((unsigned)codeloc & 0xffff);
#else
@@ -726,7 +730,11 @@ ffi_prep_closure_loc (ffi_closure *closure,
/* ori $25,low(fn) */
tramp[10] = 0x37390000 | ((unsigned long)fn & 0xffff);
/* jr $25 */
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
tramp[11] = 0x03200008;
+#else
+ tramp[11] = 0x03200009;
+#endif
/* ori $12,low(codeloc) */
tramp[12] = 0x358c0000 | ((unsigned long)codeloc & 0xffff);
diff --git a/libffi/src/mips/n32.S b/libffi/src/mips/n32.S
index c6985d30a..06e6c4607 100644
--- a/libffi/src/mips/n32.S
+++ b/libffi/src/mips/n32.S
@@ -43,7 +43,9 @@
#ifdef __GNUC__
.abicalls
#endif
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
.set mips4
+#endif
.text
.align 2
.globl ffi_call_N32
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libffi: Fix MIPS r6 support
2021-08-27 4:58 [PATCH] libffi: Fix MIPS r6 support YunQiang Su
@ 2021-08-27 21:28 ` Jeff Law
2021-08-28 7:23 ` Xi Ruoyao
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2021-08-27 21:28 UTC (permalink / raw)
To: YunQiang Su, gcc-patches
On 8/26/2021 10:58 PM, YunQiang Su wrote:
> for some instructions, MIPS r6 uses different encoding other than
> the previous releases.
>
> 1. mips/n32.S disable .set mips4: since it casuses old insn encoding
> is used.
> https://github.com/libffi/libffi/pull/396
> 2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
> different value for r6 and pre-r6.
> https://github.com/libffi/libffi/pull/401
>
> libffi/
> PR libffi/83636
> * src/mips/n32.S: disable .set mips4
> * src/mips/ffi.c: use different JR encoding for r6.
These should go to the upstream libffi project. Once accepted there you
can add them to GCC.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libffi: Fix MIPS r6 support
2021-08-27 21:28 ` Jeff Law
@ 2021-08-28 7:23 ` Xi Ruoyao
2021-08-28 12:14 ` YunQiang Su
2021-08-29 21:00 ` Jeff Law
0 siblings, 2 replies; 8+ messages in thread
From: Xi Ruoyao @ 2021-08-28 7:23 UTC (permalink / raw)
To: Jeff Law, YunQiang Su, gcc-patches
On Fri, 2021-08-27 at 15:28 -0600, Jeff Law via Gcc-patches wrote:
>
>
> On 8/26/2021 10:58 PM, YunQiang Su wrote:
> > for some instructions, MIPS r6 uses different encoding other than
> > the previous releases.
> >
> > 1. mips/n32.S disable .set mips4: since it casuses old insn encoding
> > is used.
> > https://github.com/libffi/libffi/pull/396
> > 2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
> > different value for r6 and pre-r6.
> > https://github.com/libffi/libffi/pull/401
> >
> > libffi/
> > PR libffi/83636
> > * src/mips/n32.S: disable .set mips4
> > * src/mips/ffi.c: use different JR encoding for r6.
> These should go to the upstream libffi project. Once accepted there
> you
> can add them to GCC.
Hi Jeff,
The two PRs are already merged, and released since libffi-3.3.0 (now the
upstream latest release is 3.4.2).
I don't have a MIPSr6 so I can't test though.
YunQiang: the commit message should mention the commit SHA in upstream
libffi repo's main branch, instead of a URL to PR. You can use "git
log" in gcc repo and search for commits for libffi and learn from it.
--
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libffi: Fix MIPS r6 support
2021-08-28 7:23 ` Xi Ruoyao
@ 2021-08-28 12:14 ` YunQiang Su
2021-08-29 21:00 ` Jeff Law
1 sibling, 0 replies; 8+ messages in thread
From: YunQiang Su @ 2021-08-28 12:14 UTC (permalink / raw)
To: Xi Ruoyao; +Cc: Jeff Law, YunQiang Su, gcc-patches
Xi Ruoyao via Gcc-patches <gcc-patches@gcc.gnu.org> 于2021年8月28日周六 下午3:25写道:
>
> On Fri, 2021-08-27 at 15:28 -0600, Jeff Law via Gcc-patches wrote:
> >
> >
> > On 8/26/2021 10:58 PM, YunQiang Su wrote:
> > > for some instructions, MIPS r6 uses different encoding other than
> > > the previous releases.
> > >
> > > 1. mips/n32.S disable .set mips4: since it casuses old insn encoding
> > > is used.
> > > https://github.com/libffi/libffi/pull/396
> > > 2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
> > > different value for r6 and pre-r6.
> > > https://github.com/libffi/libffi/pull/401
> > >
> > > libffi/
> > > PR libffi/83636
> > > * src/mips/n32.S: disable .set mips4
> > > * src/mips/ffi.c: use different JR encoding for r6.
> > These should go to the upstream libffi project. Once accepted there
> > you
> > can add them to GCC.
>
> Hi Jeff,
>
> The two PRs are already merged, and released since libffi-3.3.0 (now the
> upstream latest release is 3.4.2).
>
> I don't have a MIPSr6 so I can't test though.
>
We do have a qemu tarball. Please see:
Debian: http://58.246.137.130:20180/README.txt
Arch: http://58.246.137.130:20180/archlinux/dist/
> YunQiang: the commit message should mention the commit SHA in upstream
> libffi repo's main branch, instead of a URL to PR. You can use "git
> log" in gcc repo and search for commits for libffi and learn from it.
> --
> Xi Ruoyao <xry111@mengyan1223.wang>
> School of Aerospace Science and Technology, Xidian University
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libffi: Fix MIPS r6 support
2021-08-28 7:23 ` Xi Ruoyao
2021-08-28 12:14 ` YunQiang Su
@ 2021-08-29 21:00 ` Jeff Law
2021-08-30 8:47 ` YunQiang Su
1 sibling, 1 reply; 8+ messages in thread
From: Jeff Law @ 2021-08-29 21:00 UTC (permalink / raw)
To: Xi Ruoyao, YunQiang Su, gcc-patches
On 8/28/2021 1:23 AM, Xi Ruoyao wrote:
> On Fri, 2021-08-27 at 15:28 -0600, Jeff Law via Gcc-patches wrote:
>>
>> On 8/26/2021 10:58 PM, YunQiang Su wrote:
>>> for some instructions, MIPS r6 uses different encoding other than
>>> the previous releases.
>>>
>>> 1. mips/n32.S disable .set mips4: since it casuses old insn encoding
>>> is used.
>>> https://github.com/libffi/libffi/pull/396
>>> 2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
>>> different value for r6 and pre-r6.
>>> https://github.com/libffi/libffi/pull/401
>>>
>>> libffi/
>>> PR libffi/83636
>>> * src/mips/n32.S: disable .set mips4
>>> * src/mips/ffi.c: use different JR encoding for r6.
>> These should go to the upstream libffi project. Once accepted there
>> you
>> can add them to GCC.
> Hi Jeff,
>
> The two PRs are already merged, and released since libffi-3.3.0 (now the
> upstream latest release is 3.4.2).
ACK. Thanks for confirming. It's always OK to cherrypick/backport from
libffi back to GCC.
>
> I don't have a MIPSr6 so I can't test though.
Understood. Me neither, but I really should get a tiny chroot for
mipsr6 so that my tester can validate it regularly.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libffi: Fix MIPS r6 support
2021-08-29 21:00 ` Jeff Law
@ 2021-08-30 8:47 ` YunQiang Su
2021-08-30 13:46 ` Jeff Law
0 siblings, 1 reply; 8+ messages in thread
From: YunQiang Su @ 2021-08-30 8:47 UTC (permalink / raw)
To: Jeff Law, Xi Ruoyao, gcc-patches
在 2021/8/30 5:00, Jeff Law 写道:
>
>
> On 8/28/2021 1:23 AM, Xi Ruoyao wrote:
>> On Fri, 2021-08-27 at 15:28 -0600, Jeff Law via Gcc-patches wrote:
>>>
>>> On 8/26/2021 10:58 PM, YunQiang Su wrote:
>>>> for some instructions, MIPS r6 uses different encoding other than
>>>> the previous releases.
>>>>
>>>> 1. mips/n32.S disable .set mips4: since it casuses old insn encoding
>>>> is used.
>>>> https://github.com/libffi/libffi/pull/396
>>>> 2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
>>>> different value for r6 and pre-r6.
>>>> https://github.com/libffi/libffi/pull/401
>>>>
>>>> libffi/
>>>> PR libffi/83636
>>>> * src/mips/n32.S: disable .set mips4
>>>> * src/mips/ffi.c: use different JR encoding for r6.
>>> These should go to the upstream libffi project. Once accepted there
>>> you
>>> can add them to GCC.
>> Hi Jeff,
>>
>> The two PRs are already merged, and released since libffi-3.3.0 (now the
>> upstream latest release is 3.4.2).
> ACK. Thanks for confirming. It's always OK to cherrypick/backport from
> libffi back to GCC.
>
>>
>> I don't have a MIPSr6 so I can't test though.
> Understood. Me neither, but I really should get a tiny chroot for
> mipsr6 so that my tester can validate it regularly.
>
We have port Debian to MIPS64r6el.
http://58.246.137.130:20180/tools/tarball/
You can use both buster(Debian 10) or bullseye (Debian 11).
And both qemu-system and qemu-user can work.
> Jeff
> .
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libffi: Fix MIPS r6 support
2021-08-30 8:47 ` YunQiang Su
@ 2021-08-30 13:46 ` Jeff Law
2021-08-31 2:46 ` YunQiang Su
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2021-08-30 13:46 UTC (permalink / raw)
To: YunQiang Su, Xi Ruoyao, gcc-patches
On 8/30/2021 2:47 AM, YunQiang Su wrote:
> 在 2021/8/30 5:00, Jeff Law 写道:
>>
>>
>> On 8/28/2021 1:23 AM, Xi Ruoyao wrote:
>>> On Fri, 2021-08-27 at 15:28 -0600, Jeff Law via Gcc-patches wrote:
>>>>
>>>> On 8/26/2021 10:58 PM, YunQiang Su wrote:
>>>>> for some instructions, MIPS r6 uses different encoding other than
>>>>> the previous releases.
>>>>>
>>>>> 1. mips/n32.S disable .set mips4: since it casuses old insn encoding
>>>>> is used.
>>>>> https://github.com/libffi/libffi/pull/396
>>>>> 2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
>>>>> different value for r6 and pre-r6.
>>>>> https://github.com/libffi/libffi/pull/401
>>>>>
>>>>> libffi/
>>>>> PR libffi/83636
>>>>> * src/mips/n32.S: disable .set mips4
>>>>> * src/mips/ffi.c: use different JR encoding for r6.
>>>> These should go to the upstream libffi project. Once accepted there
>>>> you
>>>> can add them to GCC.
>>> Hi Jeff,
>>>
>>> The two PRs are already merged, and released since libffi-3.3.0 (now
>>> the
>>> upstream latest release is 3.4.2).
>> ACK. Thanks for confirming. It's always OK to cherrypick/backport
>> from libffi back to GCC.
>>
>>>
>>> I don't have a MIPSr6 so I can't test though.
>> Understood. Me neither, but I really should get a tiny chroot for
>> mipsr6 so that my tester can validate it regularly.
>>
>
> We have port Debian to MIPS64r6el.
> http://58.246.137.130:20180/tools/tarball/
> You can use both buster(Debian 10) or bullseye (Debian 11).
>
> And both qemu-system and qemu-user can work.
Understood. I need the minimal chroot to compress down under 100M to
make gitlab happy (that's where my scripts & jenkins system expect to
find them). My scripts to build the chroots also ensure a consistent
set of packages & version #s across the different systems being
tested. I've just never gotten around to building one for mips64r6. I
could probably take yours trim out unnecessary stuff and use it for
now. Getting a bootstrap test on the target weekly is definitely helpful.
jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] libffi: Fix MIPS r6 support
2021-08-30 13:46 ` Jeff Law
@ 2021-08-31 2:46 ` YunQiang Su
0 siblings, 0 replies; 8+ messages in thread
From: YunQiang Su @ 2021-08-31 2:46 UTC (permalink / raw)
To: Jeff Law; +Cc: YunQiang Su, Xi Ruoyao, gcc-patches
Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> 于2021年8月30日周一 下午9:48写道:
>
>
>
> On 8/30/2021 2:47 AM, YunQiang Su wrote:
> > 在 2021/8/30 5:00, Jeff Law 写道:
> >>
> >>
> >> On 8/28/2021 1:23 AM, Xi Ruoyao wrote:
> >>> On Fri, 2021-08-27 at 15:28 -0600, Jeff Law via Gcc-patches wrote:
> >>>>
> >>>> On 8/26/2021 10:58 PM, YunQiang Su wrote:
> >>>>> for some instructions, MIPS r6 uses different encoding other than
> >>>>> the previous releases.
> >>>>>
> >>>>> 1. mips/n32.S disable .set mips4: since it casuses old insn encoding
> >>>>> is used.
> >>>>> https://github.com/libffi/libffi/pull/396
> >>>>> 2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
> >>>>> different value for r6 and pre-r6.
> >>>>> https://github.com/libffi/libffi/pull/401
> >>>>>
> >>>>> libffi/
> >>>>> PR libffi/83636
> >>>>> * src/mips/n32.S: disable .set mips4
> >>>>> * src/mips/ffi.c: use different JR encoding for r6.
> >>>> These should go to the upstream libffi project. Once accepted there
> >>>> you
> >>>> can add them to GCC.
> >>> Hi Jeff,
> >>>
> >>> The two PRs are already merged, and released since libffi-3.3.0 (now
> >>> the
> >>> upstream latest release is 3.4.2).
> >> ACK. Thanks for confirming. It's always OK to cherrypick/backport
> >> from libffi back to GCC.
> >>
> >>>
> >>> I don't have a MIPSr6 so I can't test though.
> >> Understood. Me neither, but I really should get a tiny chroot for
> >> mipsr6 so that my tester can validate it regularly.
> >>
> >
> > We have port Debian to MIPS64r6el.
> > http://58.246.137.130:20180/tools/tarball/
> > You can use both buster(Debian 10) or bullseye (Debian 11).
> >
> > And both qemu-system and qemu-user can work.
> Understood. I need the minimal chroot to compress down under 100M to
A minimal tarball is ready now with size about 87M.
> make gitlab happy (that's where my scripts & jenkins system expect to
> find them). My scripts to build the chroots also ensure a consistent
> set of packages & version #s across the different systems being
> tested. I've just never gotten around to building one for mips64r6. I
> could probably take yours trim out unnecessary stuff and use it for
> now. Getting a bootstrap test on the target weekly is definitely helpful.
>
That's great.
Since the minimal rootfs lacks of lots of tools, and
if you need some tools, you can just apt install them,then.
> jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-08-31 2:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 4:58 [PATCH] libffi: Fix MIPS r6 support YunQiang Su
2021-08-27 21:28 ` Jeff Law
2021-08-28 7:23 ` Xi Ruoyao
2021-08-28 12:14 ` YunQiang Su
2021-08-29 21:00 ` Jeff Law
2021-08-30 8:47 ` YunQiang Su
2021-08-30 13:46 ` Jeff Law
2021-08-31 2:46 ` YunQiang Su
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 read-only IMAP folder(s) and NNTP newsgroup(s).