Skip to contentSkip to conversation

Import linux headers and some cleanups

PATCH Applied Jan Kiszka 9 participants 46 messages Jun 8, 2011 – Jun 26, 2011

Subsystems (2)
lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

cover Import linux headers and some cleanups

Licensing of the virtio headers is no clarified. So we can finally resolve the clumbsy and constantly buggy #ifdef'ery around old KVM and virtio headers. Recent example: current qemu-kvm does not build against 2.6.32 headers.

This series introduces an import mechanism for all required Linux headers so that the appropriate versions can be kept safely inside the QEMU tree. I've incorporated all the valuable review comments on the first version and rebased the result over current uq/master after rebasing that one over current QEMU master.

Please note that I had no chance to test-build PPC or s390.

Beside the header topic, this series also includes a few assorted KVM cleanup patches so that my queue is empty again.

CC Alexander Graf <[email protected]>
CC Andreas Färber <[email protected]>
CC Christoph Hellwig <[email protected]>
CC Eduardo Habkost <[email protected]>
CC Peter Maydell <[email protected]>

Jan Kiszka (12):
Add kernel header update script
Import kernel headers
Switch build system to accompanied kernel headers
kvm: Drop CONFIG_KVM_PARA
kvm: ppc: Drop CONFIG_KVM_PPC_PVR
kvm: Drop useless zero-initializations
kvm: Drop KVM_CAP build dependencies
kvm: x86: Drop KVM_CAP build dependencies
kvm: ppc: Drop KVM_CAP build dependencies
kvm: Clean up stubs
kvm: x86: Pass KVMState to kvm_arch_get_supported_cpuid Remove unneeded kvm.h from cpu-exec.c

 Makefile.target                      |    4 +-
 configure                            |  149 +------
 cpu-exec.c                           |    1 -
 hw/kvmclock.c                        |    9 -
 kvm-all.c                            |   13 -
 kvm-stub.c                           |   18 +-
 kvm.h                                |    2 +-
 linux-headers/COPYING                |  356 +++++++++++++++
 linux-headers/README                 |    2 +
 linux-headers/asm-powerpc/kvm.h      |  275 ++++++++++++
 linux-headers/asm-powerpc/kvm_para.h |   53 +++
 linux-headers/asm-s390/kvm.h         |   44 ++
 linux-headers/asm-s390/kvm_para.h    |   17 +
 linux-headers/asm-x86/hyperv.h       |  193 ++++++++
 linux-headers/asm-x86/kvm.h          |  324 ++++++++++++++
 linux-headers/asm-x86/kvm_para.h     |   79 ++++
 linux-headers/linux/kvm.h            |  804 ++++++++++++++++++++++++++++++++++
 linux-headers/linux/kvm_para.h       |   29 ++
 linux-headers/linux/vhost.h          |  130 ++++++
 linux-headers/linux/virtio_config.h  |   54 +++
 linux-headers/linux/virtio_ring.h    |  163 +++++++
 scripts/update-linux-headers.sh      |   55 +++
 target-i386/cpuid.c                  |   20 +-
 target-i386/kvm.c                    |  123 +-----
 target-ppc/kvm.c                     |   23 -
 target-s390x/cpu.h                   |   10 -
 target-s390x/op_helper.c             |    1 +
 27 files changed, 2630 insertions(+), 321 deletions(-)
 create mode 100644 linux-headers/COPYING
 create mode 100644 linux-headers/README
 create mode 100644 linux-headers/asm-powerpc/kvm.h
 create mode 100644 linux-headers/asm-powerpc/kvm_para.h
 create mode 100644 linux-headers/asm-s390/kvm.h
 create mode 100644 linux-headers/asm-s390/kvm_para.h
 create mode 100644 linux-headers/asm-x86/hyperv.h
 create mode 100644 linux-headers/asm-x86/kvm.h
 create mode 100644 linux-headers/asm-x86/kvm_para.h
 create mode 100644 linux-headers/linux/kvm.h
 create mode 100644 linux-headers/linux/kvm_para.h
 create mode 100644 linux-headers/linux/vhost.h
 create mode 100644 linux-headers/linux/virtio_config.h
 create mode 100644 linux-headers/linux/virtio_ring.h
 create mode 100755 scripts/update-linux-headers.sh
author
#1 lore raw

PATCH 1/12 Add kernel header update script

This helper pulls the required kernel headers for KVM and vhost into a specified directory. The update is triggered via

scripts/update-linux-headers.sh LINUX_PATH

and will place the output under linux-headers/linux and linux-headers/asm-*. It also imports the COPYING to care for headers without an explicit license.

CC Alexander Graf <[email protected]>
CC Christoph Hellwig <[email protected]>
CC Peter Maydell <[email protected]>
CC Andreas Färber <[email protected]>
---
 linux-headers/README            |    2 +
 scripts/update-linux-headers.sh |   55 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100644 linux-headers/README
 create mode 100755 scripts/update-linux-headers.sh
linux-headers/README new file +2 -0
new file mode 100644
index 0000000..5c9026b
@@ -0,0 +1,2 @@
+Automatically imported Linux kernel headers.
+Only use scripts/update-linux-headers.sh to update!
scripts/update-linux-headers.sh new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 01/12] Add kernel header update script

scripts/update-linux-headers.sh line 35

Quoted 11 lines · Jan Kiszka
scripts/update-linux-headers.sh new file +6 -0
@@ -0,0 +1,55 @@
+#!/bin/sh -e
+#
 
+if [ -z "$output" ]; then
+    output=$PWD
+fi
 
+    mkdir -p $output/linux-headers/asm-$arch

This script is rather lacking in quoting throughout. As a random example, this looks like it will break if you run the script from a directory with a space in the path.

Quoted 1 line

+tmpdir=$TMPDIR/.tmp-hdrs-$$

Better (safer) to use mktemp, I think.

Quoted 1 line

if [ -z "$linux" -o ! -d "$linux" ]; then

test -o is obsolescent in POSIX; use
if [ -z "$linux" ] || ! [ -d "$linux" ] ; then
instead.

-- PMM

author
#3 lore raw

Re: [PATCH 01/12] Add kernel header update script

Quoted 11 lines · Peter Maydell
Quoted 9 lines · Jan Kiszka
scripts/update-linux-headers.sh new file +5 -0
@@ -0,0 +1,55 @@
+#!/bin/sh -e
+#
 
+if [ -z "$output" ]; then
+    output=$PWD
+fi
Quoted 5 lines
Quoted 1 line

+ mkdir -p $output/linux-headers/asm-$arch

This script is rather lacking in quoting throughout. As a random example, this looks like it will break if you run the script from a directory with a space in the path.

True.

Quoted 4 lines
Quoted 2 lines

+tmpdir=$TMPDIR/.tmp-hdrs-$$

Better (safer) to use mktemp, I think.

Is that portable? I don't think so.

Quoted 7 lines
Quoted 2 lines

if [ -z "$linux" -o ! -d "$linux" ]; then

test -o is obsolescent in POSIX; use
if [ -z "$linux" ] || ! [ -d "$linux" ] ; then
instead.

OK.

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#4 lore raw

Re: [PATCH 01/12] Add kernel header update script

2011/6/8 Jan Kiszka <[email protected]>:

Quoted 7 lines · Peter Maydell
Quoted 4 lines · Jan Kiszka
Quoted 1 line

+tmpdir=$TMPDIR/.tmp-hdrs-$$

Better (safer) to use mktemp, I think.

Is that portable? I don't think so.

We don't expect every random end user to run this script, though, right? We already use mktemp in scripts/refresh-pxe-roms.sh, for instance.

-- PMM

author
#5 lore raw

PATCH v2 1/12 Add kernel header update script

In reply to Jan Kiszka

This helper pulls the required kernel headers for KVM and vhost into a specified directory. The update is triggered via

scripts/update-linux-headers.sh LINUX_PATH

and will place the output under linux-headers/linux and linux-headers/asm-*. It also imports the COPYING to care for headers without an explicit license.

CC Alexander Graf <[email protected]>
CC Christoph Hellwig <[email protected]>
CC Peter Maydell <[email protected]>
CC Andreas Färber <[email protected]>

---

Changes in v2:
- add quoting
- use mktemp
- avoid -o for test

 linux-headers/README            |    2 +
 scripts/update-linux-headers.sh |   55 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100644 linux-headers/README
 create mode 100755 scripts/update-linux-headers.sh
linux-headers/README new file +2 -0
new file mode 100644
index 0000000..5c9026b
@@ -0,0 +1,2 @@
+Automatically imported Linux kernel headers.
+Only use scripts/update-linux-headers.sh to update!
scripts/update-linux-headers.sh new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
1.7.1
#6 lore raw

Re: [PATCH v2 01/12] Add kernel header update script

Quoted 1 line · Jan Kiszka

+    if [ $arch == x86 ]; then

This should be a single '=' -- '==' is a bashism. The 'checkbashisms' script (available in 'devscripts' package on debian and ubuntu) catches this:

cam-vm-266:maverick:testing$ checkbashisms scripts/update-linux-headers.sh possible bashism in /home/petmay01/linaro/qemu-from-laptop/qemu/scripts/update-linux-headers.sh line 39 (should be 'b = a'):

    if [ $arch == x86 ]; then

Otherwise looks good.

-- PMM

author
#7 lore raw

PATCH v3 1/12 Add kernel header update script

In reply to Jan Kiszka

This helper pulls the required kernel headers for KVM and vhost into a specified directory. The update is triggered via

scripts/update-linux-headers.sh LINUX_PATH

and will place the output under linux-headers/linux and linux-headers/asm-*. It also imports the COPYING to care for headers without an explicit license.

CC Alexander Graf <[email protected]>
CC Christoph Hellwig <[email protected]>
CC Peter Maydell <[email protected]>
CC Andreas Färber <[email protected]>

---

Changes in v3:
- remove bashism

Changes in v2:
- add quoting
- use mktemp
- avoid -o for test

 linux-headers/README            |    2 +
 scripts/update-linux-headers.sh |   55 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)
 create mode 100644 linux-headers/README
 create mode 100755 scripts/update-linux-headers.sh
linux-headers/README new file +2 -0
new file mode 100644
index 0000000..5c9026b
@@ -0,0 +1,2 @@
+Automatically imported Linux kernel headers.
+Only use scripts/update-linux-headers.sh to update!
scripts/update-linux-headers.sh new file +55 -0

55 lines not on this page · raw message

Reviewed-by on v3 1/12
#8 lore raw

Re: [PATCH v3 01/12] Add kernel header update script

Quoted 10 lines · Jan Kiszka

This helper pulls the required kernel headers for KVM and vhost into a specified directory. The update is triggered via

   scripts/update-linux-headers.sh LINUX_PATH

---

Changes in v3:
 - remove bashism

Thanks; can't see any problems in this version.

-- PMM

author
#9 lore raw

PATCH 2/12 Import kernel headers

In reply to Jan Kiszka

These kernel headers and the COPYING file were automatically imported from current Linux git, cb0a02ecf9 (post 3.0-rc2).

Licensing:
asm-powerpc GPLv2
asm-s390 GPLv2
asm-x86 Linux top-level license (GPLv2 with exception)
linux/kvm*: Linux top-level license (GPLv2 with exception)
linux/vhost: Linux top-level license (GPLv2 with exception)
linux/virtio*: 3-clause BSB

CC Alexander Graf <[email protected]>
---
 linux-headers/COPYING                |  356 +++++++++++++++
 linux-headers/asm-powerpc/kvm.h      |  275 ++++++++++++
 linux-headers/asm-powerpc/kvm_para.h |   53 +++
 linux-headers/asm-s390/kvm.h         |   44 ++
 linux-headers/asm-s390/kvm_para.h    |   17 +
 linux-headers/asm-x86/hyperv.h       |  193 ++++++++
 linux-headers/asm-x86/kvm.h          |  324 ++++++++++++++
 linux-headers/asm-x86/kvm_para.h     |   79 ++++
 linux-headers/linux/kvm.h            |  804 ++++++++++++++++++++++++++++++++++
 linux-headers/linux/kvm_para.h       |   29 ++
 linux-headers/linux/vhost.h          |  130 ++++++
 linux-headers/linux/virtio_config.h  |   54 +++
 linux-headers/linux/virtio_ring.h    |  163 +++++++
 13 files changed, 2521 insertions(+), 0 deletions(-)
 create mode 100644 linux-headers/COPYING
 create mode 100644 linux-headers/asm-powerpc/kvm.h
 create mode 100644 linux-headers/asm-powerpc/kvm_para.h
 create mode 100644 linux-headers/asm-s390/kvm.h
 create mode 100644 linux-headers/asm-s390/kvm_para.h
 create mode 100644 linux-headers/asm-x86/hyperv.h
 create mode 100644 linux-headers/asm-x86/kvm.h
 create mode 100644 linux-headers/asm-x86/kvm_para.h
 create mode 100644 linux-headers/linux/kvm.h
 create mode 100644 linux-headers/linux/kvm_para.h
 create mode 100644 linux-headers/linux/vhost.h
 create mode 100644 linux-headers/linux/virtio_config.h
 create mode 100644 linux-headers/linux/virtio_ring.h
