qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: peter.maydell@linaro.org
Cc: Frank Blaschka <frank.blaschka@de.ibm.com>,
	qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com,
	jfrei@linux.vnet.ibm.com,
	Cornelia Huck <cornelia.huck@de.ibm.com>
Subject: [Qemu-devel] [PULL 09/11] s390/pci: implement stpcifc instruction
Date: Mon, 15 Dec 2014 12:35:30 +0100	[thread overview]
Message-ID: <1418643332-29100-10-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1418643332-29100-1-git-send-email-cornelia.huck@de.ibm.com>

From: Frank Blaschka <frank.blaschka@de.ibm.com>

This patch implements the last remaining s390 pci instruction
to query the function information block.

Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-pci-bus.h  |    1 +
 hw/s390x/s390-pci-inst.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/s390x/s390-pci-inst.h |    1 +
 target-s390x/kvm.c       |    9 +++++--
 4 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/s390-pci-bus.h b/hw/s390x/s390-pci-bus.h
index 2a9f735..35f4da5 100644
--- a/hw/s390x/s390-pci-bus.h
+++ b/hw/s390x/s390-pci-bus.h
@@ -223,6 +223,7 @@ typedef struct S390PCIBusDevice {
     uint64_t g_iota;
     uint64_t pba;
     uint64_t pal;
+    uint64_t fmb_addr;
     uint8_t isc;
     uint16_t noi;
     uint8_t sum;
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 8648594..f503665 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -766,6 +766,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
         pbdev->lgstg_blocked = false;
         break;
     case ZPCI_MOD_FC_SET_MEASURE:
+        pbdev->fmb_addr = ldq_p(&fib.fmb_addr);
         break;
     default:
         program_interrupt(&cpu->env, PGM_OPERAND, 6);
@@ -775,3 +776,66 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
     setcc(cpu, cc);
     return 0;
 }
+
+int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
+{
+    CPUS390XState *env = &cpu->env;
+    uint32_t fh;
+    ZpciFib fib;
+    S390PCIBusDevice *pbdev;
+    uint32_t data;
+    uint64_t cc = ZPCI_PCI_LS_OK;
+
+    cpu_synchronize_state(CPU(cpu));
+
+    if (env->psw.mask & PSW_MASK_PSTATE) {
+        program_interrupt(env, PGM_PRIVILEGED, 6);
+        return 0;
+    }
+
+    fh = env->regs[r1] >> 32;
+
+    if (fiba & 0x7) {
+        program_interrupt(env, PGM_SPECIFICATION, 6);
+        return 0;
+    }
+
+    pbdev = s390_pci_find_dev_by_fh(fh);
+    if (!pbdev) {
+        setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
+        return 0;
+    }
+
+    memset(&fib, 0, sizeof(fib));
+    stq_p(&fib.pba, pbdev->pba);
+    stq_p(&fib.pal, pbdev->pal);
+    stq_p(&fib.iota, pbdev->g_iota);
+    stq_p(&fib.aibv, pbdev->routes.adapter.ind_addr);
+    stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
+    stq_p(&fib.fmb_addr, pbdev->fmb_addr);
+
+    data = (pbdev->isc << 28) | (pbdev->noi << 16) |
+           (pbdev->routes.adapter.ind_offset << 8) | (pbdev->sum << 7) |
+           pbdev->routes.adapter.summary_offset;
+    stw_p(&fib.data, data);
+
+    if (pbdev->fh >> ENABLE_BIT_OFFSET) {
+        fib.fc |= 0x80;
+    }
+
+    if (pbdev->error_state) {
+        fib.fc |= 0x40;
+    }
+
+    if (pbdev->lgstg_blocked) {
+        fib.fc |= 0x20;
+    }
+
+    if (pbdev->g_iota) {
+        fib.fc |= 0x10;
+    }
+
+    cpu_physical_memory_write(fiba, (uint8_t *)&fib, sizeof(fib));
+    setcc(cpu, cc);
+    return 0;
+}
diff --git a/hw/s390x/s390-pci-inst.h b/hw/s390x/s390-pci-inst.h
index 609e3e0..1c2f458 100644
--- a/hw/s390x/s390-pci-inst.h
+++ b/hw/s390x/s390-pci-inst.h
@@ -283,5 +283,6 @@ 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);
 
 #endif
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 5d9c83a..4de05bd 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -906,8 +906,13 @@ static int kvm_pcistg_service_call(S390CPU *cpu, struct kvm_run *run)
 
 static int kvm_stpcifc_service_call(S390CPU *cpu, struct kvm_run *run)
 {
-    qemu_log_mask(LOG_UNIMP, "STPCIFC missing\n");
-    return 0;
+    uint8_t r1 = (run->s390_sieic.ipa & 0x00f0) >> 4;
+    uint64_t fiba;
+
+    cpu_synchronize_state(CPU(cpu));
+    fiba = get_base_disp_rxy(cpu, run);
+
+    return stpcifc_service_call(cpu, r1, fiba);
 }
 
 static int kvm_sic_service_call(S390CPU *cpu, struct kvm_run *run)
-- 
1.7.9.5

  parent reply	other threads:[~2014-12-15 11:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 11:35 [Qemu-devel] [PULL 00/11] s390x changes for 2.3 Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 01/11] s390: Add PCI bus support Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 02/11] s390: implement pci instructions Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 03/11] kvm: extend kvm_irqchip_add_msi_route to work on s390 Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 04/11] s390x/ccw: fix oddity in machine class init Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 05/11] s390x/css: Clean up unnecessary CONFIG_USER_ONLY wrappers Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 06/11] s390x/kvm: sync register support helper function Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 07/11] s390x/kvm: avoid syscalls by syncing registers with kvm_run Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 08/11] s390/pci: add error event support Cornelia Huck
2014-12-15 11:35 ` Cornelia Huck [this message]
2014-12-15 11:35 ` [Qemu-devel] [PULL 10/11] s390/pci: remove unnecessary cpu_synchronize_state Cornelia Huck
2014-12-15 11:35 ` [Qemu-devel] [PULL 11/11] s390x: update MAINTAINERS Cornelia Huck
2014-12-15 13:10 ` [Qemu-devel] [PULL 00/11] s390x changes for 2.3 Peter Maydell
2014-12-15 13:48   ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418643332-29100-10-git-send-email-cornelia.huck@de.ibm.com \
    --to=cornelia.huck@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=frank.blaschka@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).