[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 kvm/queue 13/16] KVM: Add KVM_EXIT_MEMORY_ERROR exit
From: |
Chao Peng |
Subject: |
[PATCH v3 kvm/queue 13/16] KVM: Add KVM_EXIT_MEMORY_ERROR exit |
Date: |
Thu, 23 Dec 2021 20:30:08 +0800 |
This new exit allows user space to handle memory-related errors.
Currently it supports two types (KVM_EXIT_MEM_MAP_SHARED/PRIVATE) of
errors which are used for shared memory <-> private memory conversion
in memory encryption usage.
After private memory is enabled, there are two places in KVM that can
exit to userspace to trigger private <-> shared conversion:
- explicit conversion: happens when guest explicitly calls into KVM to
map a range (as private or shared), KVM then exits to userspace to
do the map/unmap operations.
- implicit conversion: happens in KVM page fault handler.
* if the fault is due to a private memory access then causes a
userspace exit for a shared->private conversion request when the
page has not been allocated in the private memory backend.
* If the fault is due to a shared memory access then causes a
userspace exit for a private->shared conversion request when the
page has already been allocated in the private memory backend.
Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
Signed-off-by: Chao Peng <chao.p.peng@linux.intel.com>
---
include/uapi/linux/kvm.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 41434322fa23..d68db3b2eeec 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -243,6 +243,18 @@ struct kvm_xen_exit {
} u;
};
+struct kvm_memory_exit {
+#define KVM_EXIT_MEM_MAP_SHARED 1
+#define KVM_EXIT_MEM_MAP_PRIVATE 2
+ __u32 type;
+ union {
+ struct {
+ __u64 gpa;
+ __u64 size;
+ } map;
+ } u;
+};
+
#define KVM_S390_GET_SKEYS_NONE 1
#define KVM_S390_SKEYS_MAX 1048576
@@ -282,6 +294,7 @@ struct kvm_xen_exit {
#define KVM_EXIT_X86_BUS_LOCK 33
#define KVM_EXIT_XEN 34
#define KVM_EXIT_RISCV_SBI 35
+#define KVM_EXIT_MEMORY_ERROR 36
/* For KVM_EXIT_INTERNAL_ERROR */
/* Emulate instruction failed. */
@@ -499,6 +512,8 @@ struct kvm_run {
unsigned long args[6];
unsigned long ret[2];
} riscv_sbi;
+ /* KVM_EXIT_MEMORY_ERROR */
+ struct kvm_memory_exit mem;
/* Fix the size of the union. */
char padding[256];
};
--
2.17.1
- [PATCH v3 kvm/queue 05/16] KVM: Maintain ofs_tree for fast memslot lookup by file offset, (continued)
- [PATCH v3 kvm/queue 05/16] KVM: Maintain ofs_tree for fast memslot lookup by file offset, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 07/16] KVM: Refactor hva based memory invalidation code, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 08/16] KVM: Special handling for fd-based memory invalidation, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 06/16] KVM: Implement fd-based memory using MEMFD_OPS interfaces, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 09/16] KVM: Split out common memory invalidation code, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 10/16] KVM: Implement fd-based memory invalidation, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 11/16] KVM: Add kvm_map_gfn_range, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 12/16] KVM: Implement fd-based memory fallocation, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 13/16] KVM: Add KVM_EXIT_MEMORY_ERROR exit,
Chao Peng <=
- [PATCH v3 kvm/queue 14/16] KVM: Handle page fault for private memory, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 15/16] KVM: Use kvm_userspace_memory_region_ext, Chao Peng, 2021/12/23
- [PATCH v3 kvm/queue 16/16] KVM: Register/unregister private memory slot to memfd, Chao Peng, 2021/12/23