first pile of s390x patches for 2.4
[Qemu-devel] [PULL 03/10] sclp: sort into categories
In reply to Cornelia HuckSort the sclp consoles into the input category, just as virtio-serial. Various other sclp devices don't have an obvious category, sort them into misc.
--- hw/char/sclpconsole-lm.c | 1 + hw/char/sclpconsole.c | 1 + hw/s390x/event-facility.c | 1 + hw/s390x/sclp.c | 9 +++++++++ hw/s390x/sclpcpu.c | 2 ++ hw/s390x/sclpquiesce.c | 1 + 6 files changed, 15 insertions(+)
hw/char/sclpconsole-lm.c +1 -0
@@ -364,6 +364,7 @@ static void console_class_init(ObjectClass *klass, void *data) ec->can_handle_event = can_handle_event; ec->read_event_data = read_event_data; ec->write_event_data = write_event_data; +set_bit (DEVICE_CATEGORY_INPUT , dc->categories); }static const TypeInfo sclp_console_info = {
hw/char/sclpconsole.c +1 -0
@@ -266,6 +266,7 @@ static void console_class_init(ObjectClass *klass, void *data) ec->can_handle_event = can_handle_event; ec->read_event_data = read_event_data; ec->write_event_data = write_event_data; +set_bit (DEVICE_CATEGORY_INPUT , dc->categories); }static const TypeInfo sclp_console_info = {
hw/s390x/event-facility.c +1 -0
@@ -362,6 +362,7 @@ static void init_event_facility_class(ObjectClass *klass, void *data) dc->reset = reset_event_facility; dc->vmsd = &vmstate_event_facility; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); k->init = init_event_facility; k->command_handler = command_handler; k->event_pending = event_pending;
hw/s390x/sclp.c +9 -0
@@ -457,10 +457,19 @@ sclpMemoryHotplugDev *get_sclp_memory_hotplug_dev(void) TYPE_SCLP_MEMORY_HOTPLUG_DEV, NULL)); } +static void sclp_memory_hotplug_dev_class_init (ObjectClass *klass, +void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_MISC , dc->categories); +} +static TypeInfo sclp_memory_hotplug_dev_info = { .name =TYPE_SCLP_MEMORY_HOTPLUG_DEV , .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (sclpMemoryHotplugDev), + .class_init = sclp_memory_hotplug_dev_class_init, };static void register_types (void )
hw/s390x/sclpcpu.c +2 -0
@@ -88,12 +88,14 @@ static int irq_cpu_hotplug_init(SCLPEvent *event)static void cpu_class_init (ObjectClass *oc,void *data) {SCLPEventClass *k =SCLP_EVENT_CLASS (oc); +DeviceClass *dc =DEVICE_CLASS (oc); k->init = irq_cpu_hotplug_init; k->get_send_mask = send_mask; k->get_receive_mask = receive_mask; k->read_event_data = read_event_data; k->write_event_data =NULL ; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); }static const TypeInfo sclp_cpu_info = {
hw/s390x/sclpquiesce.c +1 -0
@@ -116,6 +116,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data) dc->reset = quiesce_reset; dc->vmsd = &vmstate_sclpquiesce; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); k->init = quiesce_init; k->get_send_mask = send_mask;
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 09/10] s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl
In reply to Cornelia HuckFrom: Alexander Yarygin <[email protected]>
Access register mode is one of the modes that control dynamic address translation. In this mode the address space is specified by values of the access registers. The effective address-space-control element is obtained from the result of the access register translation. See the "Access-Register Introduction" section of the chapter 5 "Program Execution" in "Principles of Operations" for more details.
When the CPU is in AR mode, the s390_cpu_virt_mem_rw() function must know which access register number to use for address translation. This patch does several things:
- add new parameter 'uint8_t ar' to that function
- decode ar number from intercepted instructions
- pass the ar number to s390_cpu_virt_mem_rw(), which in turn passes it to the KVM_S390_MEM_OP ioctl.
--- hw/s390x/s390-pci-inst.c | 21 +++++++++++---------- hw/s390x/s390-pci-inst.h | 7 ++++--- target-s390x/cpu.h | 30 +++++++++++++++++------------- target-s390x/ioinst.c | 42 +++++++++++++++++++++++++----------------- target-s390x/kvm.c | 46 ++++++++++++++++++++++++++++++---------------- target-s390x/mmu_helper.c | 5 +++-- 6 files changed, 90 insertions(+), 61 deletions(-)
hw/s390x/s390-pci-inst.c +11 -10
@@ -155,7 +155,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)return 0 ; } -if (s390_cpu_virt_mem_read (cpu, env->regs[r2], buffer,sizeof (*reqh))) { +if (s390_cpu_virt_mem_read (cpu, env->regs[r2], r2, buffer,sizeof (*reqh))) {return 0 ; } reqh = (ClpReqHdr *)buffer;
@@ -165,7 +165,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)return 0 ; } -if (s390_cpu_virt_mem_read (cpu, env->regs[r2], buffer, +if (s390_cpu_virt_mem_read (cpu, env->regs[r2], r2, buffer, req_len +sizeof (*resh))) {return 0 ; }
@@ -180,7 +180,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)return 0 ; } -if (s390_cpu_virt_mem_read (cpu, env->regs[r2], buffer, +if (s390_cpu_virt_mem_read (cpu, env->regs[r2], r2, buffer, req_len + res_len)) {return 0 ; }
@@ -277,7 +277,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2) } out: -if (s390_cpu_virt_mem_write (cpu, env->regs[r2], buffer, +if (s390_cpu_virt_mem_write (cpu, env->regs[r2], r2, buffer, req_len + res_len)) {return 0 ; }
@@ -546,7 +546,8 @@ out:return 0 ; } -int pcistb_service_call (S390CPU *cpu,uint8_t r1,uint8_t r3,uint64_t gaddr) +int pcistb_service_call (S390CPU *cpu,uint8_t r1,uint8_t r3,uint64_t gaddr, +uint8_t ar) {CPUS390XState *env = &cpu->env;S390PCIBusDevice *pbdev;
@@ -603,7 +604,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr)return 0 ; } -if (s390_cpu_virt_mem_read (cpu, gaddr, buffer, len)) { +if (s390_cpu_virt_mem_read (cpu, gaddr, ar, buffer, len)) {return 0 ; }
@@ -698,7 +699,7 @@ static void dereg_ioat(S390PCIBusDevice *pbdev) pbdev->g_iota =0 ; } -int mpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba) +int mpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba,uint8_t ar) {CPUS390XState *env = &cpu->env;uint8_t oc;
@@ -727,7 +728,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)return 0 ; } -if (s390_cpu_virt_mem_read (cpu, fiba, (uint8_t *)&fib,sizeof (fib))) { +if (s390_cpu_virt_mem_read (cpu, fiba, ar, (uint8_t *)&fib,sizeof (fib))) {return 0 ; }
@@ -773,7 +774,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)return 0 ; } -int stpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba) +int stpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba,uint8_t ar) {CPUS390XState *env = &cpu->env;uint32_t fh;
@@ -829,7 +830,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba) fib.fc |=0x10 ; } -if (s390_cpu_virt_mem_write (cpu, fiba, (uint8_t *)&fib,sizeof (fib))) { +if (s390_cpu_virt_mem_write (cpu, fiba, ar, (uint8_t *)&fib,sizeof (fib))) {return 0 ; }
hw/s390x/s390-pci-inst.h +4 -3
@@ -281,8 +281,9 @@ int clp_service_call(S390CPU *cpu, uint8_t r2);int pcilg_service_call (S390CPU *cpu,uint8_t r1,uint8_t r2);int pcistg_service_call (S390CPU *cpu,uint8_t r1,uint8_t r2);int rpcit_service_call (S390CPU *cpu,uint8_t r1,uint8_t r2); -int pcistb_service_call (S390CPU *cpu,uint8_t r1,uint8_t r3,uint64_t gaddr); -int mpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba); -int stpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba); +int pcistb_service_call (S390CPU *cpu,uint8_t r1,uint8_t r3,uint64_t gaddr, +uint8_t ar); +int mpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba,uint8_t ar); +int stpcifc_service_call (S390CPU *cpu,uint8_t r1,uint64_t fiba,uint8_t ar);#endif
target-s390x/cpu.h +17 -13
@@ -356,7 +356,8 @@ int s390_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#ifndef CONFIG_USER_ONLY void do_restart_interrupt (CPUS390XState *env); -static inline hwaddr decode_basedisp_s (CPUS390XState *env,uint32_t ipb) +static inline hwaddr decode_basedisp_s (CPUS390XState *env,uint32_t ipb, +uint8_t *ar) {hwaddr addr =0 ;uint8_t reg;
@@ -366,6 +367,9 @@ static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb) addr = env->regs[reg]; } addr += (ipb >>16 ) &0xfff ; +if (ar) { + *ar = reg; + }return addr; }
@@ -401,8 +405,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);void kvm_s390_floating_interrupt (struct kvm_s390_irq *irq);int kvm_s390_inject_flic (struct kvm_s390_irq *irq);void kvm_s390_access_exception (S390CPU *cpu,uint16_t code,uint64_t te_code); -int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,void *hostbuf,int len, -bool is_write); +int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,uint8_t ar,void *hostbuf, +int len,bool is_write);int kvm_s390_get_clock (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t *tod_high,uint64_t *tod_clock);#else
@@ -420,8 +424,8 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low) {return -ENOSYS ; } -static inline int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,void *hostbuf, -int len,bool is_write) +static inline int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,uint8_t ar, +void *hostbuf,int len,bool is_write) {return -ENOSYS ; }
@@ -963,15 +967,15 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code);uint32_t calc_cc (CPUS390XState *env,uint32_t cc_op,uint64_t src,uint64_t dst,uint64_t vr); -int s390_cpu_virt_mem_rw (S390CPU *cpu,vaddr laddr,void *hostbuf,int len, -bool is_write); +int s390_cpu_virt_mem_rw (S390CPU *cpu,vaddr laddr,uint8_t ar,void *hostbuf, +int len,bool is_write); -#define s390_cpu_virt_mem_read (cpu, laddr, dest, len) \ - s390_cpu_virt_mem_rw(cpu, laddr, dest, len, false) -#define s390_cpu_virt_mem_write (cpu, laddr, dest, len) \ - s390_cpu_virt_mem_rw(cpu, laddr, dest, len, true) -#define s390_cpu_virt_mem_check_write (cpu, laddr, len) \ - s390_cpu_virt_mem_rw(cpu, laddr, NULL, len, true) +#define s390_cpu_virt_mem_read (cpu, laddr, ar, dest, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, ar, dest, len, false) +#define s390_cpu_virt_mem_write (cpu, laddr, ar, dest, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, ar, dest, len, true) +#define s390_cpu_virt_mem_check_write (cpu, laddr, ar, len) \ + s390_cpu_virt_mem_rw(cpu, laddr, ar, NULL, len, true)/* The value of the TOD clock for 1.1.1970. */ #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
target-s390x/ioinst.c +25 -17
150 lines not on this page · raw message
target-s390x/kvm.c +30 -16
148 lines not on this page · raw message
target-s390x/mmu_helper.c +3 -2
@@ -435,6 +435,7 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,/** * s390_cpu_virt_mem_rw: * @laddr: the logical start address +* @ar: the access register number * @hostbuf: buffer in host memory. NULL = do only checks w/o copying * @len: length that should be transfered * @is_write: true = write, false = read
@@ -443,7 +444,7 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,* Copy from/to guest memory using logical addresses. Note that we inject a * program interrupt in case there is an error while accessing the memory. */ -int s390_cpu_virt_mem_rw (S390CPU *cpu,vaddr laddr,void *hostbuf, +int s390_cpu_virt_mem_rw (S390CPU *cpu,vaddr laddr,uint8_t ar,void *hostbuf,int len,bool is_write) {int currlen, nr_pages, i;
@@ -451,7 +452,7 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,int ret;if (kvm_enabled ()) { - ret =kvm_s390_mem_op (cpu, laddr, hostbuf, len, is_write); + ret =kvm_s390_mem_op (cpu, laddr, ar, hostbuf, len, is_write);if (ret >=0 ) {return ret; }
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 02/10] s390-virtio: sort into categories
In reply to Cornelia HuckSort the various s390-virtio devices into the same categories as their virtio-pci counterparts.
--- hw/s390x/s390-virtio-bus.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/s390x/s390-virtio-bus.c +9 -0
@@ -542,6 +542,7 @@ static void s390_virtio_net_class_init(ObjectClass *klass, void *data) k->realize = s390_virtio_net_realize; dc->props = s390_virtio_net_properties; +set_bit (DEVICE_CATEGORY_NETWORK , dc->categories); }static const TypeInfo s390_virtio_net = {
@@ -555,8 +556,10 @@ static const TypeInfo s390_virtio_net = {static void s390_virtio_blk_class_init (ObjectClass *klass,void *data) {VirtIOS390DeviceClass *k =VIRTIO_S390_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->realize = s390_virtio_blk_realize; +set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }static const TypeInfo s390_virtio_blk = {
@@ -578,6 +581,7 @@ static void s390_virtio_serial_class_init(ObjectClass *klass, void *data) k->realize = s390_virtio_serial_realize; dc->props = s390_virtio_serial_properties; +set_bit (DEVICE_CATEGORY_INPUT , dc->categories); }static const TypeInfo s390_virtio_serial = {
@@ -600,6 +604,7 @@ static void s390_virtio_rng_class_init(ObjectClass *klass, void *data) k->realize = s390_virtio_rng_realize; dc->props = s390_virtio_rng_properties; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); }static const TypeInfo s390_virtio_rng = {
@@ -658,6 +663,7 @@ static void s390_virtio_scsi_class_init(ObjectClass *klass, void *data) k->realize = s390_virtio_scsi_realize; dc->props = s390_virtio_scsi_properties; +set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }static const TypeInfo s390_virtio_scsi = {
@@ -681,6 +687,7 @@ static void s390_vhost_scsi_class_init(ObjectClass *klass, void *data) k->realize = s390_vhost_scsi_realize; dc->props = s390_vhost_scsi_properties; +set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }static const TypeInfo s390_vhost_scsi = {
@@ -704,8 +711,10 @@ static int s390_virtio_bridge_init(SysBusDevice *dev)static void s390_virtio_bridge_class_init (ObjectClass *klass,void *data) {SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->init = s390_virtio_bridge_init; +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); }static const TypeInfo s390_virtio_bridge_info = {
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 04/10] s390x/ipl: sort into categories
In reply to Cornelia HuckThe s390 ipl device has no real home (it's not really a storage device), so let's sort it into the misc category.
--- hw/s390x/ipl.c | 1 + 1 file changed, 1 insertion(+)
hw/s390x/ipl.c +1 -0
@@ -315,6 +315,7 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data) dc->props = s390_ipl_properties; dc->reset = s390_ipl_reset; dc->vmsd = &vmstate_ipl; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); }static const TypeInfo s390_ipl_info = {
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 07/10] s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB
In reply to Cornelia HuckFrom: Ekaterina Tumanova <[email protected]>
KVM prefills the SYSIB, returned by STSI 3.2.2. This patch allows userspace to intercept execution, and fill in the values, that are known to qemu: machine name (8 chars), extended machine name (256 chars), extended machine name encoding (equals 2 for UTF-8) and UUID.
STSI322 qemu handler also finds a highest virtualization level in level-3 virtualization stack that doesn't support Extended Names (Ext Name delimiter) and propagates zero Ext Name to all levels below, because this level is not capable of managing Extended Names of lower levels.
--- target-s390x/cpu.h | 8 ++++-- target-s390x/kvm.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-)
target-s390x/cpu.h +6 -2
@@ -865,9 +865,13 @@ struct sysib_322 {uint8_t name[8 ];uint32_t caf;uint8_t cpi[16 ]; -uint8_t res3[24 ]; +uint8_t res5[3 ]; +uint8_t ext_name_encoding; +uint32_t res3; +uint8_t uuid[16 ]; } vm[8 ]; -uint8_t res4[3552 ]; +uint8_t res4[1504 ]; +uint8_t ext_names[8 ][256 ]; };/* MMU defines */
target-s390x/kvm.c +71 -0
95 lines not on this page · raw message
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 08/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
Add code to make use of the new ioctl for reading from / writing to virtual guest memory. By using the ioctl, the memory accesses are now protected with the so-called ipte-lock in the kernel.
--- target-s390x/cpu.h | 7 +++++++ target-s390x/kvm.c | 40 ++++++++++++++++++++++++++++++++++++++++ target-s390x/mmu_helper.c | 7 +++++++ 3 files changed, 54 insertions(+)
target-s390x/cpu.h +7 -0
@@ -401,6 +401,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);void kvm_s390_floating_interrupt (struct kvm_s390_irq *irq);int kvm_s390_inject_flic (struct kvm_s390_irq *irq);void kvm_s390_access_exception (S390CPU *cpu,uint16_t code,uint64_t te_code); +int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,void *hostbuf,int len, +bool is_write);int kvm_s390_get_clock (uint8_t *tod_high,uint64_t *tod_clock);int kvm_s390_set_clock (uint8_t *tod_high,uint64_t *tod_clock);#else
@@ -418,6 +420,11 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low) {return -ENOSYS ; } +static inline int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,void *hostbuf, +int len,bool is_write) +{ +return -ENOSYS ; +}static inline void kvm_s390_access_exception (S390CPU *cpu,uint16_t code,uint64_t te_code) {
target-s390x/kvm.c +40 -0
@@ -123,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {static int cap_sync_regs;static int cap_async_pf; +static int cap_mem_op;static void *legacy_s390_alloc (size_t size,uint64_t *align);
@@ -247,6 +248,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) { cap_sync_regs =kvm_check_extension (s,KVM_CAP_SYNC_REGS ); cap_async_pf =kvm_check_extension (s,KVM_CAP_ASYNC_PF ); + cap_mem_op =kvm_check_extension (s,KVM_CAP_S390_MEM_OP );kvm_s390_enable_cmma (s);
@@ -550,6 +552,44 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)return kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr); } +/** +* kvm_s390_mem_op: +* @addr: the logical start address in guest memory +* @hostbuf: buffer in host memory. NULL = do only checks w/o copying +* @len: length that should be transfered +* @is_write: true = write, false = read +* Returns: 0 on success, non-zero if an exception or error occured +* +* Use KVM ioctl to read/write from/to guest memory. An access exception +* is injected into the vCPU in case of translation errors. +*/ +int kvm_s390_mem_op (S390CPU *cpu,vaddr addr,void *hostbuf,int len, +bool is_write) +{ +struct kvm_s390_mem_op mem_op = { + .gaddr = addr, + .flags =KVM_S390_MEMOP_F_INJECT_EXCEPTION , + .size = len, + .op = is_write ?KVM_S390_MEMOP_LOGICAL_WRITE + :KVM_S390_MEMOP_LOGICAL_READ , + .buf = (uint64_t )hostbuf, + }; +int ret; + +if (!cap_mem_op) { +return -ENOSYS ; + } +if (!hostbuf) { + mem_op.flags |=KVM_S390_MEMOP_F_CHECK_ONLY ; + } + + ret =kvm_vcpu_ioctl (CPU (cpu),KVM_S390_MEM_OP , &mem_op); +if (ret <0 ) { +error_printf ("KVM_S390_MEM_OP failed: %s\n" ,strerror (-ret)); + } +return ret; +} +/* * Legacy layout for s390: * Older S390 KVM requires the topmost vma of the RAM to be
target-s390x/mmu_helper.c +7 -0
@@ -450,6 +450,13 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,target_ulong *pages;int ret; +if (kvm_enabled ()) { + ret =kvm_s390_mem_op (cpu, laddr, hostbuf, len, is_write); +if (ret >=0 ) { +return ret; + } + } + nr_pages = (((laddr & ~TARGET_PAGE_MASK ) + len -1 ) >>TARGET_PAGE_BITS ) +1 ; pages =g_malloc (nr_pages *sizeof (*pages));
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 10/10] kvm: better advice for failed s390x startup
In reply to Cornelia HuckIf KVM_CREATE failed on s390x, we print a hint to enable the switch_amode kernel parameter. This only applies to old kernels, and only if the error was -EINVAL. Moreover, with new kernels, the most likely reason for -EINVAL is that pgstes were not enabled.
Let's update the error message to give a better hint on where things may need fixing.
--- kvm-all.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
kvm-all.c +11 -2
@@ -1544,8 +1544,17 @@ static int kvm_init(MachineState *ms) strerror(-ret));#ifdef TARGET_S390X -fprintf (stderr,"Please add the 'switch_amode' kernel parameter to " -"your host kernel command line\n" ); +if (ret == -EINVAL ) { +fprintf (stderr, +"Host kernel setup problem detected. Please verify:\n" ); +fprintf (stderr,"- for kernels supporting the switch_amode or" +" user_mode parameters, whether\n" ); +fprintf (stderr, +" user space is running in primary address space\n" ); +fprintf (stderr, +"- for kernels supporting the vm.allocate_pgste sysctl, " +"whether it is enabled\n" ); + }#endif goto err; }
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 05/10] s390x/mmu: Use access type definitions instead of magic values
In reply to Cornelia HuckFrom: Thomas Huth <[email protected]>
Since there are now proper definitions for the MMU access type, let's use them in the s390x MMU code, too, instead of the hard-to-understand magic values.
--- target-s390x/helper.c | 2 +- target-s390x/mmu_helper.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
target-s390x/helper.c +1 -1
@@ -162,7 +162,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr) vaddr &=0x7fffffff ; } -mmu_translate (env, vaddr,2 , asc, &raddr, &prot, false); +mmu_translate (env, vaddr,MMU_INST_FETCH , asc, &raddr, &prot, false);return raddr; }
target-s390x/mmu_helper.c +5 -5
@@ -68,7 +68,7 @@ static void trigger_prot_fault(CPUS390XState *env, target_ulong vaddr, {uint64_t tec; - tec = vaddr | (rw ==1 ?FS_WRITE :FS_READ ) |4 | asc >>46 ; + tec = vaddr | (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ ) |4 | asc >>46 ;DPRINTF ("%s: trans_exc_code=%016" PRIx64"\n" , __func__, tec);
@@ -85,7 +85,7 @@ static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr,int ilen =ILEN_LATER ;uint64_t tec; - tec = vaddr | (rw ==1 ?FS_WRITE :FS_READ ) | asc >>46 ; + tec = vaddr | (rw ==MMU_DATA_STORE ?FS_WRITE :FS_READ ) | asc >>46 ;DPRINTF ("%s: vaddr=%016" PRIx64" bits=%d\n" , __func__, vaddr, bits);
@@ -94,7 +94,7 @@ static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr, }/* Code accesses have an undefined ilc. */ -if (rw ==2 ) { +if (rw ==MMU_INST_FETCH ) { ilen =2 ; }
@@ -288,7 +288,7 @@ static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr, r =mmu_translate_region (env, vaddr, asc, asce, level, raddr, flags, rw, exc); -if ((rw ==1 ) && !(*flags &PAGE_WRITE )) { +if (rw ==MMU_DATA_STORE && !(*flags &PAGE_WRITE )) {trigger_prot_fault (env, vaddr, asc, rw, exc);return -1 ; }
@@ -338,7 +338,7 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,* Instruction: Primary * Data: Secondary */ -if (rw ==2 ) { +if (rw ==MMU_INST_FETCH ) { r =mmu_translate_asce (env, vaddr,PSW_ASC_PRIMARY , env->cregs[1 ], raddr, flags, rw, exc); *flags &= ~(PAGE_READ |PAGE_WRITE );
Signature · 1 line
2.3.7
More to come, but I'd like to get the first batch off my plate now.
The following changes since commit 52b7aba62f02cf90f57ee7e02f67d2d8445e7e40:
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150428.0' into staging (2015-04-28 18:58:15 +0100)
are available in the git repository at:
git://github.com/cohuck/qemu tags/s390x-20150430
for you to fetch changes up to 2c80e996e427ae31982f3405a762859578a6261d:
kvm: better advice for failed s390x startup (2015-04-30 13:21:42 +0200)
----------------------------------------------------------------
First pile of s390x patches for 2.4, including:
- some cleanup patches
- sort most of the s390x devices into categories
- support for the new STSI post handler, used to insert vm name and friends
- support for the new MEM_OP ioctl (including access register mode) for accessing guest memory
----------------------------------------------------------------
Alexander Yarygin (1):
s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl
Cornelia Huck (6):
virtio-ccw: sort into categories
s390-virtio: sort into categories
sclp: sort into categories
s390x/ipl: sort into categories
linux-headers: update
kvm: better advice for failed s390x startup
Ekaterina Tumanova (1):
s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB
Thomas Huth (2):
s390x/mmu: Use access type definitions instead of magic values s390x/mmu: Use ioctl for reading and writing from/to guest memory
hw/char/sclpconsole-lm.c | 1 + hw/char/sclpconsole.c | 1 + hw/s390x/event-facility.c | 1 + hw/s390x/ipl.c | 1 + hw/s390x/s390-pci-inst.c | 21 +-- hw/s390x/s390-pci-inst.h | 7 +- hw/s390x/s390-virtio-bus.c | 9 ++ hw/s390x/sclp.c | 9 ++ hw/s390x/sclpcpu.c | 2 + hw/s390x/sclpquiesce.c | 1 + hw/s390x/virtio-ccw.c | 9 ++ include/standard-headers/linux/virtio_balloon.h | 28 +++- include/standard-headers/linux/virtio_ids.h | 1 + include/standard-headers/linux/virtio_input.h | 76 +++++++++++ kvm-all.c | 13 +- linux-headers/asm-arm/kvm.h | 9 +- linux-headers/asm-arm64/kvm.h | 9 +- linux-headers/asm-mips/kvm.h | 164 +++++++++++++++--------- linux-headers/asm-s390/kvm.h | 4 + linux-headers/asm-x86/hyperv.h | 2 + linux-headers/linux/kvm.h | 66 +++++++++- linux-headers/linux/vfio.h | 2 + target-s390x/cpu.h | 37 ++++-- target-s390x/helper.c | 2 +- target-s390x/ioinst.c | 42 +++--- target-s390x/kvm.c | 145 +++++++++++++++++++-- target-s390x/mmu_helper.c | 20 ++- 27 files changed, 554 insertions(+), 128 deletions(-) create mode 100644 include/standard-headers/linux/virtio_input.h
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 01/10] virtio-ccw: sort into categories
Sort the various virtio-ccw devices into the same categories as their virtio-pci counterparts.
--- hw/s390x/virtio-ccw.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/s390x/virtio-ccw.c +9 -0
@@ -1453,6 +1453,7 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_net_properties; +set_bit (DEVICE_CATEGORY_NETWORK , dc->categories); }static const TypeInfo virtio_ccw_net = {
@@ -1479,6 +1480,7 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_blk_properties; +set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }static const TypeInfo virtio_ccw_blk = {
@@ -1505,6 +1507,7 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_serial_properties; +set_bit (DEVICE_CATEGORY_INPUT , dc->categories); }static const TypeInfo virtio_ccw_serial = {
@@ -1531,6 +1534,7 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_balloon_properties; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); }static const TypeInfo virtio_ccw_balloon = {
@@ -1558,6 +1562,7 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_scsi_properties; +set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }static const TypeInfo virtio_ccw_scsi = {
@@ -1583,6 +1588,7 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = vhost_ccw_scsi_properties; +set_bit (DEVICE_CATEGORY_STORAGE , dc->categories); }static const TypeInfo vhost_ccw_scsi = {
@@ -1620,6 +1626,7 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_rng_properties; +set_bit (DEVICE_CATEGORY_MISC , dc->categories); }static const TypeInfo virtio_ccw_rng = {
@@ -1706,9 +1713,11 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data) {SysBusDeviceClass *k =SYS_BUS_DEVICE_CLASS (klass);HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); k->init = virtual_css_bridge_init; hc->unplug = virtio_ccw_busdev_unplug; +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); }static const TypeInfo virtual_css_bridge_info = {
Signature · 1 line
2.3.7
[Qemu-devel] [PULL 06/10] linux-headers: update
In reply to Cornelia HuckThis updates linux-headers against master 4.1-rc1 (commit b787f68c36d49bb1d9236f403813641efa74a031).
--- include/standard-headers/linux/virtio_balloon.h | 28 +++- include/standard-headers/linux/virtio_ids.h | 1 + include/standard-headers/linux/virtio_input.h | 76 +++++++++++ linux-headers/asm-arm/kvm.h | 9 +- linux-headers/asm-arm64/kvm.h | 9 +- linux-headers/asm-mips/kvm.h | 164 +++++++++++++++--------- linux-headers/asm-s390/kvm.h | 4 + linux-headers/asm-x86/hyperv.h | 2 + linux-headers/linux/kvm.h | 66 +++++++++- linux-headers/linux/vfio.h | 2 + 10 files changed, 293 insertions(+), 68 deletions(-) create mode 100644 include/standard-headers/linux/virtio_input.h
include/standard-headers/linux/virtio_balloon.h +26 -2
@@ -25,6 +25,7 @@* 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. */ +#include "standard-headers/linux/types.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_config.h"
@@ -51,9 +52,32 @@ struct virtio_balloon_config {#define VIRTIO_BALLOON_S_MEMTOT 5/* Total amount of memory */ #define VIRTIO_BALLOON_S_NR 6 +/* +* Memory statistics structure. +* Driver fills an array of these structures and passes to device. +* +* NOTE: fields are laid out in a way that would make compiler add padding +* between and after fields, so we have to use compiler-specific attributes to +* pack it, to disable this padding. This also often causes compiler to +* generate suboptimal code. +* +* We maintain this statistics structure format for backwards compatibility, +* but don't follow this example. +* +* If implementing a similar structure, do something like the below instead: +* struct virtio_balloon_stat { +* __virtio16 tag; +* uint8_t reserved[6]; +* __virtio64 val; +* }; +* +* In other words, add explicit reserved fields to align field and +* structure boundaries at field size, avoiding compiler padding +* without the packed attribute. +*/ struct virtio_balloon_stat { -uint16_t tag; -uint64_t val; +__virtio16 tag; +__virtio64 val; }QEMU_PACKED ;#endif /* _LINUX_VIRTIO_BALLOON_H */
include/standard-headers/linux/virtio_ids.h +1 -0
@@ -39,5 +39,6 @@#define VIRTIO_ID_9P 9/* 9p virtio console */ #define VIRTIO_ID_RPROC_SERIAL 11/* virtio remoteproc serial link */ #define VIRTIO_ID_CAIF 12/* Virtio caif */ +#define VIRTIO_ID_INPUT 18/* virtio input */ #endif /* _LINUX_VIRTIO_IDS_H */
include/standard-headers/linux/virtio_input.h new file +76 -0
76 lines not on this page · raw message
linux-headers/asm-arm/kvm.h +8 -1
@@ -195,9 +195,16 @@ struct kvm_arch_memory_slot {#define KVM_ARM_IRQ_CPU_IRQ 0#define KVM_ARM_IRQ_CPU_FIQ 1 -/* Highest supported SPI, from VGIC_NR_IRQS */ +/* +* This used to hold the highest supported SPI, but it is now obsolete +* and only here to provide source code level compatibility with older +* userland. The highest SPI number can be set via KVM_DEV_ARM_VGIC_GRP_NR_IRQS. +*/ #define KVM_ARM_IRQ_GIC_MAX 127 +/* One single KVM irqchip, ie. the VGIC */ +#define KVM_NR_IRQCHIPS 1 +/* PSCI interface */ #define KVM_PSCI_FN_BASE 0x95c1ba5e#define KVM_PSCI_FN (n) (KVM_PSCI_FN_BASE + (n))
linux-headers/asm-arm64/kvm.h +8 -1
@@ -188,9 +188,16 @@ struct kvm_arch_memory_slot {#define KVM_ARM_IRQ_CPU_IRQ 0#define KVM_ARM_IRQ_CPU_FIQ 1 -/* Highest supported SPI, from VGIC_NR_IRQS */ +/* +* This used to hold the highest supported SPI, but it is now obsolete +* and only here to provide source code level compatibility with older +* userland. The highest SPI number can be set via KVM_DEV_ARM_VGIC_GRP_NR_IRQS. +*/ #define KVM_ARM_IRQ_GIC_MAX 127 +/* One single KVM irqchip, ie. the VGIC */ +#define KVM_NR_IRQCHIPS 1 +/* PSCI interface */ #define KVM_PSCI_FN_BASE 0x95c1ba5e#define KVM_PSCI_FN (n) (KVM_PSCI_FN_BASE + (n))
linux-headers/asm-mips/kvm.h +101 -63
201 lines not on this page · raw message
linux-headers/asm-s390/kvm.h +4 -0
@@ -150,6 +150,7 @@ struct kvm_guest_debug_arch {#define KVM_SYNC_CRS (1UL << 3)#define KVM_SYNC_ARCH0 (1UL << 4)#define KVM_SYNC_PFAULT (1UL << 5) +#define KVM_SYNC_VRS (1UL << 6)/* definition of registers in kvm_run */ struct kvm_sync_regs {__u64 prefix;/* prefix register */
@@ -164,6 +165,9 @@ struct kvm_sync_regs {__u64 pft;/* pfault token [PFAULT] */ __u64 pfs;/* pfault select [PFAULT] */ __u64 pfc;/* pfault compare [PFAULT] */ +__u64 vrs[32 ][2 ];/* vector registers */ +__u8 reserved[512 ];/* for future vector expansion */ +__u32 fpc;/* only valid with vector registers */ };#define KVM_REG_S390_TODPR (KVM_REG_S390 | KVM_REG_SIZE_U32 | 0x1)
linux-headers/asm-x86/hyperv.h +2 -0
@@ -225,6 +225,8 @@#define HV_STATUS_INVALID_HYPERCALL_CODE 2#define HV_STATUS_INVALID_HYPERCALL_INPUT 3#define HV_STATUS_INVALID_ALIGNMENT 4 +#define HV_STATUS_INSUFFICIENT_MEMORY 11 +#define HV_STATUS_INVALID_CONNECTION_ID 18#define HV_STATUS_INSUFFICIENT_BUFFERS 19 typedef struct _HV_REFERENCE_TSC_PAGE {
linux-headers/linux/kvm.h +65 -1
114 lines not on this page · raw message
linux-headers/linux/vfio.h +2 -0
@@ -160,6 +160,8 @@ struct vfio_device_info {__u32 flags;#define VFIO_DEVICE_FLAGS_RESET (1 << 0)/* Device supports reset */ #define VFIO_DEVICE_FLAGS_PCI (1 << 1)/* vfio-pci device */ +#define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)/* vfio-platform device */ +#define VFIO_DEVICE_FLAGS_AMBA (1 << 3)/* vfio-amba device */ __u32 num_regions;/* Max region index + 1 */ __u32 num_irqs;/* Max IRQ index + 1 */ };
Signature · 1 line
2.3.7
Peter Maydell
AppliedQuoted 14 lines · Cornelia Huck
More to come, but I'd like to get the first batch off my plate now.
The following changes since commit
52b7aba62f02cf90f57ee7e02f67d2d8445e7e40:Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150428.0' into staging (2015-04-28 18:58:15 +0100)
are available in the git repository at:
git://github.com/cohuck/qemutags/s390x-20150430for you to fetch changes up to
2c80e996e427ae31982f3405a762859578a6261d:kvm: better advice for failed s390x startup (2015-04-30 13:21:42 +0200)
Quoted 9 lines
----------------------------------------------------------------
First pile of s390x patches for 2.4, including:
- some cleanup patches
- sort most of the s390x devices into categories
- support for the new STSI post handler, used to insert vm name and friends
- support for the newMEM_OPioctl (including access register mode) for accessing guest memory
Applied, thanks.
-- PMM