|
|
ddf19c |
From ebcd74c2267d69fe09ca03cb8bfed7bef5ea3a85 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Thomas Huth <thuth@redhat.com>
|
|
|
ddf19c |
Date: Fri, 29 May 2020 05:54:08 -0400
|
|
|
ddf19c |
Subject: [PATCH 26/42] s390x: Add SIDA memory ops
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
|
ddf19c |
Message-id: <20200529055420.16855-27-thuth@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 97033
|
|
|
ddf19c |
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 26/38] s390x: Add SIDA memory ops
|
|
|
ddf19c |
Bugzilla: 1828317
|
|
|
ddf19c |
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
From: Janosch Frank <frankja@linux.ibm.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Protected guests save the instruction control blocks in the SIDA
|
|
|
ddf19c |
instead of QEMU/KVM directly accessing the guest's memory.
|
|
|
ddf19c |
|
|
|
ddf19c |
Let's introduce new functions to access the SIDA.
|
|
|
ddf19c |
|
|
|
ddf19c |
The memops for doing so are available with KVM_CAP_S390_PROTECTED, so
|
|
|
ddf19c |
let's check for that.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
|
|
|
ddf19c |
Reviewed-by: David Hildenbrand <david@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
|
|
|
ddf19c |
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
|
|
|
ddf19c |
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
Message-Id: <20200319131921.2367-8-frankja@linux.ibm.com>
|
|
|
ddf19c |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 1cca8265499d394d9ed4bfb75bd6e7265b529f89)
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
target/s390x/cpu.h | 7 ++++++-
|
|
|
ddf19c |
target/s390x/kvm.c | 26 ++++++++++++++++++++++++++
|
|
|
ddf19c |
target/s390x/kvm_s390x.h | 2 ++
|
|
|
ddf19c |
target/s390x/mmu_helper.c | 14 ++++++++++++++
|
|
|
ddf19c |
4 files changed, 48 insertions(+), 1 deletion(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
|
|
|
ddf19c |
index 1ff84e6b3a..edf8391504 100644
|
|
|
ddf19c |
--- a/target/s390x/cpu.h
|
|
|
ddf19c |
+++ b/target/s390x/cpu.h
|
|
|
ddf19c |
@@ -828,7 +828,12 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
|
|
|
ddf19c |
#define s390_cpu_virt_mem_check_write(cpu, laddr, ar, len) \
|
|
|
ddf19c |
s390_cpu_virt_mem_rw(cpu, laddr, ar, NULL, len, true)
|
|
|
ddf19c |
void s390_cpu_virt_mem_handle_exc(S390CPU *cpu, uintptr_t ra);
|
|
|
ddf19c |
-
|
|
|
ddf19c |
+int s390_cpu_pv_mem_rw(S390CPU *cpu, unsigned int offset, void *hostbuf,
|
|
|
ddf19c |
+ int len, bool is_write);
|
|
|
ddf19c |
+#define s390_cpu_pv_mem_read(cpu, offset, dest, len) \
|
|
|
ddf19c |
+ s390_cpu_pv_mem_rw(cpu, offset, dest, len, false)
|
|
|
ddf19c |
+#define s390_cpu_pv_mem_write(cpu, offset, dest, len) \
|
|
|
ddf19c |
+ s390_cpu_pv_mem_rw(cpu, offset, dest, len, true)
|
|
|
ddf19c |
|
|
|
ddf19c |
/* sigp.c */
|
|
|
ddf19c |
int s390_cpu_restart(S390CPU *cpu);
|
|
|
ddf19c |
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
|
|
|
ddf19c |
index af50b2c253..f67bb5ce2c 100644
|
|
|
ddf19c |
--- a/target/s390x/kvm.c
|
|
|
ddf19c |
+++ b/target/s390x/kvm.c
|
|
|
ddf19c |
@@ -154,6 +154,7 @@ static int cap_ri;
|
|
|
ddf19c |
static int cap_gs;
|
|
|
ddf19c |
static int cap_hpage_1m;
|
|
|
ddf19c |
static int cap_vcpu_resets;
|
|
|
ddf19c |
+static int cap_protected;
|
|
|
ddf19c |
|
|
|
ddf19c |
static int active_cmma;
|
|
|
ddf19c |
|
|
|
ddf19c |
@@ -351,6 +352,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
|
ddf19c |
cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
|
|
|
ddf19c |
cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ);
|
|
|
ddf19c |
cap_vcpu_resets = kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS);
|
|
|
ddf19c |
+ cap_protected = kvm_check_extension(s, KVM_CAP_S390_PROTECTED);
|
|
|
ddf19c |
|
|
|
ddf19c |
if (!kvm_check_extension(s, KVM_CAP_S390_GMAP)
|
|
|
ddf19c |
|| !kvm_check_extension(s, KVM_CAP_S390_COW)) {
|
|
|
ddf19c |
@@ -848,6 +850,30 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
|
ddf19c |
return ret;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+int kvm_s390_mem_op_pv(S390CPU *cpu, uint64_t offset, void *hostbuf,
|
|
|
ddf19c |
+ int len, bool is_write)
|
|
|
ddf19c |
+{
|
|
|
ddf19c |
+ struct kvm_s390_mem_op mem_op = {
|
|
|
ddf19c |
+ .sida_offset = offset,
|
|
|
ddf19c |
+ .size = len,
|
|
|
ddf19c |
+ .op = is_write ? KVM_S390_MEMOP_SIDA_WRITE
|
|
|
ddf19c |
+ : KVM_S390_MEMOP_SIDA_READ,
|
|
|
ddf19c |
+ .buf = (uint64_t)hostbuf,
|
|
|
ddf19c |
+ };
|
|
|
ddf19c |
+ int ret;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (!cap_mem_op || !cap_protected) {
|
|
|
ddf19c |
+ return -ENOSYS;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ ret = kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
|
|
|
ddf19c |
+ if (ret < 0) {
|
|
|
ddf19c |
+ error_report("KVM_S390_MEM_OP failed: %s", strerror(-ret));
|
|
|
ddf19c |
+ abort();
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ return ret;
|
|
|
ddf19c |
+}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
/*
|
|
|
ddf19c |
* Legacy layout for s390:
|
|
|
ddf19c |
* Older S390 KVM requires the topmost vma of the RAM to be
|
|
|
ddf19c |
diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h
|
|
|
ddf19c |
index dea813f450..6ab17c81b7 100644
|
|
|
ddf19c |
--- a/target/s390x/kvm_s390x.h
|
|
|
ddf19c |
+++ b/target/s390x/kvm_s390x.h
|
|
|
ddf19c |
@@ -19,6 +19,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
|
|
|
ddf19c |
void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
|
|
|
ddf19c |
int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
|
ddf19c |
int len, bool is_write);
|
|
|
ddf19c |
+int kvm_s390_mem_op_pv(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
|
|
|
ddf19c |
+ bool is_write);
|
|
|
ddf19c |
void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code);
|
|
|
ddf19c |
int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
|
|
|
ddf19c |
void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu);
|
|
|
ddf19c |
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
|
|
|
ddf19c |
index c9f3f34750..ec8befbdc8 100644
|
|
|
ddf19c |
--- a/target/s390x/mmu_helper.c
|
|
|
ddf19c |
+++ b/target/s390x/mmu_helper.c
|
|
|
ddf19c |
@@ -474,6 +474,20 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
|
|
|
ddf19c |
return 0;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+int s390_cpu_pv_mem_rw(S390CPU *cpu, unsigned int offset, void *hostbuf,
|
|
|
ddf19c |
+ int len, bool is_write)
|
|
|
ddf19c |
+{
|
|
|
ddf19c |
+ int ret;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (kvm_enabled()) {
|
|
|
ddf19c |
+ ret = kvm_s390_mem_op_pv(cpu, offset, hostbuf, len, is_write);
|
|
|
ddf19c |
+ } else {
|
|
|
ddf19c |
+ /* Protected Virtualization is a KVM/Hardware only feature */
|
|
|
ddf19c |
+ g_assert_not_reached();
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ return ret;
|
|
|
ddf19c |
+}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
/**
|
|
|
ddf19c |
* s390_cpu_virt_mem_rw:
|
|
|
ddf19c |
* @laddr: the logical start address
|
|
|
ddf19c |
--
|
|
|
ddf19c |
2.27.0
|
|
|
ddf19c |
|