mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jaydeep Patil <Jaydeep.Patil@imgtec.com>
To: Szabolcs Nagy <nsz@port70.net>,
	"musl@lists.openwall.com" <musl@lists.openwall.com>
Cc: Andre McCurdy <armccurdy@gmail.com>
Subject: RE: [MUSL] microMIPS32R2 O32 port
Date: Thu, 13 Apr 2017 10:37:05 +0000	[thread overview]
Message-ID: <BD7773622145634B952E5B54ACA8E349DAE2CAB5@PUMAIL01.pu.imgtec.org> (raw)
In-Reply-To: <20170413090036.GH2082@port70.net>

[-- Attachment #1: Type: text/plain, Size: 2926 bytes --]

Hi Szabolcs,

Please find the attached patch.

Thanks,
Jaydeep

>-----Original Message-----
>From: Szabolcs Nagy [mailto:nsz@port70.net]
>Sent: 13 April 2017 PM 02:31
>To: musl@lists.openwall.com
>Cc: Andre McCurdy; Jaydeep Patil
>Subject: Re: [musl] [MUSL] microMIPS32R2 O32 port
>
>* Jaydeep Patil <Jaydeep.Patil@imgtec.com> [2017-04-13 04:29:10 +0000]:
>> With this branch (micromips32r2_v2) we are supporting microMIPS cores
>that co-exist with MIPS. The MUSL library must be built with -minterlink-
>compressed option as there are couple of hand-written MIPS only functions.
>For microMIPS only cores we will create a different subarch.
>>
>
>ok the _v2 branch makes sense to me
>(the patch is sufficiently small that
>you can send it to the list)
>
>i think i was looking at _v1 before
>
>> >-----Original Message-----
>> >From: Andre McCurdy [mailto:armccurdy@gmail.com]
>> >Sent: 13 April 2017 AM 03:17
>> >To: musl@lists.openwall.com
>> >Cc: Jaydeep Patil
>> >Subject: Re: [musl] [MUSL] microMIPS32R2 O32 port
>> >
>> >On Wed, Apr 12, 2017 at 1:27 PM, Rich Felker <dalias@libc.org> wrote:
>> >> On Wed, Apr 12, 2017 at 09:25:35PM +0200, Szabolcs Nagy wrote:
>> >>> * Jaydeep Patil <Jaydeep.Patil@imgtec.com> [2017-04-12 11:54:10
>+0000]:
>> >>> > Hi Rich,
>> >>> >
>> >>> > We can reuse existing MIPS code for microMIPS. There are places
>> >>> > where
>> >we read from $ra must be compiled for MIPS.
>> >>> > Please refer to https://github.com/JaydeepIMG/musl-
>> >1/tree/micromips32r2_v2 for modifications.
>> >>> >
>> >>>
>> >>> is micromips a different encoding for mips instructions that works
>> >>> on some cpus but not others?
>> >>
>> >> Yes, it's something like thumb or thumb2 on arm, or the riscv
>> >> compressed isa. What I'm not clear on is whether there are
>> >> micromips-only cpu models that can't execute normal mips.
>> >
>> >According to:
>> >
>> >  https://imagination-technologies-cloudfront-
>>
>>assets.s3.amazonaws.com/documentation/MIPS_Architecture_microMIPS3
>2
>> >_InstructionSet_AFP_P_MD00582_06.04.pdf
>> >
>> >"microMIPS is also an alternative to the MIPS(r) instruction encoding
>> >and can be implemented in parallel or stand-alone."
>> >
>> >"If only one ISA mode exists (either MIPS or microMIPS) then this
>> >mode switch mechanism does not exist"
>> >
>> >> If so we probably need the ability to build musl as micromips, but
>> >> as long as cpus which support both support interworking (calls
>> >> between the two type of code in the same process) reasonably, I
>> >> don't think there's any reason to consider it a different subarch.
>> >>
>> >> If not (that is, if all cpus that support micromips also support
>> >> the normal mips isa) then I fail to see why there's any need to
>> >> compile musl's asm files as micromips. They're not size or
>> >> performance bottlenecks.
>> >>
>> >> Rich

[-- Attachment #2: microMIPS_32R2_v2.patch --]
[-- Type: application/octet-stream, Size: 1468 bytes --]

diff --git a/arch/mips/crt_arch.h b/arch/mips/crt_arch.h
index 9fc50d7..78832b0 100644
--- a/arch/mips/crt_arch.h
+++ b/arch/mips/crt_arch.h
@@ -1,6 +1,7 @@
 __asm__(
 ".set push\n"
 ".set noreorder\n"
+".set nomicromips\n"
 ".text \n"
 ".global _" START "\n"
 ".global " START "\n"
diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
index b3d59a4..772b3aa 100644
--- a/arch/mips/reloc.h
+++ b/arch/mips/reloc.h
@@ -36,15 +36,23 @@
 #define CRTJMP(pc,sp) __asm__ __volatile__( \
 	"move $sp,%1 ; jr %0" : : "r"(pc), "r"(sp) : "memory" )
 
+/*
+ * When compiled for microMIPS, .align makes sure that .gpword
+ * is placed at word boundary. $ra must point to first .gpword.
+ * ISA bit of $ra must be cleared for microMIPS before using it
+ * as a base address. For MIPS, ISA bit is always zero.
+*/
 #define GETFUNCSYM(fp, sym, got) __asm__ ( \
 	".hidden " #sym "\n" \
 	".set push \n" \
 	".set noreorder \n" \
+	"	.align 2 \n" \
 	"	bal 1f \n" \
 	"	 nop \n" \
 	"	.gpword . \n" \
 	"	.gpword " #sym " \n" \
-	"1:	lw %0, ($ra) \n" \
+	"1:	ins $ra, $0, 0, 1 \n" \
+	"	lw %0, ($ra) \n" \
 	"	subu %0, $ra, %0 \n" \
 	"	lw $ra, 4($ra) \n" \
 	"	addu %0, %0, $ra \n" \
diff --git a/src/thread/mips/syscall_cp.s b/src/thread/mips/syscall_cp.s
index d284626..9c5f55e 100644
--- a/src/thread/mips/syscall_cp.s
+++ b/src/thread/mips/syscall_cp.s
@@ -1,5 +1,5 @@
 .set    noreorder
-
+.set    nomicromips
 .global __cp_begin
 .hidden __cp_begin
 .type   __cp_begin,@function

  reply	other threads:[~2017-04-13 10:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05  6:33 Jaydeep Patil
2017-04-06 16:18 ` dalias
2017-04-07  6:47   ` Jaydeep Patil
2017-04-07 14:19     ` Rich Felker
2017-04-12 11:54       ` Jaydeep Patil
2017-04-12 19:25         ` Szabolcs Nagy
2017-04-12 20:27           ` Rich Felker
2017-04-12 21:47             ` Andre McCurdy
2017-04-13  4:29               ` Jaydeep Patil
2017-04-13  9:00                 ` Szabolcs Nagy
2017-04-13 10:37                   ` Jaydeep Patil [this message]
2017-04-21  9:40                     ` Jaydeep Patil
2017-04-21 13:33                     ` Rich Felker
2017-04-24  5:30                       ` Jaydeep Patil
2017-04-24 13:48                         ` Rich Felker
2017-04-25  4:45                           ` Jaydeep Patil
2017-04-25 16:52                             ` Rich Felker
2017-04-26  7:14                               ` Jaydeep Patil
2017-05-11  3:25                                 ` Jaydeep Patil
2017-05-17  8:28                                   ` Jaydeep Patil
2017-05-26  3:46                                   ` Jaydeep Patil
2017-05-28  2:00                                     ` Rich Felker
2017-05-31 13:11                                       ` Rich Felker
2017-06-01  4:21                                         ` Jaydeep Patil
2017-04-21 13:26                 ` Rich Felker

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=BD7773622145634B952E5B54ACA8E349DAE2CAB5@PUMAIL01.pu.imgtec.org \
    --to=jaydeep.patil@imgtec.com \
    --cc=armccurdy@gmail.com \
    --cc=musl@lists.openwall.com \
    --cc=nsz@port70.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).