All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yoder Stuart-B08248 <B08248@freescale.com>
To: "kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: RFC: New API for PPC for vcpu mmu access
Date: Wed, 2 Feb 2011 20:30:09 +0000	[thread overview]
Message-ID: <9F6FE96B71CF29479FF1CDC8046E15030BCD11@039-SN1MPN1-002.039d.mgd.msft.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 6996 bytes --]

Below is a proposal for a new API for PPC to allow KVM clients

to set MMU state in a vcpu.



BookE processors have one or more software managed TLBs and

currently there is no mechanism for Qemu to initialize

or access them.  This is needed for normal initialization

as well as debug.



There are 4 APIs:



-KVM_PPC_SET_MMU_TYPE allows the client to negotiate the type

of MMU with KVM-- the type determines the size and format

of the data in the other APIs



-KVM_PPC_INVALIDATE_TLB invalidates all TLB entries in all

TLBs in the vcpu



-KVM_PPC_SET_TLBE sets a TLB entry-- the Power architecture

specifies the format of the MMU data passed in



-KVM_PPC_GET_TLB allows searching, reading a specific TLB entry,

or iterating over an entire TLB.  Some TLBs may have an unspecified

geometry and thus the need to be able to iterate in order

to dump the TLB.  The Power architecture specifies the format

of the MMU data



Feedback welcome.



Thanks,

Stuart Yoder



------------------------------------------------------------------



KVM PPC MMU API

---------------



User space can query whether the APIs to access the vcpu mmu

is available with the KVM_CHECK_EXTENSION API using

the KVM_CAP_PPC_MMU argument.



If the KVM_CAP_PPC_MMU return value is non-zero it specifies that

the following APIs are available:



   KVM_PPC_SET_MMU_TYPE

   KVM_PPC_INVALIDATE_TLB

   KVM_PPC_SET_TLBE

   KVM_PPC_GET_MMU





KVM_PPC_SET_MMU_TYPE

--------------------



Capability: KVM_CAP_PPC_SET_MMU_TYPE

Architectures: powerpc

Type: vcpu ioctl

Parameters: __u32 mmu_type (in)

Returns: 0 if specified MMU type is supported, else -1



Sets the MMU type.  Valid input values are:

   BOOKE_NOHV   0x1

   BOOKE_HV     0x2



A return value of 0x0 indicates that KVM supports

the specified MMU type.



KVM_PPC_INVALIDATE_TLB

----------------------



Capability: KVM_CAP_PPC_MMU

Architectures: powerpc

Type: vcpu ioctl

Parameters: none

Returns: 0 on success, -1 on error



Invalidates all TLB entries in all TLBs of the vcpu.



KVM_PPC_SET_TLBE

----------------



Capability: KVM_CAP_PPC_MMU

Architectures: powerpc

Type: vcpu ioctl

Parameters:

        For mmu types BOOKE_NOHV and BOOKE_HV : struct kvm_ppc_booke_mmu (in)

Returns: 0 on success, -1 on error



Sets an MMU entry in a virtual CPU.



For mmu types BOOKE_NOHV and BOOKE_HV:



      To write a TLB entry, set the mas fields of kvm_ppc_booke_mmu

      as per the Power architecture.



      struct kvm_ppc_booke_mmu {

            union {

                  __u64 mas0_1;

                  struct {

                        __u32 mas0;

                        __u32 mas1;

                  };

            };

            __u64 mas2;

            union {

                  __u64 mas7_3

                  struct {

                        __u32 mas7;

                        __u32 mas3;

                  };

            };

            union {

                  __u64 mas5_6

                  struct {

                        __u64 mas5;

                        __u64 mas6;

                  };

            }

            __u32 mas8;

      };



      For a mmu type of BOOKE_NOHV, the mas5 and mas8 fields

      in kvm_ppc_booke_mmu are present but not supported.





KVM_PPC_GET_TLB

---------------



Capability: KVM_CAP_PPC_MMU

Architectures: powerpc

Type: vcpu ioctl

Parameters: struct kvm_ppc_get_mmu (in/out)

Returns: 0 on success

         -1 on error

         errno = ENOENT when iterating and there are no more entries to read



Reads an MMU entry from a virtual CPU.



      struct kvm_ppc_get_mmu {

            /* in */

                void *mmu;

            __u32 flags;

                  /* a bitmask of flags to the API */

                    /*     TLB_READ_FIRST   0x1      */

                    /*     TLB_SEARCH       0x2      */

            /* out */

            __u32 max_entries;

      };



