Skip to contentSkip to conversation

SPARC64: Implement sparcv9 ldfa/stfa instructions

PATCH Superseded Tsuneo Saito 4 participants 19 messages Jul 13, 2011 – Jul 15, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover SPARC64: Implement sparcv9 ldfa/stfa instructions

Hi,

This patch series implements sparcv9 stfa/ldfa instructions with non block-transfer ASIs that implementations seem to be left unfinished. This patch also adds fp_disabled exception checks on stfa/ldfa as they are FP instructions.

 target-sparc/op_helper.c |   31 ++++++++++++++++++++++---------
 target-sparc/translate.c |   14 ++++++++++++--
 2 files changed, 34 insertions(+), 11 deletions(-)
#1 lore raw

PATCH 1/4 SPARC64: Implement ldfa/lddfa/ldqfa instructions properly

This patch implements sparcv9 ldfa/lddfa/ldqfa instructions with non block-load ASIs.

---
 target-sparc/op_helper.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
target-sparc/op_helper.c +11 -5
index fd0cfbd..a75ac4f 100644
@@ -3331,7 +3331,7 @@ void helper_ldda_asi(target_ulong addr, int asi, int rd)
 void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
 {
     unsigned int i;
-    target_ulong val;
+    CPU_DoubleU u;
 
     helper_check_align(addr, 3);
     addr = asi_address_mask(env, asi, addr);
@@ -3371,17 +3371,23 @@ void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
         break;
     }
 
