From c771320e9357c9b85634002daedfe5c8988f27a6 Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Thu, 5 Oct 2017 08:44:26 +0200 Subject: s390/mm,kvm: improve detection of KVM guest faults The identification of guest fault currently relies on the PF_VCPU flag. This is set in guest_entry_irqoff and cleared in guest_exit_irqoff. Both functions are called by __vcpu_run, the PF_VCPU flag is set for quite a lot of kernel code outside of the guest execution. Replace the PF_VCPU scheme with the PIF_GUEST_FAULT in the pt_regs and make the program check handler code in entry.S set the bit only for exception that occurred between the .Lsie_gmap and .Lsie_done labels. Reviewed-by: Christian Borntraeger Signed-off-by: Martin Schwidefsky Signed-off-by: Heiko Carstens --- arch/s390/mm/fault.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'arch/s390/mm') diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 242b78c0a9ec..be974b3eb7e4 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -117,7 +117,7 @@ static inline int user_space_fault(struct pt_regs *regs) return 1; if (trans_exc_code == 2) /* secondary space -> set_fs */ return current->thread.mm_segment.ar4; - if (current->flags & PF_VCPU) + if (test_pt_regs_flag(regs, PIF_GUEST_FAULT)) return 1; return 0; } @@ -209,7 +209,7 @@ static void dump_fault_info(struct pt_regs *regs) pr_cont("kernel "); } #ifdef CONFIG_PGSTE - else if ((current->flags & PF_VCPU) && S390_lowcore.gmap) { + else if (test_pt_regs_flag(regs, PIF_GUEST_FAULT)) { struct gmap *gmap = (struct gmap *)S390_lowcore.gmap; asce = gmap->asce; pr_cont("gmap "); @@ -438,7 +438,7 @@ static inline int do_exception(struct pt_regs *regs, int access) down_read(&mm->mmap_sem); #ifdef CONFIG_PGSTE - gmap = (current->flags & PF_VCPU) ? + gmap = test_pt_regs_flag(regs, PIF_GUEST_FAULT) ? (struct gmap *) S390_lowcore.gmap : NULL; if (gmap) { current->thread.gmap_addr = address; -- cgit v1.2.3-59-g8ed1b