For mmu types BOOKE_NOHV and BOOKE_HV :



      The "void *mmu" field of kvm_ppc_get_mmu points to

        a struct of type "struct kvm_ppc_booke_mmu".



      If TLBnCFG[NENTRY] > 0 and TLBnCFG[ASSOC] > 0, the TLB has

      of known number of entries and associativity.  The mas0[ESEL]

      and mas2[EPN] fields specify which entry to read.



      If TLBnCFG[NENTRY] == 0 the number of TLB entries is

      undefined and this API can be used to iterate over

      the entire TLB selected with TLBSEL in mas0.



      -To read a TLB entry:



         set the following fields in the mmu struct (struct kvm_ppc_booke_mmu):

            flags=0

            mas0[TLBSEL] // select which TLB is being read

            mas0[ESEL]   // select which entry is being read

            mas2[EPN]    // effective address



         On return the following fields are updated as per the Power architecture:

            mas0

            mas1

            mas2

            mas3

            mas7



      -To iterate over a TLB (read all entries):



        To start an interation sequence, set the following fields in

        the mmu struct (struct kvm_ppc_booke_mmu)

            flags=TLB_READ_FIRST

            mas0[TLBSEL]  // select which TLB is being read



        On return the following fields are updated:

            mas0           // set as per Power arch

            mas1           // set as per Power arch

            mas2           // set as per Power arch

            mas3           // set as per Power arch

            mas7           // set as per Power arch

            max_entries    // Contains upper limit on number of entries that may

                           // be returned. A value of 0xffffffff means there is

                           // no meaningful upper bound.



        For subsequent calls to the API the following output fields must

        be passed back into the API unmodified:

            flags

            mas0

            mas2



        A return value of -ENOENT indicates that there are no more

        entries to be read.



      -To search for TLB entry



         To search for TLB entry, set the following fields in

         the mmu struct (struct kvm_ppc_booke_mmu):

            flags=TLB_SEARCH

            mas2[EPN]    // effective address to search for

            mas6         // set as per the Power arch

            mas5         // set as per the Power arch



         On return, the following fields are updated as per the Power architecture:

            mas0

            mas1

            mas2

            mas3

            mas7

[-- Attachment #2: Type: text/html, Size: 25124 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Yoder Stuart-B08248 <B08248@freescale.com>
To: "kvm-ppc@vger.kernel.org" <kvm-ppc@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] RFC: New API for PPC for vcpu mmu access
Date: Wed, 2 Feb 2011 20:30:09 +0000	[thread overview]
Message-ID: <9F6FE96B71CF29479FF1CDC8046E15030BCD11@039-SN1MPN1-002.039d.mgd.msft.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 6996 bytes --]

Below is a proposal for a new API for PPC to allow KVM clients

to set MMU state in a vcpu.



BookE processors have one or more software managed TLBs and

currently there is no mechanism for Qemu to initialize

or access them.  This is needed for normal initialization

as well as debug.



There are 4 APIs:



-KVM_PPC_SET_MMU_TYPE allows the client to negotiate the type

of MMU with KVM-- the type determines the size and format

of the data in the other APIs



-KVM_PPC_INVALIDATE_TLB invalidates all TLB entries in all

TLBs in the vcpu



-KVM_PPC_SET_TLBE sets a TLB entry-- the Power architecture

specifies the format of the MMU data passed in



-KVM_PPC_GET_TLB allows searching, reading a specific TLB entry,

or iterating over an entire TLB.  Some TLBs may have an unspecified

geometry and thus the need to be able to iterate in order

to dump the TLB.  The Power architecture specifies the format

of the MMU data



Feedback welcome.



Thanks,

Stuart Yoder



------------------------------------------------------------------



KVM PPC MMU API

---------------



User space can query whether the APIs to access the vcpu mmu

is available with the KVM_CHECK_EXTENSION API using

the KVM_CAP_PPC_MMU argument.



If the KVM_CAP_PPC_MMU return value is non-zero it specifies that

the following APIs are available:



   KVM_PPC_SET_MMU_TYPE

   KVM_PPC_INVALIDATE_TLB

   KVM_PPC_SET_TLBE

   KVM_PPC_GET_MMU





KVM_PPC_SET_MMU_TYPE

--------------------



Capability: KVM_CAP_PPC_SET_MMU_TYPE

Architectures: powerpc

Type: vcpu ioctl

Parameters: __u32 mmu_type (in)

Returns: 0 if specified MMU type is supported, else -1



Sets the MMU type.  Valid input values are:

   BOOKE_NOHV   0x1

   BOOKE_HV     0x2



