mirror of
https://github.com/torvalds/linux.git
synced 2026-07-30 11:11:26 +02:00
KVM: s390: Implement KVM_PRE_FAULT_MEMORY
Implement and enable the KVM_PRE_FAULT_MEMORY ioctl for s390. Faulted-in pages will be marked as accessed, unlike x86, otherwise they will trigger a minor fault when accessed. Avoiding such faults is one of the points of KVM_PRE_FAULT_MEMORY. Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Message-ID: <20260527144358.186359-3-imbrenda@linux.ibm.com>
This commit is contained in:
parent
499d2e4b75
commit
bea77e83c0
|
|
@ -30,6 +30,7 @@ config KVM
|
|||
select KVM_VFIO
|
||||
select VIRT_XFER_TO_GUEST_WORK
|
||||
select KVM_MMU_LOCKLESS_AGING
|
||||
select KVM_GENERIC_PRE_FAULT_MEMORY
|
||||
help
|
||||
Support hosting paravirtualized guest machines using the SIE
|
||||
virtualization capability on the mainframe. This should work
|
||||
|
|
|
|||
|
|
@ -630,6 +630,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
|
|||
case KVM_CAP_S390_USER_OPEREXEC:
|
||||
case KVM_CAP_S390_KEYOP:
|
||||
case KVM_CAP_S390_VSIE_ESAMODE:
|
||||
case KVM_CAP_PRE_FAULT_MEMORY:
|
||||
r = 1;
|
||||
break;
|
||||
case KVM_CAP_SET_GUEST_DEBUG2:
|
||||
|
|
@ -5736,6 +5737,50 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* kvm_arch_vcpu_pre_fault_memory() -- pre-fault and link gmap dat tables
|
||||
* @vcpu: the vcpu that shall appear to have generated the fault-in.
|
||||
* @range: the range that needs to be faulted in.
|
||||
*
|
||||
* The first page of the given range is faulted in and the corresponding gmap
|
||||
* page tables are created, as if the given vCPU had performed a read
|
||||
* operation.
|
||||
* If the range starts outside any memslots, an error is returned. An error is
|
||||
* also returned for UCONTROL VMs, which should instead use the
|
||||
* KVM_S390_VCPU_FAULT ioctl.
|
||||
*
|
||||
* Return:
|
||||
* * %-ENOENT if the range lies outside of a memslot.
|
||||
* * %-EINVAL in case of invalid state (for example if the VM is UCONTROL).
|
||||
* * %-EIO if errors happen while faulting-in the page (will trigger a warning
|
||||
* in the caller).
|
||||
* * other error codes < 0 in case of other errors.
|
||||
* * otherwise a number > 0 of bytes that have been faulted in successfully.
|
||||
*/
|
||||
long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu, struct kvm_pre_fault_memory *range)
|
||||
{
|
||||
struct guest_fault f = { .gfn = gpa_to_gfn(range->gpa), };
|
||||
gpa_t end;
|
||||
int rc;
|
||||
|
||||
if (kvm_is_ucontrol(vcpu->kvm))
|
||||
return -EINVAL;
|
||||
|
||||
rc = kvm_s390_faultin_gfn(vcpu, NULL, &f);
|
||||
if (rc == PGM_ADDRESSING)
|
||||
return -ENOENT;
|
||||
if (rc > 0)
|
||||
return -EIO;
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (f.ptep)
|
||||
return PAGE_SIZE;
|
||||
|
||||
end = ALIGN(range->gpa + PAGE_SIZE, f.crste_region3 ? _REGION3_SIZE : HPAGE_SIZE);
|
||||
return min(range->size, end - range->gpa);
|
||||
}
|
||||
|
||||
/**
|
||||
* kvm_test_age_gfn() - test young
|
||||
* @kvm: the kvm instance
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user