linux-headers/COPYING new file +74 -0
new file mode 100644
index 0000000..ca442d3
@@ -0,0 +1,356 @@
+
+   NOTE! This copyright does *not* cover user programs that use kernel
+ services by normal system calls - this is merely considered normal use
+ of the kernel, and does *not* fall under the heading of "derived work".
+ Also note that the GPL below is copyrighted by the Free Software
+ Foundation, but the instance of code that it refers to (the Linux
+ kernel) is copyrighted by me and others who actually wrote it.
+
+ Also note that the only valid version of the GPL as far as the kernel
+ is concerned is _this_ particular version of the license (ie v2, not
+ v2.2 or v3.x or whatever), unless explicitly otherwise stated.
+
+			Linus Torvalds
+
+----------------------------------------
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+

+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". +
+Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. +
+ 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+

+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)

+

+These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. +
+Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following:
+

+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)

+
+The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable.
+
+If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code.
+

+ 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances.
+
+It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice.
+
+This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License.
+

+ 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+

+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. +
+ To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. +
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+

+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

+
+
+Also add information on how to contact you by electronic and paper mail. +
+If the program is interactive, make it output a short notice like this +when it starts in an interactive mode:
+

+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.

+
+The hypothetical commands show w' and show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than show w' and show c'; they could even be +mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker. +
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License.

linux-headers/asm-powerpc/kvm.h new file +275 -0

275 lines not on this page · raw message

linux-headers/asm-powerpc/kvm_para.h new file +53 -0

53 lines not on this page · raw message

linux-headers/asm-s390/kvm.h new file +44 -0

44 lines not on this page · raw message

linux-headers/asm-s390/kvm_para.h new file +17 -0
new file mode 100644
index 0000000..8e2dd67
@@ -0,0 +1,17 @@
+/*
+ * asm-s390/kvm_para.h - definition for paravirtual devices on s390
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ *
+ *    Author(s): Christian Borntraeger <[email protected]>
+ */
+
+#ifndef __S390_KVM_PARA_H
+#define __S390_KVM_PARA_H
+
+
+#endif /* __S390_KVM_PARA_H */
linux-headers/asm-x86/hyperv.h new file +193 -0

193 lines not on this page · raw message

linux-headers/asm-x86/kvm.h new file +324 -0

324 lines not on this page · raw message

linux-headers/asm-x86/kvm_para.h new file +79 -0

79 lines not on this page · raw message

linux-headers/linux/kvm.h new file +804 -0

804 lines not on this page · raw message

linux-headers/linux/kvm_para.h new file +29 -0
new file mode 100644
index 0000000..b315e27
@@ -0,0 +1,29 @@
+#ifndef __LINUX_KVM_PARA_H
+#define __LINUX_KVM_PARA_H
+
+/*
+ * This header file provides a method for making a hypercall to the host
+ * Architectures should define:
+ * - kvm_hypercall0, kvm_hypercall1...
+ * - kvm_arch_para_features
+ * - kvm_para_available
+ */
+
+/* Return values for hypercalls */
+#define KVM_ENOSYS		1000
+#define KVM_EFAULT		EFAULT
+#define KVM_E2BIG		E2BIG
+#define KVM_EPERM		EPERM
+
+#define KVM_HC_VAPIC_POLL_IRQ		1
+#define KVM_HC_MMU_OP			2
+#define KVM_HC_FEATURES			3
+#define KVM_HC_PPC_MAP_MAGIC_PAGE	4
+
+/*
+ * hypercalls use architecture specific
+ */
+#include <asm/kvm_para.h>
+
+#endif /* __LINUX_KVM_PARA_H */
+
linux-headers/linux/vhost.h new file +130 -0

130 lines not on this page · raw message

linux-headers/linux/virtio_config.h new file +54 -0

54 lines not on this page · raw message

linux-headers/linux/virtio_ring.h new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
1.7.1
author
#10 lore raw

PATCH 3/12 Switch build system to accompanied kernel headers

In reply to Jan Kiszka

This helps reducing our build-time checks for feature support in the available Linux kernel headers. And it helps users that do not have sufficiently recent headers installed on their build machine.

Consequently, the patch removes and build-time checks for kvm and vhost in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are supposed to be provided by QEMU only.

s390 needs some extra love as it carries redefinitions from kernel headers.

CC Alexander Graf <[email protected]>
---
 Makefile.target          |    4 +-
 configure                |  151 ++++++----------------------------------------
 target-s390x/cpu.h       |   10 ---
 target-s390x/op_helper.c |    1 +
 4 files changed, 21 insertions(+), 145 deletions(-)
Makefile.target +1 -3
index 5c22df8..be9c0e8 100644
@@ -14,7 +14,7 @@ endif
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
-QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H
+QEMU_CFLAGS+= -I.. -I../linux-headers -I$(TARGET_PATH) -DNEED_CPU_H
 
 include $(SRC_PATH)/Makefile.objs
 
@@ -37,8 +37,6 @@ ifndef CONFIG_HAIKU
 LIBS+=-lm
 endif
 
-kvm.o kvm-all.o vhost.o vhost_net.o kvmclock.o: QEMU_CFLAGS+=$(KVM_CFLAGS)
-
 config-target.h: config-target.h-timestamp
 config-target.h-timestamp: config-target.mak
 
configure +19 -132

202 lines not on this page · raw message

target-s390x/cpu.h +0 -10
index 4e5c391..b5e587f 100644
@@ -313,16 +313,6 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
 /* from s390-virtio-bus */
 extern const target_phys_addr_t virtio_size;
 
-#ifndef KVM_S390_SIGP_STOP
-#define KVM_S390_SIGP_STOP              0
-#define KVM_S390_PROGRAM_INT            0
-#define KVM_S390_SIGP_SET_PREFIX        0
-#define KVM_S390_RESTART                0
-#define KVM_S390_INT_VIRTIO             0
-#define KVM_S390_INT_SERVICE            0
-#define KVM_S390_INT_EMERGENCY          0
-#endif
-
 #endif
 void cpu_lock(void);
 void cpu_unlock(void);
target-s390x/op_helper.c +1 -0
index db03a79..9429698 100644
@@ -23,6 +23,7 @@
 #include "helpers.h"
 #include <string.h>
 #include "kvm.h"
+#include <linux/kvm.h>
 #include "qemu-timer.h"
 
 /*****************************************************************************/
Signature · 1 line
1.7.1
#11 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Quoted 10 lines · Jan Kiszka

This helps reducing our build-time checks for feature support in the available Linux kernel headers. And it helps users that do not have sufficiently recent headers installed on their build machine.

Consequently, the patch removes and build-time checks for kvm and vhost in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are supposed to be provided by QEMU only.

s390 needs some extra love as it carries redefinitions from kernel headers.

Yes. I was wondering if we should unconditionally include the kernel headers there. The problem I'm seeing there is that I don't know if that would work fine on non-Linux hosts, as that code definitely gets compiled there, while KVM code is not.

Quoted 2 lines

[...]

Quoted 26 lines
target-s390x/cpu.h +0 -10
index 4e5c391..b5e587f 100644
@@ -313,16 +313,6 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
 /* from s390-virtio-bus */
 extern const target_phys_addr_t virtio_size;
 
-#ifndef KVM_S390_SIGP_STOP
-#define KVM_S390_SIGP_STOP              0
-#define KVM_S390_PROGRAM_INT            0
-#define KVM_S390_SIGP_SET_PREFIX        0
-#define KVM_S390_RESTART                0
-#define KVM_S390_INT_VIRTIO             0
-#define KVM_S390_INT_SERVICE            0
-#define KVM_S390_INT_EMERGENCY          0
-#endif
-
 #endif
 void cpu_lock(void);
 void cpu_unlock(void);
target-s390x/op_helper.c +0 -0
index db03a79..9429698 100644

target-s390x/op_helper.c line 26

Quoted 4 lines
target-s390x/op_helper.c +1 -0
@@ -23,6 +23,7 @@
 #include "helpers.h"
 #include <string.h>
 #include "kvm.h"
+#include <linux/kvm.h>

Have you tried to compile this on non-Linux?

Alex

author
#12 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Quoted 51 lines · Alexander Graf

On 08.06.2011, at 16:10, Jan Kiszka wrote:

This helps reducing our build-time checks for feature support in the available Linux kernel headers. And it helps users that do not have sufficiently recent headers installed on their build machine.

Consequently, the patch removes and build-time checks for kvm and vhost in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are supposed to be provided by QEMU only.

s390 needs some extra love as it carries redefinitions from kernel headers.

Yes. I was wondering if we should unconditionally include the kernel headers there. The problem I'm seeing there is that I don't know if that would work fine on non-Linux hosts, as that code definitely gets compiled there, while KVM code is not.

[...]

target-s390x/cpu.h +0 -10
index 4e5c391..b5e587f 100644
@@ -313,16 +313,6 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
 /* from s390-virtio-bus */
 extern const target_phys_addr_t virtio_size;
 
-#ifndef KVM_S390_SIGP_STOP
-#define KVM_S390_SIGP_STOP              0
-#define KVM_S390_PROGRAM_INT            0
-#define KVM_S390_SIGP_SET_PREFIX        0
-#define KVM_S390_RESTART                0
-#define KVM_S390_INT_VIRTIO             0
-#define KVM_S390_INT_SERVICE            0
-#define KVM_S390_INT_EMERGENCY          0
-#endif
-
 #endif
 void cpu_lock(void);
 void cpu_unlock(void);
target-s390x/op_helper.c +1 -0
index db03a79..9429698 100644
@@ -23,6 +23,7 @@
 #include "helpers.h"
 #include <string.h>
 #include "kvm.h"
+#include <linux/kvm.h>
 
Quoted 1 line

Have you tried to compile this on non-Linux?

Sorry, I don't have "non-Linux" around. :) Do you expect build problems with that header? Why?

BTW, if you depend on KVM_* constants for non-KVM builds, that looks a bit fishy to me. Why is that code built at all in that setup?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#13 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Quoted 52 lines · Jan Kiszka
Quoted 51 lines · Alexander Graf

On 08.06.2011, at 16:10, Jan Kiszka wrote:

This helps reducing our build-time checks for feature support in the available Linux kernel headers. And it helps users that do not have sufficiently recent headers installed on their build machine.

Consequently, the patch removes and build-time checks for kvm and vhost in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are supposed to be provided by QEMU only.

s390 needs some extra love as it carries redefinitions from kernel headers.

Yes. I was wondering if we should unconditionally include the kernel headers there. The problem I'm seeing there is that I don't know if that would work fine on non-Linux hosts, as that code definitely gets compiled there, while KVM code is not.

[...]

target-s390x/cpu.h +0 -10
index 4e5c391..b5e587f 100644
@@ -313,16 +313,6 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
 /* from s390-virtio-bus */
 extern const target_phys_addr_t virtio_size;
 
-#ifndef KVM_S390_SIGP_STOP
-#define KVM_S390_SIGP_STOP              0
-#define KVM_S390_PROGRAM_INT            0
-#define KVM_S390_SIGP_SET_PREFIX        0
-#define KVM_S390_RESTART                0
-#define KVM_S390_INT_VIRTIO             0
-#define KVM_S390_INT_SERVICE            0
-#define KVM_S390_INT_EMERGENCY          0
-#endif
-
 #endif
 void cpu_lock(void);
 void cpu_unlock(void);
target-s390x/op_helper.c +1 -0
index db03a79..9429698 100644
@@ -23,6 +23,7 @@
 #include "helpers.h"
 #include <string.h>
 #include "kvm.h"
+#include <linux/kvm.h>
 
Quoted 4 lines
Quoted 1 line

Have you tried to compile this on non-Linux?

Sorry, I don't have "non-Linux" around. :) Do you expect build problems with that header? Why?

Do you have a git tree handy? I can give a Mac build a try then.

Quoted 2 lines

BTW, if you depend on KVM_* constants for non-KVM builds, that looks a bit fishy to me. Why is that code built at all in that setup?

The reason for that is that I didn't want to clutter the emulation code with #ifdefs:

static void program_interrupt(CPUState *env, uint32_t code, int ilc)

{
    qemu_log("program interrupt at %#" PRIx64 "\n", env->psw.addr);

    if (kvm_enabled()) {
        kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
    } else {
        env->int_pgm_code = code;
        env->int_pgm_ilc = ilc;
        env->exception_index = EXCP_PGM;
        cpu_loop_exit();
    }
}

This breaks compilation when KVM_S390_PROGRAM_INT is not defined. I'm very open to suggestions on how to improve this though :).

Alex

author
#14 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Quoted 55 lines · Alexander Graf
Quoted 52 lines · Jan Kiszka
Quoted 51 lines · Alexander Graf

On 08.06.2011, at 16:10, Jan Kiszka wrote:

This helps reducing our build-time checks for feature support in the available Linux kernel headers. And it helps users that do not have sufficiently recent headers installed on their build machine.

Consequently, the patch removes and build-time checks for kvm and vhost in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are supposed to be provided by QEMU only.

s390 needs some extra love as it carries redefinitions from kernel headers.

Yes. I was wondering if we should unconditionally include the kernel headers there. The problem I'm seeing there is that I don't know if that would work fine on non-Linux hosts, as that code definitely gets compiled there, while KVM code is not.

[...]

target-s390x/cpu.h +0 -10
index 4e5c391..b5e587f 100644
@@ -313,16 +313,6 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
 /* from s390-virtio-bus */
 extern const target_phys_addr_t virtio_size;
 