A return value of 0x0 indicates that KVM supports

the specified MMU type.



KVM_PPC_INVALIDATE_TLB

----------------------



Capability: KVM_CAP_PPC_MMU

Architectures: powerpc

Type: vcpu ioctl

Parameters: none

Returns: 0 on success, -1 on error



Invalidates all TLB entries in all TLBs of the vcpu.



KVM_PPC_SET_TLBE

----------------



Capability: KVM_CAP_PPC_MMU

Architectures: powerpc

Type: vcpu ioctl

Parameters:

        For mmu types BOOKE_NOHV and BOOKE_HV : struct kvm_ppc_booke_mmu (in)

Returns: 0 on success, -1 on error



Sets an MMU entry in a virtual CPU.



For mmu types BOOKE_NOHV and BOOKE_HV:



      To write a TLB entry, set the mas fields of kvm_ppc_booke_mmu

      as per the Power architecture.



      struct kvm_ppc_booke_mmu {

            union {

                  __u64 mas0_1;

                  struct {

                        __u32 mas0;

                        __u32 mas1;

                  };

            };

            __u64 mas2;

            union {

                  __u64 mas7_3

                  struct {

                        __u32 mas7;

                        __u32 mas3;

                  };

            };

            union {

                  __u64 mas5_6

                  struct {

                        __u64 mas5;

                        __u64 mas6;

                  };

            }

            __u32 mas8;

      };



      For a mmu type of BOOKE_NOHV, the mas5 and mas8 fields

      in kvm_ppc_booke_mmu are present but not supported.





KVM_PPC_GET_TLB

---------------



Capability: KVM_CAP_PPC_MMU

Architectures: powerpc

Type: vcpu ioctl

Parameters: struct kvm_ppc_get_mmu (in/out)

Returns: 0 on success

         -1 on error

         errno = ENOENT when iterating and there are no more entries to read



Reads an MMU entry from a virtual CPU.



      struct kvm_ppc_get_mmu {

            /* in */

                void *mmu;

            __u32 flags;

                  /* a bitmask of flags to the API */

                    /*     TLB_READ_FIRST   0x1      */

                    /*     TLB_SEARCH       0x2      */

            /* out */

            __u32 max_entries;

      };



For mmu types BOOKE_NOHV and BOOKE_HV :



      The "void *mmu" field of kvm_ppc_get_mmu points to

        a struct of type "struct kvm_ppc_booke_mmu".



      If TLBnCFG[NENTRY] > 0 and TLBnCFG[ASSOC] > 0, the TLB has

      of known number of entries and associativity.  The mas0[ESEL]

      and mas2[EPN] fields specify which entry to read.



      If TLBnCFG[NENTRY] == 0 the number of TLB entries is

      undefined and this API can be used to iterate over

      the entire TLB selected with TLBSEL in mas0.



      -To read a TLB entry:



         set the following fields in the mmu struct (struct kvm_ppc_booke_mmu):

            flags=0

            mas0[TLBSEL] // select which TLB is being read

            mas0[ESEL]   // select which entry is being read

            mas2[EPN]    // effective address



         On return the following fields are updated as per the Power architecture:

            mas0

            mas1

            mas2

            mas3

            mas7



      -To iterate over a TLB (read all entries):



        To start an interation sequence, set the following fields in

        the mmu struct (struct kvm_ppc_booke_mmu)

            flags=TLB_READ_FIRST

            mas0[TLBSEL]  // select which TLB is being read



        On return the following fields are updated:

            mas0           // set as per Power arch

            mas1           // set as per Power arch

            mas2           // set as per Power arch

            mas3           // set as per Power arch

            mas7           // set as per Power arch

            max_entries    // Contains upper limit on number of entries that may

                           // be returned. A value of 0xffffffff means there is

                           // no meaningful upper bound.



        For subsequent calls to the API the following output fields must

        be passed back into the API unmodified:

            flags

            mas0

            mas2



        A return value of -ENOENT indicates that there are no more

        entries to be read.



      -To search for TLB entry



         To search for TLB entry, set the following fields in

         the mmu struct (struct kvm_ppc_booke_mmu):

            flags=TLB_SEARCH

            mas2[EPN]    // effective address to search for

            mas6         // set as per the Power arch

            mas5         // set as per the Power arch



         On return, the following fields are updated as per the Power architecture:

            mas0

            mas1

            mas2

            mas3

            mas7

