linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm: x86: move architecture-specific code into kvm_arch_vcpu_fault
@ 2021-08-11  3:17 Hou Wenlong
  2021-08-11 18:52 ` Sean Christopherson
  0 siblings, 1 reply; 7+ messages in thread
From: Hou Wenlong @ 2021-08-11  3:17 UTC (permalink / raw)
  To: kvm
  Cc: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, x86, H. Peter Anvin, linux-kernel

The function kvm_arch_vcpu_fault can handle architecture-specific
case, so move pio-data fault case into it for x86.

Signed-off-by: Hou Wenlong <houwenlong93@linux.alibaba.com>
---
 arch/x86/kvm/x86.c  | 8 ++++++++
 virt/kvm/kvm_main.c | 4 ----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e5d5c5ed7dd4..30b0706eced8 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5348,6 +5348,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
 
 vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
 {
+	if (vmf->pgoff == KVM_PIO_PAGE_OFFSET) {
+		struct page *page = virt_to_page(vcpu->arch.pio_data);
+
+		get_page(page);
+		vmf->page = page;
+		return 0;
+	}
+
 	return VM_FAULT_SIGBUS;
 }
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index b50dbe269f4b..084fba09eca0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3370,10 +3370,6 @@ static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf)
 
 	if (vmf->pgoff == 0)
 		page = virt_to_page(vcpu->run);
-#ifdef CONFIG_X86
-	else if (vmf->pgoff == KVM_PIO_PAGE_OFFSET)
-		page = virt_to_page(vcpu->arch.pio_data);
-#endif
 #ifdef CONFIG_KVM_MMIO
 	else if (vmf->pgoff == KVM_COALESCED_MMIO_PAGE_OFFSET)
 		page = virt_to_page(vcpu->kvm->coalesced_mmio_ring);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-23 14:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11  3:17 [PATCH] kvm: x86: move architecture-specific code into kvm_arch_vcpu_fault Hou Wenlong
2021-08-11 18:52 ` Sean Christopherson
2021-08-12  4:02   ` [PATCH v2 1/2] KVM: Refactor kvm_arch_vcpu_fault() to return a struct page pointer Hou Wenlong
2021-08-12  4:02     ` [PATCH v2 2/2] kvm: x86: move architecture specific code into kvm_arch_vcpu_fault Hou Wenlong
2021-08-12  9:04     ` [PATCH v2 1/2] KVM: Refactor kvm_arch_vcpu_fault() to return a struct page pointer David Hildenbrand
2021-08-12 15:41       ` Paolo Bonzini
2021-08-23 14:12       ` Christian Borntraeger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).