-#ifndef KVM_S390_SIGP_STOP
-#define KVM_S390_SIGP_STOP              0
-#define KVM_S390_PROGRAM_INT            0
-#define KVM_S390_SIGP_SET_PREFIX        0
-#define KVM_S390_RESTART                0
-#define KVM_S390_INT_VIRTIO             0
-#define KVM_S390_INT_SERVICE            0
-#define KVM_S390_INT_EMERGENCY          0
-#endif
-
 #endif
 void cpu_lock(void);
 void cpu_unlock(void);
target-s390x/op_helper.c +1 -0
index db03a79..9429698 100644
@@ -23,6 +23,7 @@
 #include "helpers.h"
 #include <string.h>
 #include "kvm.h"
+#include <linux/kvm.h>
 
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Have you tried to compile this on non-Linux?

Sorry, I don't have "non-Linux" around. :) Do you expect build problems with that header? Why?

Do you have a git tree handy? I can give a Mac build a try then.

Try git://git.kiszka.org/qemu-kvm.git queues/kvm-upstream

Quoted 20 lines
Quoted 3 lines

BTW, if you depend on KVM_* constants for non-KVM builds, that looks a bit fishy to me. Why is that code built at all in that setup?

The reason for that is that I didn't want to clutter the emulation code with #ifdefs:

static void program_interrupt(CPUState *env, uint32_t code, int ilc)

{
    qemu_log("program interrupt at %#" PRIx64 "\n", env->psw.addr);

    if (kvm_enabled()) {
        kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
    } else {
        env->int_pgm_code = code;
        env->int_pgm_ilc = ilc;
        env->exception_index = EXCP_PGM;
        cpu_loop_exit();
    }
}
Quoted 1 line

This breaks compilation when KVM_S390_PROGRAM_INT is not defined. I'm very open to suggestions on how to improve this though :).

Callbacks? See cpu_interrupt_handler e.g.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#15 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

In reply to Jan Kiszka

Am 08.06.2011 16:10, schrieb Jan Kiszka:

Quoted 54 lines

This helps reducing our build-time checks for feature support in the available Linux kernel headers. And it helps users that do not have sufficiently recent headers installed on their build machine.

Consequently, the patch removes and build-time checks for kvm and vhost in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are supposed to be provided by QEMU only.

s390 needs some extra love as it carries redefinitions from kernel headers.

CC Alexander Graf <[email protected]>

---
Makefile.target | 4 +-
configure | 151 ++++++---------------------------------------- target-s390x/cpu.h | 10 ---
target-s390x/op_helper.c | 1 +

4 files changed, 21 insertions(+), 145 deletions(-)
Makefile.target +1 -1
index 5c22df8..be9c0e8 100644
@@ -14,7 +14,7 @@ endif
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
-QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H
+QEMU_CFLAGS+= -I.. -I../linux-headers -I$(TARGET_PATH) -DNEED_CPU_H
 

include $(SRC_PATH)/Makefile.objs

Makefile.target +0 -0
@@ -37,8 +37,6 @@ ifndef CONFIG_HAIKU

LIBS+=-lm
endif

-kvm.o kvm-all.o vhost.o vhost_net.o kvmclock.o:
QEMU_CFLAGS+=$(KVM_CFLAGS)
-
config-target.h: config-target.h-timestamp
config-target.h-timestamp: config-target.mak

configure +0 -0
index d38b952..0e1dc46 100755
@@ -113,8 +113,7 @@ curl=""

curses=""
docs=""
fdt=""

configure +1 -2
-kvm=""
-kvm_para=""
+kvm="yes"
Quoted 1 line

nptl=""

Are you planning to add kvm support for all platforms which don't support it today? If not, kvm="yes" should be restricted to platforms with kvm support.

Otherwise, QEMU builds will fail very early:

ERROR: Host kernel lacks signalfd() support, but KVM depends on it when the IO thread is disabled.

Of course, users of those non-kvm platforms can set --disable-kvm, but I don't think that is the correct solution.

Even with kvm disabled, builds still fail for non-kvm systems:

In file included from /qemu/hw/kvmclock.c:21:
/qemu/linux-headers/linux/kvm_para.h:26:26: warning: asm/kvm_para.h:
No such file or directory

Cheers,

Stefan

#16 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Quoted 44 lines · Stefan Weil

Am 08.06.2011 16:10, schrieb Jan Kiszka:

Quoted 43 lines

This helps reducing our build-time checks for feature support in the available Linux kernel headers. And it helps users that do not have sufficiently recent headers installed on their build machine.

Consequently, the patch removes and build-time checks for kvm and vhost in configure, the --kerneldir switch, and KVM_CFLAGS. Kernel headers are supposed to be provided by QEMU only.

s390 needs some extra love as it carries redefinitions from kernel headers.

CC Alexander Graf <[email protected]>

---
Makefile.target | 4 +-
configure | 151 ++++++---------------------------------------- target-s390x/cpu.h | 10 ---
target-s390x/op_helper.c | 1 +

4 files changed, 21 insertions(+), 145 deletions(-)
Makefile.target +1 -1
index 5c22df8..be9c0e8 100644
@@ -14,7 +14,7 @@ endif
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
-QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H
+QEMU_CFLAGS+= -I.. -I../linux-headers -I$(TARGET_PATH) -DNEED_CPU_H
 

include $(SRC_PATH)/Makefile.objs

Makefile.target +0 -0
@@ -37,8 +37,6 @@ ifndef CONFIG_HAIKU

LIBS+=-lm
endif

-kvm.o kvm-all.o vhost.o vhost_net.o kvmclock.o:
QEMU_CFLAGS+=$(KVM_CFLAGS)
-
config-target.h: config-target.h-timestamp
config-target.h-timestamp: config-target.mak

Quoted 15 lines
Quoted 11 lines
configure +0 -0
index d38b952..0e1dc46 100755
@@ -113,8 +113,7 @@ curl=""

curses=""
docs=""
fdt=""

configure +1 -2
-kvm=""
-kvm_para=""
+kvm="yes"
Quoted 1 line

nptl=""

Are you planning to add kvm support for all platforms which don't support it today?

That would mean replacing all their kernels with Linux. Will take a bit longer.

I simply overshot with my cleanups:

configure +4 -2
index 3286e33..e6847c4 100755
@@ -113,7 +113,7 @@ curl=""
 curses=""
 docs=""
 fdt=""
-kvm="yes"
+kvm=""
 nptl=""
 sdl=""
 vnc="yes"
@@ -129,7 +129,7 @@ xen=""
 xen_ctrl_version=""
 linux_aio=""
 attr=""
-vhost_net="yes"
+vhost_net=""
 xfs=""
 
 gprof="no"
@@ -457,6 +457,8 @@ Haiku)
   linux="yes"
   linux_user="yes"
   usb="linux"
+  kvm="yes"
+  vhost_net="yes"
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi

Will post this as a patch tomorrow.

Quoted 7 lines

If not, kvm="yes" should be restricted to platforms with kvm support.

Otherwise, QEMU builds will fail very early:

ERROR: Host kernel lacks signalfd() support, but KVM depends on it when the IO thread is disabled.

Quoted 8 lines

Of course, users of those non-kvm platforms can set --disable-kvm, but I don't think that is the correct solution.

Even with kvm disabled, builds still fail for non-kvm systems:

In file included from /qemu/hw/kvmclock.c:21:
/qemu/linux-headers/linux/kvm_para.h:26:26: warning: asm/kvm_para.h: No
such file or directory

That indicates symlink emulation under Windows does not support directories. Can you confirm this (check what <builddir>/linux-headers/asm became)? Then we would have to link all files in the arch header dir individually.

Jan

#17 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Am 22.06.2011 23:37, schrieb Jan Kiszka:

Quoted 17 lines · Stefan Weil
Quoted 7 lines

If not, kvm="yes" should be restricted to platforms with kvm support.

Otherwise, QEMU builds will fail very early:

ERROR: Host kernel lacks signalfd() support, but KVM depends on it when the IO thread is disabled.

Quoted 8 lines

Of course, users of those non-kvm platforms can set --disable-kvm, but I don't think that is the correct solution.

Even with kvm disabled, builds still fail for non-kvm systems:

In file included from /qemu/hw/kvmclock.c:21:
/qemu/linux-headers/linux/kvm_para.h:26:26: warning: asm/kvm_para.h: No such file or directory

Quoted 6 lines

That indicates symlink emulation under Windows does not support directories. Can you confirm this (check what <builddir>/linux-headers/asm became)? Then we would have to link all files in the arch header dir individually.

Jan

Even when cross compiling for w32 (on a linux host), kvmclock.c does not compile:

$ LANG=C make CFLAGS=-g
  CC    i386-softmmu/kvmclock.o
In file included from /home/stefan/src/qemu/savannah/qemu/hw/kvmclock.c:20:
/home/stefan/src/qemu/savannah/qemu/linux-headers/linux/kvm.h:10:25: warning: linux/types.h: No such file or directory
/home/stefan/src/qemu/savannah/qemu/linux-headers/linux/kvm.h:12:25: warning: linux/ioctl.h: No such file or directory
In file included from /home/stefan/src/qemu/savannah/qemu/linux-headers/linux/kvm.h:13,
                 from /home/stefan/src/qemu/savannah/qemu/hw/kvmclock.c:20:
../linux-headers/asm/kvm.h:32: error: expected specifier-qualifier-list before '__u32'
../linux-headers/asm/kvm.h:41: error: expected specifier-qualifier-list before '__u8'
../linux-headers/asm/kvm.h:61: error: expected specifier-qualifier-list before '__u64'

Is kvmclock.c really needed for non-kvm platforms? Or does it simply need a obj-i386-$(CONFIG_KVM) in Makefile.target?

Stefan

#18 lore raw

Re: [PATCH 03/12] Switch build system to accompanied kernel headers

Quoted 45 lines · Stefan Weil

Am 22.06.2011 23:37, schrieb Jan Kiszka:

Quoted 17 lines · Stefan Weil
Quoted 7 lines

If not, kvm="yes" should be restricted to platforms with kvm support.

Otherwise, QEMU builds will fail very early:

ERROR: Host kernel lacks signalfd() support, but KVM depends on it when the IO thread is disabled.

Quoted 8 lines

Of course, users of those non-kvm platforms can set --disable-kvm, but I don't think that is the correct solution.

Even with kvm disabled, builds still fail for non-kvm systems:

In file included from /qemu/hw/kvmclock.c:21:
/qemu/linux-headers/linux/kvm_para.h:26:26: warning: asm/kvm_para.h: No such file or directory

Quoted 6 lines

That indicates symlink emulation under Windows does not support directories. Can you confirm this (check what <builddir>/linux-headers/asm became)? Then we would have to link all files in the arch header dir individually.

Jan

Even when cross compiling for w32 (on a linux host), kvmclock.c does not compile:

$ LANG=C make CFLAGS=-g
  CC    i386-softmmu/kvmclock.o
In file included from /home/stefan/src/qemu/savannah/qemu/hw/kvmclock.c:20:
/home/stefan/src/qemu/savannah/qemu/linux-headers/linux/kvm.h:10:25:
warning: linux/types.h: No such file or directory
/home/stefan/src/qemu/savannah/qemu/linux-headers/linux/kvm.h:12:25:
warning: linux/ioctl.h: No such file or directory
In file included from
/home/stefan/src/qemu/savannah/qemu/linux-headers/linux/kvm.h:13,
                 from /home/stefan/src/qemu/savannah/qemu/hw/kvmclock.c:20:
../linux-headers/asm/kvm.h:32: error: expected specifier-qualifier-list
before '__u32'
../linux-headers/asm/kvm.h:41: error: expected specifier-qualifier-list
before '__u8'
../linux-headers/asm/kvm.h:61: error: expected specifier-qualifier-list
before '__u64'
Quoted 2 lines

Is kvmclock.c really needed for non-kvm platforms? Or does it simply need a obj-i386-$(CONFIG_KVM) in Makefile.target?

It's not needed, specifically as we do not (yet) emulate the pv interfaces of KVM. But changing the makefile won't suffice, we also need to stub out kvmclock_create.

Right now I'm fighting to get a mingw build that far at all. The version I have here (gcc 4.6 based) does not include liberity (but apparently links fine without as well). Then there are tons of other errors and warnings. Do you have some tree with recent fixes?

