-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new patches from virt-pvm/linux#7 (comment)
- Loading branch information
Showing
4 changed files
with
107 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From: bysui <[email protected]> | ||
Subject: https://github.com/virt-pvm/linux/issues/7#issuecomment-2079017654 | ||
--- | ||
diff --git a/arch/x86/kvm/pvm/pvm.c b/arch/x86/kvm/pvm/pvm.c | ||
index 37e8a19bc..97babe4a7 100644 | ||
--- a/arch/x86/kvm/pvm/pvm.c | ||
+++ b/arch/x86/kvm/pvm/pvm.c | ||
@@ -1176,10 +1176,14 @@ static int pvm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) | ||
* user memory region before the VM entry. | ||
*/ | ||
pvm->msr_vcpu_struct = data; | ||
- if (!data) | ||
+ if (!data) { | ||
kvm_gpc_deactivate(&pvm->pvcs_gpc); | ||
- else if (kvm_gpc_activate(&pvm->pvcs_gpc, data, PAGE_SIZE)) | ||
- return 1; | ||
+ } | ||
+ } else if (kvm_gpc_activate(&pvm->pvcs_gpc, data, PAGE_SIZE)) { | ||
+ if (msr_info->host_initiated) | ||
+ kvm_make_request(KVM_REQ_GPC_REFRESH, vcpu); | ||
+ return 1; | ||
+ } | ||
break; | ||
case MSR_PVM_SUPERVISOR_RSP: | ||
pvm->msr_supervisor_rsp = msr_info->data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,93 @@ | ||
From: bysui <[email protected]> | ||
Subject: https://github.com/virt-pvm/linux/issues/7#issuecomment-2069445537 | ||
Subject: https://github.com/virt-pvm/linux/issues/7#issuecomment-2079017654 | ||
--- | ||
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c | ||
index adcea8ecf..8b883523c 100644 | ||
--- a/arch/x86/kernel/setup.c | ||
+++ b/arch/x86/kernel/setup.c | ||
@@ -719,6 +719,27 @@ static void __init x86_report_nx(void) | ||
} | ||
} | ||
|
||
+#ifdef CONFIG_X86_64 | ||
+static void __init x86_reserve_vmalloc_range(void) | ||
+{ | ||
+ static struct vm_struct pvm; | ||
+ unsigned long size = 32UL << 39; | ||
+ | ||
+ if (pgtable_l5_enabled()) | ||
+ size = 32UL << 48; | ||
+ | ||
+ pvm.addr = (void *)(VMALLOC_END + 1 - size); | ||
+ pvm.size = size; | ||
+ pvm.flags = VM_ALLOC | VM_NO_GUARD; | ||
+ | ||
+ vm_area_add_early(&pvm); | ||
+} | ||
+#else | ||
+static void __init x86_reserve_vmalloc_range(void) | ||
+{ | ||
+} | ||
+#endif | ||
+ | ||
/* | ||
* Determine if we were loaded by an EFI loader. If so, then we have also been | ||
* passed the efi memmap, systab, etc., so we should use these data structures | ||
@@ -961,6 +982,7 @@ void __init setup_arch(char **cmdline_p) | ||
* defined and before each memory section base is used. | ||
*/ | ||
kernel_randomize_memory(); | ||
+ x86_reserve_vmalloc_range(); | ||
|
||
#ifdef CONFIG_X86_32 | ||
/* max_low_pfn get updated here */ | ||
diff --git a/arch/x86/kvm/pvm/host_mmu.c b/arch/x86/kvm/pvm/host_mmu.c | ||
index 35e97f4f7..f4da658b1 100644 | ||
index a60a7c78c..3ead2b301 100644 | ||
--- a/arch/x86/kvm/pvm/host_mmu.c | ||
+++ b/arch/x86/kvm/pvm/host_mmu.c | ||
@@ -35,8 +35,9 @@ static int __init guest_address_space_init(void) | ||
return -1; | ||
} | ||
@@ -51,9 +51,8 @@ static int __init guest_address_space_init(void) | ||
pml4_index_start = L4_PT_INDEX(PVM_GUEST_MAPPING_START); | ||
pml4_index_end = L4_PT_INDEX(RAW_CPU_ENTRY_AREA_BASE); | ||
|
||
- pvm_va_range = get_vm_area_align(DEFAULT_RANGE_L5_SIZE, PT_L5_SIZE, | ||
- VM_ALLOC|VM_NO_GUARD); | ||
- if (!pvm_va_range) { | ||
+ pvm_va_range = find_vm_area((void *)(VMALLOC_END + 1 - DEFAULT_RANGE_L5_SIZE)); | ||
+ if (!pvm_va_range || pvm_va_range->size != DEFAULT_RANGE_L5_SIZE) | ||
pml5_index_start = 0x1ff; | ||
pml5_index_end = 0x1ff; | ||
} else { | ||
@@ -62,9 +61,8 @@ static int __init guest_address_space_init(void) | ||
(u64)pvm_va_range->size); | ||
} | ||
} else { | ||
- pvm_va_range = get_vm_area_align(DEFAULT_RANGE_L4_SIZE, PT_L4_SIZE, | ||
- VM_ALLOC|VM_NO_GUARD); | ||
- if (!pvm_va_range) | ||
+ pvm_va_range = find_vm_area((void *)(VMALLOC_END + 1 - DEFAULT_RANGE_L4_SIZE));_vm_area_align(DEFAULT_RANGE_L4_SIZE, PT_L4_SIZE, | ||
+ if (!pvm_va_range || pvm_va_range->size != DEFAULT_RANGE_L4_SIZE)O_GUARD); | ||
return -1; | ||
|
||
- pvm_va_range_l4 = get_vm_area_align(DEFAULT_RANGE_L4_SIZE, PT_L4_SIZE, | ||
- VM_ALLOC|VM_NO_GUARD); | ||
+ pvm_va_range_l4 = __get_vm_area_caller(DEFAULT_RANGE_L4_SIZE, VM_ALLOC|VM_NO_GUARD, | ||
+ VMALLOC_END - DEFAULT_RANGE_L4_SIZE, VMALLOC_END, | ||
+ __builtin_return_address(0)); | ||
if (!pvm_va_range_l4) | ||
return -1; | ||
pml4_index_start = L4_PT_INDEX((u64)pvm_va_range->addr); | ||
@@ -133,8 +131,6 @@ int __init host_mmu_init(void) | ||
|
||
void host_mmu_destroy(void) | ||
{ | ||
- if (pvm_va_range) | ||
- free_vm_area(pvm_va_range); | ||
if (host_mmu_root_pgd) | ||
free_page((unsigned long)(void *)host_mmu_root_pgd); | ||
if (host_mmu_la57_top_p4d) | ||
diff --git a/mm/vmalloc.c b/mm/vmalloc.c | ||
index 6e4b95f24..0b8b2d4ed 100644 | ||
index 6e4b95f24..64ba3bbb4 100644 | ||
--- a/mm/vmalloc.c | ||
+++ b/mm/vmalloc.c | ||
@@ -2623,6 +2623,8 @@ struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags, | ||
NUMA_NO_NODE, GFP_KERNEL, caller); | ||
@@ -2681,6 +2681,8 @@ struct vm_struct *find_vm_area(const void *addr) | ||
return va->vm; | ||
} | ||
|
||
+ EXPORT_SYMBOL_GPL(__get_vm_area_caller); | ||
+EXPORT_SYMBOL_GPL(find_vm_area); | ||
+ | ||
/** | ||
* get_vm_area - reserve a contiguous kernel virtual area | ||
* @size: size of the area | ||
* remove_vm_area - find and remove a continuous kernel virtual area | ||
* @addr: base address |