[PATCH] [SCSI] virtio-scsi: Add real 2-clause BSD license to header
This is analogous to commit a1b383870a made by Rusty Russell to all the VirtIO headers at the time. This eases the use of the header as is by other OSes. Signed-off-by: Bryan Venteicher bry...@daemoninthecloset.org --- include/linux/virtio_scsi.h | 28 ++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h index dc8d305..a91fb52 100644 --- a/include/linux/virtio_scsi.h +++ b/include/linux/virtio_scsi.h @@ -1,7 +1,31 @@ +/* + * This header is BSD licensed so anyone can use the definitions to implement + * compatible drivers/servers. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #ifndef _LINUX_VIRTIO_SCSI_H #define _LINUX_VIRTIO_SCSI_H -/* This header is BSD licensed so anyone can use the definitions to implement - * compatible drivers/servers. */ #define VIRTIO_SCSI_CDB_SIZE 32 #define VIRTIO_SCSI_SENSE_SIZE 96 -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Enabling IA32_TSC_ADJUST for guest VM
On Thu, Oct 11, 2012 at 12:47:39AM +, Auld, Will wrote: Marcelo, You are suggesting that I: Kvm_host.h: Struct kvm_x86_ops { ... change Int (*set_msr)(struct kvm_vcpu * vcpu, u32 mrs_index, u64 data); to Int (*set_msr)(struct kvm_vcpu * vcpu, u32 mrs_index, u64 data, bool from_guest); ... }; and so on down the line to set_msr_common(), kvm_write_tsc()... in a separate patch before other related patches? Yes. 'bool guest_initiated' is nicer IMO. As far as the initialization after live migration, I will provide some output with explanation once I am able to again. At the moment, I have hosed my system and need to figure out what's wrong and fix it first. Ok no problem. Thanks, Will -Original Message- From: Marcelo Tosatti [mailto:mtosa...@redhat.com] Sent: Wednesday, October 10, 2012 5:53 AM To: Auld, Will Cc: Avi Kivity; kvm@vger.kernel.org; Zhang, Xiantao; Liu, Jinsong Subject: Re: [PATCH] Enabling IA32_TSC_ADJUST for guest VM On Tue, Oct 09, 2012 at 04:10:30PM +, Auld, Will wrote: I am just testing the second version of this patch. It addresses all the comments so far except Marcelo's issue with breaking the function compute_guest_tsc(). Lets try to merge the missing patch from Zachary first (that'll make it clear). I needed to put the call for updating the TSC_ADJUST_MSR in kvm_write_tsc() to ensure it is only called from user space. Other changes added to vmcs offset should not be tracked in TSC_ADJUST_MSR. Please have a separate, earlier patch making that explicit (by passing a bool to kvm_x86_ops-set_msr then to kvm_set_msr_common). that = whether msr write is guest initiated or not. I had some trouble with the order of initialization during live migration. TSC_ADJUST is initialized first but then wiped out by multiple initializations of tsc. The fix for this is to not update TSC_ADJUST if the vmcs offset is not actually changing with the tsc write. So, after migration outcome is that vmcs offset gets defined independent from the migrating value of TSC_ADJUST. I believe this is what we want to happen. Can you please be more explicit regarding wiped out by multiple initializations of tsc ? It is probably best to maintain TSC_ADJUST separately, in software, and then calculate TSC_OFFSET. Thanks, Will -Original Message- From: Avi Kivity [mailto:a...@redhat.com] Sent: Tuesday, October 09, 2012 5:12 AM To: Marcelo Tosatti Cc: Auld, Will; kvm@vger.kernel.org; Zhang, Xiantao Subject: Re: [PATCH] Enabling IA32_TSC_ADJUST for guest VM On 10/08/2012 07:30 PM, Marcelo Tosatti wrote: From Intel's manual: • If an execution of WRMSR to the IA32_TIME_STAMP_COUNTER MSR adds (or subtracts) value X from the TSC, the logical processor also adds (or subtracts) value X from the IA32_TSC_ADJUST MSR. This is not handled in the patch. To support migration, it will be necessary to differentiate between guest initiated and userspace-model initiated msr write. That is, only guest initiated TSC writes should affect the value of IA32_TSC_ADJUST MSR. Avi, any better idea? I think we need that anyway, since there are some read-only MSRs that need to be configured by the host (nvmx capabilities). So if we add that feature it will be useful elsewhere. I don't think it's possible to do it in any other way: Local offset value of the IA32_TSC for a logical processor. Reset value is Zero. A write to IA32_TSC will modify the local offset in IA32_TSC_ADJUST and the content of IA32_TSC, but does not affect the internal invariant TSC hardware. What we want to do is affect the internal invariant TSC hardware, so we can't do that through the normal means. btw, will tsc writes from userspace (after live migration) cause tsc skew? If so we should think how to model a guest-wide tsc. -- error compiling committee.c: too many arguments to function N?r??yb?X??ǧv?^?){.n?+h????ܨ}???Ơz?j:+v??? zZ+??+zf???h???~i???z??w??)ߢf -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Using PCI config space to indicate config location
On Thu, Oct 11, 2012 at 11:48:22AM +1030, Rusty Russell wrote: Michael S. Tsirkin m...@redhat.com writes: On Mon, Oct 08, 2012 at 12:51:25PM +1030, Rusty Russell wrote: Note before anyone gets confused; we were talking about using the PCI config space to indicate what BAR(s) the virtio stuff is in. An alternative would be to simply specify a new layout format in BAR1. One problem we are still left with is this: device specific config accesses are still non atomic. This is a problem for multibyte fields such as MAC address where MAC could change while we are accessing it. It's also a problem for related fields, eg. console width and height, or disk geometry. I was thinking about some backwards compatible way to solve this, but if we are willing to break compatiblity or use some mode switch, how about we give up on virtio config space completely, and do everything besides IO and ISR through guest memory? I think there's still a benefit in the simple publishing of information: I don't really want to add a control queue for the console. One reason I thought using a vq is handy is because this would let us get by with a single MSI vector. Currently we need at least 2 for config changes + a shared one for vqs. But I don't insist. But inevitably, once-static information can change in later versions, and it's horrible to have config information plus a bit that says don't use this, use the control queue. Here's a table from a quick audit: Driver Config Device changesDriver writes... after init? net YY NN block YY YY console YY NN rng NN NN balloon YY YY scsiYN YN 9p YN NN For config space reads, I suggest the driver publish a generation count. You mean device? For writes, the standard seems to be a commit latch. We could abuse the generation count for this: the driver writes to it to commit config changes. I think this will work. There are a couple of things that bother me: This assumes read accesses have no side effects, and these are sometimes handy. Also the semantics for write aren't very clear to me. I guess device must buffer data until generation count write? This assumes the device has a buffer to store writes, and it must track each byte written. I kind of dislike this tracking of accessed bytes. Also, device would need to resolve conflicts if any in some device specific way. Maybe it's a good idea to make the buffer accesses explicit instead? IOW require driver to declare intent to read/request write of a specific config range. We could for example do it like this: __le32 config_offset; __le32 config_len; __u8 config_cmd; /* write-only: 0 - read, 1 - write config_len bytes at config_offset from/to config space to/from device memory */ But maybe this is over-engineering? ie: /* Fields in VIRTIO_PCI_CAP_COMMON_CFG: */ struct virtio_pci_common_cfg { /* About the whole device. */ __le32 device_feature_select; /* read-write */ __le32 device_feature; /* read-only */ __le32 guest_feature_select;/* read-write */ __le32 guest_feature; /* read-only */ __le32 config_gen_and_latch;/* read-write */ __le16 msix_config; /* read-write */ __u8 device_status; /* read-write */ __u8 unused; /* About a specific virtqueue. */ __le16 queue_select;/* read-write */ __le16 queue_align; /* read-write, power of 2. */ __le16 queue_size; /* read-write, power of 2. */ __le16 queue_msix_vector;/* read-write */ __le64 queue_address; /* read-write: 0x == DNE. */ }; Thoughts? Rusty. PS. Let's make all the virtio-device config LE, too... We'll need some new API for devices then: currently we pass bytes. -- MST -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC 1/2] kvm: Handle undercommitted guest case in PLE handler
On Wed, 10 Oct 2012 09:24:55 -0500, Andrew Theurer haban...@linux.vnet.ibm.com wrote: Below is again 8 x 20-way VMs, but this time I tried out Nikunj's gang scheduling patches. While I am not recommending gang scheduling, I think it's a good data point. The performance is 3.88x the PLE result. https://docs.google.com/open?id=0B6tfUNlZ-14wWXdscWcwNTVEY3M That looks pretty good and serves the purpose. And the result says it all. Note that the task switching intervals of 4ms are quite obvious again, and this time all vCPUs from same VM run at the same time. It represents the best possible outcome. Anyway, I thought the bitmaps might help better visualize what's going on. -Andrew Regards Nikunj -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/3] virtio-net: inline header support
On Thu, Oct 11, 2012 at 10:33:31AM +1030, Rusty Russell wrote: Paolo Bonzini pbonz...@redhat.com writes: Il 09/10/2012 06:59, Rusty Russell ha scritto: Paolo Bonzini pbonz...@redhat.com writes: Il 05/10/2012 07:43, Rusty Russell ha scritto: That's good. But virtio_blk's scsi command is insoluble AFAICT. As I said to Anthony, the best rules are always and never, so I'd really rather not have to grandfather that in. It is, but we can add a rule that if the (transport) flag VIRTIO_RING_F_ANY_HEADER_SG is set, the cdb field is always 32 bytes in virtio-blk. Could we do that? It's the cmd length I'm concerned about; is it always 32 in practice for some reason? It is always 32 or less except in very obscure cases that are pretty much confined to iSCSI. We don't care about the obscure cases, and the extra bytes don't hurt. BTW, 32 is the default cdb_size used by virtio-scsi. Currently qemu does: struct sg_io_hdr hdr; memset(hdr, 0, sizeof(struct sg_io_hdr)); hdr.interface_id = 'S'; hdr.cmd_len = req-elem.out_sg[1].iov_len; hdr.cmdp = req-elem.out_sg[1].iov_base; hdr.dxfer_len = 0; If it's a command which expects more output data, there's no way to guess where the boundary is between that command and the data. Yep, so I understood the problem right. OK. Well, Anthony wants qemu to be robust in this regard, so I am tempted to rework all the qemu drivers to handle arbitrary layouts. They could use a good audit anyway. I agree here. Still trying to understand whether we can agree to use a feature bit for this, or not. This would become a glaring exception, but I'm tempted to fix it to 32 bytes at the same time as we get the new pci layout (ie. for the virtio 1.0 spec). But this isn't a virtio-pci only issue, is it? qemu has s390 bus with same limmitation. How can we tie it to pci layout? Maybe what you mean is to use a transport feature for this and tie *that* to new layout in case of pci? The Linux driver would carefully be backwards compatible, of course, and the spec would document why. Cheers, Rusty. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] [SCSI] virtio-scsi: Add real 2-clause BSD license to header
Il 11/10/2012 08:41, Bryan Venteicher ha scritto: This is analogous to commit a1b383870a made by Rusty Russell to all the VirtIO headers at the time. This eases the use of the header as is by other OSes. Signed-off-by: Bryan Venteicher bry...@daemoninthecloset.org Acked-by: Paolo Bonzini pbonz...@redhat.com --- include/linux/virtio_scsi.h | 28 ++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h index dc8d305..a91fb52 100644 --- a/include/linux/virtio_scsi.h +++ b/include/linux/virtio_scsi.h @@ -1,7 +1,31 @@ +/* + * This header is BSD licensed so anyone can use the definitions to implement + * compatible drivers/servers. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #ifndef _LINUX_VIRTIO_SCSI_H #define _LINUX_VIRTIO_SCSI_H -/* This header is BSD licensed so anyone can use the definitions to implement - * compatible drivers/servers. */ #define VIRTIO_SCSI_CDB_SIZE 32 #define VIRTIO_SCSI_SENSE_SIZE 96 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] virt: Repairs Migration_multi_host_fd test Pylint correction.
Pylint correction makes migration_multi_host_fd test dysfunctional. pull-request: https://github.com/autotest/virt-test/pull/55 Signed-off-by: Jiří Župka jzu...@redhat.com --- kvm/tests/migration_multi_host_fd.py |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kvm/tests/migration_multi_host_fd.py b/kvm/tests/migration_multi_host_fd.py index ec9210a..7f08205 100644 --- a/kvm/tests/migration_multi_host_fd.py +++ b/kvm/tests/migration_multi_host_fd.py @@ -105,7 +105,7 @@ def run_migration_multi_host_fd(test, params, env): s = self._create_server(mig_port) try: conn, _ = s.accept() -fd = s.fileno() +fd = conn.fileno() logging.debug(File descrtiptor %d used for migration. % (fd)) -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[Autotest][PATCH] virt: Adds multi_host_migration early boot tests.
pull-request: https://github.com/autotest/virt-test/pull/56 Signed-off-by: Jiří Župka jzu...@redhat.com --- kvm/cfg/multi-host-tests.cfg.sample |2 ++ kvm/tests/migration_multi_host_fd.py |7 +-- shared/cfg/subtests.cfg.sample | 17 +++-- virttest/env_process.py |3 --- virttest/kvm_vm.py | 21 +++-- virttest/utils_test.py | 34 ++ 6 files changed, 59 insertions(+), 25 deletions(-) diff --git a/kvm/cfg/multi-host-tests.cfg.sample b/kvm/cfg/multi-host-tests.cfg.sample index d47e756..20bc385 100644 --- a/kvm/cfg/multi-host-tests.cfg.sample +++ b/kvm/cfg/multi-host-tests.cfg.sample @@ -23,6 +23,8 @@ variants: only smallpages only pc only Fedora.17.64 +cpu_model = core2duo +cpu_model_flags = +sse3 only migrate_multi_host # Runs qemu, f16 64 bit guest OS, install, boot, shutdown diff --git a/kvm/tests/migration_multi_host_fd.py b/kvm/tests/migration_multi_host_fd.py index ec9210a..bc6e404 100644 --- a/kvm/tests/migration_multi_host_fd.py +++ b/kvm/tests/migration_multi_host_fd.py @@ -34,8 +34,11 @@ def run_migration_multi_host_fd(test, params, env): fd_src=mig_data.params['migration_fd']) def _check_vms_source(self, mig_data): -for vm in mig_data.vms: -vm.wait_for_login(timeout=self.login_timeout) +start_mig_tout = mig_data.params.get(start_migration_timeout, + None) +if start_mig_tout is None: +for vm in mig_data.vms: +vm.wait_for_login(timeout=self.login_timeout) self._hosts_barrier(mig_data.hosts, mig_data.mig_id, 'prepare_VMS', 60) diff --git a/shared/cfg/subtests.cfg.sample b/shared/cfg/subtests.cfg.sample index 695d60e..61dd79a 100644 --- a/shared/cfg/subtests.cfg.sample +++ b/shared/cfg/subtests.cfg.sample @@ -973,7 +973,7 @@ variants: kill_vm_on_error = yes iterations = 2 used_mem = 1024 -mig_timeout = 4800 +mig_timeout = 480 disk_prepare_timeout = 360 comm_port = 13234 regain_ip_cmd = killall dhclient; sleep 10; dhclient; @@ -990,6 +990,20 @@ variants: -fd: type = migration_multi_host_fd +variants: +#Time when start migration +- after_login_vm: +paused_after_start_vm = no +- early_boot_vm: +no measure_migration_speed +login_timeout = 420 +paused_after_start_vm = yes +variants: +-timeout_0: +start_migration_timeout = 0 +-timeout_6: +start_migration_timeout = 6 + - migration_multi_host_with_file_transfer: install setup image_copy unattended_install.cdrom type = migration_multi_host_with_file_transfer vms = vm1 @@ -1065,7 +1079,6 @@ variants: - rhel6.3.0: machine_type = rhel6.3.0 - - boot_savevm: install setup image_copy unattended_install.cdrom type = boot_savevm savevm_delay = 0.3 diff --git a/virttest/env_process.py b/virttest/env_process.py index f309fe2..0b3bd4e 100644 --- a/virttest/env_process.py +++ b/virttest/env_process.py @@ -106,9 +106,6 @@ def preprocess_vm(test, params, env, name): vm.create(name, params, test.bindir, migration_mode=params.get(migration_mode), migration_fd=params.get(migration_fd)) -if params.get(paused_after_start_vm) == yes: -if vm.state() != paused: -vm.pause() else: # Don't start the VM, just update its params vm.params = params diff --git a/virttest/kvm_vm.py b/virttest/kvm_vm.py index c9bbe57..7436553 100644 --- a/virttest/kvm_vm.py +++ b/virttest/kvm_vm.py @@ -1785,16 +1785,17 @@ class VM(virt_vm.BaseVM): output_func=utils_misc.log_line, output_params=(outfile,)) -# start guest -if self.monitor.verify_status(paused): -try: -self.monitor.cmd(cont) -except kvm_monitor.QMPCmdError, e: -if ((e.data['class'] == MigrationExpected) and -(migration_mode is not None)): -logging.debug(Migration did not start yet...) -else: -raise e +if params.get(paused_after_start_vm) != yes: +#
Re: [PATCH] vhost-blk: Add vhost-blk support v2
On Tue, Oct 09, 2012 at 04:05:18PM +0800, Asias He wrote: vhost-blk is an in-kernel virito-blk device accelerator. Due to lack of proper in-kernel AIO interface, this version converts guest's I/O request to bio and use submit_bio() to submit I/O directly. So this version any supports raw block device as guest's disk image, e.g. /dev/sda, /dev/ram0. We can add file based image support to vhost-blk once we have in-kernel AIO interface. There are some work in progress for in-kernel AIO interface from Dave Kleikamp and Zach Brown: http://marc.info/?l=linux-fsdevelm=133312234313122 Performance evaluation: - 1) LKVM Fio with libaio ioengine on Fusion IO device using kvm tool IOPS Before After Improvement seq-read 107 121 +13.0% seq-write 130 179 +37.6% rnd-read 102 122 +19.6% rnd-write 125 159 +27.0% 2) QEMU Fio with libaio ioengine on Fusion IO device using QEMU IOPS Before After Improvement seq-read 76 123 +61.8% seq-write 139 173 +24.4% rnd-read 73 120 +64.3% rnd-write 75 156 +108.0% Userspace bits: - 1) LKVM The latest vhost-blk userspace bits for kvm tool can be found here: g...@github.com:asias/linux-kvm.git blk.vhost-blk 2) QEMU The latest vhost-blk userspace prototype for QEMU can be found here: g...@github.com:asias/qemu.git blk.vhost-blk Signed-off-by: Asias He as...@redhat.com --- drivers/vhost/Kconfig | 1 + drivers/vhost/Kconfig.blk | 10 + drivers/vhost/Makefile| 2 + drivers/vhost/blk.c | 641 ++ drivers/vhost/blk.h | 8 + 5 files changed, 662 insertions(+) create mode 100644 drivers/vhost/Kconfig.blk create mode 100644 drivers/vhost/blk.c create mode 100644 drivers/vhost/blk.h diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig index 202bba6..acd8038 100644 --- a/drivers/vhost/Kconfig +++ b/drivers/vhost/Kconfig @@ -11,4 +11,5 @@ config VHOST_NET if STAGING source drivers/vhost/Kconfig.tcm +source drivers/vhost/Kconfig.blk endif diff --git a/drivers/vhost/Kconfig.blk b/drivers/vhost/Kconfig.blk new file mode 100644 index 000..ff8ab76 --- /dev/null +++ b/drivers/vhost/Kconfig.blk @@ -0,0 +1,10 @@ +config VHOST_BLK + tristate Host kernel accelerator for virtio blk (EXPERIMENTAL) + depends on BLOCK EXPERIMENTAL m + ---help--- + This kernel module can be loaded in host kernel to accelerate + guest block with virtio_blk. Not to be confused with virtio_blk + module itself which needs to be loaded in guest kernel. + + To compile this driver as a module, choose M here: the module will + be called vhost_blk. diff --git a/drivers/vhost/Makefile b/drivers/vhost/Makefile index a27b053..1a8a4a5 100644 --- a/drivers/vhost/Makefile +++ b/drivers/vhost/Makefile @@ -2,3 +2,5 @@ obj-$(CONFIG_VHOST_NET) += vhost_net.o vhost_net-y := vhost.o net.o obj-$(CONFIG_TCM_VHOST) += tcm_vhost.o +obj-$(CONFIG_VHOST_BLK) += vhost_blk.o +vhost_blk-y := blk.o diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c new file mode 100644 index 000..6b2445a --- /dev/null +++ b/drivers/vhost/blk.c @@ -0,0 +1,641 @@ +/* + * Copyright (C) 2011 Taobao, Inc. + * Author: Liu Yuan tailai...@taobao.com + * + * Copyright (C) 2012 Red Hat, Inc. + * Author: Asias He as...@redhat.com + * + * This work is licensed under the terms of the GNU GPL, version 2. + * + * virtio-blk server in host kernel. + */ + +#include linux/miscdevice.h +#include linux/module.h +#include linux/vhost.h +#include linux/virtio_blk.h +#include linux/mutex.h +#include linux/file.h +#include linux/kthread.h +#include linux/blkdev.h + +#include vhost.c +#include vhost.h +#include blk.h + +#define BLK_HDR 0 What's this for, exactly? Please add a comment. + +static DEFINE_IDA(vhost_blk_index_ida); + +enum { + VHOST_BLK_VQ_REQ = 0, + VHOST_BLK_VQ_MAX = 1, +}; + +struct req_page_list { + struct page **pages; + int pages_nr; +}; + +struct vhost_blk_req { + struct llist_node llnode; + struct req_page_list *pl; + struct vhost_blk *blk; + + struct iovec *iov; + int iov_nr; + + struct bio **bio; + atomic_t bio_nr; + + sector_t sector; + int write; + u16 head; + long len; + + u8 *status; Is this a userspace pointer? If yes it must be tagged as such. Please run code checker - it will catch other bugs for you too. +}; + +struct vhost_blk { + struct task_struct *host_kick; + struct vhost_blk_req *reqs; + struct vhost_virtqueue vq; + struct llist_head llhead; + struct vhost_dev dev; + u16 reqs_nr; + int index; +}; + +static inline int iov_num_pages(struct iovec *iov) +{ +
Re: [PATCH] virt: Repairs Migration_multi_host_fd test Pylint correction.
On 10/11/2012 09:30 AM, Jiří Župka wrote: Pylint correction makes migration_multi_host_fd test dysfunctional. Ops, I'm sorry about that, applied! pull-request: https://github.com/autotest/virt-test/pull/55 Signed-off-by: Jiří Župka jzu...@redhat.com --- kvm/tests/migration_multi_host_fd.py |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kvm/tests/migration_multi_host_fd.py b/kvm/tests/migration_multi_host_fd.py index ec9210a..7f08205 100644 --- a/kvm/tests/migration_multi_host_fd.py +++ b/kvm/tests/migration_multi_host_fd.py @@ -105,7 +105,7 @@ def run_migration_multi_host_fd(test, params, env): s = self._create_server(mig_port) try: conn, _ = s.accept() -fd = s.fileno() +fd = conn.fileno() logging.debug(File descrtiptor %d used for migration. % (fd)) -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] KVM: MMU: fix release noslot pfn
On 10/10/2012 11:11 PM, Marcelo Tosatti wrote: Why does is_error_pfn() return true for mmio spte? Its not an error, after all. Please kill is_invalid_pfn and use - is_error_pfn for checking for errors (mmio spte is not an error pfn, its a special pfn) - add explicit is_noslot_pfn checks where necessary in the code (say to avoid interpreting a noslot_pfn's pfn address bits). (should have noticed this earlier, sorry). Never mind, your comments are always appreciated! ;) Marcelo, is it good to you? (will post it after your check and full test) diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c index 837f13e..3a4d967 100644 --- a/arch/powerpc/kvm/book3s_32_mmu_host.c +++ b/arch/powerpc/kvm/book3s_32_mmu_host.c @@ -155,7 +155,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) /* Get host physical address for gpa */ hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte-raddr PAGE_SHIFT); - if (is_error_pfn(hpaddr)) { + if (is_error_noslot_pfn(hpaddr)) { printk(KERN_INFO Couldn't get guest page for gfn %lx!\n, orig_pte-eaddr); r = -EINVAL; diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c index 0688b6b..6c230a2 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c @@ -92,7 +92,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) /* Get host physical address for gpa */ hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte-raddr PAGE_SHIFT); - if (is_error_pfn(hpaddr)) { + if (is_error_noslot_pfn(hpaddr)) { printk(KERN_INFO Couldn't get guest page for gfn %lx!\n, orig_pte-eaddr); r = -EINVAL; goto out; diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index ff38b66..4b47eeb 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -521,7 +521,7 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, if (likely(!pfnmap)) { unsigned long tsize_pages = 1 (tsize + 10 - PAGE_SHIFT); pfn = gfn_to_pfn_memslot(slot, gfn); - if (is_error_pfn(pfn)) { + if (is_error_noslot_pfn(pfn)) { printk(KERN_ERR Couldn't get real page for gfn %lx!\n, (long)gfn); return; diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 56c0e39..54c3557 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2699,7 +2699,7 @@ static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu, * PT_PAGE_TABLE_LEVEL and there would be no adjustment done * here. */ - if (!is_error_pfn(pfn) !kvm_is_mmio_pfn(pfn) + if (!is_error_noslot_pfn(pfn) !kvm_is_mmio_pfn(pfn) level == PT_PAGE_TABLE_LEVEL PageTransCompound(pfn_to_page(pfn)) !has_wrprotected_page(vcpu-kvm, gfn, PT_DIRECTORY_LEVEL)) { @@ -2733,7 +2733,7 @@ static bool handle_abnormal_pfn(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, bool ret = true; /* The pfn is invalid, report the error! */ - if (unlikely(is_invalid_pfn(pfn))) { + if (unlikely(is_error_pfn(pfn))) { *ret_val = kvm_handle_bad_page(vcpu, gfn, pfn); goto exit; } diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c index daff69e..7709a75 100644 --- a/arch/x86/kvm/mmu_audit.c +++ b/arch/x86/kvm/mmu_audit.c @@ -116,7 +116,7 @@ static void audit_mappings(struct kvm_vcpu *vcpu, u64 *sptep, int level) gfn = kvm_mmu_page_get_gfn(sp, sptep - sp-spt); pfn = gfn_to_pfn_atomic(vcpu-kvm, gfn); - if (is_error_pfn(pfn)) + if (is_error_noslot_pfn(pfn)) return; hpa = pfn PAGE_SHIFT; diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index f887e4c..89f3241 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -323,7 +323,7 @@ FNAME(prefetch_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, protect_clean_gpte(pte_access, gpte); pfn = pte_prefetch_gfn_to_pfn(vcpu, gfn, no_dirty_log (pte_access ACC_WRITE_MASK)); - if (is_invalid_pfn(pfn)) + if (is_error_pfn(pfn)) return false; /* diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1eefebe..91f8f71 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4502,7 +4502,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva) * instruction - ... */ pfn = gfn_to_pfn(vcpu-kvm, gpa_to_gfn(gpa)); - if (!is_error_pfn(pfn)) { + if (!is_error_noslot_pfn(pfn)) { kvm_release_pfn_clean(pfn); return true;
Re: [PATCH v4 5/5] KVM: MMU: introduce FNAME(prefetch_gpte)
On 10/10/2012 11:21 PM, Marcelo Tosatti wrote: pgprintk(%s: gpte %llx spte %p\n, __func__, (u64)gpte, spte); + +gfn = gpte_to_gfn(gpte); pte_access = sp-role.access gpte_access(vcpu, gpte); protect_clean_gpte(pte_access, gpte); -pfn = gfn_to_pfn_atomic(vcpu-kvm, gpte_to_gfn(gpte)); +pfn = pte_prefetch_gfn_to_pfn(vcpu, gfn, +no_dirty_log (pte_access ACC_WRITE_MASK)); Is this a bugfix? No. It is a cleanup. Actually, pte_prefetch_gfn_to_pfn(vcpu, gfn, false) is the same as gfn_to_pfn_atomic -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] KVM: MMU: fix release noslot pfn
On Thu, Oct 11, 2012 at 09:06:12PM +0800, Xiao Guangrong wrote: On 10/10/2012 11:11 PM, Marcelo Tosatti wrote: Why does is_error_pfn() return true for mmio spte? Its not an error, after all. Please kill is_invalid_pfn and use - is_error_pfn for checking for errors (mmio spte is not an error pfn, its a special pfn) - add explicit is_noslot_pfn checks where necessary in the code (say to avoid interpreting a noslot_pfn's pfn address bits). (should have noticed this earlier, sorry). Never mind, your comments are always appreciated! ;) Marcelo, is it good to you? (will post it after your check and full test) Yes, this works (please check the validity of each case in addition to testing, haven't done it). Also add a oneline comment on top of each is_error_pfn,is_noslot_pfn,is_error_noslot_pfn /* is_noslot_pfn: userspace translation valid but no memory slot */ /* is_error_pfn: ... */ etc. Thanks. diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c index 837f13e..3a4d967 100644 --- a/arch/powerpc/kvm/book3s_32_mmu_host.c +++ b/arch/powerpc/kvm/book3s_32_mmu_host.c @@ -155,7 +155,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) /* Get host physical address for gpa */ hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte-raddr PAGE_SHIFT); - if (is_error_pfn(hpaddr)) { + if (is_error_noslot_pfn(hpaddr)) { printk(KERN_INFO Couldn't get guest page for gfn %lx!\n, orig_pte-eaddr); r = -EINVAL; diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c index 0688b6b..6c230a2 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/arch/powerpc/kvm/book3s_64_mmu_host.c @@ -92,7 +92,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) /* Get host physical address for gpa */ hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte-raddr PAGE_SHIFT); - if (is_error_pfn(hpaddr)) { + if (is_error_noslot_pfn(hpaddr)) { printk(KERN_INFO Couldn't get guest page for gfn %lx!\n, orig_pte-eaddr); r = -EINVAL; goto out; diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index ff38b66..4b47eeb 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -521,7 +521,7 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, if (likely(!pfnmap)) { unsigned long tsize_pages = 1 (tsize + 10 - PAGE_SHIFT); pfn = gfn_to_pfn_memslot(slot, gfn); - if (is_error_pfn(pfn)) { + if (is_error_noslot_pfn(pfn)) { printk(KERN_ERR Couldn't get real page for gfn %lx!\n, (long)gfn); return; diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 56c0e39..54c3557 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2699,7 +2699,7 @@ static void transparent_hugepage_adjust(struct kvm_vcpu *vcpu, * PT_PAGE_TABLE_LEVEL and there would be no adjustment done * here. */ - if (!is_error_pfn(pfn) !kvm_is_mmio_pfn(pfn) + if (!is_error_noslot_pfn(pfn) !kvm_is_mmio_pfn(pfn) level == PT_PAGE_TABLE_LEVEL PageTransCompound(pfn_to_page(pfn)) !has_wrprotected_page(vcpu-kvm, gfn, PT_DIRECTORY_LEVEL)) { @@ -2733,7 +2733,7 @@ static bool handle_abnormal_pfn(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, bool ret = true; /* The pfn is invalid, report the error! */ - if (unlikely(is_invalid_pfn(pfn))) { + if (unlikely(is_error_pfn(pfn))) { *ret_val = kvm_handle_bad_page(vcpu, gfn, pfn); goto exit; } diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c index daff69e..7709a75 100644 --- a/arch/x86/kvm/mmu_audit.c +++ b/arch/x86/kvm/mmu_audit.c @@ -116,7 +116,7 @@ static void audit_mappings(struct kvm_vcpu *vcpu, u64 *sptep, int level) gfn = kvm_mmu_page_get_gfn(sp, sptep - sp-spt); pfn = gfn_to_pfn_atomic(vcpu-kvm, gfn); - if (is_error_pfn(pfn)) + if (is_error_noslot_pfn(pfn)) return; hpa = pfn PAGE_SHIFT; diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index f887e4c..89f3241 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -323,7 +323,7 @@ FNAME(prefetch_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, protect_clean_gpte(pte_access, gpte); pfn = pte_prefetch_gfn_to_pfn(vcpu, gfn, no_dirty_log (pte_access ACC_WRITE_MASK)); - if (is_invalid_pfn(pfn)) + if (is_error_pfn(pfn)) return false; /* diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1eefebe..91f8f71 100644 ---
Configuring virtual ethernet interfaces on KVM guests?
Dear KVM Subscribers: I am new to this list and to KVM, so please bear with me. I'm in search of documentation on how to configure virtual ethernet interfaces on guest VMs. In a CentOS 6.3 environment, after successfully installing my first KVM host machine, I've configured the following virtual ethernet interfaces on a guest VM to accommodate ip-based virtual hosts in Apache: eth0 = private IP A eth0:1 = private IP B eth0:2 = private IP C These private IPs are NATed at the firewall. Everything was working fine until my host was rebooted and I lost connectivity to the guest's three interfaces. I've read elsewhere that NetworkManager doesn't work well with KVM on the host, so I've stopped and disabled it in favor of network on the guest, too. Now, with NetworkManager out of the picture on the guest, a reboot no longer overwrites resolv.conf, as has been documented elsewhere. However, to get the guest's three interfaces back, I've found that I need to clear the guest's iptable cache, which isn't much of a solution. In retrospect, I'm wondering if I should switch to named-based virtual hosts in Apache and forget configuring virtual ethernet interfaces on a guest VM because it's not workable. Thanks, in advance, for your recommendations and patience. Mark Ferguson Systems Administrator Colorado State Library 7400 East Arapahoe Road, Suite 75 Centennial, CO 80112 303-422-1150, ext. 108 303-431-9752 (fax) -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/12] KVM: PPC: Mask ea's high 32-bits in 32/64 instr emulation
Mask high 32 bits of effective address in emulation layer for guests running in 32-bit mode. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: added BOOK3S implementation. arch/powerpc/include/asm/kvm_ppc.h | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index a08e756..4a3fdbd 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -296,11 +296,21 @@ static inline void kvmppc_lazy_ee_enable(void) static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb) { ulong ea; + ulong msr_64bit = 0; ea = kvmppc_get_gpr(vcpu, rb); if (ra) ea += kvmppc_get_gpr(vcpu, ra); +#if defined(CONFIG_PPC_BOOK3E_64) + msr_64bit = MSR_CM; +#elif defined(CONFIG_PPC_BOOK3S_64) + msr_64bit = MSR_SF; +#endif + + if (!(vcpu-arch.shared-msr msr_64bit)) + ea = (uint32_t)ea; + return ea; } -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 00/12] KVM: PPC: 64-bit Book3E arch support
This patchset adds arch support to KVM for 64-bit Book3E PowerPC procesosrs with Embedded.Hypervisor category. The support is limited to the bolted TLB miss exception handlers version and was validated on Freescale's e5500 cores using P5020DS boards. This patchset is based on Alex G. kvm-ppc-next branch with the following core prerequisites: The changes since commit 8b7b80b9ebb46dd88fbb94e918297295cf312b59: powerpc: Uprobes port to powerpc up to commit 8b64a9dfb091f1eca8b7e58da82f1e7d1d5fe0ad: powerpc/booke64: Use SPRG0/3 scratch for bolted TLB miss crit int and the changes since commit d0832a75075b1119635e0f48549e378040cf5e67: powerpc/85xx: add HOTPLUG_CPU support up to commit 39be5b4a7f232870aad0b3c130791eacd0d34347: powerpc/booke: Add CPU_FTR_EMB_HV check for e5500. available in the git repository git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git Mihai Caraman (12): KVM: PPC: e500: Silence bogus GCC warning in tlb code KVM: PPC: booke: Fix get_tb() compile error on 64-bit KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler KVM: PPC64: bookehv: Add support for interrupt handling KVM: PPC: Add emulation helper for getting instruction ea KVM: PPC: Mask ea's high 32-bits in 32/64 instr emulation KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit KVM: PPC: bookehv: Add guest computation mode for irq delivery KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation KVM: PPC: booke: Add EPCR support in sregs KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface Documentation/virtual/kvm/api.txt |1 + arch/powerpc/include/asm/kvm.h |2 + arch/powerpc/include/asm/kvm_booke_hv_asm.h | 25 + arch/powerpc/include/asm/kvm_ppc.h | 21 arch/powerpc/include/asm/mmu-book3e.h |2 +- arch/powerpc/kvm/booke.c| 43 - arch/powerpc/kvm/booke.h|1 + arch/powerpc/kvm/booke_emulate.c| 12 ++- arch/powerpc/kvm/bookehv_interrupts.S | 145 --- arch/powerpc/kvm/e500.h |8 +- arch/powerpc/kvm/e500_emulate.c | 15 ++- arch/powerpc/kvm/e500_tlb.c | 38 +++ 12 files changed, 265 insertions(+), 48 deletions(-) -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/12] KVM: PPC: booke: Fix get_tb() compile error on 64-bit
Include header file for get_tb() declaration. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/booke.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 3d1f35d..7c9c389 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -36,6 +36,7 @@ #include asm/dbell.h #include asm/hw_irq.h #include asm/irq.h +#include asm/time.h #include timing.h #include booke.h -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07/12] KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation
Mask high 32 bits of MAS2's effective page number in tlbwe emulation for guests running in 32-bit mode. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: patch splited. arch/powerpc/kvm/e500_tlb.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index b5a188a..6c0997e 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -871,6 +871,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) gtlbe-mas1 = vcpu-arch.shared-mas1; gtlbe-mas2 = vcpu-arch.shared-mas2; + if (!(vcpu-arch.shared-msr MSR_CM)) + gtlbe-mas2 = 0xUL; gtlbe-mas7_3 = vcpu-arch.shared-mas7_3; trace_kvm_booke206_gtlb_write(vcpu-arch.shared-mas0, gtlbe-mas1, -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery
When delivering guest IRQs, update MSR computation mode according to guest interrupt computation mode found in EPCR. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: added intermediate msr variable. arch/powerpc/kvm/booke.c |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 7c9c389..86f0d0d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -312,6 +312,7 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu, bool crit; bool keep_irq = false; enum int_class int_class; + ulong new_msr = vcpu-arch.shared-msr; /* Truncate crit indicators in 32 bit mode */ if (!(vcpu-arch.shared-msr MSR_SF)) { @@ -407,7 +408,13 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu, set_guest_esr(vcpu, vcpu-arch.queued_esr); if (update_dear == true) set_guest_dear(vcpu, vcpu-arch.queued_dear); - kvmppc_set_msr(vcpu, vcpu-arch.shared-msr msr_mask); + + new_msr = msr_mask; +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + if (vcpu-arch.epcr SPRN_EPCR_ICM) + new_msr |= MSR_CM; +#endif + kvmppc_set_msr(vcpu, new_msr); if (!keep_irq) clear_bit(priority, vcpu-arch.pending_exceptions); -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 04/12] KVM: PPC64: bookehv: Add support for interrupt handling
Add interrupt handling support for 64-bit bookehv hosts. Unify 32 and 64 bit implementations using a common stack layout and a common execution flow starting from kvm_handler_common macro. Update documentation for 64-bit input register values. This patch only address the bolted TLB miss exception handlers version. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: updated CRIT and TLB exception handling following core side changes. arch/powerpc/include/asm/kvm_booke_hv_asm.h | 25 + arch/powerpc/kvm/bookehv_interrupts.S | 138 +-- 2 files changed, 155 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_booke_hv_asm.h b/arch/powerpc/include/asm/kvm_booke_hv_asm.h index a37a12a..7ad5af7 100644 --- a/arch/powerpc/include/asm/kvm_booke_hv_asm.h +++ b/arch/powerpc/include/asm/kvm_booke_hv_asm.h @@ -17,6 +17,7 @@ * there are no exceptions for which we fall through directly to * the normal host handler. * + * 32-bit host * Expected inputs (normal exceptions): * SCRATCH0 = saved r10 * r10 = thread struct @@ -33,6 +34,30 @@ * *(r8 + GPR9) = saved r9 * *(r8 + GPR10) = saved r10 (r10 not yet clobbered) * *(r8 + GPR11) = saved r11 + * + * 64-bit host + * Expected inputs (GEN/GDBELL/DBG/MC exception types): + * r10 = saved CR + * r13 = PACA_POINTER + * *(r13 + PACA_EX##type + EX_R10) = saved r10 + * *(r13 + PACA_EX##type + EX_R11) = saved r11 + * SPRN_SPRG_##type##_SCRATCH = saved r13 + * + * Expected inputs (CRIT exception type): + * r10 = saved CR + * r13 = PACA_POINTER + * *(r13 + PACA_EX##type + EX_R10) = saved r10 + * *(r13 + PACA_EX##type + EX_R11) = saved r11 + * *(r13 + PACA_EX##type + EX_R13) = saved r13 + * + * Expected inputs (TLB exception type): + * r10 = saved CR + * r13 = PACA_POINTER + * *(r13 + PACA_EX##type + EX_TLB_R10) = saved r10 + * *(r13 + PACA_EX##type + EX_TLB_R11) = saved r11 + * SPRN_SPRG_GEN_SCRATCH = saved r13 + * + * Only the bolted version of TLB miss exception handlers is supported now. */ .macro DO_KVM intno srr1 #ifdef CONFIG_KVM_BOOKE_HV diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S index fa6d552..e8ed7d6 100644 --- a/arch/powerpc/kvm/bookehv_interrupts.S +++ b/arch/powerpc/kvm/bookehv_interrupts.S @@ -16,6 +16,7 @@ * * Author: Varun Sethi varun.se...@freescale.com * Author: Scott Wood scotw...@freescale.com + * Author: Mihai Caraman mihai.cara...@freescale.com * * This file is derived from arch/powerpc/kvm/booke_interrupts.S */ @@ -30,28 +31,33 @@ #include asm/bitsperlong.h #include asm/thread_info.h +#ifdef CONFIG_64BIT +#include asm/exception-64e.h +#else #include ../kernel/head_booke.h /* for THREAD_NORMSAVE() */ +#endif #define LONGBYTES (BITS_PER_LONG / 8) #define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES)) /* The host stack layout: */ -#define HOST_R1 (0 * LONGBYTES) /* Implied by stwu. */ -#define HOST_CALLEE_LR (1 * LONGBYTES) -#define HOST_RUN(2 * LONGBYTES) /* struct kvm_run */ +#define HOST_R1 0 /* Implied by stwu. */ +#define HOST_CALLEE_LR PPC_LR_STKOFF +#define HOST_RUN(HOST_CALLEE_LR + LONGBYTES) /* * r2 is special: it holds 'current', and it made nonvolatile in the * kernel with the -ffixed-r2 gcc option. */ -#define HOST_R2 (3 * LONGBYTES) -#define HOST_CR (4 * LONGBYTES) -#define HOST_NV_GPRS(5 * LONGBYTES) +#define HOST_R2 (HOST_RUN + LONGBYTES) +#define HOST_CR (HOST_R2 + LONGBYTES) +#define HOST_NV_GPRS(HOST_CR + LONGBYTES) #define __HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES)) #define HOST_NV_GPR(n) __HOST_NV_GPR(__REG_##n) #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + LONGBYTES) #define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) ~15) /* Align. */ -#define HOST_STACK_LR (HOST_STACK_SIZE + LONGBYTES) /* In caller stack frame. */ +/* LR in caller stack frame. */ +#define HOST_STACK_LR (HOST_STACK_SIZE + PPC_LR_STKOFF) #define NEED_EMU 0x0001 /* emulation -- save nv regs */ #define NEED_DEAR 0x0002 /* save faulting DEAR */ @@ -198,6 +204,122 @@ b kvmppc_resume_host .endm +#ifdef CONFIG_64BIT +/* Exception types */ +#define EX_GEN 1 +#define EX_GDBELL 2 +#define EX_DBG 3 +#define EX_MC 4 +#define EX_CRIT5 +#define EX_TLB 6 + +/* + * For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h + */ +.macro kvm_handler intno type scratch, paca_ex, ex_r10, ex_r11, srr0, srr1, flags + _GLOBAL(kvmppc_handler_\intno\()_\srr1) + mr r11, r4 + /* +* Get vcpu from Paca: paca-__current.thread-kvm_vcpu +*/ + PPC_LL r4, PACACURRENT(r13) + PPC_LL r4, (THREAD + THREAD_KVM_VCPU)(r4) + stw r10, VCPU_CR(r4) + PPC_STL r11,
[PATCH 01/12] KVM: PPC: e500: Silence bogus GCC warning in tlb code
64-bit GCC 4.5.1 warns about an uninitialized variable which was guarded by a flag. Initialize the variable to make it happy. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/e500_tlb.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index c733894..23b3de6 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -415,7 +415,8 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, struct tlbe_ref *ref) { struct kvm_memory_slot *slot; - unsigned long pfn, hva; + unsigned long pfn = 0; /* shut up 64-bit GCC */ + unsigned long hva; int pfnmap = 0; int tsize = BOOK3E_PAGESZ_4K; -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/12] KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler
GET_VCPU define will not be implemented for 64-bit for performance reasons so get rid of it also on 32-bit. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/bookehv_interrupts.S |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S index 099fe82..fa6d552 100644 --- a/arch/powerpc/kvm/bookehv_interrupts.S +++ b/arch/powerpc/kvm/bookehv_interrupts.S @@ -32,9 +32,6 @@ #include ../kernel/head_booke.h /* for THREAD_NORMSAVE() */ -#define GET_VCPU(vcpu, thread) \ - PPC_LL vcpu, THREAD_KVM_VCPU(thread) - #define LONGBYTES (BITS_PER_LONG / 8) #define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES)) @@ -206,7 +203,7 @@ */ .macro kvm_handler intno srr0, srr1, flags _GLOBAL(kvmppc_handler_\intno\()_\srr1) - GET_VCPU(r11, r10) + PPC_LL r11, THREAD_KVM_VCPU(r10) PPC_STL r3, VCPU_GPR(R3)(r11) mfspr r3, SPRN_SPRG_RSCRATCH0 PPC_STL r4, VCPU_GPR(R4)(r11) @@ -233,7 +230,7 @@ _GLOBAL(kvmppc_handler_\intno\()_\srr1) .macro kvm_lvl_handler intno scratch srr0, srr1, flags _GLOBAL(kvmppc_handler_\intno\()_\srr1) mfspr r10, SPRN_SPRG_THREAD - GET_VCPU(r11, r10) + PPC_LL r11, THREAD_KVM_VCPU(r10) PPC_STL r3, VCPU_GPR(R3)(r11) mfspr r3, \scratch PPC_STL r4, VCPU_GPR(R4)(r11) -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs
Add KVM_SREGS_E_64 feature and EPCR spr support in get/set sregs for 64-bit hosts. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/booke.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index e6159f5..d396374 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1215,6 +1215,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu, u64 tb = get_tb(); sregs-u.e.features |= KVM_SREGS_E_BASE; +#ifdef CONFIG_64BIT + sregs-u.e.features |= KVM_SREGS_E_64; +#endif sregs-u.e.csrr0 = vcpu-arch.csrr0; sregs-u.e.csrr1 = vcpu-arch.csrr1; @@ -1226,6 +1229,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu, sregs-u.e.dec = kvmppc_get_dec(vcpu, tb); sregs-u.e.tb = tb; sregs-u.e.vrsave = vcpu-arch.vrsave; +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + sregs-u.e.epcr = vcpu-arch.epcr; +#endif } static int set_sregs_base(struct kvm_vcpu *vcpu, @@ -1241,6 +1247,7 @@ static int set_sregs_base(struct kvm_vcpu *vcpu, set_guest_dear(vcpu, sregs-u.e.dear); vcpu-arch.vrsave = sregs-u.e.vrsave; kvmppc_set_tcr(vcpu, sregs-u.e.tcr); + kvmppc_set_epcr(vcpu, sregs-u.e.epcr); if (sregs-u.e.update_special KVM_SREGS_E_UPDATE_DEC) { vcpu-arch.dec = sregs-u.e.dec; -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 08/12] KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit
Extend MAS2 EPN mask to retain most significant bits on 64-bit hosts. Use this mask in tlb effective address accessor. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/include/asm/mmu-book3e.h |2 +- arch/powerpc/kvm/e500.h |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h index eeabcdb..99d43e0 100644 --- a/arch/powerpc/include/asm/mmu-book3e.h +++ b/arch/powerpc/include/asm/mmu-book3e.h @@ -59,7 +59,7 @@ #define MAS1_TSIZE_SHIFT 7 #define MAS1_TSIZE(x) (((x) MAS1_TSIZE_SHIFT) MAS1_TSIZE_MASK) -#define MAS2_EPN 0xF000 +#define MAS2_EPN (~0xFFFUL) #define MAS2_X00x0040 #define MAS2_X10x0020 #define MAS2_W 0x0010 diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h index 32e98a7..c70d37e 100644 --- a/arch/powerpc/kvm/e500.h +++ b/arch/powerpc/kvm/e500.h @@ -154,7 +154,7 @@ get_tlb_size(const struct kvm_book3e_206_tlb_entry *tlbe) static inline gva_t get_tlb_eaddr(const struct kvm_book3e_206_tlb_entry *tlbe) { - return tlbe-mas2 0xf000; + return tlbe-mas2 MAS2_EPN; } static inline u64 get_tlb_bytes(const struct kvm_book3e_206_tlb_entry *tlbe) -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/12] KVM: PPC: bookehv: Add EPCR support in mtspr/mfspr emulation
Add EPCR support in booke mtspr/mfspr emulation. EPCR register is defined only for 64-bit and HV categories, we will expose it at this point only to 64-bit virtual processors running on 64-bit HV hosts. Define a reusable setter function for vcpu's EPCR. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: extended guard defines with CONFIG_KVM_BOOKE_HV required by arch's epcr and shadow_epcr fields. arch/powerpc/kvm/booke.c | 10 ++ arch/powerpc/kvm/booke.h |1 + arch/powerpc/kvm/booke_emulate.c | 12 +++- 3 files changed, 22 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 86f0d0d..e6159f5 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1473,6 +1473,16 @@ void kvmppc_core_flush_memslot(struct kvm *kvm, struct kvm_memory_slot *memslot) { } +void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr) +{ +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + vcpu-arch.epcr = new_epcr; + vcpu-arch.shadow_epcr = ~SPRN_EPCR_GICM; + if (vcpu-arch.epcr SPRN_EPCR_ICM) + vcpu-arch.shadow_epcr |= SPRN_EPCR_GICM; +#endif +} + void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr) { vcpu-arch.tcr = new_tcr; diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h index ba61974..e9b88e4 100644 --- a/arch/powerpc/kvm/booke.h +++ b/arch/powerpc/kvm/booke.h @@ -69,6 +69,7 @@ extern unsigned long kvmppc_booke_handlers; void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr); void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr); +void kvmppc_set_epcr(struct kvm_vcpu *vcpu, u32 new_epcr); void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr); void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits); void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits); diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c index 514790f..8d9d8f9 100644 --- a/arch/powerpc/kvm/booke_emulate.c +++ b/arch/powerpc/kvm/booke_emulate.c @@ -240,7 +240,12 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val) case SPRN_MCSR: vcpu-arch.mcsr = ~spr_val; break; - +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + case SPRN_EPCR: + kvmppc_set_epcr(vcpu, spr_val); + mtspr(SPRN_EPCR, vcpu-arch.shadow_epcr); + break; +#endif default: emulated = EMULATE_FAIL; } @@ -335,6 +340,11 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val) case SPRN_MCSR: *spr_val = vcpu-arch.mcsr; break; +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + case SPRN_EPCR: + *spr_val = vcpu-arch.epcr; + break; +#endif default: emulated = EMULATE_FAIL; -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea
Add emulation helper for getting instruction ea and refactor tlb instruction emulation to use it. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: use _t_ype instead of _t_arget _r_egister in tlbilx emulation. arch/powerpc/include/asm/kvm_ppc.h | 11 +++ arch/powerpc/kvm/e500.h|6 +++--- arch/powerpc/kvm/e500_emulate.c| 15 ++- arch/powerpc/kvm/e500_tlb.c| 33 +++-- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 609cca3..a08e756 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -293,4 +293,15 @@ static inline void kvmppc_lazy_ee_enable(void) #endif } +static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb) +{ + ulong ea; + + ea = kvmppc_get_gpr(vcpu, rb); + if (ra) + ea += kvmppc_get_gpr(vcpu, ra); + + return ea; +} + #endif /* __POWERPC_KVM_PPC_H__ */ diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h index d162286..32e98a7 100644 --- a/arch/powerpc/kvm/e500.h +++ b/arch/powerpc/kvm/e500.h @@ -129,9 +129,9 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500, ulong value); int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu); int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu); -int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb); -int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, int rb); -int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb); +int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea); +int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int type, gva_t ea); +int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, gva_t ea); int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500); void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500); diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c index e04b0ef..3bf2486 100644 --- a/arch/powerpc/kvm/e500_emulate.c +++ b/arch/powerpc/kvm/e500_emulate.c @@ -88,7 +88,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, int emulated = EMULATE_DONE; int ra = get_ra(inst); int rb = get_rb(inst); - int rt = get_rt(inst); + gva_t ea; switch (get_op(inst)) { case 31: @@ -113,15 +113,20 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, break; case XOP_TLBSX: - emulated = kvmppc_e500_emul_tlbsx(vcpu,rb); + ea = kvmppc_get_ea_indexed(vcpu, ra, rb); + emulated = kvmppc_e500_emul_tlbsx(vcpu, ea); break; - case XOP_TLBILX: - emulated = kvmppc_e500_emul_tlbilx(vcpu, rt, ra, rb); + case XOP_TLBILX: { + int t = (inst 21) 0x3; + ea = kvmppc_get_ea_indexed(vcpu, ra, rb); + emulated = kvmppc_e500_emul_tlbilx(vcpu, t, ea); break; + } case XOP_TLBIVAX: - emulated = kvmppc_e500_emul_tlbivax(vcpu, ra, rb); + ea = kvmppc_get_ea_indexed(vcpu, ra, rb); + emulated = kvmppc_e500_emul_tlbivax(vcpu, ea); break; default: diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index 23b3de6..b5a188a 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -689,14 +689,11 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500, ulong value) return EMULATE_DONE; } -int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb) +int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea) { struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); unsigned int ia; int esel, tlbsel; - gva_t ea; - - ea = ((ra) ? kvmppc_get_gpr(vcpu, ra) : 0) + kvmppc_get_gpr(vcpu, rb); ia = (ea 2) 0x1; @@ -723,7 +720,7 @@ int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb) } static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel, - int pid, int rt) + int pid, int type) { struct kvm_book3e_206_tlb_entry *tlbe; int tid, esel; @@ -732,7 +729,7 @@ static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel, for (esel = 0; esel vcpu_e500-gtlb_params[tlbsel].entries; esel++) { tlbe = get_entry(vcpu_e500, tlbsel, esel); tid = get_tlb_tid(tlbe); - if (rt == 0 || tid == pid) { + if (type == 0 || tid == pid) { inval_gtlbe_on_host(vcpu_e500, tlbsel, esel);
[PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface
Implement ONE_REG interface for EPCR register adding KVM_REG_PPC_EPCR to the list of ONE_REG PPC supported registers. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- Documentation/virtual/kvm/api.txt |1 + arch/powerpc/include/asm/kvm.h|2 ++ arch/powerpc/kvm/booke.c | 16 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index e726d76..c78dff4 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -1773,6 +1773,7 @@ registers, find a list below: PPC | KVM_REG_PPC_VPA_ADDR | 64 PPC | KVM_REG_PPC_VPA_SLB | 128 PPC | KVM_REG_PPC_VPA_DTL | 128 + PPC | KVM_REG_PPC_EPCR | 32 4.69 KVM_GET_ONE_REG diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h index b89ae4d..beb6b20 100644 --- a/arch/powerpc/include/asm/kvm.h +++ b/arch/powerpc/include/asm/kvm.h @@ -386,4 +386,6 @@ struct kvm_book3e_206_tlb_params { #define KVM_REG_PPC_VPA_SLB(KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x83) #define KVM_REG_PPC_VPA_DTL(KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84) +#define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85) + #endif /* __LINUX_KVM_POWERPC_H */ diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index d396374..60b8237 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1395,6 +1395,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) vcpu-arch.dbg_reg.dac[dac], sizeof(u64)); break; } +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + case KVM_REG_PPC_EPCR: + r = copy_to_user((u32 __user *)(long)reg-addr, +vcpu-arch.epcr, sizeof(u32)); + break; +#endif default: break; } @@ -1422,6 +1428,16 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) (u64 __user *)(long)reg-addr, sizeof(u64)); break; } +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + case KVM_REG_PPC_EPCR: { + u32 new_epcr; + r = copy_from_user(new_epcr, +(u32 __user *)(long)reg-addr, sizeof(u32)); + if (r == 0) + kvmppc_set_epcr(vcpu, new_epcr); + break; + } +#endif default: break; } -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFC 1/2] kvm: Handle undercommitted guest case in PLE handler
On 10/11/2012 12:57 AM, Andrew Theurer wrote: On Wed, 2012-10-10 at 23:13 +0530, Raghavendra K T wrote: On 10/10/2012 07:54 PM, Andrew Theurer wrote: I ran 'perf sched map' on the dbench workload for medium and large VMs, and I thought I would share some of the results. I think it helps to visualize what's going on regarding the yielding. These files are png bitmaps, generated from processing output from 'perf sched map' (and perf data generated from 'perf sched record'). The Y axis is the host cpus, each row being 10 pixels high. For these tests, there are 80 host cpus, so the total height is 800 pixels. The X axis is time (in microseconds), with each pixel representing 1 microsecond. Each bitmap plots 30,000 microseconds. The bitmaps are quite wide obviously, and zooming in/out while viewing is recommended. Each row (each host cpu) is assigned a color based on what thread is running. vCPUs of the same VM are assigned a common color (like red, blue, magenta, etc), and each vCPU has a unique brightness for that color. There are a maximum of 12 assignable colors, so in any VMs 12 revert to vCPU color of gray. I would use more colors, but it becomes harder to distinguish one color from another. The white color represents missing data from perf, and black color represents any thread which is not a vCPU. For the following tests, VMs were pinned to host NUMA nodes and to specific cpus to help with consistency and operate within the constraints of the last test (gang scheduler). Here is a good example of PLE. These are 10-way VMs, 16 of them (as described above only 12 of the VMs have a color, rest are gray). https://docs.google.com/open?id=0B6tfUNlZ-14wdmFqUmE5QjJHMFU This looks very nice to visualize what is happening. Beginning of the graph looks little messy but later it is clear. If you zoom out and look at the whole bitmap, you may notice the 4ms intervals of the scheduler. They are pretty well aligned across all cpus. Normally, for cpu bound workloads, we would expect to see each thread to run for 4 ms, then something else getting to run, and so on. That is mostly true in this test. We have 2x over-commit and we generally see the switching of threads at 4ms. One thing to note is that not all vCPU threads for the same VM run at exactly the same time, and that is expected and the whole reason for lock-holder preemption. Now, if you zoom in on the bitmap, you should notice within the 4ms intervals there is some task switching going on. This is most likely because of the yield_to initiated by the PLE handler. In this case there is not that much yielding to do. It's quite clean, and the performance is quite good. Below is an example of PLE, but this time with 20-way VMs, 8 of them. CPU over-commit is still 2x. https://docs.google.com/open?id=0B6tfUNlZ-14wdmFqUmE5QjJHMFU I think this link still 10x16. Could you paste the link again? Oops https://docs.google.com/open?id=0B6tfUNlZ-14wSGtYYzZtRTcyVjQ This one looks quite different. In short, it's a mess. The switching between tasks can be lower than 10 microseconds. It basically never recovers. There is constant yielding all the time. Below is again 8 x 20-way VMs, but this time I tried out Nikunj's gang scheduling patches. While I am not recommending gang scheduling, I think it's a good data point. The performance is 3.88x the PLE result. https://docs.google.com/open?id=0B6tfUNlZ-14wWXdscWcwNTVEY3M Yes.. we see lot of yields. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] KVM: Add KVM_VCPU_GET_REG_LIST/KVM_CAP_REG_LIST.
Marcelo Tosatti mtosa...@redhat.com writes: On Wed, Sep 05, 2012 at 05:28:46PM +0930, Rusty Russell wrote: ... +struct kvm_reg_list { +__u64 n; /* number of registers in reg[] */ +__u64 reg[0]; +}; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 169a001..453fe93 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2082,6 +2082,23 @@ out_free2: break; } #endif +#ifdef KVM_HAVE_REG_LIST +case KVM_VCPU_GET_REG_LIST: { +struct kvm_reg_list __user *user_list = argp; +struct kvm_reg_list reg_list; +unsigned n; + +if (copy_from_user(reg_list, user_list, sizeof reg_list)) +return -EFAULT; +n = reg_list.n; +reg_list.n = kvm_arch_num_regs(vcpu); The code does not actually support more than 2^32 registers, does it? Why __u64 n ? Well, the interface is simpler, and the alignment issues vanish. kvm_arch_num_regs could return a 64-bit number in future if we want to get completely insane :) Cheers, Rusty. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 03/16] target-i386: Add cpu object access routines for Hypervisor level.
On 10/10/12 11:40, Andreas Färber wrote: Am 10.10.2012 17:22, schrieb Don Slutz: On 10/09/12 15:13, Don Slutz wrote: On 10/09/12 12:25, Marcelo Tosatti wrote: On Mon, Sep 24, 2012 at 10:32:05AM -0400, Don Slutz wrote: +static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque, +const char *name, Error **errp) +{ +X86CPU *cpu = X86_CPU(obj); +uint32_t value; + +visit_type_uint32(v, value, name, errp); +if (error_is_set(errp)) { +return; +} + +if (value != 0 value 0x4000) { +value += 0x4000; +} Whats the purpose of this? Adds ambiguity. [...] This is direct copy with adjustment from x86_cpuid_set_xlevel(): if (value 0x8000) { value += 0x8000; } (Pending patch: http://comments.gmane.org/gmane.comp.emulators.qemu/172703 adds this) (Any pending patch can be changed ;)) The adjustment is that 0 is a legal value. See http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html This does mean that just like xlevel=1 and xlevel=0x8001 are the same; hypervisor-level=1 and hypervisor-level=0x401 are the same. If this is not wanted, I have no issue with removing it. I have no strong opinion either way, but if there's only one call site, I'd prefer to apply these fixups to user input before setting the property and to have the property setter error out on invalid values. I consider that cleaner than silently fixing up values inside the setter. Regards, Andreas I find more then one call site. And one of them is converting the predefined x86 cpus (like 486). So I am not planning on a change. I have finished up the v7 changes except for this. I will wait until some time tomorrow to send it in case there is more on this topic. -Don Slutz -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] kvm tools: fix help output for run command
This dummy patch remove tabs in help output. Introduced in commit: ae9ec23 kvm tools: generate command line options dynamically Signed-off-by: William Dauchy wdau...@gmail.com --- tools/kvm/builtin-run.c | 32 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index 1b046dc..50495a3 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -96,34 +96,34 @@ void kvm_run_set_wrapper_sandbox(void) OPT_STRING('\0', name, (cfg)-guest_name, guest name, \ A name for the guest),\ OPT_INTEGER('c', cpus, (cfg)-nrcpus, Number of CPUs), \ - OPT_U64('m', mem, (cfg)-ram_size, Virtual machine memory size\ - in MiB.), \ + OPT_U64('m', mem, (cfg)-ram_size, Virtual machine memory \ +size in MiB.), \ OPT_CALLBACK('\0', shmem, NULL, \ [pci:]addr:size[:handle=handle][:create], \ Share host shmem with guest via pci device, \ shmem_parser, NULL), \ - OPT_CALLBACK('d', disk, kvm, image or rootfs_dir, Disk \ - image or rootfs directory, img_name_parser,\ + OPT_CALLBACK('d', disk, kvm, image or rootfs_dir, Disk\ +image or rootfs directory, img_name_parser, \ kvm), \ - OPT_BOOLEAN('\0', balloon, (cfg)-balloon, Enable virtio\ - balloon), \ + OPT_BOOLEAN('\0', balloon, (cfg)-balloon, Enable virtio \ +balloon),\ OPT_BOOLEAN('\0', vnc, (cfg)-vnc, Enable VNC framebuffer),\ OPT_BOOLEAN('\0', sdl, (cfg)-sdl, Enable SDL framebuffer),\ - OPT_BOOLEAN('\0', rng, (cfg)-virtio_rng, Enable virtio Random\ - Number Generator), \ + OPT_BOOLEAN('\0', rng, (cfg)-virtio_rng, Enable virtio\ +Random Number Generator),\ OPT_CALLBACK('\0', 9p, NULL, dir_to_share,tag_name, \ -Enable virtio 9p to share files between host and \ -guest, virtio_9p_rootdir_parser, kvm),\ - OPT_STRING('\0', console, (cfg)-console, serial, virtio or \ - hv, Console to use), \ +Enable virtio 9p to share files between host and \ + guest, virtio_9p_rootdir_parser, kvm), \ + OPT_STRING('\0', console, (cfg)-console, serial, virtio or\ +hv, Console to use), \ OPT_STRING('\0', dev, (cfg)-dev, device_file, \ KVM device file), \ OPT_CALLBACK('\0', tty, NULL, tty id, \ Remap guest TTY into a pty on the host, \ tty_parser, NULL), \ OPT_STRING('\0', sandbox, (cfg)-sandbox, script, \ - Run this script when booting into custom \ - rootfs), \ + Run this script when booting into custom \ +rootfs), \ OPT_STRING('\0', hugetlbfs, (cfg)-hugetlbfs_path, path, \ Hugetlbfs path), \ \ @@ -141,8 +141,8 @@ void kvm_run_set_wrapper_sandbox(void) OPT_CALLBACK_DEFAULT('n', network, NULL, network params,\ Create a new guest NIC, \ netdev_parser, NULL, kvm), \ - OPT_BOOLEAN('\0', no-dhcp, (cfg)-no_dhcp, Disable kernel DHCP\ - in rootfs mode), \ + OPT_BOOLEAN('\0', no-dhcp, (cfg)-no_dhcp, Disable kernel \ +DHCP in rootfs mode),\ \ OPT_GROUP(BIOS options:), \ OPT_INTEGER('\0', vidmode, (cfg)-vidmode, \ -- 1.7.10.4 -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] kvm/ftrace: change the diplaying format of vector in trace_msi_set_irq
This patch changes the way to diplay the vector in trace_msi_set_irq from %x to %u. Currently, it mismatches another output of ftrace such as kvm_msi_set_irq and kvm_inj_virq which uses %u. Signed-off-by: Koki Sanagi sanagi.k...@jp.fujitsu.com --- include/trace/events/kvm.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/trace/events/kvm.h b/include/trace/events/kvm.h index 7ef9e75..0a83632 100644 --- a/include/trace/events/kvm.h +++ b/include/trace/events/kvm.h @@ -109,7 +109,7 @@ TRACE_EVENT(kvm_msi_set_irq, __entry-data = data; ), - TP_printk(dst %u vec %x (%s|%s|%s%s), + TP_printk(dst %u vec %u (%s|%s|%s%s), (u8)(__entry-address 12), (u8)__entry-data, __print_symbolic((__entry-data 8 0x7), kvm_deliver_mode), (__entry-address (12)) ? logical : physical, N�r��yb�X��ǧv�^�){.n�+h����ܨ}���Ơz�j:+v���zZ+��+zf���h���~i���z��w���?��)ߢf
[PATCH qom-cpu v2 4/7] cpus: Pass CPUState to qemu_cpu_is_self()
Change return type to bool, move to include/qemu/cpu.h and add documentation. Signed-off-by: Andreas Färber afaer...@suse.de --- cpus.c | 10 -- exec.c |3 ++- hw/apic.c |6 -- include/qemu/cpu.h | 10 ++ kvm-all.c |4 +++- qemu-common.h |1 - target-i386/kvm.c |6 -- 7 Dateien geändert, 27 Zeilen hinzugefügt(+), 13 Zeilen entfernt(-) diff --git a/cpus.c b/cpus.c index 750a76f..849ea8a 100644 --- a/cpus.c +++ b/cpus.c @@ -638,9 +638,10 @@ void qemu_init_cpu_loop(void) void run_on_cpu(CPUArchState *env, void (*func)(void *data), void *data) { +CPUState *cpu = ENV_GET_CPU(env); struct qemu_work_item wi; -if (qemu_cpu_is_self(env)) { +if (qemu_cpu_is_self(cpu)) { func(data); return; } @@ -855,7 +856,7 @@ static void qemu_cpu_kick_thread(CPUArchState *env) exit(1); } #else /* _WIN32 */ -if (!qemu_cpu_is_self(env)) { +if (!qemu_cpu_is_self(cpu)) { SuspendThread(cpu-hThread); cpu_signal(0); ResumeThread(cpu-hThread); @@ -890,11 +891,8 @@ void qemu_cpu_kick_self(void) #endif } -int qemu_cpu_is_self(void *_env) +bool qemu_cpu_is_self(CPUState *cpu) { -CPUArchState *env = _env; -CPUState *cpu = ENV_GET_CPU(env); - return qemu_thread_is_self(cpu-thread); } diff --git a/exec.c b/exec.c index 7899042..e21be32 100644 --- a/exec.c +++ b/exec.c @@ -1685,6 +1685,7 @@ static void cpu_unlink_tb(CPUArchState *env) /* mask must never be zero, except for A20 change call */ static void tcg_handle_interrupt(CPUArchState *env, int mask) { +CPUState *cpu = ENV_GET_CPU(env); int old_mask; old_mask = env-interrupt_request; @@ -1694,7 +1695,7 @@ static void tcg_handle_interrupt(CPUArchState *env, int mask) * If called from iothread context, wake the target cpu in * case its halted. */ -if (!qemu_cpu_is_self(env)) { +if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(env); return; } diff --git a/hw/apic.c b/hw/apic.c index ccf2819..1b4cd2f 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -107,7 +107,7 @@ static void apic_sync_vapic(APICCommonState *s, int sync_type) length = offsetof(VAPICState, enabled) - offsetof(VAPICState, isr); if (sync_type SYNC_TO_VAPIC) { -assert(qemu_cpu_is_self(s-cpu-env)); +assert(qemu_cpu_is_self(CPU(s-cpu))); vapic_state.tpr = s-tpr; vapic_state.enabled = 1; @@ -363,10 +363,12 @@ static int apic_irq_pending(APICCommonState *s) /* signal the CPU if an irq is pending */ static void apic_update_irq(APICCommonState *s) { +CPUState *cpu = CPU(s-cpu); + if (!(s-spurious_vec APIC_SV_ENABLE)) { return; } -if (!qemu_cpu_is_self(s-cpu-env)) { +if (!qemu_cpu_is_self(cpu)) { cpu_interrupt(s-cpu-env, CPU_INTERRUPT_POLL); } else if (apic_irq_pending(s) 0) { cpu_interrupt(s-cpu-env, CPU_INTERRUPT_HARD); diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h index ad706a6..7be983d 100644 --- a/include/qemu/cpu.h +++ b/include/qemu/cpu.h @@ -78,5 +78,15 @@ struct CPUState { */ void cpu_reset(CPUState *cpu); +/** + * qemu_cpu_is_self: + * @cpu: The vCPU to check against. + * + * Checks whether the caller is executing on the vCPU thread. + * + * Returns: %true if called from @cpu's thread, %false otherwise. + */ +bool qemu_cpu_is_self(CPUState *cpu); + #endif diff --git a/kvm-all.c b/kvm-all.c index 92a7137..db01aeb 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -854,9 +854,11 @@ static MemoryListener kvm_memory_listener = { static void kvm_handle_interrupt(CPUArchState *env, int mask) { +CPUState *cpu = ENV_GET_CPU(env); + env-interrupt_request |= mask; -if (!qemu_cpu_is_self(env)) { +if (!qemu_cpu_is_self(cpu)) { qemu_cpu_kick(env); } } diff --git a/qemu-common.h b/qemu-common.h index b54612b..2094742 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -326,7 +326,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id); /* Unblock cpu */ void qemu_cpu_kick(void *env); void qemu_cpu_kick_self(void); -int qemu_cpu_is_self(void *env); /* work queue */ struct qemu_work_item { diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 5b18383..cf3d2f1 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1552,9 +1552,10 @@ static int kvm_get_debugregs(CPUX86State *env) int kvm_arch_put_registers(CPUX86State *env, int level) { +CPUState *cpu = ENV_GET_CPU(env); int ret; -assert(cpu_is_stopped(env) || qemu_cpu_is_self(env)); +assert(cpu_is_stopped(env) || qemu_cpu_is_self(cpu)); ret = kvm_getput_regs(env, 1); if (ret 0) { @@ -1609,9 +1610,10 @@ int kvm_arch_put_registers(CPUX86State *env, int level) int kvm_arch_get_registers(CPUX86State *env) { +CPUState *cpu = ENV_GET_CPU(env); int ret; -assert(cpu_is_stopped(env) ||
Re: Using PCI config space to indicate config location
Michael S. Tsirkin m...@redhat.com writes: On Thu, Oct 11, 2012 at 11:48:22AM +1030, Rusty Russell wrote: Michael S. Tsirkin m...@redhat.com writes: On Mon, Oct 08, 2012 at 12:51:25PM +1030, Rusty Russell wrote: Note before anyone gets confused; we were talking about using the PCI config space to indicate what BAR(s) the virtio stuff is in. An alternative would be to simply specify a new layout format in BAR1. One problem we are still left with is this: device specific config accesses are still non atomic. This is a problem for multibyte fields such as MAC address where MAC could change while we are accessing it. It's also a problem for related fields, eg. console width and height, or disk geometry. I was thinking about some backwards compatible way to solve this, but if we are willing to break compatiblity or use some mode switch, how about we give up on virtio config space completely, and do everything besides IO and ISR through guest memory? I think there's still a benefit in the simple publishing of information: I don't really want to add a control queue for the console. One reason I thought using a vq is handy is because this would let us get by with a single MSI vector. Currently we need at least 2 for config changes + a shared one for vqs. But I don't insist. Hmmm, that is true. Here's a table from a quick audit: Driver Config Device changesDriver writes... after init? net YY NN block YY YY console YY NN rng NN NN balloon YY YY scsiYN YN 9p YN NN For config space reads, I suggest the driver publish a generation count. You mean device? Yes, sorry. For writes, the standard seems to be a commit latch. We could abuse the generation count for this: the driver writes to it to commit config changes. I think this will work. There are a couple of things that bother me: This assumes read accesses have no side effects, and these are sometimes handy. Also the semantics for write aren't very clear to me. I guess device must buffer data until generation count write? This assumes the device has a buffer to store writes, and it must track each byte written. I kind of dislike this tracking of accessed bytes. Also, device would need to resolve conflicts if any in some device specific way. It should be trivial to implement: you keep a scratch copy of the config space, and copy it to the master copy when they hit the latch. Implementation of this will show whether I've missed anything here, I think. Maybe it's a good idea to make the buffer accesses explicit instead? IOW require driver to declare intent to read/request write of a specific config range. We could for example do it like this: __le32 config_offset; __le32 config_len; __u8 config_cmd; /* write-only: 0 - read, 1 - write config_len bytes at config_offset from/to config space to/from device memory */ But maybe this is over-engineering? Seems overengineering since the config space is quite small in practice. PS. Let's make all the virtio-device config LE, too... We'll need some new API for devices then: currently we pass bytes. Yes, but driver authors expect that anyway. We can retro-define virito-mmio to be LE (since all current users are), so this is v. tempting. Cheers, Rusty. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] [SCSI] virtio-scsi: Add real 2-clause BSD license to header
Paolo Bonzini pbonz...@redhat.com writes: Il 11/10/2012 08:41, Bryan Venteicher ha scritto: This is analogous to commit a1b383870a made by Rusty Russell to all the VirtIO headers at the time. This eases the use of the header as is by other OSes. Signed-off-by: Bryan Venteicher bry...@daemoninthecloset.org Acked-by: Paolo Bonzini pbonz...@redhat.com Applied! Thanks, Rusty. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/3] virtio-net: inline header support
Michael S. Tsirkin m...@redhat.com writes: On Thu, Oct 11, 2012 at 10:33:31AM +1030, Rusty Russell wrote: OK. Well, Anthony wants qemu to be robust in this regard, so I am tempted to rework all the qemu drivers to handle arbitrary layouts. They could use a good audit anyway. I agree here. Still trying to understand whether we can agree to use a feature bit for this, or not. I'd *like* to imply it by the new PCI layout, but if it doesn't work we'll add a new feature bit. I'm resisting a feature bit, since it constrains future implementations which could otherwise assume it. This would become a glaring exception, but I'm tempted to fix it to 32 bytes at the same time as we get the new pci layout (ie. for the virtio 1.0 spec). But this isn't a virtio-pci only issue, is it? qemu has s390 bus with same limmitation. How can we tie it to pci layout? They can use a transport feature if they need to, of course. But perhaps the timing with ccw will coincide with the fix, in which they don't need to, but it might be a bit late. Cornelia? Cheers, Rusty. -- To unsubscribe from this list: send the line unsubscribe kvm in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/12] KVM: PPC: booke: Fix get_tb() compile error on 64-bit
Include header file for get_tb() declaration. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/booke.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 3d1f35d..7c9c389 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -36,6 +36,7 @@ #include asm/dbell.h #include asm/hw_irq.h #include asm/irq.h +#include asm/time.h #include timing.h #include booke.h -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07/12] KVM: PPC: e500: Mask MAS2 EPN high 32-bits in 32/64 tlbwe emulation
Mask high 32 bits of MAS2's effective page number in tlbwe emulation for guests running in 32-bit mode. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: patch splited. arch/powerpc/kvm/e500_tlb.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index b5a188a..6c0997e 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -871,6 +871,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) gtlbe-mas1 = vcpu-arch.shared-mas1; gtlbe-mas2 = vcpu-arch.shared-mas2; + if (!(vcpu-arch.shared-msr MSR_CM)) + gtlbe-mas2 = 0xUL; gtlbe-mas7_3 = vcpu-arch.shared-mas7_3; trace_kvm_booke206_gtlb_write(vcpu-arch.shared-mas0, gtlbe-mas1, -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/12] KVM: PPC: bookehv: Add guest computation mode for irq delivery
When delivering guest IRQs, update MSR computation mode according to guest interrupt computation mode found in EPCR. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: added intermediate msr variable. arch/powerpc/kvm/booke.c |9 - 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 7c9c389..86f0d0d 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -312,6 +312,7 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu, bool crit; bool keep_irq = false; enum int_class int_class; + ulong new_msr = vcpu-arch.shared-msr; /* Truncate crit indicators in 32 bit mode */ if (!(vcpu-arch.shared-msr MSR_SF)) { @@ -407,7 +408,13 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu, set_guest_esr(vcpu, vcpu-arch.queued_esr); if (update_dear == true) set_guest_dear(vcpu, vcpu-arch.queued_dear); - kvmppc_set_msr(vcpu, vcpu-arch.shared-msr msr_mask); + + new_msr = msr_mask; +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + if (vcpu-arch.epcr SPRN_EPCR_ICM) + new_msr |= MSR_CM; +#endif + kvmppc_set_msr(vcpu, new_msr); if (!keep_irq) clear_bit(priority, vcpu-arch.pending_exceptions); -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 04/12] KVM: PPC64: bookehv: Add support for interrupt handling
Add interrupt handling support for 64-bit bookehv hosts. Unify 32 and 64 bit implementations using a common stack layout and a common execution flow starting from kvm_handler_common macro. Update documentation for 64-bit input register values. This patch only address the bolted TLB miss exception handlers version. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: updated CRIT and TLB exception handling following core side changes. arch/powerpc/include/asm/kvm_booke_hv_asm.h | 25 + arch/powerpc/kvm/bookehv_interrupts.S | 138 +-- 2 files changed, 155 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_booke_hv_asm.h b/arch/powerpc/include/asm/kvm_booke_hv_asm.h index a37a12a..7ad5af7 100644 --- a/arch/powerpc/include/asm/kvm_booke_hv_asm.h +++ b/arch/powerpc/include/asm/kvm_booke_hv_asm.h @@ -17,6 +17,7 @@ * there are no exceptions for which we fall through directly to * the normal host handler. * + * 32-bit host * Expected inputs (normal exceptions): * SCRATCH0 = saved r10 * r10 = thread struct @@ -33,6 +34,30 @@ * *(r8 + GPR9) = saved r9 * *(r8 + GPR10) = saved r10 (r10 not yet clobbered) * *(r8 + GPR11) = saved r11 + * + * 64-bit host + * Expected inputs (GEN/GDBELL/DBG/MC exception types): + * r10 = saved CR + * r13 = PACA_POINTER + * *(r13 + PACA_EX##type + EX_R10) = saved r10 + * *(r13 + PACA_EX##type + EX_R11) = saved r11 + * SPRN_SPRG_##type##_SCRATCH = saved r13 + * + * Expected inputs (CRIT exception type): + * r10 = saved CR + * r13 = PACA_POINTER + * *(r13 + PACA_EX##type + EX_R10) = saved r10 + * *(r13 + PACA_EX##type + EX_R11) = saved r11 + * *(r13 + PACA_EX##type + EX_R13) = saved r13 + * + * Expected inputs (TLB exception type): + * r10 = saved CR + * r13 = PACA_POINTER + * *(r13 + PACA_EX##type + EX_TLB_R10) = saved r10 + * *(r13 + PACA_EX##type + EX_TLB_R11) = saved r11 + * SPRN_SPRG_GEN_SCRATCH = saved r13 + * + * Only the bolted version of TLB miss exception handlers is supported now. */ .macro DO_KVM intno srr1 #ifdef CONFIG_KVM_BOOKE_HV diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S index fa6d552..e8ed7d6 100644 --- a/arch/powerpc/kvm/bookehv_interrupts.S +++ b/arch/powerpc/kvm/bookehv_interrupts.S @@ -16,6 +16,7 @@ * * Author: Varun Sethi varun.se...@freescale.com * Author: Scott Wood scotw...@freescale.com + * Author: Mihai Caraman mihai.cara...@freescale.com * * This file is derived from arch/powerpc/kvm/booke_interrupts.S */ @@ -30,28 +31,33 @@ #include asm/bitsperlong.h #include asm/thread_info.h +#ifdef CONFIG_64BIT +#include asm/exception-64e.h +#else #include ../kernel/head_booke.h /* for THREAD_NORMSAVE() */ +#endif #define LONGBYTES (BITS_PER_LONG / 8) #define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES)) /* The host stack layout: */ -#define HOST_R1 (0 * LONGBYTES) /* Implied by stwu. */ -#define HOST_CALLEE_LR (1 * LONGBYTES) -#define HOST_RUN(2 * LONGBYTES) /* struct kvm_run */ +#define HOST_R1 0 /* Implied by stwu. */ +#define HOST_CALLEE_LR PPC_LR_STKOFF +#define HOST_RUN(HOST_CALLEE_LR + LONGBYTES) /* * r2 is special: it holds 'current', and it made nonvolatile in the * kernel with the -ffixed-r2 gcc option. */ -#define HOST_R2 (3 * LONGBYTES) -#define HOST_CR (4 * LONGBYTES) -#define HOST_NV_GPRS(5 * LONGBYTES) +#define HOST_R2 (HOST_RUN + LONGBYTES) +#define HOST_CR (HOST_R2 + LONGBYTES) +#define HOST_NV_GPRS(HOST_CR + LONGBYTES) #define __HOST_NV_GPR(n) (HOST_NV_GPRS + ((n - 14) * LONGBYTES)) #define HOST_NV_GPR(n) __HOST_NV_GPR(__REG_##n) #define HOST_MIN_STACK_SIZE (HOST_NV_GPR(R31) + LONGBYTES) #define HOST_STACK_SIZE ((HOST_MIN_STACK_SIZE + 15) ~15) /* Align. */ -#define HOST_STACK_LR (HOST_STACK_SIZE + LONGBYTES) /* In caller stack frame. */ +/* LR in caller stack frame. */ +#define HOST_STACK_LR (HOST_STACK_SIZE + PPC_LR_STKOFF) #define NEED_EMU 0x0001 /* emulation -- save nv regs */ #define NEED_DEAR 0x0002 /* save faulting DEAR */ @@ -198,6 +204,122 @@ b kvmppc_resume_host .endm +#ifdef CONFIG_64BIT +/* Exception types */ +#define EX_GEN 1 +#define EX_GDBELL 2 +#define EX_DBG 3 +#define EX_MC 4 +#define EX_CRIT5 +#define EX_TLB 6 + +/* + * For input register values, see arch/powerpc/include/asm/kvm_booke_hv_asm.h + */ +.macro kvm_handler intno type scratch, paca_ex, ex_r10, ex_r11, srr0, srr1, flags + _GLOBAL(kvmppc_handler_\intno\()_\srr1) + mr r11, r4 + /* +* Get vcpu from Paca: paca-__current.thread-kvm_vcpu +*/ + PPC_LL r4, PACACURRENT(r13) + PPC_LL r4, (THREAD + THREAD_KVM_VCPU)(r4) + stw r10, VCPU_CR(r4) + PPC_STL r11,
[PATCH 01/12] KVM: PPC: e500: Silence bogus GCC warning in tlb code
64-bit GCC 4.5.1 warns about an uninitialized variable which was guarded by a flag. Initialize the variable to make it happy. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/e500_tlb.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index c733894..23b3de6 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -415,7 +415,8 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, struct tlbe_ref *ref) { struct kvm_memory_slot *slot; - unsigned long pfn, hva; + unsigned long pfn = 0; /* shut up 64-bit GCC */ + unsigned long hva; int pfnmap = 0; int tsize = BOOK3E_PAGESZ_4K; -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/12] KVM: PPC: bookehv: Remove GET_VCPU macro from exception handler
GET_VCPU define will not be implemented for 64-bit for performance reasons so get rid of it also on 32-bit. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/bookehv_interrupts.S |7 ++- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S index 099fe82..fa6d552 100644 --- a/arch/powerpc/kvm/bookehv_interrupts.S +++ b/arch/powerpc/kvm/bookehv_interrupts.S @@ -32,9 +32,6 @@ #include ../kernel/head_booke.h /* for THREAD_NORMSAVE() */ -#define GET_VCPU(vcpu, thread) \ - PPC_LL vcpu, THREAD_KVM_VCPU(thread) - #define LONGBYTES (BITS_PER_LONG / 8) #define VCPU_GUEST_SPRG(n) (VCPU_GUEST_SPRGS + (n * LONGBYTES)) @@ -206,7 +203,7 @@ */ .macro kvm_handler intno srr0, srr1, flags _GLOBAL(kvmppc_handler_\intno\()_\srr1) - GET_VCPU(r11, r10) + PPC_LL r11, THREAD_KVM_VCPU(r10) PPC_STL r3, VCPU_GPR(R3)(r11) mfspr r3, SPRN_SPRG_RSCRATCH0 PPC_STL r4, VCPU_GPR(R4)(r11) @@ -233,7 +230,7 @@ _GLOBAL(kvmppc_handler_\intno\()_\srr1) .macro kvm_lvl_handler intno scratch srr0, srr1, flags _GLOBAL(kvmppc_handler_\intno\()_\srr1) mfspr r10, SPRN_SPRG_THREAD - GET_VCPU(r11, r10) + PPC_LL r11, THREAD_KVM_VCPU(r10) PPC_STL r3, VCPU_GPR(R3)(r11) mfspr r3, \scratch PPC_STL r4, VCPU_GPR(R4)(r11) -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 11/12] KVM: PPC: booke: Add EPCR support in sregs
Add KVM_SREGS_E_64 feature and EPCR spr support in get/set sregs for 64-bit hosts. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/kvm/booke.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index e6159f5..d396374 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1215,6 +1215,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu, u64 tb = get_tb(); sregs-u.e.features |= KVM_SREGS_E_BASE; +#ifdef CONFIG_64BIT + sregs-u.e.features |= KVM_SREGS_E_64; +#endif sregs-u.e.csrr0 = vcpu-arch.csrr0; sregs-u.e.csrr1 = vcpu-arch.csrr1; @@ -1226,6 +1229,9 @@ static void get_sregs_base(struct kvm_vcpu *vcpu, sregs-u.e.dec = kvmppc_get_dec(vcpu, tb); sregs-u.e.tb = tb; sregs-u.e.vrsave = vcpu-arch.vrsave; +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + sregs-u.e.epcr = vcpu-arch.epcr; +#endif } static int set_sregs_base(struct kvm_vcpu *vcpu, @@ -1241,6 +1247,7 @@ static int set_sregs_base(struct kvm_vcpu *vcpu, set_guest_dear(vcpu, sregs-u.e.dear); vcpu-arch.vrsave = sregs-u.e.vrsave; kvmppc_set_tcr(vcpu, sregs-u.e.tcr); + kvmppc_set_epcr(vcpu, sregs-u.e.epcr); if (sregs-u.e.update_special KVM_SREGS_E_UPDATE_DEC) { vcpu-arch.dec = sregs-u.e.dec; -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 08/12] KVM: PPC: booke: Extend MAS2 EPN mask for 64-bit
Extend MAS2 EPN mask to retain most significant bits on 64-bit hosts. Use this mask in tlb effective address accessor. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- arch/powerpc/include/asm/mmu-book3e.h |2 +- arch/powerpc/kvm/e500.h |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h index eeabcdb..99d43e0 100644 --- a/arch/powerpc/include/asm/mmu-book3e.h +++ b/arch/powerpc/include/asm/mmu-book3e.h @@ -59,7 +59,7 @@ #define MAS1_TSIZE_SHIFT 7 #define MAS1_TSIZE(x) (((x) MAS1_TSIZE_SHIFT) MAS1_TSIZE_MASK) -#define MAS2_EPN 0xF000 +#define MAS2_EPN (~0xFFFUL) #define MAS2_X00x0040 #define MAS2_X10x0020 #define MAS2_W 0x0010 diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h index 32e98a7..c70d37e 100644 --- a/arch/powerpc/kvm/e500.h +++ b/arch/powerpc/kvm/e500.h @@ -154,7 +154,7 @@ get_tlb_size(const struct kvm_book3e_206_tlb_entry *tlbe) static inline gva_t get_tlb_eaddr(const struct kvm_book3e_206_tlb_entry *tlbe) { - return tlbe-mas2 0xf000; + return tlbe-mas2 MAS2_EPN; } static inline u64 get_tlb_bytes(const struct kvm_book3e_206_tlb_entry *tlbe) -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/12] KVM: PPC: e500: Add emulation helper for getting instruction ea
Add emulation helper for getting instruction ea and refactor tlb instruction emulation to use it. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- v1: use _t_ype instead of _t_arget _r_egister in tlbilx emulation. arch/powerpc/include/asm/kvm_ppc.h | 11 +++ arch/powerpc/kvm/e500.h|6 +++--- arch/powerpc/kvm/e500_emulate.c| 15 ++- arch/powerpc/kvm/e500_tlb.c| 33 +++-- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 609cca3..a08e756 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h @@ -293,4 +293,15 @@ static inline void kvmppc_lazy_ee_enable(void) #endif } +static inline ulong kvmppc_get_ea_indexed(struct kvm_vcpu *vcpu, int ra, int rb) +{ + ulong ea; + + ea = kvmppc_get_gpr(vcpu, rb); + if (ra) + ea += kvmppc_get_gpr(vcpu, ra); + + return ea; +} + #endif /* __POWERPC_KVM_PPC_H__ */ diff --git a/arch/powerpc/kvm/e500.h b/arch/powerpc/kvm/e500.h index d162286..32e98a7 100644 --- a/arch/powerpc/kvm/e500.h +++ b/arch/powerpc/kvm/e500.h @@ -129,9 +129,9 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500, ulong value); int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu); int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu); -int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb); -int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int rt, int ra, int rb); -int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb); +int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea); +int kvmppc_e500_emul_tlbilx(struct kvm_vcpu *vcpu, int type, gva_t ea); +int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, gva_t ea); int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500); void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500); diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c index e04b0ef..3bf2486 100644 --- a/arch/powerpc/kvm/e500_emulate.c +++ b/arch/powerpc/kvm/e500_emulate.c @@ -88,7 +88,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, int emulated = EMULATE_DONE; int ra = get_ra(inst); int rb = get_rb(inst); - int rt = get_rt(inst); + gva_t ea; switch (get_op(inst)) { case 31: @@ -113,15 +113,20 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, break; case XOP_TLBSX: - emulated = kvmppc_e500_emul_tlbsx(vcpu,rb); + ea = kvmppc_get_ea_indexed(vcpu, ra, rb); + emulated = kvmppc_e500_emul_tlbsx(vcpu, ea); break; - case XOP_TLBILX: - emulated = kvmppc_e500_emul_tlbilx(vcpu, rt, ra, rb); + case XOP_TLBILX: { + int t = (inst 21) 0x3; + ea = kvmppc_get_ea_indexed(vcpu, ra, rb); + emulated = kvmppc_e500_emul_tlbilx(vcpu, t, ea); break; + } case XOP_TLBIVAX: - emulated = kvmppc_e500_emul_tlbivax(vcpu, ra, rb); + ea = kvmppc_get_ea_indexed(vcpu, ra, rb); + emulated = kvmppc_e500_emul_tlbivax(vcpu, ea); break; default: diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c index 23b3de6..b5a188a 100644 --- a/arch/powerpc/kvm/e500_tlb.c +++ b/arch/powerpc/kvm/e500_tlb.c @@ -689,14 +689,11 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500, ulong value) return EMULATE_DONE; } -int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb) +int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, gva_t ea) { struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); unsigned int ia; int esel, tlbsel; - gva_t ea; - - ea = ((ra) ? kvmppc_get_gpr(vcpu, ra) : 0) + kvmppc_get_gpr(vcpu, rb); ia = (ea 2) 0x1; @@ -723,7 +720,7 @@ int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb) } static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel, - int pid, int rt) + int pid, int type) { struct kvm_book3e_206_tlb_entry *tlbe; int tid, esel; @@ -732,7 +729,7 @@ static void tlbilx_all(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel, for (esel = 0; esel vcpu_e500-gtlb_params[tlbsel].entries; esel++) { tlbe = get_entry(vcpu_e500, tlbsel, esel); tid = get_tlb_tid(tlbe); - if (rt == 0 || tid == pid) { + if (type == 0 || tid == pid) { inval_gtlbe_on_host(vcpu_e500, tlbsel, esel);
[PATCH 12/12] KVM: PPC: booke: Get/set guest EPCR register using ONE_REG interface
Implement ONE_REG interface for EPCR register adding KVM_REG_PPC_EPCR to the list of ONE_REG PPC supported registers. Signed-off-by: Mihai Caraman mihai.cara...@freescale.com --- Documentation/virtual/kvm/api.txt |1 + arch/powerpc/include/asm/kvm.h|2 ++ arch/powerpc/kvm/booke.c | 16 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index e726d76..c78dff4 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -1773,6 +1773,7 @@ registers, find a list below: PPC | KVM_REG_PPC_VPA_ADDR | 64 PPC | KVM_REG_PPC_VPA_SLB | 128 PPC | KVM_REG_PPC_VPA_DTL | 128 + PPC | KVM_REG_PPC_EPCR | 32 4.69 KVM_GET_ONE_REG diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h index b89ae4d..beb6b20 100644 --- a/arch/powerpc/include/asm/kvm.h +++ b/arch/powerpc/include/asm/kvm.h @@ -386,4 +386,6 @@ struct kvm_book3e_206_tlb_params { #define KVM_REG_PPC_VPA_SLB(KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x83) #define KVM_REG_PPC_VPA_DTL(KVM_REG_PPC | KVM_REG_SIZE_U128 | 0x84) +#define KVM_REG_PPC_EPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0x85) + #endif /* __LINUX_KVM_POWERPC_H */ diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index d396374..60b8237 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -1395,6 +1395,12 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) vcpu-arch.dbg_reg.dac[dac], sizeof(u64)); break; } +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + case KVM_REG_PPC_EPCR: + r = copy_to_user((u32 __user *)(long)reg-addr, +vcpu-arch.epcr, sizeof(u32)); + break; +#endif default: break; } @@ -1422,6 +1428,16 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) (u64 __user *)(long)reg-addr, sizeof(u64)); break; } +#if defined(CONFIG_64BIT) defined(CONFIG_KVM_BOOKE_HV) + case KVM_REG_PPC_EPCR: { + u32 new_epcr; + r = copy_from_user(new_epcr, +(u32 __user *)(long)reg-addr, sizeof(u32)); + if (r == 0) + kvmppc_set_epcr(vcpu, new_epcr); + break; + } +#endif default: break; } -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe kvm-ppc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html