I would suggest you to set up a buildbot for the Windows platform. That should help to get notifications about breakages a bit earlier. And that may help to keep their number down (this broken window thing: once the first few got damaged, no one will bother about smashing another one.

Jan

#19 lore raw

PATCH 1/1 Fix fallouts from Linux header inclusion

From: Jan Kiszka <[email protected]>

This is an all-in-one fix for the smaller and bigger mistakes of the build system changes for accompanied Linux headers:
- only enable KVM and vhost on Linux hosts
- fix powerpc asm header symlink
- do not use Linux headers on non-Linux hosts
- fix kvmclock for !CONFIG_KVM
- fix s390 build on non-Linux hosts

---

Let me know if separate patches are preferred for this.

 Makefile.target          |    8 ++++++--
 configure                |   34 +++++++++++++++++++---------------
 hw/kvmclock.h            |   10 ++++++++++
 target-s390x/op_helper.c |    6 +++++-
 4 files changed, 40 insertions(+), 18 deletions(-)
Makefile.target +6 -2
index 03d3646..d3971a6 100644
@@ -14,7 +14,10 @@ endif
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
-QEMU_CFLAGS+= -I.. -I../linux-headers -I$(TARGET_PATH) -DNEED_CPU_H
+ifdef CONFIG_LINUX
+QEMU_CFLAGS += -I../linux-headers
+endif
+QEMU_CFLAGS += -I.. -I$(TARGET_PATH) -DNEED_CPU_H
 
 include $(SRC_PATH)/Makefile.objs
 
@@ -234,7 +237,8 @@ obj-i386-y += cirrus_vga.o sga.o apic.o ioapic.o piix_pci.o
 obj-i386-y += vmport.o
 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o
 obj-i386-y += debugcon.o multiboot.o
-obj-i386-y += pc_piix.o kvmclock.o
+obj-i386-y += pc_piix.o
+obj-i386-$(CONFIG_KVM) += kvmclock.o
 obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o
 
 # shared objects
configure +19 -15
index 856b41e..e523976 100755
@@ -113,7 +113,7 @@ curl=""
 curses=""
 docs=""
 fdt=""
-kvm="yes"
+kvm=""
 nptl=""
 sdl=""
 vnc="yes"
@@ -129,7 +129,7 @@ xen=""
 xen_ctrl_version=""
 linux_aio=""
 attr=""
-vhost_net="yes"
+vhost_net=""
 xfs=""
 
 gprof="no"
@@ -457,6 +457,8 @@ Haiku)
   linux="yes"
   linux_user="yes"
   usb="linux"
+  kvm="yes"
+  vhost_net="yes"
   if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     audio_possible_drivers="$audio_possible_drivers fmod"
   fi
@@ -3444,19 +3446,21 @@ if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
 fi
 
 # use included Linux headers
-includes="-I\$(SRC_PATH)/linux-headers $includes"
-mkdir -p linux-headers
-case "$cpu" in
-i386|x86_64)
-  symlink $source_path/linux-headers/asm-x86 linux-headers/asm
-  ;;
-ppcemb|ppc|ppc64)
-  symlink $source_path/linux-headers/asm-x86 linux-headers/asm
-  ;;
-s390x)
-  symlink $source_path/linux-headers/asm-s390 linux-headers/asm
-  ;;
-esac
+if test "$linux" = "yes" ; then
+  includes="-I\$(SRC_PATH)/linux-headers $includes"
+  mkdir -p linux-headers
+  case "$cpu" in
+  i386|x86_64)
+    symlink $source_path/linux-headers/asm-x86 linux-headers/asm
+    ;;
+  ppcemb|ppc|ppc64)
+    symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
+    ;;
+  s390x)
+    symlink $source_path/linux-headers/asm-s390 linux-headers/asm
+    ;;
+  esac
+fi
 
 echo "LDFLAGS+=$ldflags" >> $config_target_mak
 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
hw/kvmclock.h +10 -0
index 7a83cbe..252ea13 100644
@@ -11,4 +11,14 @@
  *
  */
 
+#ifdef CONFIG_KVM
+
 void kvmclock_create(void);
+
+#else /* CONFIG_KVM */
+
+static inline void kvmclock_create(void)
+{
+}
+
+#endif /* !CONFIG_KVM */
target-s390x/op_helper.c +5 -1
index 9429698..6a3c1f6 100644
@@ -23,8 +23,10 @@
 #include "helpers.h"
 #include <string.h>
 #include "kvm.h"
-#include <linux/kvm.h>
 #include "qemu-timer.h"
+#ifdef CONFIG_KVM
+#include <linux/kvm.h>
+#endif
 
 /*****************************************************************************/
 /* Softmmu support */
@@ -2332,7 +2334,9 @@ static void program_interrupt(CPUState *env, uint32_t code, int ilc)
     qemu_log("program interrupt at %#" PRIx64 "\n", env->psw.addr);
 
     if (kvm_enabled()) {
+#ifdef CONFIG_KVM
         kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
+#endif
     } else {
         env->int_pgm_code = code;
         env->int_pgm_ilc = ilc;
Tested-by on v1 1/1
#20 lore raw

Re: [Qemu-devel] [PATCH] Fix fallouts from Linux header inclusion

Am 23.06.2011 um 10:05 schrieb Jan Kiszka:

Quoted 11 lines

From: Jan Kiszka <[email protected]>

This is an all-in-one fix for the smaller and bigger mistakes of the build system changes for accompanied Linux headers:
- only enable KVM and vhost on Linux hosts
- fix powerpc asm header symlink
- do not use Linux headers on non-Linux hosts
- fix kvmclock for !CONFIG_KVM
- fix s390 build on non-Linux hosts

Builds okay on Darwin/ppc64.

Andreas

Quoted 152 lines

---

Let me know if separate patches are preferred for this.

Makefile.target          |    8 ++++++--
configure                |   34 +++++++++++++++++++---------------
hw/kvmclock.h            |   10 ++++++++++
target-s390x/op_helper.c |    6 +++++-
4 files changed, 40 insertions(+), 18 deletions(-)
Makefile.target +4 -1
index 03d3646..d3971a6 100644
@@ -14,7 +14,10 @@ endif
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
-QEMU_CFLAGS+= -I.. -I../linux-headers -I$(TARGET_PATH) -DNEED_CPU_H
+ifdef CONFIG_LINUX
+QEMU_CFLAGS += -I../linux-headers
+endif
+QEMU_CFLAGS += -I.. -I$(TARGET_PATH) -DNEED_CPU_H
 

include $(SRC_PATH)/Makefile.objs

Makefile.target +0 -0
@@ -234,7 +237,8 @@ obj-i386-y += cirrus_vga.o sga.o apic.o ioapic.o  

piix_pci.o
obj-i386-y += vmport.o
obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o

Makefile.target +2 -1
-obj-i386-y += pc_piix.o kvmclock.o
+obj-i386-y += pc_piix.o
+obj-i386-$(CONFIG_KVM) += kvmclock.o

obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o

# shared objects
configure +0 -0
index 856b41e..e523976 100755
@@ -113,7 +113,7 @@ curl=""

curses=""
docs=""
fdt=""

configure +1 -1
-kvm="yes"
+kvm=""

nptl=""
sdl=""
vnc="yes"

configure +0 -0
@@ -129,7 +129,7 @@ xen=""

xen_ctrl_version=""
linux_aio=""
attr=""

configure +1 -1
-vhost_net="yes"
+vhost_net=""

xfs=""

gprof="no"

configure +2 -0
@@ -457,6 +457,8 @@ Haiku)
  linux="yes"
  linux_user="yes"
  usb="linux"
+  kvm="yes"
+  vhost_net="yes"
  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
    audio_possible_drivers="$audio_possible_drivers fmod"
  fi
@@ -3444,19 +3446,21 @@ if test "$target_linux_user" = "yes" -o  

"$target_bsd_user" = "yes" ; then
fi

# use included Linux headers
configure +15 -13
-includes="-I\$(SRC_PATH)/linux-headers $includes"
-mkdir -p linux-headers
-case "$cpu" in
-i386|x86_64)
-  symlink $source_path/linux-headers/asm-x86 linux-headers/asm
-  ;;
-ppcemb|ppc|ppc64)
-  symlink $source_path/linux-headers/asm-x86 linux-headers/asm
-  ;;
-s390x)
-  symlink $source_path/linux-headers/asm-s390 linux-headers/asm
-  ;;
-esac
+if test "$linux" = "yes" ; then
+  includes="-I\$(SRC_PATH)/linux-headers $includes"
+  mkdir -p linux-headers
+  case "$cpu" in
+  i386|x86_64)
+    symlink $source_path/linux-headers/asm-x86 linux-headers/asm
+    ;;
+  ppcemb|ppc|ppc64)
+    symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
+    ;;
+  s390x)
+    symlink $source_path/linux-headers/asm-s390 linux-headers/asm
+    ;;
+  esac
+fi

echo "LDFLAGS+=$ldflags" >> $config_target_mak
echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak

hw/kvmclock.h +10 -0
index 7a83cbe..252ea13 100644
@@ -11,4 +11,14 @@
 *
 */
 
+#ifdef CONFIG_KVM
+
 void kvmclock_create(void);
+
+#else /* CONFIG_KVM */
+
+static inline void kvmclock_create(void)
+{
+}
+
+#endif /* !CONFIG_KVM */
target-s390x/op_helper.c +3 -1
index 9429698..6a3c1f6 100644
@@ -23,8 +23,10 @@
 #include "helpers.h"
 #include <string.h>
 #include "kvm.h"
-#include <linux/kvm.h>
 #include "qemu-timer.h"
+#ifdef CONFIG_KVM
+#include <linux/kvm.h>
+#endif
 

/ *****************************************************************************/ /* Softmmu support */

target-s390x/op_helper.c +2 -0
@@ -2332,7 +2334,9 @@ static void program_interrupt(CPUState *env,  
 uint32_t code, int ilc)
    qemu_log("program interrupt at %#" PRIx64 "\n", env->psw.addr);
 
    if (kvm_enabled()) {
+#ifdef CONFIG_KVM
        kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
+#endif
    } else {
        env->int_pgm_code = code;
        env->int_pgm_ilc = ilc;
Tested-by on v1 1/1
#21 lore raw

Re: [PATCH] Fix fallouts from Linux header inclusion

In reply to Jan Kiszka

Am 23.06.2011 10:05, schrieb Jan Kiszka:

Quoted 10 lines

From: Jan Kiszka <[email protected]>

This is an all-in-one fix for the smaller and bigger mistakes of the build system changes for accompanied Linux headers:
- only enable KVM and vhost on Linux hosts
- fix powerpc asm header symlink
- do not use Linux headers on non-Linux hosts
- fix kvmclock for !CONFIG_KVM
- fix s390 build on non-Linux hosts

Quoted 2 lines

The patch fixes the kvm related build errors for mingw32.

Stefan

Applied
#22 lore raw

Re: [Qemu-devel] [PATCH] Fix fallouts from Linux header inclusion

In reply to Jan Kiszka

Thanks, applied.

Quoted 160 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

This is an all-in-one fix for the smaller and bigger mistakes of the build system changes for accompanied Linux headers:
 - only enable KVM and vhost on Linux hosts
 - fix powerpc asm header symlink
 - do not use Linux headers on non-Linux hosts
 - fix kvmclock for !CONFIG_KVM
 - fix s390 build on non-Linux hosts

---

Let me know if separate patches are preferred for this.

 Makefile.target          |    8 ++++++--
 configure                |   34 +++++++++++++++++++--------------- hw/kvmclock.h            |   10 ++++++++++ target-s390x/op_helper.c |    6 +++++-

 4 files changed, 40 insertions(+), 18 deletions(-)
Makefile.target +4 -1
index 03d3646..d3971a6 100644
@@ -14,7 +14,10 @@ endif
 
  TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
  $(call set-vpath, $(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw)
-QEMU_CFLAGS+= -I.. -I../linux-headers -I$(TARGET_PATH) -DNEED_CPU_H
+ifdef CONFIG_LINUX
+QEMU_CFLAGS += -I../linux-headers
+endif
+QEMU_CFLAGS += -I.. -I$(TARGET_PATH) -DNEED_CPU_H
 

 include $(SRC_PATH)/Makefile.objs

Makefile.target +0 -0
@@ -234,7 +237,8 @@ obj-i386-y += cirrus_vga.o sga.o apic.o ioapic.o piix_pci.o

 obj-i386-y += vmport.o
 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o

Makefile.target +2 -1
-obj-i386-y += pc_piix.o kvmclock.o
+obj-i386-y += pc_piix.o
+obj-i386-$(CONFIG_KVM) += kvmclock.o

 obj-i386-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o

 # shared objects
configure +0 -0
index 856b41e..e523976 100755
@@ -113,7 +113,7 @@ curl=""

 curses=""
 docs=""
 fdt=""

configure +1 -1
-kvm="yes"
+kvm=""

 nptl=""
 sdl=""
 vnc="yes"

configure +0 -0
@@ -129,7 +129,7 @@ xen=""

 xen_ctrl_version=""
 linux_aio=""
 attr=""

configure +1 -1
-vhost_net="yes"
+vhost_net=""

 xfs=""

 gprof="no"

configure +0 -0
@@ -457,6 +457,8 @@ Haiku)

  linux="yes"
  linux_user="yes"
  usb="linux"
+  kvm="yes"
+  vhost_net="yes"
  if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then audio_possible_drivers="$audio_possible_drivers fmod" fi

configure +0 -0
@@ -3444,19 +3446,21 @@ if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then

 fi

 # use included Linux headers
configure +15 -13
-includes="-I\$(SRC_PATH)/linux-headers $includes"
-mkdir -p linux-headers
-case "$cpu" in
-i386|x86_64)
-  symlink $source_path/linux-headers/asm-x86 linux-headers/asm
-  ;;
-ppcemb|ppc|ppc64)
-  symlink $source_path/linux-headers/asm-x86 linux-headers/asm
-  ;;
-s390x)
-  symlink $source_path/linux-headers/asm-s390 linux-headers/asm
-  ;;
-esac
+if test "$linux" = "yes" ; then
+  includes="-I\$(SRC_PATH)/linux-headers $includes"
+  mkdir -p linux-headers
+  case "$cpu" in
+  i386|x86_64)
+    symlink $source_path/linux-headers/asm-x86 linux-headers/asm
+    ;;
+  ppcemb|ppc|ppc64)
+    symlink $source_path/linux-headers/asm-powerpc linux-headers/asm
+    ;;
+  s390x)
+    symlink $source_path/linux-headers/asm-s390 linux-headers/asm
+    ;;
+  esac
+fi

 echo "LDFLAGS+=$ldflags" >> $config_target_mak echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak

