From: Avi Kivity <avi@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: kvm-ppc@vger.kernel.org, kvm list <kvm@vger.kernel.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
Scott Wood <scottwood@freescale.com>
Subject: Re: [PATCH 04/14] KVM: PPC: e500: MMU API
Date: Mon, 31 Oct 2011 13:24:20 +0000 [thread overview]
Message-ID: <4EAEA184.4050807@redhat.com> (raw)
In-Reply-To: <1320047596-20577-5-git-send-email-agraf@suse.de>
On 10/31/2011 09:53 AM, Alexander Graf wrote:
> From: Scott Wood <scottwood@freescale.com>
>
> This implements a shared-memory API for giving host userspace access to
> the guest's TLB.
>
>
> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index 7945b0b..ab1136f 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -1383,6 +1383,38 @@ The following flags are defined:
> If datamatch flag is set, the event will be signaled only if the written value
> to the registered address is equal to datamatch in struct kvm_ioeventfd.
>
> +4.59 KVM_DIRTY_TLB
> +
> +Capability: KVM_CAP_SW_TLB
> +Architectures: ppc
> +Type: vcpu ioctl
> +Parameters: struct kvm_dirty_tlb (in)
> +Returns: 0 on success, -1 on error
> +
> +struct kvm_dirty_tlb {
> + __u64 bitmap;
> + __u32 num_dirty;
> +};
This is not 32/64 bit safe. e500 is 32-bit only, yes? but what if
someone wants to emulate an e500 on a ppc64? maybe it's better to add
padding here.
Another alternative is to drop the num_dirty field (and let the kernel
compute it instead, shouldn't take long?), and have the third argument
to ioctl() reference the bitmap directly.
> +
> +This must be called whenever userspace has changed an entry in the shared
> +TLB, prior to calling KVM_RUN on the associated vcpu.
> +
> +The "bitmap" field is the userspace address of an array. This array
> +consists of a number of bits, equal to the total number of TLB entries as
> +determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
> +nearest multiple of 64.
> +
> +Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
> +array.
> +
> +The array is little-endian: the bit 0 is the least significant bit of the
> +first byte, bit 8 is the least significant bit of the second byte, etc.
> +This avoids any complications with differing word sizes.
And people say little/big endian is just a matter of taste.
> +
> +The "num_dirty" field is a performance hint for KVM to determine whether it
> +should skip processing the bitmap and just invalidate everything. It must
> +be set to the number of set bits in the bitmap.
> +
> 4.62 KVM_CREATE_SPAPR_TCE
>
> Capability: KVM_CAP_SPAPR_TCE
> @@ -1700,3 +1732,45 @@ HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
> HTAB invisible to the guest.
>
> When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
> +
> +6.3 KVM_CAP_SW_TLB
> +
> +Architectures: ppc
> +Parameters: args[0] is the address of a struct kvm_config_tlb
> +Returns: 0 on success; -1 on error
> +
> +struct kvm_config_tlb {
> + __u64 params;
> + __u64 array;
> + __u32 mmu_type;
> + __u32 array_len;
> +};
Would it not be simpler to use args[0-3] for this, instead of yet
another indirection?
> +
> +Configures the virtual CPU's TLB array, establishing a shared memory area
> +between userspace and KVM. The "params" and "array" fields are userspace
> +addresses of mmu-type-specific data structures. The "array_len" field is an
> +safety mechanism, and should be set to the size in bytes of the memory that
> +userspace has reserved for the array. It must be at least the size dictated
> +by "mmu_type" and "params".
> +
> +While KVM_RUN is active, the shared region is under control of KVM. Its
> +contents are undefined, and any modification by userspace results in
> +boundedly undefined behavior.
> +
> +On return from KVM_RUN, the shared region will reflect the current state of
> +the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB
> +to tell KVM which entries have been changed, prior to calling KVM_RUN again
> +on this vcpu.
We already have another mechanism for such shared memory,
mmap(vcpu_fd). x86 uses it for the coalesced mmio region as well as the
traditional kvm_run area. Please consider using it.
> +
> +For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
> + - The "params" field is of type "struct kvm_book3e_206_tlb_params".
> + - The "array" field points to an array of type "struct
> + kvm_book3e_206_tlb_entry".
> + - The array consists of all entries in the first TLB, followed by all
> + entries in the second TLB.
> + - Within a TLB, entries are ordered first by increasing set number. Within a
> + set, entries are ordered by way (increasing ESEL).
> + - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
> + where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
> + - The tsize field of mas1 shall be set to 4K on TLB0, even though the
> + hardware ignores this value for TLB0.
Holy shit.
> @@ -95,6 +90,9 @@ struct kvmppc_vcpu_e500 {
> u32 tlb1cfg;
> u64 mcar;
>
> + struct page **shared_tlb_pages;
> + int num_shared_tlb_pages;
> +
I missed the requirement that things be page aligned.
If you use mmap(vcpu_fd) this becomes simpler; you can use
get_free_pages() and have a single pointer. You can also use vmap() on
this array (but get_free_pages() is faster).
--
error compiling committee.c: too many arguments to function
WARNING: multiple messages have this Message-ID (diff)
From: Avi Kivity <avi@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: kvm-ppc@vger.kernel.org, kvm list <kvm@vger.kernel.org>,
Marcelo Tosatti <mtosatti@redhat.com>,
Scott Wood <scottwood@freescale.com>
Subject: Re: [PATCH 04/14] KVM: PPC: e500: MMU API
Date: Mon, 31 Oct 2011 15:24:20 +0200 [thread overview]
Message-ID: <4EAEA184.4050807@redhat.com> (raw)
In-Reply-To: <1320047596-20577-5-git-send-email-agraf@suse.de>
On 10/31/2011 09:53 AM, Alexander Graf wrote:
> From: Scott Wood <scottwood@freescale.com>
>
> This implements a shared-memory API for giving host userspace access to
> the guest's TLB.
>
>
> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index 7945b0b..ab1136f 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
> @@ -1383,6 +1383,38 @@ The following flags are defined:
> If datamatch flag is set, the event will be signaled only if the written value
> to the registered address is equal to datamatch in struct kvm_ioeventfd.
>
> +4.59 KVM_DIRTY_TLB
> +
> +Capability: KVM_CAP_SW_TLB
> +Architectures: ppc
> +Type: vcpu ioctl
> +Parameters: struct kvm_dirty_tlb (in)
> +Returns: 0 on success, -1 on error
> +
> +struct kvm_dirty_tlb {
> + __u64 bitmap;
> + __u32 num_dirty;
> +};
This is not 32/64 bit safe. e500 is 32-bit only, yes? but what if
someone wants to emulate an e500 on a ppc64? maybe it's better to add
padding here.
Another alternative is to drop the num_dirty field (and let the kernel
compute it instead, shouldn't take long?), and have the third argument
to ioctl() reference the bitmap directly.
> +
> +This must be called whenever userspace has changed an entry in the shared
> +TLB, prior to calling KVM_RUN on the associated vcpu.
> +
> +The "bitmap" field is the userspace address of an array. This array
> +consists of a number of bits, equal to the total number of TLB entries as
> +determined by the last successful call to KVM_CONFIG_TLB, rounded up to the
> +nearest multiple of 64.
> +
> +Each bit corresponds to one TLB entry, ordered the same as in the shared TLB
> +array.
> +
> +The array is little-endian: the bit 0 is the least significant bit of the
> +first byte, bit 8 is the least significant bit of the second byte, etc.
> +This avoids any complications with differing word sizes.
And people say little/big endian is just a matter of taste.
> +
> +The "num_dirty" field is a performance hint for KVM to determine whether it
> +should skip processing the bitmap and just invalidate everything. It must
> +be set to the number of set bits in the bitmap.
> +
> 4.62 KVM_CREATE_SPAPR_TCE
>
> Capability: KVM_CAP_SPAPR_TCE
> @@ -1700,3 +1732,45 @@ HTAB address part of SDR1 contains an HVA instead of a GPA, as PAPR keeps the
> HTAB invisible to the guest.
>
> When this capability is enabled, KVM_EXIT_PAPR_HCALL can occur.
> +
> +6.3 KVM_CAP_SW_TLB
> +
> +Architectures: ppc
> +Parameters: args[0] is the address of a struct kvm_config_tlb
> +Returns: 0 on success; -1 on error
> +
> +struct kvm_config_tlb {
> + __u64 params;
> + __u64 array;
> + __u32 mmu_type;
> + __u32 array_len;
> +};
Would it not be simpler to use args[0-3] for this, instead of yet
another indirection?
> +
> +Configures the virtual CPU's TLB array, establishing a shared memory area
> +between userspace and KVM. The "params" and "array" fields are userspace
> +addresses of mmu-type-specific data structures. The "array_len" field is an
> +safety mechanism, and should be set to the size in bytes of the memory that
> +userspace has reserved for the array. It must be at least the size dictated
> +by "mmu_type" and "params".
> +
> +While KVM_RUN is active, the shared region is under control of KVM. Its
> +contents are undefined, and any modification by userspace results in
> +boundedly undefined behavior.
> +
> +On return from KVM_RUN, the shared region will reflect the current state of
> +the guest's TLB. If userspace makes any changes, it must call KVM_DIRTY_TLB
> +to tell KVM which entries have been changed, prior to calling KVM_RUN again
> +on this vcpu.
We already have another mechanism for such shared memory,
mmap(vcpu_fd). x86 uses it for the coalesced mmio region as well as the
traditional kvm_run area. Please consider using it.
> +
> +For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
> + - The "params" field is of type "struct kvm_book3e_206_tlb_params".
> + - The "array" field points to an array of type "struct
> + kvm_book3e_206_tlb_entry".
> + - The array consists of all entries in the first TLB, followed by all
> + entries in the second TLB.
> + - Within a TLB, entries are ordered first by increasing set number. Within a
> + set, entries are ordered by way (increasing ESEL).
> + - The hash for determining set number in TLB0 is: (MAS2 >> 12) & (num_sets - 1)
> + where "num_sets" is the tlb_sizes[] value divided by the tlb_ways[] value.
> + - The tsize field of mas1 shall be set to 4K on TLB0, even though the
> + hardware ignores this value for TLB0.
Holy shit.
> @@ -95,6 +90,9 @@ struct kvmppc_vcpu_e500 {
> u32 tlb1cfg;
> u64 mcar;
>
> + struct page **shared_tlb_pages;
> + int num_shared_tlb_pages;
> +
I missed the requirement that things be page aligned.
If you use mmap(vcpu_fd) this becomes simpler; you can use
get_free_pages() and have a single pointer. You can also use vmap() on
this array (but get_free_pages() is faster).
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-10-31 13:24 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-31 7:53 [PULL 00/14] ppc patch queue 2011-10-31 Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with preemption disabled Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 12:50 ` [PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with Avi Kivity
2011-10-31 12:50 ` [PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with preemption disabled Avi Kivity
2011-10-31 18:52 ` [PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with Scott Wood
2011-10-31 18:52 ` [PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with preemption disabled Scott Wood
2011-11-01 9:00 ` [PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with Avi Kivity
2011-11-01 9:00 ` [PATCH 01/14] KVM: PPC: e500: don't translate gfn to pfn with preemption disabled Avi Kivity
2011-10-31 7:53 ` [PATCH 02/14] KVM: PPC: e500: Eliminate preempt_disable in local_sid_destroy_all Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 03/14] KVM: PPC: e500: clear up confusion between host and guest entries Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 04/14] KVM: PPC: e500: MMU API Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 13:24 ` Avi Kivity [this message]
2011-10-31 13:24 ` Avi Kivity
2011-10-31 20:12 ` Scott Wood
2011-10-31 20:12 ` Scott Wood
2011-11-01 8:58 ` Avi Kivity
2011-11-01 8:58 ` Avi Kivity
2011-11-01 9:55 ` Avi Kivity
2011-11-01 9:55 ` Avi Kivity
2011-11-01 16:16 ` Scott Wood
2011-11-01 16:16 ` Scott Wood
2011-11-02 10:33 ` Avi Kivity
2011-11-02 10:33 ` Avi Kivity
2011-11-10 14:20 ` Alexander Graf
2011-11-10 14:20 ` Alexander Graf
2011-11-10 14:16 ` Avi Kivity
2011-11-10 14:16 ` Avi Kivity
2011-10-31 7:53 ` [PATCH 05/14] KVM: PPC: e500: tlbsx: fix tlb0 esel Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 06/14] KVM: PPC: e500: Don't hardcode PIR=0 Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 13:27 ` Avi Kivity
2011-10-31 13:27 ` Avi Kivity
2011-10-31 7:53 ` [PATCH 07/14] KVM: PPC: Fix build failure with HV KVM and CBE Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 08/14] Revert "KVM: PPC: Add support for explicit HIOR setting" Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 13:30 ` [PATCH 08/14] Revert "KVM: PPC: Add support for explicit HIOR Avi Kivity
2011-10-31 13:30 ` [PATCH 08/14] Revert "KVM: PPC: Add support for explicit HIOR setting" Avi Kivity
2011-10-31 23:49 ` Alexander Graf
2011-10-31 23:49 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 09/14] KVM: PPC: Add generic single register ioctls Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 13:36 ` Avi Kivity
2011-10-31 13:36 ` Avi Kivity
2011-10-31 17:26 ` Jan Kiszka
2011-10-31 17:26 ` Jan Kiszka
2011-11-10 14:22 ` Alexander Graf
2011-11-10 14:22 ` Alexander Graf
2011-11-10 16:05 ` Marcelo Tosatti
2011-11-10 16:05 ` Marcelo Tosatti
2011-11-10 16:49 ` Alexander Graf
2011-11-10 16:49 ` Alexander Graf
2011-11-10 17:35 ` Marcelo Tosatti
2011-11-10 17:35 ` Marcelo Tosatti
2011-11-15 23:45 ` Alexander Graf
2011-11-15 23:45 ` Alexander Graf
2011-11-23 12:47 ` Marcelo Tosatti
2011-11-23 12:47 ` Marcelo Tosatti
2011-12-19 12:58 ` Alexander Graf
2011-12-19 12:58 ` Alexander Graf
2011-12-19 17:29 ` Marcelo Tosatti
2011-12-19 17:29 ` Marcelo Tosatti
2011-10-31 7:53 ` [PATCH 10/14] KVM: PPC: Add support for explicit HIOR setting Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 11/14] KVM: PPC: Whitespace fix for kvm.h Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 12/14] KVM: Fix whitespace in kvm_para.h Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 13/14] KVM: PPC: E500: Support hugetlbfs Alexander Graf
2011-10-31 7:53 ` Alexander Graf
2011-10-31 13:38 ` Avi Kivity
2011-10-31 13:38 ` Avi Kivity
2011-11-10 14:24 ` Alexander Graf
2011-11-10 14:24 ` Alexander Graf
2011-10-31 7:53 ` [PATCH 14/14] PPC: Fix race in mtmsr paravirt implementation Alexander Graf
2011-10-31 7:53 ` 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=4EAEA184.4050807@redhat.com \
--to=avi@redhat.com \
--cc=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=scottwood@freescale.com \
/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.