From nobody Wed Sep 21 09:30:06 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MXY6R21PYz4crn2; Wed, 21 Sep 2022 09:30:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MXY6R0xNCz3ZLR; Wed, 21 Sep 2022 09:30:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663752607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SA81y/tCHOLc3jycjYwz6cDsB1t1ZBZl9png34acLY0=; b=k7FJa+AZySwaw73PUJBHnoxewqIecRA9B7JR5UPLuZnk67pxvdLeXDr2jxZd/M+YFQwPuS XQqxFABzTdUAlVFDVDVqHeURtfooaUzX1yf7WSn6uJeh7BI1I0QpDb6+W7R0khH/EEhE49 mqzMzNhFiKE8EZNkqZWFeJRWOGVMsbDqi9f1dWZbmlyoCHK+voS9MSz25mmhT7TpOPh8xO enIAwkIhvvIrgqwhc/Yjy3w+UYRzzrYfBlSf42nORCd0xQdm1flFZVR1V+xlyT7imKusbw b/zYvhjQGAZU+tKJ3phQ+GZU6+3/kUg1z8teF/t/DZKN5y1fTDf19mayaoWCfQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MXY6R01gLz11tK; Wed, 21 Sep 2022 09:30:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28L9U6PB054483; Wed, 21 Sep 2022 09:30:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28L9U6Pe054480; Wed, 21 Sep 2022 09:30:06 GMT (envelope-from git) Date: Wed, 21 Sep 2022 09:30:06 GMT Message-Id: <202209210930.28L9U6Pe054480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f4fe1b19bce8 - stable/13 - i386 copyout/in_fast: handle page fault from KVA access List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f4fe1b19bce87552c1c32dad2c62fcf48fc327ac Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663752607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SA81y/tCHOLc3jycjYwz6cDsB1t1ZBZl9png34acLY0=; b=ftGv5dvlT8DQwWBQtTmhv58rXpGoy/Q4k6hgb8uKNAan/Bg6dQCYm1WxNy44bTsquWwEyJ /olWA6LQiZTmy7PAiWUoIo2fmhV9o26DKTRKGkOJU3HscnOWrLXGxmpkeYZKeJCqWcwe5f vFUDdJGESWFxTSFoG95MuUWvss37RMMoJN/Lyoy3VBNZP3sBXI6t0e/mLCqEOnPyjCGaPF NijUQAJ+G9WC8Oadybd39EFGzi58HmFtHRpUg4VYSkbTIvJkNRE47ozfI7fYzP0ZxWz39y vFOCynir8AxlKIRWwp349wmRfoUF76XCt105QmbDv3Fb+JfYkFnrTc6FsgcvnA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663752607; a=rsa-sha256; cv=none; b=h+otwGpwPiGHEmXv0917tZCykEiM80FDG1g6/zt+y8moVfOJ+D/dyygJIZs1N9lB4VFuXr 5BYqD2nZM/JEhlp76Djp59OSd0NWuSCrRLD2M6S9to/dvxeX/N/Pn+zpWcmVJh8C4nZR8/ 43Lspn81WBjojFnmtMubFvTzndrebm8Ivdsk9gfvbolI84vsJZuOD4XrfEEXuYlZ8XCytU oFJhoat2NGxX+Z+8IQ3o5yb79Kf7R4oVPv1PZf/KKsgWua14FRSJyn/Hipdm8ZDIgXxFxx MScdiumwWVv2WwTuWDLw7oSFHZYZxHslw0BMKyNEfI1wSSeZz7jBmNis2wRAbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f4fe1b19bce87552c1c32dad2c62fcf48fc327ac commit f4fe1b19bce87552c1c32dad2c62fcf48fc327ac Author: Konstantin Belousov AuthorDate: 2022-09-08 20:15:32 +0000 Commit: Konstantin Belousov CommitDate: 2022-09-21 09:29:02 +0000 i386 copyout/in_fast: handle page fault from KVA access (cherry picked from commit 49587b8fb4d12166d30efb7111d32f4606a1e73b) --- sys/i386/i386/copyout_fast.s | 21 +++++++++------------ sys/i386/i386/exception.s | 25 +++++++++++++++---------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/sys/i386/i386/copyout_fast.s b/sys/i386/i386/copyout_fast.s index 70647fe7613d..4391f36b18e4 100644 --- a/sys/i386/i386/copyout_fast.s +++ b/sys/i386/i386/copyout_fast.s @@ -47,32 +47,30 @@ ENTRY(copyout_fast) pushl %ebx movl 20(%ebp),%ebx /* KCR3 */ - movl PCPU(CURPCB),%edx - movl PCB_CR3(%edx),%edx /* UCR3 */ /* bcopy(%esi = kaddr, %edi = PCPU(copyout_buf), %ecx = len) */ movl 16(%ebp),%ecx movl 8(%ebp),%esi + movl %esp,%eax + movl $copyout_fault,%edx + cli movl PCPU(COPYOUT_BUF),%edi - rep; movsb +pf_y1: rep; movsb movl 16(%ebp),%ecx /* len */ movl PCPU(COPYOUT_BUF),%esi /* kaddr */ movl 12(%ebp),%edi /* uaddr */ - - movl %esp,%eax movl PCPU(TRAMPSTK),%esp - + movl PCPU(CURPCB),%edx + movl PCB_CR3(%edx),%edx /* UCR3 */ movl %edx,%cr3 movl $copyout_fault,%edx - /* bcopy(%esi = PCPU(copyout_buf), %edi = udaddr, %ecx = len) */ pf_x1: rep; movsb movl %ebx,%cr3 movl %eax,%esp sti - xorl %eax,%eax popl %ebx popl %edi @@ -93,10 +91,10 @@ ENTRY(copyin_fast) movl PCB_CR3(%eax),%edx /* UCR3 */ movl 16(%ebp),%ecx /* len */ movl 8(%ebp),%esi /* udaddr */ + movl %esp,%eax + cli movl PCPU(COPYOUT_BUF),%edi /* kaddr */ - - movl %esp,%eax movl PCPU(TRAMPSTK),%esp movl %edx,%cr3 movl $copyout_fault,%edx @@ -110,10 +108,9 @@ pf_x2: rep; movsb movl 16(%ebp),%ecx movl 12(%ebp),%edi movl PCPU(COPYOUT_BUF),%esi - rep; movsb +pf_y2: rep; movsb sti - xorl %eax,%eax popl %ebx popl %edi diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index 272ebb5a2460..8a2194038af6 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -133,15 +133,15 @@ IDTVEC(prot) jmp irettraps IDTVEC(page) testl $PSL_VM, TF_EFLAGS-TF_ERR(%esp) - jnz 4f + jnz 5f testb $SEL_RPL_MASK, TF_CS-TF_ERR(%esp) - jnz 4f + jnz 5f cmpl $PMAP_TRM_MIN_ADDRESS, TF_EIP-TF_ERR(%esp) - jb 4f + jb 5f pushl %eax movl TF_EIP-TF_ERR+4(%esp), %eax addl $1f, %eax - call 5f + call 6f 1: cmpl $pf_x1, %eax je 2f cmpl $pf_x2, %eax @@ -157,16 +157,21 @@ IDTVEC(page) cmpl $pf_x7, %eax je 2f cmpl $pf_x8, %eax - jne 3f -2: popl %eax - movl %ebx, %cr3 + je 2f + cmpl $pf_y1, %eax + je 3f + cmpl $pf_y2, %eax + je 3f + jmp 4f +2: movl %ebx, %cr3 +3: popl %eax movl %edx, TF_EIP-TF_ERR(%esp) addl $4, %esp iret -3: popl %eax -4: pushl $T_PAGEFLT +4: popl %eax +5: pushl $T_PAGEFLT jmp alltraps -5: subl (%esp), %eax +6: subl (%esp), %eax retl IDTVEC(rsvd_pti) IDTVEC(rsvd)