hw/kvmclock.h +10 -0
index 7a83cbe..252ea13 100644
@@ -11,4 +11,14 @@
  *
  */
 
+#ifdef CONFIG_KVM
+
  void kvmclock_create(void);
+
+#else /* CONFIG_KVM */
+
+static inline void kvmclock_create(void)
+{
+}
+
+#endif /* !CONFIG_KVM */
target-s390x/op_helper.c +5 -1
index 9429698..6a3c1f6 100644
@@ -23,8 +23,10 @@
  #include "helpers.h"
  #include <string.h>
  #include "kvm.h"
-#include <linux/kvm.h>
  #include "qemu-timer.h"
+#ifdef CONFIG_KVM
+#include <linux/kvm.h>
+#endif
 
  /*****************************************************************************/
  /* Softmmu support */
@@ -2332,7 +2334,9 @@ static void program_interrupt(CPUState *env, uint32_t code, int ilc)
     qemu_log("program interrupt at %#" PRIx64 "\n", env->psw.addr);
 
     if (kvm_enabled()) {
+#ifdef CONFIG_KVM
         kvm_s390_interrupt(env, KVM_S390_PROGRAM_INT, code);
+#endif
     } else {
         env->int_pgm_code = code;
         env->int_pgm_ilc = ilc;
author
#23 lore raw

PATCH 4/12 kvm: Drop CONFIG_KVM_PARA

In reply to Jan Kiszka

The kvm_para.h header is now always available.

---
 configure         |    1 -
 hw/kvmclock.c     |    9 ---------
 target-i386/kvm.c |   26 +-------------------------
 3 files changed, 1 insertions(+), 35 deletions(-)
configure +0 -1
index 0e1dc46..ed54db9 100755
@@ -3218,7 +3218,6 @@ case "$target_arch2" in
       \( "$target_arch2" = "x86_64" -a "$cpu" = "i386"   \) -o \
       \( "$target_arch2" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
       echo "CONFIG_KVM=y" >> $config_target_mak
-      echo "CONFIG_KVM_PARA=y" >> $config_target_mak
       if test $vhost_net = "yes" ; then
         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
       fi
hw/kvmclock.c +0 -9
index 004c4ad..692ad18 100644
@@ -17,8 +17,6 @@
 #include "kvm.h"
 #include "kvmclock.h"
 
-#if defined(CONFIG_KVM_PARA) && defined(KVM_CAP_ADJUST_CLOCK)
-
 #include <linux/kvm.h>
 #include <linux/kvm_para.h>
 
@@ -120,10 +118,3 @@ static void kvmclock_register_device(void)
 }
 
 device_init(kvmclock_register_device);
-
-#else /* !(CONFIG_KVM_PARA && KVM_CAP_ADJUST_CLOCK) */
-
-void kvmclock_create(void)
-{
-}
-#endif /* !(CONFIG_KVM_PARA && KVM_CAP_ADJUST_CLOCK) */
target-i386/kvm.c +1 -25
index 1ae2d61..0efcf97 100644
@@ -18,6 +18,7 @@
 #include <sys/utsname.h>
 
 #include <linux/kvm.h>
+#include <linux/kvm_para.h>
 
 #include "qemu-common.h"
 #include "sysemu.h"
@@ -29,10 +30,6 @@
 #include "hw/apic.h"
 #include "ioport.h"
 
-#ifdef CONFIG_KVM_PARA
-#include <linux/kvm_para.h>
-#endif
-//
 //#define DEBUG_KVM
 
 #ifdef DEBUG_KVM
@@ -62,9 +59,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 
 static bool has_msr_star;
 static bool has_msr_hsave_pa;
-#if defined(CONFIG_KVM_PARA) && defined(KVM_CAP_ASYNC_PF)
 static bool has_msr_async_pf_en;
-#endif
 static int lm_capable_kernel;
 
 static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
@@ -92,7 +87,6 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
     return cpuid;
 }
 
-#ifdef CONFIG_KVM_PARA
 struct kvm_para_features {
     int cap;
     int feature;
@@ -118,7 +112,6 @@ static int get_para_features(CPUState *env)
 
     return features;
 }
-#endif
 
 
 uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
@@ -128,9 +121,7 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
     int i, max;
     uint32_t ret = 0;
     uint32_t cpuid_1_edx;
-#ifdef CONFIG_KVM_PARA
     int has_kvm_features = 0;
-#endif
 
     max = 1;
     while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {
@@ -140,11 +131,9 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
     for (i = 0; i < cpuid->nent; ++i) {
         if (cpuid->entries[i].function == function &&
             cpuid->entries[i].index == index) {
-#ifdef CONFIG_KVM_PARA
             if (cpuid->entries[i].function == KVM_CPUID_FEATURES) {
                 has_kvm_features = 1;
             }
-#endif
             switch (reg) {
             case R_EAX:
                 ret = cpuid->entries[i].eax;
@@ -177,12 +166,10 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
 
     qemu_free(cpuid);
 
-#ifdef CONFIG_KVM_PARA
     /* fallback for older kernels */
     if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
         ret = get_para_features(env);
     }
-#endif
 
     return ret;
 }
@@ -377,9 +364,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     uint32_t limit, i, j, cpuid_i;
     uint32_t unused;
     struct kvm_cpuid_entry2 *c;
-#ifdef CONFIG_KVM_PARA
     uint32_t signature[3];
-#endif
 
     env->cpuid_features &= kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);
 
@@ -397,7 +382,6 @@ int kvm_arch_init_vcpu(CPUState *env)
 
     cpuid_i = 0;
 
-#ifdef CONFIG_KVM_PARA
     /* Paravirtualization CPUIDs */
     memcpy(signature, "KVMKVMKVM\0\0\0", 12);
     c = &cpuid_data.entries[cpuid_i++];
@@ -418,8 +402,6 @@ int kvm_arch_init_vcpu(CPUState *env)
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
 #endif
 
-#endif
-
     cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
 
     for (i = 0; i <= limit; i++) {
@@ -931,12 +913,10 @@ static int kvm_put_msrs(CPUState *env, int level)
         kvm_msr_entry_set(&msrs[n++], MSR_KVM_SYSTEM_TIME,
                           env->system_time_msr);
         kvm_msr_entry_set(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr);
-#if defined(CONFIG_KVM_PARA) && defined(KVM_CAP_ASYNC_PF)
         if (has_msr_async_pf_en) {
             kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN,
                               env->async_pf_en_msr);
         }
-#endif
     }
 #ifdef KVM_CAP_MCE
     if (env->mcg_cap) {
@@ -1172,11 +1152,9 @@ static int kvm_get_msrs(CPUState *env)
 #endif
     msrs[n++].index = MSR_KVM_SYSTEM_TIME;
     msrs[n++].index = MSR_KVM_WALL_CLOCK;
-#if defined(CONFIG_KVM_PARA) && defined(KVM_CAP_ASYNC_PF)
     if (has_msr_async_pf_en) {
         msrs[n++].index = MSR_KVM_ASYNC_PF_EN;
     }
-#endif
 
 #ifdef KVM_CAP_MCE
     if (env->mcg_cap) {
@@ -1253,11 +1231,9 @@ static int kvm_get_msrs(CPUState *env)
             }
 #endif
             break;
-#if defined(CONFIG_KVM_PARA) && defined(KVM_CAP_ASYNC_PF)
         case MSR_KVM_ASYNC_PF_EN:
             env->async_pf_en_msr = msrs[i].data;
             break;
-#endif
         }
     }
 
Signature · 1 line
1.7.1
author
#24 lore raw

PATCH 5/12 kvm: ppc: Drop CONFIG_KVM_PPC_PVR

In reply to Jan Kiszka

Required header support is now unconditionally available.

CC Alexander Graf <[email protected]>
---
 configure        |    1 -
 target-ppc/kvm.c |    9 ---------
 2 files changed, 0 insertions(+), 10 deletions(-)
configure +0 -1
index ed54db9..0947f98 100755
@@ -3221,7 +3221,6 @@ case "$target_arch2" in
       if test $vhost_net = "yes" ; then
         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
       fi
-      echo "CONFIG_KVM_PPC_PVR=y" >> $config_target_mak
     fi
 esac
 if test "$target_bigendian" = "yes" ; then
target-ppc/kvm.c +0 -9
index e7b1b10..0500e3f 100644
@@ -104,21 +104,12 @@ static int kvm_arch_sync_sregs(CPUState *cenv)
         }
     }
 
-#if !defined(CONFIG_KVM_PPC_PVR)
-    if (1) {
-        fprintf(stderr, "kvm error: missing PVR setting capability\n");
-        return -ENOSYS;
-    }
-#endif
-
     ret = kvm_vcpu_ioctl(cenv, KVM_GET_SREGS, &sregs);
     if (ret) {
         return ret;
     }
 
-#ifdef CONFIG_KVM_PPC_PVR
     sregs.pvr = cenv->spr[SPR_PVR];
-#endif
     return kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs);
 }
 
Signature · 1 line
1.7.1
author
#26 lore raw

PATCH 6/12 kvm: Drop useless zero-initializations

In reply to Jan Kiszka

Backing KVMState is alreay zero-initialized.

---
 kvm-all.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
kvm-all.c +0 -5
index 106eb3a..4a9910a 100644
@@ -764,28 +764,23 @@ int kvm_init(void)
     }
 #endif
 
-    s->vcpu_events = 0;
 #ifdef KVM_CAP_VCPU_EVENTS
     s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
 #endif
 
-    s->robust_singlestep = 0;
 #ifdef KVM_CAP_X86_ROBUST_SINGLESTEP
     s->robust_singlestep =
         kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
 #endif
 
-    s->debugregs = 0;
 #ifdef KVM_CAP_DEBUGREGS
     s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
 #endif
 
-    s->xsave = 0;
 #ifdef KVM_CAP_XSAVE
     s->xsave = kvm_check_extension(s, KVM_CAP_XSAVE);
 #endif
 
-    s->xcrs = 0;
 #ifdef KVM_CAP_XCRS
     s->xcrs = kvm_check_extension(s, KVM_CAP_XCRS);
 #endif
Signature · 1 line
1.7.1
author
#27 lore raw

PATCH 7/12 kvm: Drop KVM_CAP build dependencies

In reply to Jan Kiszka

No longer needed with accompanied kernel headers. We are only left with build dependencies that are controlled by kvm arch headers.

CC Alexander Graf <[email protected]>
---
 kvm-all.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
kvm-all.c +0 -8
index 4a9910a..cbc2532 100644
@@ -757,21 +757,17 @@ int kvm_init(void)
     s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
 
     s->broken_set_mem_region = 1;
-#ifdef KVM_CAP_JOIN_MEMORY_REGIONS_WORKS
     ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
     if (ret > 0) {
         s->broken_set_mem_region = 0;
     }
-#endif
 
 #ifdef KVM_CAP_VCPU_EVENTS
     s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
 #endif
 
-#ifdef KVM_CAP_X86_ROBUST_SINGLESTEP
     s->robust_singlestep =
         kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
-#endif
 
 #ifdef KVM_CAP_DEBUGREGS
     s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
@@ -850,7 +846,6 @@ static void kvm_handle_io(uint16_t port, void *data, int direction, int size,
     }
 }
 
-#ifdef KVM_CAP_INTERNAL_ERROR_DATA
 static int kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
 {
     fprintf(stderr, "KVM internal error.");
@@ -877,7 +872,6 @@ static int kvm_handle_internal_error(CPUState *env, struct kvm_run *run)
      */
     return -1;
 }
-#endif
 
 void kvm_flush_coalesced_mmio_buffer(void)
 {
@@ -1008,11 +1002,9 @@ int kvm_cpu_exec(CPUState *env)
                     (uint64_t)run->hw.hardware_exit_reason);
             ret = -1;
             break;
-#ifdef KVM_CAP_INTERNAL_ERROR_DATA
         case KVM_EXIT_INTERNAL_ERROR:
             ret = kvm_handle_internal_error(env, run);
             break;
-#endif
         default:
             DPRINTF("kvm_arch_handle_exit\n");
             ret = kvm_arch_handle_exit(env, run);
Signature · 1 line
1.7.1
#28 lore raw

Re: [PATCH 07/12] kvm: Drop KVM_CAP build dependencies

Quoted 2 lines · Jan Kiszka

No longer needed with accompanied kernel headers. We are only left with build dependencies that are controlled by kvm arch headers.

This should completely rule out all CAPs right? IIRC, all CAPs are defined in generic code, so we don't get number overlaps.

Quoted 13 lines
CC Alexander Graf <[email protected]>

---
kvm-all.c | 8 --------

1 files changed, 0 insertions(+), 8 deletions(-)
kvm-all.c +0 -0
index 4a9910a..cbc2532 100644
@@ -757,21 +757,17 @@ int kvm_init(void)
    s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);

kvm-all.c int kvm_init(void) · line 765

Quoted 10 lines
kvm-all.c +0 -2
 
    s->broken_set_mem_region = 1;
-#ifdef KVM_CAP_JOIN_MEMORY_REGIONS_WORKS
    ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
    if (ret > 0) {
        s->broken_set_mem_region = 0;
    }
-#endif
 
 #ifdef KVM_CAP_VCPU_EVENTS

... which leaves the question why this one is still here :).