[-- Attachment #2: Type: text/html, Size: 25124 bytes --]

             reply	other threads:[~2011-02-02 20:30 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 20:30 Yoder Stuart-B08248 [this message]
2011-02-02 20:30 ` [Qemu-devel] RFC: New API for PPC for vcpu mmu access Yoder Stuart-B08248
2011-02-02 20:33 Yoder Stuart-B08248
2011-02-02 20:33 ` Yoder Stuart-B08248
2011-02-02 21:33 ` Alexander Graf
2011-02-02 21:33   ` Alexander Graf
2011-02-02 22:08   ` Scott Wood
2011-02-02 22:08     ` Scott Wood
2011-02-03  9:19     ` Alexander Graf
2011-02-03  9:19       ` Alexander Graf
2011-02-04 22:33       ` Scott Wood
2011-02-04 22:33         ` Scott Wood
2011-02-07 15:43         ` Alexander Graf
2011-02-07 15:43           ` Alexander Graf
2011-02-07 16:40           ` Yoder Stuart-B08248
2011-02-07 16:40             ` Yoder Stuart-B08248
2011-02-07 16:49             ` Alexander Graf
2011-02-07 16:49               ` Alexander Graf
2011-02-07 18:52               ` Scott Wood
2011-02-07 18:52                 ` Scott Wood
2011-02-07 19:56                 ` Yoder Stuart-B08248
2011-02-07 19:56                   ` Yoder Stuart-B08248
2011-02-09 17:03                   ` Alexander Graf
2011-02-09 17:03                     ` Alexander Graf
2011-02-07 20:15           ` Scott Wood
2011-02-07 20:15             ` Scott Wood
2011-02-09 17:21             ` Alexander Graf
2011-02-09 17:21               ` Alexander Graf
2011-02-09 23:09               ` Scott Wood
2011-02-09 23:09                 ` Scott Wood
2011-02-10 11:45                 ` Alexander Graf
2011-02-10 11:45                   ` Alexander Graf
2011-02-10 18:51                   ` Scott Wood
2011-02-10 18:51                     ` Scott Wood
2011-02-11  0:20                     ` Alexander Graf
2011-02-11  0:20                       ` Alexander Graf
2011-02-11  0:22                       ` Alexander Graf
2011-02-11  0:22                         ` Alexander Graf
2011-02-11  1:41                         ` Alexander Graf
2011-02-11  1:41                           ` Alexander Graf
2011-02-11 20:53                           ` Scott Wood
2011-02-11 20:53                             ` Scott Wood
2011-02-11 21:07                             ` Alexander Graf
2011-02-11 21:07                               ` Alexander Graf
2011-02-12  0:57                               ` Scott Wood
2011-02-12  0:57                                 ` Scott Wood
2011-02-13 22:43                                 ` Alexander Graf
2011-02-13 22:43                                   ` Alexander Graf
2011-02-14 17:11                                   ` Scott Wood
2011-02-14 17:11                                     ` Scott Wood
2011-02-14 20:19                                     ` Alexander Graf
2011-02-14 20:19                                       ` Alexander Graf
2011-02-14 21:16                                       ` Scott Wood
2011-02-14 21:16                                         ` Scott Wood
2011-02-14 23:39                                         ` Alexander Graf
2011-02-14 23:39                                           ` Alexander Graf
2011-02-14 23:49                                           ` Scott Wood
2011-02-14 23:49                                             ` Scott Wood
2011-02-15  0:00                                             ` Alexander Graf
2011-02-15  0:00                                               ` Alexander Graf
2011-02-07 17:13       ` Avi Kivity
2011-02-07 17:13         ` Avi Kivity
2011-02-07 17:30         ` Yoder Stuart-B08248
2011-02-07 17:30           ` Yoder Stuart-B08248
2011-02-08  9:10           ` Avi Kivity
2011-02-08  9:10             ` Avi Kivity
2011-02-10  0:04       ` Scott Wood
2011-02-10  0:04         ` Scott Wood
2011-02-10 11:55         ` Alexander Graf
2011-02-10 11:55           ` Alexander Graf
2011-02-10 12:31           ` Edgar E. Iglesias
2011-02-10 12:31             ` Edgar E. Iglesias
2011-02-02 22:34   ` Yoder Stuart-B08248
2011-02-02 22:34     ` Yoder Stuart-B08248
2011-02-03  9:29     ` Alexander Graf
2011-02-03  9:29       ` 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=9F6FE96B71CF29479FF1CDC8046E15030BCD11@039-SN1MPN1-002.039d.mgd.msft.net \
    --to=b08248@freescale.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@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.