All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: "list@suse.de:PowerPC" <qemu-ppc@nongnu.org>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Greg Kurz <gkurz@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] target-ppc: fix 32 bit build break in the page table lookup code
Date: Thu, 13 Feb 2014 15:53:16 +0100	[thread overview]
Message-ID: <7CD7CBCE-A4EB-491C-B12E-6A69102FEE1A@suse.de> (raw)
In-Reply-To: <8738jnu37z.fsf@linux.vnet.ibm.com>


On 13.02.2014, at 04:00, Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> wrote:

> Greg Kurz <gkurz@linux.vnet.ibm.com> writes:
> 
>> The 396bb9874 commit reworked page table lookup to support kvm.
>> Unfortunately this breaks 32 bit build:
>> 
>> target-ppc/mmu-hash64.h: In function ‘ppc_hash64_load_hpte0’:
>> target-ppc/mmu-hash64.h:90:23: error: cast to pointer from integer of
>> different size
>> 
>> target-ppc/mmu-hash64.h: In function ‘ppc_hash64_load_hpte1’:
>> target-ppc/mmu-hash64.h:101:23: error: cast to pointer from integer of
>> different size
>> 
>> The problem is that we have two cases to handle here:
>> - the HTAB is external and it is accessed with a pointer
>> - the HTAB is emulated and it is accessed with a hwaddr
>> 
>> Depending on the way the HTAB is controlled, we should use the appropriate
>> type:
>> - controlled by kvm, it is copied to an allocated buffer (pointer)
>> - controlled by qemu with an allocated buffer (pointer)
>> - controlled by qemu with soft mmu (hwaddr)
>> 
>> This patch introduces an explicit distinction between the two cases in
>> the new page table lookup code.
> 
> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

I wouldn't mind something slightly lighter weight. How about this one instead? If you guys think it's better to have an actual type for the token I'd pull in this patch as is though.


Alex

diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c
index 4e574d9..3240427 100644
--- a/target-ppc/mmu-hash64.c
+++ b/target-ppc/mmu-hash64.c
@@ -340,7 +340,7 @@ uint64_t ppc_hash64_start_access(PowerPCCPU *cpu, target_ulong pte_index)
      * accessible PTEG.
      */
     if (cpu->env.external_htab) {
-        token = (uint64_t) cpu->env.external_htab + pte_offset;
+        token = (uint64_t)(uintptr_t) cpu->env.external_htab + pte_offset;
     } else if (cpu->env.htab_base) {
         token = cpu->env.htab_base + pte_offset;
     }
diff --git a/target-ppc/mmu-hash64.h b/target-ppc/mmu-hash64.h
index 9c9ca1d..8fb2ae4 100644
--- a/target-ppc/mmu-hash64.h
+++ b/target-ppc/mmu-hash64.h
@@ -85,22 +85,24 @@ void ppc_hash64_stop_access(uint64_t token);
 static inline target_ulong ppc_hash64_load_hpte0(CPUPPCState *env,
                                                  uint64_t token, int index)
 {
-    index *= HASH_PTE_SIZE_64;
+    uint64_t addr;
+    addr = token + (index * HASH_PTE_SIZE_64) + HASH_PTE_SIZE_64/2;
     if (env->external_htab) {
-        return  ldq_p((const void *)(token + index));
+        return  ldq_p((const void *)(uintptr_t)addr);
     } else {
-        return ldq_phys(token + index);
+        return ldq_phys(addr);
     }
 }

 static inline target_ulong ppc_hash64_load_hpte1(CPUPPCState *env,
                                                  uint64_t token, int index)
 {
-    index *= HASH_PTE_SIZE_64;
+    uint64_t addr;
+    addr = token + (index * HASH_PTE_SIZE_64) + HASH_PTE_SIZE_64/2;
     if (env->external_htab) {
-        return  ldq_p((const void *)(token + index + HASH_PTE_SIZE_64/2));
+        return  ldq_p((const void *)(uintptr_t)addr);
     } else {
-        return ldq_phys(token + index + HASH_PTE_SIZE_64/2);
+        return ldq_phys(addr);
     }
 }

  reply	other threads:[~2014-02-13 14:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28  7:59 [Qemu-devel] [PATCH V9 0/5] target-ppc: Add support for dumping guest memory using qemu gdb server Aneesh Kumar K.V
2014-01-28  7:59 ` [Qemu-devel] [PATCH V9 1/5] target-ppc: Update external_htab even when HTAB is managed by kernel Aneesh Kumar K.V
2014-01-28  8:00 ` [Qemu-devel] [PATCH V9 2/5] target-ppc: Fix htab_mask calculation Aneesh Kumar K.V
2014-02-11 18:46   ` Aneesh Kumar K.V
2014-02-12 10:32     ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2014-02-13  2:59   ` [Qemu-devel] [PATCH V10] " Aneesh Kumar K.V
2014-02-13 10:40     ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2014-02-13 14:51       ` Alexander Graf
2014-02-14 13:06         ` Alexander Graf
2014-02-14 13:54           ` Alexander Graf
2014-02-14 14:28             ` Alexander Graf
2014-02-14 14:42               ` Alexander Graf
2014-02-15 11:02                 ` Greg Kurz
2014-01-28  8:00 ` [Qemu-devel] [PATCH V9 3/5] target-ppc: Fix page table lookup with kvm enabled Aneesh Kumar K.V
2014-02-10 16:27   ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2014-02-12 15:24     ` [Qemu-devel] [PATCH] target-ppc: fix 32 bit build break in the page table lookup code Greg Kurz
2014-02-13  3:00       ` Aneesh Kumar K.V
2014-02-13 14:53         ` Alexander Graf [this message]
2014-02-13 16:54           ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2014-02-14  9:25             ` Alexander Graf
2014-01-28  8:00 ` [Qemu-devel] [PATCH V9 4/5] target-ppc: Change the hpte sore API Aneesh Kumar K.V
2014-01-28  8:00 ` [Qemu-devel] [PATCH V9 5/5] target-ppc: Update ppc_hash64_store_hpte to support updating in-kernel htab Aneesh Kumar K.V
2014-02-10 15:25   ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2014-02-12 15:40     ` [Qemu-devel] [PATCH] target-ppc: fix warn_unused_result build break with in-kernel HTAB support Greg Kurz
2014-02-13  3:00       ` Aneesh Kumar K.V
2014-02-13 14:51         ` Alexander Graf
2014-02-06 14:58 ` [Qemu-devel] [PATCH V9 0/5] target-ppc: Add support for dumping guest memory using qemu gdb server Alexander Graf

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=7CD7CBCE-A4EB-491C-B12E-6A69102FEE1A@suse.de \
    --to=agraf@suse.de \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.