Alex

author
#29 lore raw

Re: [PATCH 07/12] kvm: Drop KVM_CAP build dependencies

Quoted 7 lines · Alexander Graf
Quoted 2 lines · Jan Kiszka

No longer needed with accompanied kernel headers. We are only left with build dependencies that are controlled by kvm arch headers.

This should completely rule out all CAPs right? IIRC, all CAPs are defined in generic code, so we don't get number overlaps.

"We are only left with build dependencies that are controlled by kvm arch headers." E.g. KVM_CAP_VCPU_EVENTS.

Quoted 23 lines
Quoted 23 lines
CC Alexander Graf <[email protected]>

---
kvm-all.c | 8 --------

1 files changed, 0 insertions(+), 8 deletions(-)
kvm-all.c +0 -2
index 4a9910a..cbc2532 100644
@@ -757,21 +757,17 @@ int kvm_init(void)
    s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
 
    s->broken_set_mem_region = 1;
-#ifdef KVM_CAP_JOIN_MEMORY_REGIONS_WORKS
    ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
    if (ret > 0) {
        s->broken_set_mem_region = 0;
    }
-#endif
 
Quoted 3 lines

kvm-all.c int kvm_init(void) · line 765

Quoted 1 line
kvm-all.c +0 -0
 #ifdef KVM_CAP_VCPU_EVENTS

... which leaves the question why this one is still here :).

See above (does PPC support it?).

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#30 lore raw

Re: [PATCH 07/12] kvm: Drop KVM_CAP build dependencies

Quoted 35 lines · Jan Kiszka
Quoted 7 lines · Alexander Graf
Quoted 2 lines · Jan Kiszka

No longer needed with accompanied kernel headers. We are only left with build dependencies that are controlled by kvm arch headers.

This should completely rule out all CAPs right? IIRC, all CAPs are defined in generic code, so we don't get number overlaps.

"We are only left with build dependencies that are controlled by kvm arch headers." E.g. KVM_CAP_VCPU_EVENTS.

Quoted 23 lines
Quoted 23 lines
CC Alexander Graf <[email protected]>

---
kvm-all.c | 8 --------

1 files changed, 0 insertions(+), 8 deletions(-)
kvm-all.c +0 -2
index 4a9910a..cbc2532 100644
@@ -757,21 +757,17 @@ int kvm_init(void)
   s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
 
   s->broken_set_mem_region = 1;
-#ifdef KVM_CAP_JOIN_MEMORY_REGIONS_WORKS
   ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
   if (ret > 0) {
       s->broken_set_mem_region = 0;
   }
-#endif
 
Quoted 5 lines
Quoted 3 lines

kvm-all.c int kvm_init(void) · line 765

Quoted 1 line
kvm-all.c +0 -0
 #ifdef KVM_CAP_VCPU_EVENTS

... which leaves the question why this one is still here :).

See above (does PPC support it?).

Well, regardless of support, the #ifdef shouldn't be required, right?

include/linux/kvm.h:518:#define KVM_CAP_VCPU_EVENTS 41

... as long as there's a runtime check :)

Alex

author
#31 lore raw

Re: [PATCH 07/12] kvm: Drop KVM_CAP build dependencies

Quoted 42 lines · Alexander Graf
Quoted 39 lines · Jan Kiszka
Quoted 7 lines · Alexander Graf
Quoted 2 lines · Jan Kiszka

No longer needed with accompanied kernel headers. We are only left with build dependencies that are controlled by kvm arch headers.

This should completely rule out all CAPs right? IIRC, all CAPs are defined in generic code, so we don't get number overlaps.

"We are only left with build dependencies that are controlled by kvm arch headers." E.g. KVM_CAP_VCPU_EVENTS.

Quoted 26 lines
Quoted 14 lines
CC Alexander Graf <[email protected]>

---
kvm-all.c | 8 --------

1 files changed, 0 insertions(+), 8 deletions(-)
kvm-all.c +0 -0
index 4a9910a..cbc2532 100644
@@ -757,21 +757,17 @@ int kvm_init(void)
   s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);

kvm-all.c int kvm_init(void) · line 765

Quoted 10 lines
kvm-all.c +0 -2
 
   s->broken_set_mem_region = 1;
-#ifdef KVM_CAP_JOIN_MEMORY_REGIONS_WORKS
   ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
   if (ret > 0) {
       s->broken_set_mem_region = 0;
   }
-#endif
 
 #ifdef KVM_CAP_VCPU_EVENTS

... which leaves the question why this one is still here :).

Quoted 7 lines
Quoted 1 line

See above (does PPC support it?).

Well, regardless of support, the #ifdef shouldn't be required, right?

include/linux/kvm.h:518:#define KVM_CAP_VCPU_EVENTS 41

... as long as there's a runtime check :)

Are all types and dependent constants available? Maybe it is the case here, but you cannot generally assume this if a CAP is per-arch.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#32 lore raw

Re: [PATCH 07/12] kvm: Drop KVM_CAP build dependencies

Quoted 45 lines · Jan Kiszka
Quoted 44 lines · Alexander Graf
Quoted 40 lines · Jan Kiszka
Quoted 7 lines · Alexander Graf
Quoted 2 lines · Jan Kiszka

No longer needed with accompanied kernel headers. We are only left with build dependencies that are controlled by kvm arch headers.

This should completely rule out all CAPs right? IIRC, all CAPs are defined in generic code, so we don't get number overlaps.

"We are only left with build dependencies that are controlled by kvm arch headers." E.g. KVM_CAP_VCPU_EVENTS.

Quoted 23 lines
Quoted 23 lines
CC Alexander Graf <[email protected]>

---
kvm-all.c | 8 --------

1 files changed, 0 insertions(+), 8 deletions(-)
kvm-all.c +0 -2
index 4a9910a..cbc2532 100644
@@ -757,21 +757,17 @@ int kvm_init(void)
  s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
 
  s->broken_set_mem_region = 1;
-#ifdef KVM_CAP_JOIN_MEMORY_REGIONS_WORKS
  ret = kvm_check_extension(s, KVM_CAP_JOIN_MEMORY_REGIONS_WORKS);
  if (ret > 0) {
      s->broken_set_mem_region = 0;
  }
-#endif
 
Quoted 3 lines

kvm-all.c int kvm_init(void) · line 765

Quoted 1 line
kvm-all.c +0 -0
 #ifdef KVM_CAP_VCPU_EVENTS

... which leaves the question why this one is still here :).

See above (does PPC support it?).

Quoted 8 lines
Quoted 5 lines

Well, regardless of support, the #ifdef shouldn't be required, right?

include/linux/kvm.h:518:#define KVM_CAP_VCPU_EVENTS 41

... as long as there's a runtime check :)

Are all types and dependent constants available? Maybe it is the case here, but you cannot generally assume this if a CAP is per-arch.

Ah, I see what you mean. Maybe it'd be easier to use __KVM_HAVE_VCPU_EVENTS instead of the implicitly defined CAP? But then again, once all the version CAP #ifdefs are gone, the only ones left are the ones for arch features, so I guess your approach is valid :)

Alex

author
#33 lore raw

PATCH 8/12 kvm: x86: Drop KVM_CAP build dependencies

In reply to Jan Kiszka

No longer needed with accompanied kernel headers.

---
 target-i386/kvm.c |   67 ++--------------------------------------------------
 1 files changed, 3 insertions(+), 64 deletions(-)
target-i386/kvm.c +3 -64
index 0efcf97..1c2d32c 100644
@@ -94,9 +94,7 @@ struct kvm_para_features {
     { KVM_CAP_CLOCKSOURCE, KVM_FEATURE_CLOCKSOURCE },
     { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
     { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
-#ifdef KVM_CAP_ASYNC_PF
     { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
-#endif
     { -1, -1 }
 };
 
@@ -193,7 +191,6 @@ static void kvm_unpoison_all(void *param)
     }
 }
 
-#ifdef KVM_CAP_MCE
 static void kvm_hwpoison_page_add(ram_addr_t ram_addr)
 {
     HWPoisonPage *page;
@@ -239,7 +236,6 @@ static void kvm_mce_inject(CPUState *env, target_phys_addr_t paddr, int code)
                        cpu_x86_support_mca_broadcast(env) ?
                        MCE_INJECT_BROADCAST : 0);
 }
-#endif /* KVM_CAP_MCE */
 
 static void hardware_memory_error(void)
 {
@@ -249,7 +245,6 @@ static void hardware_memory_error(void)
 
 int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr)
 {
-#ifdef KVM_CAP_MCE
     ram_addr_t ram_addr;
     target_phys_addr_t paddr;
 
@@ -269,9 +264,7 @@ int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr)
         }
         kvm_hwpoison_page_add(ram_addr);
         kvm_mce_inject(env, paddr, code);
-    } else
-#endif /* KVM_CAP_MCE */
-    {
+    } else {
         if (code == BUS_MCEERR_AO) {
             return 0;
         } else if (code == BUS_MCEERR_AR) {
@@ -285,7 +278,6 @@ int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr)
 
 int kvm_arch_on_sigbus(int code, void *addr)
 {
-#ifdef KVM_CAP_MCE
     if ((first_cpu->mcg_cap & MCG_SER_P) && addr && code == BUS_MCEERR_AO) {
         ram_addr_t ram_addr;
         target_phys_addr_t paddr;
@@ -300,9 +292,7 @@ int kvm_arch_on_sigbus(int code, void *addr)
         }
         kvm_hwpoison_page_add(ram_addr);
         kvm_mce_inject(first_cpu, paddr, code);
-    } else
-#endif /* KVM_CAP_MCE */
-    {
+    } else {
         if (code == BUS_MCEERR_AO) {
             return 0;
         } else if (code == BUS_MCEERR_AR) {
@@ -316,7 +306,6 @@ int kvm_arch_on_sigbus(int code, void *addr)
 
 static int kvm_inject_mce_oldstyle(CPUState *env)
 {
-#ifdef KVM_CAP_MCE
     if (!kvm_has_vcpu_events() && env->exception_injected == EXCP12_MCHK) {
         unsigned int bank, bank_num = env->mcg_cap & 0xff;
         struct kvm_x86_mce mce;
@@ -342,7 +331,6 @@ static int kvm_inject_mce_oldstyle(CPUState *env)
 
         return kvm_vcpu_ioctl(env, KVM_X86_SET_MCE, &mce);
     }
-#endif /* KVM_CAP_MCE */
     return 0;
 }
 
@@ -398,9 +386,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     c->eax = env->cpuid_kvm_features & kvm_arch_get_supported_cpuid(env,
                                                 KVM_CPUID_FEATURES, 0, R_EAX);
 
-#ifdef KVM_CAP_ASYNC_PF
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
-#endif
 
     cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
 
@@ -481,7 +467,6 @@ int kvm_arch_init_vcpu(CPUState *env)
 
     cpuid_data.cpuid.nent = cpuid_i;
 
-#ifdef KVM_CAP_MCE
     if (((env->cpuid_version >> 8)&0xF) >= 6
         && (env->cpuid_features&(CPUID_MCE|CPUID_MCA)) == (CPUID_MCE|CPUID_MCA)
         && kvm_check_extension(env->kvm_state, KVM_CAP_MCE) > 0) {
@@ -508,7 +493,6 @@ int kvm_arch_init_vcpu(CPUState *env)
 
         env->mcg_cap = mcg_cap;
     }
-#endif
 
     qemu_add_vm_change_state_handler(cpu_update_state, env);
 
@@ -600,7 +584,6 @@ int kvm_arch_init(KVMState *s)
      * that case we need to stick with the default, i.e. a 256K maximum BIOS
      * size.
      */
-#ifdef KVM_CAP_SET_IDENTITY_MAP_ADDR
     if (kvm_check_extension(s, KVM_CAP_SET_IDENTITY_MAP_ADDR)) {
         /* Allows up to 16M BIOSes. */
         identity_base = 0xfeffc000;
@@ -610,7 +593,7 @@ int kvm_arch_init(KVMState *s)
             return ret;
         }
     }
-#endif
+
     /* Set TSS base one page after EPT identity map. */
     ret = kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, identity_base + 0x1000);
     if (ret < 0) {
@@ -745,7 +728,6 @@ static int kvm_put_fpu(CPUState *env)
     return kvm_vcpu_ioctl(env, KVM_SET_FPU, &fpu);
 }
 
-#ifdef KVM_CAP_XSAVE
 #define XSAVE_CWD_RIP     2
 #define XSAVE_CWD_RDP     4
 #define XSAVE_MXCSR       6
@@ -753,11 +735,9 @@ static int kvm_put_fpu(CPUState *env)
 #define XSAVE_XMM_SPACE   40
 #define XSAVE_XSTATE_BV   128
 #define XSAVE_YMMH_SPACE  144
-#endif
 
 static int kvm_put_xsave(CPUState *env)
 {
-#ifdef KVM_CAP_XSAVE
     int i, r;
     struct kvm_xsave* xsave;
     uint16_t cwd, swd, twd, fop;
@@ -788,14 +768,10 @@ static int kvm_put_xsave(CPUState *env)
     r = kvm_vcpu_ioctl(env, KVM_SET_XSAVE, xsave);
     qemu_free(xsave);
     return r;
-#else
-    return kvm_put_fpu(env);
-#endif
 }
 
 static int kvm_put_xcrs(CPUState *env)
 {
-#ifdef KVM_CAP_XCRS
     struct kvm_xcrs xcrs;
 
     if (!kvm_has_xcrs()) {
@@ -807,9 +783,6 @@ static int kvm_put_xcrs(CPUState *env)
     xcrs.xcrs[0].xcr = 0;
     xcrs.xcrs[0].value = env->xcr0;
     return kvm_vcpu_ioctl(env, KVM_SET_XCRS, &xcrs);
-#else
-    return 0;
-#endif
 }
 
 static int kvm_put_sregs(CPUState *env)
@@ -918,7 +891,6 @@ static int kvm_put_msrs(CPUState *env, int level)
                               env->async_pf_en_msr);
         }
     }
