From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: "open list:PReP" <qemu-ppc@nongnu.org>,
Paul Mackerras <paulus@samba.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH -V5] target-ppc: Fix page table lookup with kvm enabled
Date: Wed, 06 Nov 2013 22:38:22 +0530 [thread overview]
Message-ID: <87zjphsbjt.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <33725426-3675-4C1B-B82C-0063B835F565@suse.de>
Alexander Graf <agraf@suse.de> writes:
> On 11.10.2013, at 09:58, Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> wrote:
>
>> Alexander Graf <agraf@suse.de> writes:
>>
>>> On 11.10.2013, at 13:13, Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> wrote:
>>>
>>>> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>>>>
>>>> With kvm enabled, we store the hash page table information in the hypervisor.
>>>> Use ioctl to read the htab contents. Without this we get the below error when
>>>> trying to read the guest address
>>>>
>>>> (gdb) x/10 do_fork
>>>> 0xc000000000098660 <do_fork>: Cannot access memory at address 0xc000000000098660
>>>> (gdb)
>>>>
>>>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>>>> ---
>>>> Changes from V4:
>>>> * Rewrite to avoid two code paths for doing hash lookups
>>
>> ....
>>
>>>> +
>>>> + i = 0;
>>>> + hpte = pte_index * HASH_PTE_SIZE_64;
>>>> if (likely((flags & H_EXACT) == 0)) {
>>>> pte_index &= ~7ULL;
>>>> - hpte = pte_index * HASH_PTE_SIZE_64;
>>>> - for (i = 0; ; ++i) {
>>>> + token = ppc_hash64_start_access(ppc_env_get_cpu(env), pte_index);
>>>> + do {
>>>
>>> Why convert this into a while loop?
>>
>> I am moving i = 0 outside the loop. Hence found while () better than for(;;++i)
>
> Outside of what loop? You're only moving it outside of the if().
I meant moving i = 0 outside of for loop initialization part
here is how it would look like with for
i = 0;
if ()
for(;;i++) {
if () {
break;
}
}
} else {
}
hpte += i * HASH_PTE_SIZE_64;
I found do { } while (i++) better than for loop
>
>>
>>>
>>>> if (i == 8) {
>>>> + ppc_hash64_stop_access(token);
>>>> return H_PTEG_FULL;
>>>> }
>>>> - if ((ppc_hash64_load_hpte0(env, hpte) & HPTE64_V_VALID) == 0) {
>>>> + if ((ppc_hash64_load_hpte0(token, i) & HPTE64_V_VALID) == 0) {
>>>> break;
>>>> }
>>>> - hpte += HASH_PTE_SIZE_64;
>>>> - }
>>>> + } while (i++);
>>>> + ppc_hash64_stop_access(token);
>>
>> ....
....
>>> You also want to cache kvmppc_uses_htab_fd(cpu) so it doesn't have to
>>> call an ioctl every time we try to read a PTE. I guess the best spot
>>> for it would be to put it into env.
>>
>> didn't get that. We already cache that value as
>>
>> bool kvmppc_has_cap_htab_fd(void)
>> {
>> return cap_htab_fd;
>> }
>>
>> Looking at the kernel capability check I do find an issue, So with both
>> hv and pr loaded as module, that would always return true. Now that is
>> not we want here. Ideally we should have all these as VM ioctl and not
>> device ioctl. I had asked that as a fixme in the HV PR patchset.
>
> As you've realized we only cache the ability for an htab fd, not whether we are actually using one. That needs to be a separate variable.
>
As mentioned earlier we can't really cache the htab fd, because the
interface doesn't support random reads of hash page table.
-aneesh
next prev parent reply other threads:[~2013-11-06 17:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-11 11:13 [Qemu-devel] [PATCH -V5] target-ppc: Fix page table lookup with kvm enabled Aneesh Kumar K.V
2013-10-11 13:36 ` Alexander Graf
2013-10-11 16:58 ` Aneesh Kumar K.V
2013-10-27 18:29 ` Alexander Graf
2013-11-06 17:08 ` Aneesh Kumar K.V [this message]
2013-11-06 17:18 ` 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=87zjphsbjt.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=paulus@samba.org \
--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.