-    val = helper_ld_asi(addr, asi, size, 0);
     switch(size) {
     default:
     case 4:
-        *((uint32_t *)&env->fpr[rd]) = val;
+        *((uint32_t *)&env->fpr[rd]) = helper_ld_asi(addr, asi, size, 0);
         break;
     case 8:
-        *((int64_t *)&DT0) = val;
+        u.ll = helper_ld_asi(addr, asi, size, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
         break;
     case 16:
-        // XXX
+        u.ll = helper_ld_asi(addr, asi, 8, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
+        u.ll = helper_ld_asi(addr + 8, asi, 8, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
         break;
     }
 }
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] SPARC64: Implement ldfa/lddfa/ldqfa instructions properly

Quoted 36 lines · Tsuneo Saito

This patch implements sparcv9 ldfa/lddfa/ldqfa instructions with non block-load ASIs.

---
 target-sparc/op_helper.c |   16 +++++++++++-----

 1 files changed, 11 insertions(+), 5 deletions(-)
target-sparc/op_helper.c +1 -2
index fd0cfbd..a75ac4f 100644
@@ -3331,7 +3331,7 @@ void helper_ldda_asi(target_ulong addr, int asi, int rd)
  void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
  {
     unsigned int i;
-    target_ulong val;
+    CPU_DoubleU u;
 
     helper_check_align(addr, 3);
     addr = asi_address_mask(env, asi, addr);
@@ -3371,17 +3371,23 @@ void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
         break;
     }
 
-    val = helper_ld_asi(addr, asi, size, 0);
     switch(size) {

    default:
    case 4:
-        *((uint32_t *)&env->fpr[rd]) = val;
+        *((uint32_t *)&env->fpr[rd]) = helper_ld_asi(addr, asi, size, 0); break;
    case 8:
-        *((int64_t *)&DT0) = val;
+        u.ll = helper_ld_asi(addr, asi, size, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;

Quoted 8 lines

+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower; break;
    case 16:
-        // XXX
+        u.ll = helper_ld_asi(addr, asi, 8, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
+        u.ll = helper_ld_asi(addr + 8, asi, 8, 0);

In general the patch is an improvement, however the ASIs are passed as is to helper_ld_asi() and there the block ASIs would trigger unassigned access faults. So you should perform some arithmetic with the ASI numbers to make them match non-block ASIs, for example asi & ~0x6. This only works in the specific block ASIs, so I'd move this inside the switch block for cases 0x16, 0x17, 0x1e, 0x1f etc. By the way, aren't those the ASIs in question? The manual (UltraSPARC Architecture 2007) is a bit confusing.

Quoted 10 lines

+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower; break;
    }
 }
--
1.7.5.4

#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] SPARC64: Implement ldfa/lddfa/ldqfa instructions properly

Quoted 41 lines · Blue Swirl
Quoted 40 lines · Tsuneo Saito

This patch implements sparcv9 ldfa/lddfa/ldqfa instructions with non block-load ASIs.

---
 target-sparc/op_helper.c |   16 +++++++++++-----

 1 files changed, 11 insertions(+), 5 deletions(-)
target-sparc/op_helper.c +1 -2
index fd0cfbd..a75ac4f 100644
@@ -3331,7 +3331,7 @@ void helper_ldda_asi(target_ulong addr, int asi, int rd)
  void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
  {
     unsigned int i;
-    target_ulong val;
+    CPU_DoubleU u;
 
     helper_check_align(addr, 3);
     addr = asi_address_mask(env, asi, addr);
@@ -3371,17 +3371,23 @@ void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
         break;
     }
 
-    val = helper_ld_asi(addr, asi, size, 0);
     switch(size) {

    default:
    case 4:
-        *((uint32_t *)&env->fpr[rd]) = val;
+        *((uint32_t *)&env->fpr[rd]) = helper_ld_asi(addr, asi, size, 0); break;
    case 8:
-        *((int64_t *)&DT0) = val;
+        u.ll = helper_ld_asi(addr, asi, size, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
        break;
    case 16:
-        // XXX

Quoted 8 lines
Quoted 4 lines

+        u.ll = helper_ld_asi(addr, asi, 8, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
+        u.ll = helper_ld_asi(addr + 8, asi, 8, 0);

In general the patch is an improvement, however the ASIs are passed as is to helper_ld_asi() and there the block ASIs would trigger unassigned access faults.

You mean the not [yet] implemented block ASIs? The implemented ones return earlier
and for the not implemented ones unassigned access fault appears to be a right thing to do.
Do you have an example where we would have an unassigned access fault for an implemented ASI ?

Quoted 15 lines

So you should perform some arithmetic with
the ASI numbers to make them match non-block ASIs, for example asi & ~0x6. This only works in the specific block ASIs, so I'd move this inside the switch block for cases 0x16, 0x17, 0x1e, 0x1f etc. By the way, aren't those the ASIs in question? The manual (UltraSPARC Architecture 2007) is a bit confusing.

Quoted 8 lines

+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower; break;
    }
 }
--
1.7.5.4

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#4 lore raw

Re: [Qemu-devel] [PATCH 1/4] SPARC64: Implement ldfa/lddfa/ldqfa instructions properly

Quoted 51 lines · Artyom Tarasenko
Quoted 41 lines · Blue Swirl
Quoted 40 lines · Tsuneo Saito

This patch implements sparcv9 ldfa/lddfa/ldqfa instructions with non block-load ASIs.

---
 target-sparc/op_helper.c |   16 +++++++++++-----

 1 files changed, 11 insertions(+), 5 deletions(-)
target-sparc/op_helper.c +1 -2
index fd0cfbd..a75ac4f 100644
@@ -3331,7 +3331,7 @@ void helper_ldda_asi(target_ulong addr, int asi, int rd)
  void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
  {
     unsigned int i;
-    target_ulong val;
+    CPU_DoubleU u;
 
     helper_check_align(addr, 3);
     addr = asi_address_mask(env, asi, addr);
@@ -3371,17 +3371,23 @@ void helper_ldf_asi(target_ulong addr, int asi, int size, int rd)
         break;
     }
 
-    val = helper_ld_asi(addr, asi, size, 0);
     switch(size) {

    default:
    case 4:
-        *((uint32_t *)&env->fpr[rd]) = val;
+        *((uint32_t *)&env->fpr[rd]) = helper_ld_asi(addr, asi, size, 0); break;
    case 8:
-        *((int64_t *)&DT0) = val;
+        u.ll = helper_ld_asi(addr, asi, size, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
        break;
    case 16:
-        // XXX

Quoted 8 lines
Quoted 4 lines

+        u.ll = helper_ld_asi(addr, asi, 8, 0);
+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower;
+        u.ll = helper_ld_asi(addr + 8, asi, 8, 0);

In general the patch is an improvement, however the ASIs are passed as is to helper_ld_asi() and there the block ASIs would trigger unassigned access faults.

Quoted 6 lines

You mean the not [yet] implemented block ASIs? The implemented ones return earlier
and for the not implemented ones unassigned access fault appears to be a right thing to do.
Do you have an example where we would have an unassigned access fault for an implemented ASI ?

This patch would implement the unimplemented ones by calling helper_ld_asi(), but the ASIs do not match. Instead of 0x1f (as if user little endian secondary address space block ASI), 0x19 (corresponding non-block ASI) should be used. Also helper_ld_asi() should not be changed to accept block ASIs, because then they would be accepted also for non-block accesses.

Quoted 24 lines
Quoted 15 lines

So you should perform some arithmetic with
the ASI numbers to make them match non-block ASIs, for example asi & ~0x6. This only works in the specific block ASIs, so I'd move this inside the switch block for cases 0x16, 0x17, 0x1e, 0x1f etc. By the way, aren't those the ASIs in question? The manual (UltraSPARC Architecture 2007) is a bit confusing.

Quoted 8 lines

+        *((uint32_t *)&env->fpr[rd++]) = u.l.upper;
+        *((uint32_t *)&env->fpr[rd++]) = u.l.lower; break;
    }
 }
--
1.7.5.4

--
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/

#5 lore raw

Re: [Qemu-devel] [PATCH 1/4] SPARC64: Implement ldfa/lddfa/ldqfa instructions properly

Hi,

At Wed, 13 Jul 2011 21:19:16 +0300,

Quoted 9 lines · Blue Swirl
Quoted 8 lines · Artyom Tarasenko
Quoted 7 lines · Blue Swirl

On Wed, Jul 13, 2011 at 6:30 AM, Tsuneo Saito <[email protected]> wrote:
So you should perform some arithmetic with
the ASI numbers to make them match non-block ASIs, for example asi & ~0x6. This only works in the specific block ASIs, so I'd move this inside the switch block for cases 0x16, 0x17, 0x1e, 0x1f etc. By the way, aren't those the ASIs in question? The manual (UltraSPARC Architecture 2007) is a bit confusing.

Thanks for the review!
I didn't know these ASIs (0x16, 0x17, 0x1e, 0x1f) as I was looking at the JPS 1.0.4 specification. I'll add codes for these ASIs.

----
Tsuneo Saito <[email protected]>

#6 lore raw

PATCH 2/4 SPARC64: fp_disabled checks on ldfa/lddfa/ldqfa

In reply to Tsuneo Saito

ldfa/lddfa/ldqfa instructions should raise fp_disabled exceptions if %pstate.PEF==0 or %fprs.FEF==0.

---
 target-sparc/translate.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
target-sparc/translate.c +6 -0
index f32a674..d07eb25 100644
@@ -4484,10 +4484,14 @@ static void disas_sparc_insn(DisasContext * dc)
                 case 0x2d: /* V9 prefetch, no effect */
                     goto skip_move;
                 case 0x30: /* V9 ldfa */
+                    if (gen_trap_ifnofpu(dc, cpu_cond))
+                        goto jmp_insn;
                     save_state(dc, cpu_cond);
                     gen_ldf_asi(cpu_addr, insn, 4, rd);
                     goto skip_move;
                 case 0x33: /* V9 lddfa */
+                    if (gen_trap_ifnofpu(dc, cpu_cond))
+                        goto jmp_insn;
                     save_state(dc, cpu_cond);
                     gen_ldf_asi(cpu_addr, insn, 8, DFPREG(rd));
                     goto skip_move;
@@ -4495,6 +4499,8 @@ static void disas_sparc_insn(DisasContext * dc)
                     goto skip_move;
                 case 0x32: /* V9 ldqfa */
                     CHECK_FPU_FEATURE(dc, FLOAT128);
+                    if (gen_trap_ifnofpu(dc, cpu_cond))
+                        goto jmp_insn;
                     save_state(dc, cpu_cond);
                     gen_ldf_asi(cpu_addr, insn, 16, QFPREG(rd));
                     goto skip_move;
Signature · 1 line
1.7.5.4
#7 lore raw

PATCH 3/4 SPARC64: Implement stfa/stdfa/stqfa instrcutions properly

In reply to Tsuneo Saito

This patch implements sparcv9 stfa/stdfa/stqfa instructions with non block-store ASIs.

---
 target-sparc/op_helper.c |   15 +++++++++++----
 target-sparc/translate.c |    2 --
 2 files changed, 11 insertions(+), 6 deletions(-)
target-sparc/op_helper.c +11 -4
index a75ac4f..fe71829 100644
@@ -3396,6 +3396,7 @@ void helper_stf_asi(target_ulong addr, int asi, int size, int rd)
 {
     unsigned int i;
     target_ulong val = 0;
+    CPU_DoubleU u;
 
     helper_check_align(addr, 3);
     addr = asi_address_mask(env, asi, addr);
@@ -3440,16 +3441,22 @@ void helper_stf_asi(target_ulong addr, int asi, int size, int rd)
     switch(size) {
     default:
     case 4:
-        val = *((uint32_t *)&env->fpr[rd]);
+        helper_st_asi(addr, *(uint32_t *)&env->fpr[rd], asi, size);
         break;
     case 8:
-        val = *((int64_t *)&DT0);
+        u.l.upper = *(uint32_t *)&env->fpr[rd++];
+        u.l.lower = *(uint32_t *)&env->fpr[rd++];
+        helper_st_asi(addr, u.ll, asi, size);
         break;
     case 16:
-        // XXX
+        u.l.upper = *(uint32_t *)&env->fpr[rd++];
+        u.l.lower = *(uint32_t *)&env->fpr[rd++];
+        helper_st_asi(addr, u.ll, asi, 8);
+        u.l.upper = *(uint32_t *)&env->fpr[rd++];
+        u.l.lower = *(uint32_t *)&env->fpr[rd++];
+        helper_st_asi(addr + 8, u.ll, asi, 8);
         break;
     }
-    helper_st_asi(addr, val, asi, size);
 }
 
 target_ulong helper_cas_asi(target_ulong addr, target_ulong val1,
target-sparc/translate.c +0 -2
index d07eb25..95e78a3 100644
@@ -4739,12 +4739,10 @@ static void disas_sparc_insn(DisasContext * dc)
                         r_const = tcg_const_i32(7);
                         gen_helper_check_align(cpu_addr, r_const);
                         tcg_temp_free_i32(r_const);
-                        gen_op_load_fpr_QT0(QFPREG(rd));
                         gen_stf_asi(cpu_addr, insn, 16, QFPREG(rd));
                     }
                     break;
                 case 0x37: /* V9 stdfa */
-                    gen_op_load_fpr_DT0(DFPREG(rd));
                     gen_stf_asi(cpu_addr, insn, 8, DFPREG(rd));
                     break;
                 case 0x3c: /* V9 casa */
Signature · 1 line
1.7.5.4
#8 lore raw

PATCH 4/4 SPARC64: fp_disabled checks on stfa/stdfa/stqfa

In reply to Tsuneo Saito

stfa/stdfa/stqfa instructions should raise fp_disabled exceptions if %pstate.PEF==0 or %fprs.FEF==0.

---
 target-sparc/translate.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
target-sparc/translate.c +6 -0
index 95e78a3..94c1000 100644
@@ -4729,6 +4729,8 @@ static void disas_sparc_insn(DisasContext * dc)
                 switch (xop) {
 #ifdef TARGET_SPARC64
                 case 0x34: /* V9 stfa */
+                    if (gen_trap_ifnofpu(dc, cpu_cond))
+                        goto jmp_insn;
                     gen_stf_asi(cpu_addr, insn, 4, rd);
                     break;
                 case 0x36: /* V9 stqfa */
@@ -4736,6 +4738,8 @@ static void disas_sparc_insn(DisasContext * dc)
                         TCGv_i32 r_const;
 
                         CHECK_FPU_FEATURE(dc, FLOAT128);
+                        if (gen_trap_ifnofpu(dc, cpu_cond))
+                            goto jmp_insn;
                         r_const = tcg_const_i32(7);
                         gen_helper_check_align(cpu_addr, r_const);
                         tcg_temp_free_i32(r_const);
@@ -4743,6 +4747,8 @@ static void disas_sparc_insn(DisasContext * dc)
                     }
                     break;
                 case 0x37: /* V9 stdfa */
+                    if (gen_trap_ifnofpu(dc, cpu_cond))
+                        goto jmp_insn;
                     gen_stf_asi(cpu_addr, insn, 8, DFPREG(rd));
                     break;
                 case 0x3c: /* V9 casa */
Signature · 1 line
1.7.5.4
Acked-by on the v1 series
#9 lore raw
In reply to Tsuneo Saito

Hi,

Quoted 6 lines · Tsuneo Saito

Hi,

This patch series implements sparcv9 stfa/ldfa instructions with non block-transfer ASIs that implementations seem to be left unfinished. This patch also adds fp_disabled exception checks on stfa/ldfa as they are FP instructions.

Nice series!
May I ask what have you used as a test case to discover the problem? Please use the scripts/checkpatch.pl script to check coding style, there are some braces missing in 2/4 and 4/4 patches.
The contents

Quoted 5 lines

 target-sparc/op_helper.c |   31 ++++++++++++++++++++++--------- target-sparc/translate.c |   14 ++++++++++++--

 2 files changed, 34 insertions(+), 11 deletions(-)
Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#10 lore raw

Hi,

At Wed, 13 Jul 2011 10:57:19 +0200,

Quoted 10 lines · Artyom Tarasenko
Quoted 6 lines · Tsuneo Saito

Hi,

This patch series implements sparcv9 stfa/ldfa instructions with non block-transfer ASIs that implementations seem to be left unfinished. This patch also adds fp_disabled exception checks on stfa/ldfa as they are FP instructions.

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

Quoted 4 lines

Please use the scripts/checkpatch.pl script to check coding style, there are some braces missing in 2/4 and 4/4 patches. The contents

Thanks for the review!
I'll fix the coding style problems and post the fixed version.

----
Tsuneo Saito <[email protected]>

#11 lore raw
Quoted 5 lines · On 13/07/11 12:06, [email protected] wrote:
Quoted 2 lines

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

That's good to hear. How far have you managed to get a 64-bit Linux kernel to boot to date?

ATB,

Mark.

Signature · 7 lines
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063

Sirius Labs: http://www.siriusit.co.uk/labs
#12 lore raw

Hi,

At Wed, 13 Jul 2011 13:09:28 +0100,

Quoted 8 lines · Mark Cave-Ayland
Quoted 5 lines
Quoted 2 lines

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

That's good to hear. How far have you managed to get a 64-bit Linux kernel to boot to date?

With dirty hacks other than the ldfa/stfa fixes, I have managed to get the busybox shell prompt using a kernel with initramfs. I'm planning to send other fixes after cleaning them up.

----
Tsuneo Saito <[email protected]>

#13 lore raw
Quoted 10 lines · On Wed, Jul 13, 2011 at 3:48 PM, <[email protected]> wrote:

Hi,

At Wed, 13 Jul 2011 13:09:28 +0100,

Quoted 6 lines · Mark Cave-Ayland
Quoted 5 lines
Quoted 2 lines

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

Quoted 6 lines
Quoted 2 lines

That's good to hear. How far have you managed to get a 64-bit Linux kernel to boot to date?

With dirty hacks other than the ldfa/stfa fixes, I have managed to get the busybox shell prompt using a kernel with initramfs. I'm planning to send other fixes after cleaning them up.

Great! In which areas are the hacks needed?

#14 lore raw

Hi,

At Wed, 13 Jul 2011 19:34:10 +0300,

Quoted 9 lines · Blue Swirl
Quoted 8 lines · On Wed, Jul 13, 2011 at 3:48 PM, <[email protected]> wrote:

At Wed, 13 Jul 2011 13:09:28 +0100,

Quoted 6 lines · Mark Cave-Ayland
Quoted 5 lines
Quoted 2 lines

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

That's good to hear. How far have you managed to get a 64-bit Linux kernel to boot to date?

With dirty hacks other than the ldfa/stfa fixes, I have managed to get the busybox shell prompt using a kernel with initramfs. I'm planning to send other fixes after cleaning them up.

Great! In which areas are the hacks needed?

Roughly speaking I've added/changed the following so far:
- %fprs register dirty bits support
- hardware interrupt handing (both interrupt controller and cpu side) also needed to modify the openbios.
- nonfaulting load ASI
glibc memcpy seems to use nonfaulting loads

----
Tsuneo Saito <[email protected]>

#15 lore raw
Quoted 16 lines · On Thu, Jul 14, 2011 at 5:13 AM, <[email protected]> wrote:

Hi,

At Wed, 13 Jul 2011 19:34:10 +0300,

Quoted 12 lines · Blue Swirl
Quoted 11 lines · On Wed, Jul 13, 2011 at 3:48 PM,  <[email protected]> wrote:

At Wed, 13 Jul 2011 13:09:28 +0100,

Quoted 8 lines · Mark Cave-Ayland
Quoted 5 lines
Quoted 2 lines

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

That's good to hear. How far have you managed to get a 64-bit Linux kernel to boot to date?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

With dirty hacks other than the ldfa/stfa fixes, I have managed to get the busybox shell prompt using a kernel with initramfs. I'm planning to send other fixes after cleaning them up.

Great! In which areas are the hacks needed?

Roughly speaking I've added/changed the following so far:
- %fprs register dirty bits support

O, that's interesting. Does glibc use it?

Quoted 2 lines

- hardware interrupt handing (both interrupt controller and cpu side) also needed to modify the openbios.

Nice. A lot of work indeed.

Quoted 2 lines

- nonfaulting load ASI
 glibc memcpy seems to use nonfaulting loads

You mean other than the implemented 0x82/83 and 0x8a/8b ones, or that the current implementation is buggy?

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#16 lore raw

At Thu, 14 Jul 2011 09:38:18 +0200,

Quoted 19 lines · Artyom Tarasenko
Quoted 18 lines · On Thu, Jul 14, 2011 at 5:13 AM, <[email protected]> wrote:

At Wed, 13 Jul 2011 19:34:10 +0300,

Quoted 16 lines · Blue Swirl
Quoted 14 lines · On Wed, Jul 13, 2011 at 3:48 PM,  <[email protected]> wrote:

At Wed, 13 Jul 2011 13:09:28 +0100,

Quoted 8 lines · Mark Cave-Ayland
Quoted 5 lines
Quoted 2 lines

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

That's good to hear. How far have you managed to get a 64-bit Linux kernel to boot to date?

With dirty hacks other than the ldfa/stfa fixes, I have managed to get the busybox shell prompt using a kernel with initramfs. I'm planning to send other fixes after cleaning them up.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Great! In which areas are the hacks needed?

Roughly speaking I've added/changed the following so far:
- %fprs register dirty bits support

O, that's interesting. Does glibc use it?

The linux kernel saves FPU registers context based on %fprs dirty bits. We need to implement these bits in order to make context switches work properly.

Quoted 10 lines
Quoted 2 lines

- hardware interrupt handing (both interrupt controller and cpu side) also needed to modify the openbios.

Nice. A lot of work indeed.

Quoted 2 lines

- nonfaulting load ASI
 glibc memcpy seems to use nonfaulting loads

You mean other than the implemented 0x82/83 and 0x8a/8b ones, or that the current implementation is buggy?

The softmmu version of current implementation is incorrect. Nonfaulting loads should generate exceptions in the same way as normal loads. The CPU hardware should not return zero automatically if no memory mapping exists. The system software is responsible for nonfaulting loads to read zero if no mapping is availale.

The differences between nonfaulting loads and normal loads are:
- that DSFSR.NF bit is set for nonfaulting loads on MMU faults.
- the result of loads on memory region mapped by TTEs with NFO bit set.

----
Tsuneo Saito <[email protected]>

#17 lore raw
Quoted 23 lines · On Thu, Jul 14, 2011 at 12:13 PM, <[email protected]> wrote:

At Thu, 14 Jul 2011 09:38:18 +0200,

Quoted 21 lines · Artyom Tarasenko
Quoted 20 lines · On Thu, Jul 14, 2011 at 5:13 AM,  <[email protected]> wrote:

At Wed, 13 Jul 2011 19:34:10 +0300,

Quoted 17 lines · Blue Swirl
Quoted 8 lines · On Wed, Jul 13, 2011 at 3:48 PM,  <[email protected]> wrote:

At Wed, 13 Jul 2011 13:09:28 +0100,

Quoted 6 lines · Mark Cave-Ayland
Quoted 5 lines
Quoted 2 lines

Nice series!
May I ask what have you used as a test case to discover the problem?

I found the problem when I was trying to run the linux/sparc64 kernel. It seemed that copy_to_user() did not work as expected.

Quoted 6 lines
Quoted 2 lines

That's good to hear. How far have you managed to get a 64-bit Linux kernel to boot to date?

With dirty hacks other than the ldfa/stfa fixes, I have managed to get the busybox shell prompt using a kernel with initramfs. I'm planning to send other fixes after cleaning them up.

Great! In which areas are the hacks needed?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Roughly speaking I've added/changed the following so far:
- %fprs register dirty bits support

O, that's interesting. Does glibc use it?

The linux kernel saves FPU registers context based on %fprs dirty bits. We need to implement these bits in order to make context switches work properly.

This could be implemented so that each instruction that writes to FPU registers updates the dirty bits. A more advanced version could try to do this more lazily (end of basic block or after any exception generating instruction) but that may be tricky.

Quoted 17 lines
Quoted 10 lines
Quoted 2 lines

- hardware interrupt handing (both interrupt controller and cpu side) also needed to modify the openbios.

Nice. A lot of work indeed.

Quoted 2 lines

- nonfaulting load ASI
 glibc memcpy seems to use nonfaulting loads

You mean other than the implemented 0x82/83 and 0x8a/8b ones, or that the current implementation is buggy?

The softmmu version of current implementation is incorrect. Nonfaulting loads should generate exceptions in the same way as normal loads.  The CPU hardware should not return zero automatically if no memory mapping exists.  The system software is responsible for nonfaulting loads to read zero if no mapping is availale.

Quoted 3 lines

The differences between nonfaulting loads and normal loads are:
- that DSFSR.NF bit is set for nonfaulting loads on MMU faults.
- the result of loads on memory region mapped by TTEs with NFO bit set.

I hope this is documented somewhere.

#18 lore raw

At Thu, 14 Jul 2011 18:31:52 +0300,

Quoted 7 lines · Blue Swirl
Quoted 6 lines · On Thu, Jul 14, 2011 at 12:13 PM, <[email protected]> wrote:

The softmmu version of current implementation is incorrect. Nonfaulting loads should generate exceptions in the same way as normal loads.  The CPU hardware should not return zero automatically if no memory mapping exists.  The system software is responsible for nonfaulting loads to read zero if no mapping is availale.

Quoted 5 lines
Quoted 3 lines

The differences between nonfaulting loads and normal loads are:
- that DSFSR.NF bit is set for nonfaulting loads on MMU faults.
- the result of loads on memory region mapped by TTEs with NFO bit set.

I hope this is documented somewhere.

In the UA2007 spec it is partly documented in "9.6 Nonfaulting Load", but I couldn't find out the description of the SFSR (Synchronous Fault Status Register) in UA2007...
In the JPS1 spec, the SFSR register is described in F.10.9.

----
Tsuneo Saito <[email protected]>