-#ifdef KVM_CAP_MCE
     if (env->mcg_cap) {
         int i;
 
@@ -928,7 +900,6 @@ static int kvm_put_msrs(CPUState *env, int level)
             kvm_msr_entry_set(&msrs[n++], MSR_MC0_CTL + i, env->mce_banks[i]);
         }
     }
-#endif
 
     msr_data.info.nmsrs = n;
 
@@ -962,7 +933,6 @@ static int kvm_get_fpu(CPUState *env)
 
 static int kvm_get_xsave(CPUState *env)
 {
-#ifdef KVM_CAP_XSAVE
     struct kvm_xsave* xsave;
     int ret, i;
     uint16_t cwd, swd, twd, fop;
@@ -998,14 +968,10 @@ static int kvm_get_xsave(CPUState *env)
             sizeof env->ymmh_regs);
     qemu_free(xsave);
     return 0;
-#else
-    return kvm_get_fpu(env);
-#endif
 }
 
 static int kvm_get_xcrs(CPUState *env)
 {
-#ifdef KVM_CAP_XCRS
     int i, ret;
     struct kvm_xcrs xcrs;
 
@@ -1026,9 +992,6 @@ static int kvm_get_xcrs(CPUState *env)
         }
     }
     return 0;
-#else
-    return 0;
-#endif
 }
 
 static int kvm_get_sregs(CPUState *env)
@@ -1156,7 +1119,6 @@ static int kvm_get_msrs(CPUState *env)
         msrs[n++].index = MSR_KVM_ASYNC_PF_EN;
     }
 
-#ifdef KVM_CAP_MCE
     if (env->mcg_cap) {
         msrs[n++].index = MSR_MCG_STATUS;
         msrs[n++].index = MSR_MCG_CTL;
@@ -1164,7 +1126,6 @@ static int kvm_get_msrs(CPUState *env)
             msrs[n++].index = MSR_MC0_CTL + i;
         }
     }
-#endif
 
     msr_data.info.nmsrs = n;
     ret = kvm_vcpu_ioctl(env, KVM_GET_MSRS, &msr_data);
@@ -1215,21 +1176,17 @@ static int kvm_get_msrs(CPUState *env)
         case MSR_KVM_WALL_CLOCK:
             env->wall_clock_msr = msrs[i].data;
             break;
-#ifdef KVM_CAP_MCE
         case MSR_MCG_STATUS:
             env->mcg_status = msrs[i].data;
             break;
         case MSR_MCG_CTL:
             env->mcg_ctl = msrs[i].data;
             break;
-#endif
         default:
-#ifdef KVM_CAP_MCE
             if (msrs[i].index >= MSR_MC0_CTL &&
                 msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
                 env->mce_banks[msrs[i].index - MSR_MC0_CTL] = msrs[i].data;
             }
-#endif
             break;
         case MSR_KVM_ASYNC_PF_EN:
             env->async_pf_en_msr = msrs[i].data;
@@ -1265,7 +1222,6 @@ static int kvm_get_mp_state(CPUState *env)
 
 static int kvm_put_vcpu_events(CPUState *env, int level)
 {
-#ifdef KVM_CAP_VCPU_EVENTS
     struct kvm_vcpu_events events;
 
     if (!kvm_has_vcpu_events()) {
@@ -1294,14 +1250,10 @@ static int kvm_put_vcpu_events(CPUState *env, int level)
     }
 
     return kvm_vcpu_ioctl(env, KVM_SET_VCPU_EVENTS, &events);
-#else
-    return 0;
-#endif
 }
 
 static int kvm_get_vcpu_events(CPUState *env)
 {
-#ifdef KVM_CAP_VCPU_EVENTS
     struct kvm_vcpu_events events;
     int ret;
 
@@ -1331,7 +1283,6 @@ static int kvm_get_vcpu_events(CPUState *env)
     }
 
     env->sipi_vector = events.sipi_vector;
-#endif
 
     return 0;
 }
@@ -1339,7 +1290,6 @@ static int kvm_get_vcpu_events(CPUState *env)
 static int kvm_guest_debug_workarounds(CPUState *env)
 {
     int ret = 0;
-#ifdef KVM_CAP_SET_GUEST_DEBUG
     unsigned long reinject_trap = 0;
 
     if (!kvm_has_vcpu_events()) {
@@ -1363,13 +1313,11 @@ static int kvm_guest_debug_workarounds(CPUState *env)
         (!kvm_has_robust_singlestep() && env->singlestep_enabled)) {
         ret = kvm_update_guest_debug(env, reinject_trap);
     }
-#endif /* KVM_CAP_SET_GUEST_DEBUG */
     return ret;
 }
 
 static int kvm_put_debugregs(CPUState *env)
 {
-#ifdef KVM_CAP_DEBUGREGS
     struct kvm_debugregs dbgregs;
     int i;
 
@@ -1385,14 +1333,10 @@ static int kvm_put_debugregs(CPUState *env)
     dbgregs.flags = 0;
 
     return kvm_vcpu_ioctl(env, KVM_SET_DEBUGREGS, &dbgregs);
-#else
-    return 0;
-#endif
 }
 
 static int kvm_get_debugregs(CPUState *env)
 {
-#ifdef KVM_CAP_DEBUGREGS
     struct kvm_debugregs dbgregs;
     int i, ret;
 
@@ -1409,7 +1353,6 @@ static int kvm_get_debugregs(CPUState *env)
     }
     env->dr[4] = env->dr[6] = dbgregs.dr6;
     env->dr[5] = env->dr[7] = dbgregs.dr7;
-#endif
 
     return 0;
 }
@@ -1635,7 +1578,6 @@ static int kvm_handle_halt(CPUState *env)
     return 0;
 }
 
-#ifdef KVM_CAP_SET_GUEST_DEBUG
 int kvm_arch_insert_sw_breakpoint(CPUState *env, struct kvm_sw_breakpoint *bp)
 {
     static const uint8_t int3 = 0xcc;
@@ -1816,7 +1758,6 @@ void kvm_arch_update_guest_debug(CPUState *env, struct kvm_guest_debug *dbg)
         }
     }
 }
-#endif /* KVM_CAP_SET_GUEST_DEBUG */
 
 static bool host_supports_vmx(void)
 {
@@ -1863,12 +1804,10 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run)
                 run->ex.exception, run->ex.error_code);
         ret = -1;
         break;
-#ifdef KVM_CAP_SET_GUEST_DEBUG
     case KVM_EXIT_DEBUG:
         DPRINTF("kvm_exit_debug\n");
         ret = kvm_handle_debug(&run->debug.arch);
         break;
-#endif /* KVM_CAP_SET_GUEST_DEBUG */
     default:
         fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason);
         ret = -1;
Signature · 1 line
1.7.1
author
#34 lore raw

PATCH 9/12 kvm: ppc: Drop KVM_CAP build dependencies

In reply to Jan Kiszka

No longer needed with accompanied kernel headers.

CC Alexander Graf <[email protected]>
---
 target-ppc/kvm.c |   14 --------------
 1 files changed, 0 insertions(+), 14 deletions(-)
target-ppc/kvm.c +0 -14
index 0500e3f..21f35af 100644
@@ -65,18 +65,10 @@ static void kvm_kick_env(void *env)
 
 int kvm_arch_init(KVMState *s)
 {
-#ifdef KVM_CAP_PPC_UNSET_IRQ
     cap_interrupt_unset = kvm_check_extension(s, KVM_CAP_PPC_UNSET_IRQ);
-#endif
-#ifdef KVM_CAP_PPC_IRQ_LEVEL
     cap_interrupt_level = kvm_check_extension(s, KVM_CAP_PPC_IRQ_LEVEL);
-#endif
-#ifdef KVM_CAP_PPC_SEGSTATE
     cap_segstate = kvm_check_extension(s, KVM_CAP_PPC_SEGSTATE);
-#endif
-#ifdef KVM_CAP_PPC_BOOKE_SREGS
     cap_booke_sregs = kvm_check_extension(s, KVM_CAP_PPC_BOOKE_SREGS);
-#endif
 
     if (!cap_interrupt_level) {
         fprintf(stderr, "KVM: Couldn't find level irq capability. Expect the "
@@ -217,7 +209,6 @@ int kvm_arch_get_registers(CPUState *env)
             return ret;
         }
 
-#ifdef KVM_CAP_PPC_BOOKE_SREGS
         if (sregs.u.e.features & KVM_SREGS_E_BASE) {
             env->spr[SPR_BOOKE_CSRR0] = sregs.u.e.csrr0;
             env->spr[SPR_BOOKE_CSRR1] = sregs.u.e.csrr1;
@@ -314,7 +305,6 @@ int kvm_arch_get_registers(CPUState *env)
                 env->spr[SPR_BOOKE_PID2] = sregs.u.e.impl.fsl.pid2;
             }
         }
-#endif
     }
 
     if (cap_segstate) {
@@ -323,7 +313,6 @@ int kvm_arch_get_registers(CPUState *env)
             return ret;
         }
 
-#ifdef KVM_CAP_PPC_SEGSTATE
         ppc_store_sdr1(env, sregs.u.s.sdr1);
 
         /* Sync SLB */
@@ -346,7 +335,6 @@ int kvm_arch_get_registers(CPUState *env)
             env->IBAT[0][i] = sregs.u.s.ppc32.ibat[i] & 0xffffffff;
             env->IBAT[1][i] = sregs.u.s.ppc32.ibat[i] >> 32;
         }
-#endif
     }
 
     return 0;
@@ -525,7 +513,6 @@ int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len)
 {
     uint32_t *hc = (uint32_t*)buf;
 
-#ifdef KVM_CAP_PPC_GET_PVINFO
     struct kvm_ppc_pvinfo pvinfo;
 
     if (kvm_check_extension(env->kvm_state, KVM_CAP_PPC_GET_PVINFO) &&
@@ -534,7 +521,6 @@ int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len)
 
         return 0;
     }
