Patchwork Re: "Bad ram offset"?

login
register
mail settings
Submitter Blue Swirl
Date Sept. 28, 2010, 7:45 p.m.
Message ID <AANLkTikAVzoEjHA+4PHUqhD8Bpvx5mTDVqo5GYgPTq3o@mail.gmail.com>
Download mbox | patch
Permalink /patch/66023/
State New
Headers show

Comments

Blue Swirl - Sept. 28, 2010, 7:45 p.m.
On Tue, Sep 28, 2010 at 7:31 PM, Artyom Tarasenko
<atar4qemu@googlemail.com> wrote:
> 2010/9/28 Blue Swirl <blauwirbel@gmail.com>:
>> On Mon, Sep 27, 2010 at 9:19 PM, Artyom Tarasenko
>> <atar4qemu@googlemail.com> wrote:
>>> In today's git master:
>>>
>>> $ ./qemu-system-sparc64 -M sun4u -m 2048
>>> Bad ram offset ffffffff80000000
>>
>> Smells like unwanted sign extension somewhere.
>
> fwiw, tested -m 2048 with i386 and x86-64 and they both are fine with
> it. So it must be something platform-specific.

In a way, on SS-20 the problem is with cpu_physical_memory_write_rom
for idreg, which is at 0xef0000000. The sign extension happens in
qemu_get_ram_ptr() or just before that.

Here's my 'work in progress' patch:

Patch

diff --git a/exec.c b/exec.c
index 9b5464f..892aa06 100644
--- a/exec.c
+++ b/exec.c
@@ -154,7 +154,7 @@  typedef struct PageDesc {

 /* Size of the L2 (and L3, etc) page tables.  */
 #define L2_BITS 10
-#define L2_SIZE (1 << L2_BITS)
+#define L2_SIZE (1ULL << L2_BITS)

 /* The bits remaining after N lower levels of page tables.  */
 #define P_L1_BITS_REM \
@@ -432,7 +432,8 @@  static PhysPageDesc
*phys_page_find_alloc(target_phys_addr_t index, int alloc)

         for (i = 0; i < L2_SIZE; i++) {
             pd[i].phys_offset = IO_MEM_UNASSIGNED;
-            pd[i].region_offset = (index + i) << TARGET_PAGE_BITS;
+            pd[i].region_offset = (index + (target_phys_addr_t)i)
+                << TARGET_PAGE_BITS;
         }
     }