|
|
586cba |
From 27c1d979a994f5afc59c3520af58d15aa5aae723 Mon Sep 17 00:00:00 2001
|
|
|
586cba |
From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
|
|
|
586cba |
Date: Fri, 6 May 2022 17:39:56 +0200
|
|
|
586cba |
Subject: [PATCH 29/32] target/s390x: kvm: Honor storage keys during emulation
|
|
|
586cba |
|
|
|
586cba |
RH-Author: Thomas Huth <thuth@redhat.com>
|
|
|
586cba |
RH-MergeRequest: 109: Honor storage keys during emulation of I/O instructions
|
|
|
586cba |
RH-Commit: [2/2] 346dee1e13bfe1c074e4c6a4417091711d852f9c (thuth/qemu-kvm-cs9)
|
|
|
586cba |
RH-Bugzilla: 2111994
|
|
|
586cba |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
586cba |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
586cba |
RH-Acked-by: Claudio Imbrenda <None>
|
|
|
586cba |
|
|
|
586cba |
Storage key controlled protection is currently not honored when
|
|
|
586cba |
emulating instructions.
|
|
|
586cba |
If available, enable key protection for the MEM_OP ioctl, thereby
|
|
|
586cba |
enabling it for the s390_cpu_virt_mem_* functions, when using kvm.
|
|
|
586cba |
As a result, the emulation of the following instructions honors storage
|
|
|
586cba |
keys:
|
|
|
586cba |
|
|
|
586cba |
* CLP
|
|
|
586cba |
The Synch I/O CLP command would need special handling in order
|
|
|
586cba |
to support storage keys, but is currently not supported.
|
|
|
586cba |
* CHSC
|
|
|
586cba |
Performing commands asynchronously would require special
|
|
|
586cba |
handling, but commands are currently always synchronous.
|
|
|
586cba |
* STSI
|
|
|
586cba |
* TSCH
|
|
|
586cba |
Must (and does) not change channel if terminated due to
|
|
|
586cba |
protection.
|
|
|
586cba |
* MSCH
|
|
|
586cba |
Suppressed on protection, works because fetching instruction.
|
|
|
586cba |
* SSCH
|
|
|
586cba |
Suppressed on protection, works because fetching instruction.
|
|
|
586cba |
* STSCH
|
|
|
586cba |
* STCRW
|
|
|
586cba |
Suppressed on protection, this works because no partial store is
|
|
|
586cba |
possible, because the operand cannot span multiple pages.
|
|
|
586cba |
* PCISTB
|
|
|
586cba |
* MPCIFC
|
|
|
586cba |
* STPCIFC
|
|
|
586cba |
|
|
|
586cba |
Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
|
|
|
586cba |
Message-Id: <20220506153956.2217601-3-scgl@linux.ibm.com>
|
|
|
586cba |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
586cba |
|
|
|
586cba |
(cherry picked from commit 54354861d21b69ec0781f43e67b8d4f6edad7e3f)
|
|
|
586cba |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2111994
|
|
|
586cba |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
586cba |
---
|
|
|
586cba |
target/s390x/kvm/kvm.c | 9 +++++++++
|
|
|
586cba |
1 file changed, 9 insertions(+)
|
|
|
586cba |
|
|
|
586cba |
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
|
|
|
586cba |
index 74f089d87f..1f1d1a33b8 100644
|
|
|
586cba |
--- a/target/s390x/kvm/kvm.c
|
|
|
586cba |
+++ b/target/s390x/kvm/kvm.c
|
|
|
586cba |
@@ -152,12 +152,15 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
|
|
586cba |
static int cap_sync_regs;
|
|
|
586cba |
static int cap_async_pf;
|
|
|
586cba |
static int cap_mem_op;
|
|
|
586cba |
+static int cap_mem_op_extension;
|
|
|
586cba |
static int cap_s390_irq;
|
|
|
586cba |
static int cap_ri;
|
|
|
586cba |
static int cap_hpage_1m;
|
|
|
586cba |
static int cap_vcpu_resets;
|
|
|
586cba |
static int cap_protected;
|
|
|
586cba |
|
|
|
586cba |
+static bool mem_op_storage_key_support;
|
|
|
586cba |
+
|
|
|
586cba |
static int active_cmma;
|
|
|
586cba |
|
|
|
586cba |
static int kvm_s390_query_mem_limit(uint64_t *memory_limit)
|
|
|
586cba |
@@ -355,6 +358,8 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
|
|
|
586cba |
cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
|
|
|
586cba |
cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
|
|
|
586cba |
cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
|
|
|
586cba |
+ cap_mem_op_extension = kvm_check_extension(s, KVM_CAP_S390_MEM_OP_EXTENSION);
|
|
|
586cba |
+ mem_op_storage_key_support = cap_mem_op_extension > 0;
|
|
|
586cba |
cap_s390_irq = kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ);
|
|
|
586cba |
cap_vcpu_resets = kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS);
|
|
|
586cba |
cap_protected = kvm_check_extension(s, KVM_CAP_S390_PROTECTED);
|
|
|
586cba |
@@ -843,6 +848,7 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
|
586cba |
: KVM_S390_MEMOP_LOGICAL_READ,
|
|
|
586cba |
.buf = (uint64_t)hostbuf,
|
|
|
586cba |
.ar = ar,
|
|
|
586cba |
+ .key = (cpu->env.psw.mask & PSW_MASK_KEY) >> PSW_SHIFT_KEY,
|
|
|
586cba |
};
|
|
|
586cba |
int ret;
|
|
|
586cba |
|
|
|
586cba |
@@ -852,6 +858,9 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
|
|
|
586cba |
if (!hostbuf) {
|
|
|
586cba |
mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
|
|
|
586cba |
}
|
|
|
586cba |
+ if (mem_op_storage_key_support) {
|
|
|
586cba |
+ mem_op.flags |= KVM_S390_MEMOP_F_SKEY_PROTECTION;
|
|
|
586cba |
+ }
|
|
|
586cba |
|
|
|
586cba |
ret = kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
|
|
|
586cba |
if (ret < 0) {
|
|
|
586cba |
--
|
|
|
586cba |
2.31.1
|
|
|
586cba |
|