-#endif
 
     /*
      * Fallback to always fail hypercalls:
Signature · 1 line
1.7.1
#35 lore raw

Re: [Qemu-devel] [PATCH 09/12] kvm: ppc: Drop KVM_CAP build dependencies

On Wed, Jun 08, 2011 at 04:11:03PM +0200, Jan Kiszka wrote:
<snip>

target-ppc/kvm.c int kvm_arch_get_registers(CPUState *env) · line 214

Quoted 8 lines
target-ppc/kvm.c +0 -1
@@ -217,7 +209,6 @@ int kvm_arch_get_registers(CPUState *env)
             return ret;
         }
 
-#ifdef KVM_CAP_PPC_BOOKE_SREGS
         if (sregs.u.e.features & KVM_SREGS_E_BASE) {
             env->spr[SPR_BOOKE_CSRR0] = sregs.u.e.csrr0;
             env->spr[SPR_BOOKE_CSRR1] = sregs.u.e.csrr1;

Which tree/commit-id did you use as base for this series? This chunk doesn't apply on uq/master (patch 11/12, on the other hand, doesn't apply against qemu.git/master, only uq/master).

After some patch hunting, I found out that the series apply cleanly if I apply it against a manual merge of uq/master and qemu.git/master, but maybe there is a branch that already had all the dependencies, that I didn't know about?

Signature · 1 line
Eduardo
#36 lore raw

Re: [PATCH 09/12] kvm: ppc: Drop KVM_CAP build dependencies

Quoted 15 lines · Eduardo Habkost

On Wed, Jun 08, 2011 at 04:11:03PM +0200, Jan Kiszka wrote:
<snip>

target-ppc/kvm.c int kvm_arch_get_registers(CPUState *env) · line 214

Quoted 8 lines
target-ppc/kvm.c +0 -1
@@ -217,7 +209,6 @@ int kvm_arch_get_registers(CPUState *env)
             return ret;
         }
 
-#ifdef KVM_CAP_PPC_BOOKE_SREGS
         if (sregs.u.e.features & KVM_SREGS_E_BASE) {
             env->spr[SPR_BOOKE_CSRR0] = sregs.u.e.csrr0;
             env->spr[SPR_BOOKE_CSRR1] = sregs.u.e.csrr1;

Which tree/commit-id did you use as base for this series? This chunk doesn't apply on uq/master (patch 11/12, on the other hand, doesn't apply against qemu.git/master, only uq/master).

Quoted 4 lines

After some patch hunting, I found out that the series apply cleanly if I apply it against a manual merge of uq/master and qemu.git/master, but maybe there is a branch that already had all the dependencies, that I didn't know about?

As I wrote in the introduction, the series requires a trivial rebase of uq/master over current qemu master (because of this patch).

Jan

author
#38 lore raw

PATCH 10/12 kvm: Clean up stubs

In reply to Jan Kiszka

No one references kvm_check_extension, kvm_has_vcpu_events, and kvm_has_robust_singlestep outside KVM code.

kvm_update_guest_debug is never called, thus has no job besides returning an error.

---
 kvm-stub.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)
kvm-stub.c +1 -17
index 1c95452..1e835c6 100644
@@ -42,11 +42,6 @@ int kvm_uncoalesce_mmio_region(target_phys_addr_t start, ram_addr_t size)
     return -ENOSYS;
 }
 
-int kvm_check_extension(KVMState *s, unsigned int extension)
-{
-    return 0;
-}
-
 int kvm_init(void)
 {
     return -ENOSYS;
@@ -78,16 +73,6 @@ int kvm_has_sync_mmu(void)
     return 0;
 }
 
-int kvm_has_vcpu_events(void)
-{
-    return 0;
-}
-
-int kvm_has_robust_singlestep(void)
-{
-    return 0;
-}
-
 int kvm_has_many_ioeventfds(void)
 {
     return 0;
@@ -99,8 +84,7 @@ void kvm_setup_guest_memory(void *start, size_t size)
 
 int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap)
 {
-    tb_flush(env);
-    return 0;
+    return -ENOSYS;
 }
 
 int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
Signature · 1 line
1.7.1
author
#39 lore raw

PATCH 11/12 kvm: x86: Pass KVMState to kvm_arch_get_supported_cpuid

In reply to Jan Kiszka

kvm_arch_get_supported_cpuid checks for global cpuid restrictions, it does not require any CPUState reference. Changing its interface allows to call it before any VCPU is initialized.

CC Eduardo Habkost <[email protected]>
---
 kvm.h               |    2 +-
 target-i386/cpuid.c |   20 ++++++++++++--------
 target-i386/kvm.c   |   30 +++++++++++++++---------------
 3 files changed, 28 insertions(+), 24 deletions(-)
kvm.h +1 -1
index d565dba..243b063 100644
@@ -157,7 +157,7 @@ bool kvm_arch_stop_on_emulation_error(CPUState *env);
 
 int kvm_check_extension(KVMState *s, unsigned int extension);
 
-uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
+uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
                                       uint32_t index, int reg);
 void kvm_cpu_synchronize_state(CPUState *env);
 void kvm_cpu_synchronize_post_reset(CPUState *env);
target-i386/cpuid.c +12 -8
index 79e7580..e1ae3af 100644
@@ -1144,10 +1144,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         break;
     case 7:
         if (kvm_enabled()) {
-            *eax = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EAX);
-            *ebx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EBX);
-            *ecx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_ECX);
-            *edx = kvm_arch_get_supported_cpuid(env, 0x7, count, R_EDX);
+            KVMState *s = env->kvm_state;
+
+            *eax = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EAX);
+            *ebx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EBX);
+            *ecx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_ECX);
+            *edx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EDX);
         } else {
             *eax = 0;
             *ebx = 0;
@@ -1179,10 +1181,12 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
             break;
         }
         if (kvm_enabled()) {
-            *eax = kvm_arch_get_supported_cpuid(env, 0xd, count, R_EAX);
-            *ebx = kvm_arch_get_supported_cpuid(env, 0xd, count, R_EBX);
-            *ecx = kvm_arch_get_supported_cpuid(env, 0xd, count, R_ECX);
-            *edx = kvm_arch_get_supported_cpuid(env, 0xd, count, R_EDX);
+            KVMState *s = env->kvm_state;
+
+            *eax = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EAX);
+            *ebx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EBX);
+            *ecx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_ECX);
+            *edx = kvm_arch_get_supported_cpuid(s, 0xd, count, R_EDX);
         } else {
             *eax = 0;
             *ebx = 0;
target-i386/kvm.c +15 -15
index 1c2d32c..5ebb054 100644
@@ -98,12 +98,12 @@ struct kvm_para_features {
     { -1, -1 }
 };
 
-static int get_para_features(CPUState *env)
+static int get_para_features(KVMState *s)
 {
     int i, features = 0;
 
     for (i = 0; i < ARRAY_SIZE(para_features) - 1; i++) {
-        if (kvm_check_extension(env->kvm_state, para_features[i].cap)) {
+        if (kvm_check_extension(s, para_features[i].cap)) {
             features |= (1 << para_features[i].feature);
         }
     }
@@ -112,7 +112,7 @@ static int get_para_features(CPUState *env)
 }
 
 
-uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
+uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function,
                                       uint32_t index, int reg)
 {
     struct kvm_cpuid2 *cpuid;
@@ -122,7 +122,7 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
     int has_kvm_features = 0;
 
     max = 1;
-    while ((cpuid = try_get_cpuid(env->kvm_state, max)) == NULL) {
+    while ((cpuid = try_get_cpuid(s, max)) == NULL) {
         max *= 2;
     }
 
@@ -153,7 +153,7 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
                     /* On Intel, kvm returns cpuid according to the Intel spec,
                      * so add missing bits according to the AMD spec:
                      */
-                    cpuid_1_edx = kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);
+                    cpuid_1_edx = kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
                     ret |= cpuid_1_edx & 0x183f7ff;
                     break;
                 }
@@ -166,7 +166,7 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function,
 
     /* fallback for older kernels */
     if (!has_kvm_features && (function == KVM_CPUID_FEATURES)) {
-        ret = get_para_features(env);
+        ret = get_para_features(s);
     }
 
     return ret;
@@ -349,25 +349,25 @@ int kvm_arch_init_vcpu(CPUState *env)
         struct kvm_cpuid2 cpuid;
         struct kvm_cpuid_entry2 entries[100];
     } __attribute__((packed)) cpuid_data;
+    KVMState *s = env->kvm_state;
     uint32_t limit, i, j, cpuid_i;
     uint32_t unused;
     struct kvm_cpuid_entry2 *c;
     uint32_t signature[3];
 
-    env->cpuid_features &= kvm_arch_get_supported_cpuid(env, 1, 0, R_EDX);
+    env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
 
     i = env->cpuid_ext_features & CPUID_EXT_HYPERVISOR;
-    env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(env, 1, 0, R_ECX);
+    env->cpuid_ext_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_ECX);
     env->cpuid_ext_features |= i;
 
-    env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(env, 0x80000001,
+    env->cpuid_ext2_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
                                                              0, R_EDX);
-    env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(env, 0x80000001,
+    env->cpuid_ext3_features &= kvm_arch_get_supported_cpuid(s, 0x80000001,
                                                              0, R_ECX);
-    env->cpuid_svm_features  &= kvm_arch_get_supported_cpuid(env, 0x8000000A,
+    env->cpuid_svm_features  &= kvm_arch_get_supported_cpuid(s, 0x8000000A,
                                                              0, R_EDX);
 
-
     cpuid_i = 0;
 
     /* Paravirtualization CPUIDs */
@@ -383,8 +383,8 @@ int kvm_arch_init_vcpu(CPUState *env)
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_FEATURES;
-    c->eax = env->cpuid_kvm_features & kvm_arch_get_supported_cpuid(env,
-                                                KVM_CPUID_FEATURES, 0, R_EAX);
+    c->eax = env->cpuid_kvm_features &
+        kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
 
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
 
@@ -453,7 +453,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     /* Call Centaur's CPUID instructions they are supported. */
     if (env->cpuid_xlevel2 > 0) {
         env->cpuid_ext4_features &=
-            kvm_arch_get_supported_cpuid(env, 0xC0000001, 0, R_EDX);
+            kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
         cpu_x86_cpuid(env, 0xC0000000, 0, &limit, &unused, &unused, &unused);
 
         for (i = 0xC0000000; i <= limit; i++) {
Signature · 1 line
1.7.1
#40 lore raw

Re: [Qemu-devel] [PATCH 11/12] kvm: x86: Pass KVMState to kvm_arch_get_supported_cpuid

Quoted 3 lines · Jan Kiszka

kvm_arch_get_supported_cpuid checks for global cpuid restrictions, it does not require any CPUState reference. Changing its interface allows to call it before any VCPU is initialized.

I'm wondering if it wouldn't be simpler to keep the existing interface but just initialize CPUState->kvm_state earlier (today it is initialized only on kvm_init_vcpu(), although the kvm_state global is initialized much earlier).

Even with this new KVMState-based interface, code that needs to use these functions before kvm_init_vcpu() (e.g. check_features_against_host()) will have to use the 'kvm_state' global (and I would like to avoid that).

Signature · 1 line
Eduardo
author
#41 lore raw

Re: [Qemu-devel] [PATCH 11/12] kvm: x86: Pass KVMState to kvm_arch_get_supported_cpuid

Quoted 9 lines · Eduardo Habkost
Quoted 3 lines · Jan Kiszka

kvm_arch_get_supported_cpuid checks for global cpuid restrictions, it does not require any CPUState reference. Changing its interface allows to call it before any VCPU is initialized.

I'm wondering if it wouldn't be simpler to keep the existing interface but just initialize CPUState->kvm_state earlier (today it is initialized only on kvm_init_vcpu(), although the kvm_state global is initialized much earlier).

If there was more need for a slit up, I would agree. But I do not see it.

Quoted 5 lines

Even with this new KVMState-based interface, code that needs to use these functions before kvm_init_vcpu() (e.g. check_features_against_host()) will have to use the 'kvm_state' global (and I would like to avoid that).

That is a different topic that needs to be resolved for other use cases as well (e.g. for kvm devices). In many cases you should be able to find a way to pass kvm_state from functions that already holds a reference. Is that not true for your use case?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#42 lore raw

Re: [Qemu-devel] [PATCH 11/12] kvm: x86: Pass KVMState to kvm_arch_get_supported_cpuid

On Thu, Jun 09, 2011 at 07:41:03PM +0200, Jan Kiszka wrote:
<snip>

Quoted 6 lines
Quoted 4 lines

I'm wondering if it wouldn't be simpler to keep the existing interface but just initialize CPUState->kvm_state earlier (today it is initialized only on kvm_init_vcpu(), although the kvm_state global is initialized much earlier).

If there was more need for a slit up, I would agree. But I do not see it.

I guess it won't hurt to make the functions require only what they really need.

Quoted 10 lines
Quoted 5 lines

Even with this new KVMState-based interface, code that needs to use these functions before kvm_init_vcpu() (e.g. check_features_against_host()) will have to use the 'kvm_state' global (and I would like to avoid that).

That is a different topic that needs to be resolved for other use cases as well (e.g. for kvm devices). In many cases you should be able to find a way to pass kvm_state from functions that already holds a reference. Is that not true for your use case?

My use case is cpu_x86_register()/check_features_against_host(), that hold only a CPUState reference, and I wouldn't like to add a new reference to the kvm_state global variable there.

Signature · 1 line
Eduardo
#43 lore raw

Re: [Qemu-devel] [PATCH 11/12] kvm: x86: Pass KVMState to kvm_arch_get_supported_cpuid

Quoted 11 lines · Eduardo Habkost

On Thu, Jun 09, 2011 at 07:41:03PM +0200, Jan Kiszka wrote:
<snip>

Quoted 6 lines
Quoted 4 lines

I'm wondering if it wouldn't be simpler to keep the existing interface but just initialize CPUState->kvm_state earlier (today it is initialized only on kvm_init_vcpu(), although the kvm_state global is initialized much earlier).

If there was more need for a slit up, I would agree. But I do not see it.

I guess it won't hurt to make the functions require only what they really need.

Yes, so this patch has an independent value IMO.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

Even with this new KVMState-based interface, code that needs to use these functions before kvm_init_vcpu() (e.g. check_features_against_host()) will have to use the 'kvm_state' global (and I would like to avoid that).

Quoted 8 lines
Quoted 4 lines

That is a different topic that needs to be resolved for other use cases as well (e.g. for kvm devices). In many cases you should be able to find a way to pass kvm_state from functions that already holds a reference. Is that not true for your use case?

My use case is cpu_x86_register()/check_features_against_host(), that hold only a CPUState reference, and I wouldn't like to add a new reference to the kvm_state global variable there.

For me, this is like requiring kvm_state for kvm_check_extension, and I wouldn't hesitate using the global state until we solved that in a better way. But if you feel like it's not appropriate here, then let's go for early/late vcpu init.

Jan

author
#44 lore raw

PATCH 12/12 Remove unneeded kvm.h from cpu-exec.c

In reply to Jan Kiszka

This was obsoleted by 6792a57bf1.

---
 cpu-exec.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
cpu-exec.c +0 -1
index 6ddd8dd..9bb6405 100644
@@ -20,7 +20,6 @@
 #include "exec.h"
 #include "disas.h"
 #include "tcg.h"
-#include "kvm.h"
 #include "qemu-barrier.h"
 
 #if defined(__sparc__) && !defined(CONFIG_SOLARIS)
Signature · 1 line
1.7.1
#45 lore raw
In reply to Jan Kiszka
Quoted 11 lines · Jan Kiszka

Licensing of the virtio headers is no clarified. So we can finally resolve the clumbsy and constantly buggy #ifdef'ery around old KVM and virtio headers. Recent example: current qemu-kvm does not build against 2.6.32 headers.

This series introduces an import mechanism for all required Linux headers so that the appropriate versions can be kept safely inside the QEMU tree. I've incorporated all the valuable review comments on the first version and rebased the result over current uq/master after rebasing that one over current QEMU master.

Quoted 4 lines

Please note that I had no chance to test-build PPC or s390.

Beside the header topic, this series also includes a few assorted KVM cleanup patches so that my queue is empty again.

Applied all, thanks.